Mock Hcm.prompt
# Phase 4 — Standalone Mock HCM server ## Context to read before starting - `.cursorrules` - `context/05-hcm-contract.md` - `context/06-testing.md` — "Mock HCM server" section Phases 1, 2, and 3 are complete. --- ## Task Refine and complete the HCM mock server so it works as a deployable standalone HTTP server, with in-memory state and basic logic that simulates real HCM behavior. --- ## Deliverables checklist ### 1. `mock-hcm.service.ts` - [ ] In-memory state: map of processed requests by `idempotencyKey` - [ ] Attempt counter by `idempotencyKey` (to simulate successful retry on 2nd attempt) - [ ] Method `resetState()` — clears all state - [ ] Method `setScenario(scenario)` — changes active scenario - [ ] Method `getScenario()` — returns current scenario - [ ] Scenario `success_on_retry_2`: fails on first attempt, returns 201 on second ### 2. mock-hcm.controller.ts `GET /hcm/balance`: | X-Mock-Scenario | Behavior | |---|---| | `success` (default) | 200 with hardcoded balance: `availableDays: 10`, `totalAssigned: 15` | | `not_found` | 404 | | `timeout` | `await sleep(5000)` — forces microservice timeout | | `server_error` | 503 | `POST /hcm/time-off`: | X-Mock-Scenario | Behavior | |---|---| | `success` (default) | 201 with generated `hcmRequestId: uuid()` | | `insufficient_balance` | 422 with `{ error: "INSUFFICIENT_BALANCE", availableDays: 1.5 }` | | `invalid_dimensions` | 400 | | `server_error` | 503 | | `idempotent` | If `idempotencyKey` exists: 200 with `idempotent: true`. Otherwise: 201 | | `success_on_retry_2` | First attempt: 503. Second attempt with same key: 201 | `POST /mock/control` (internal control endpoint): - Body: `{ scenario: string }` — changes active scenario - Body: `{ action: "reset" }` — clears state ### 3. mock-hcm.helpers.ts
fill the variables
This prompt has 3 variables. Pro fills them into a ready-to-paste prompt for you — no manual find-and-replace.
{error: "INSUFFICIENT_BALANCE", availableDays: 1.5}{scenario: string}{action: "reset"}
Unlock with Pro →when to use it
Community prompt sourced from the open-source GitHub repo JuniRanger/time-off-microservice (no explicit license). A "Mock Hcm.prompt" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.
tags
productivitycommunitydeveloper
source
JuniRanger/time-off-microservice · no explicit license
more in Productivity
Productivity✓ tested
Summarize a doc into decisions & actions
chief of staff who extracts what to DO, not just what was said
Productivity✓ tested
Draft a reply to a hard email
calm, direct communicator who de-escalates without caving
Productivity✓ tested
Turn a brain-dump into a weekly plan
planning coach who protects your focus, not just your calendar