|
| 1 | +# Prison Filters Template |
| 2 | + |
| 3 | +## Description |
| 4 | + |
| 5 | +This pull request implements the following changes: |
| 6 | + |
| 7 | +**Controller Logic:** |
| 8 | + |
| 9 | +- [ ] Replaced `encodedHmppsId` variable with `hmppsId` in the endpoint. |
| 10 | +- [ ] Added `<b>Applicable filters</b>: <ul><li>prisons</li></ul>` to the endpoint description. |
| 11 | +- [ ] Updated `@Parameter` annotation for `hmppsId`: |
| 12 | + - [ ] Changed description to "The HMPPS ID of the person". |
| 13 | + - [ ] Removed URL encoding example. |
| 14 | +- [ ] Added `@RequestAttribute filters: ConsumerFilters?` parameter to the controller function. |
| 15 | +- [ ] Added logic to throw a validation exception when a bad request error is received from the upstream service. |
| 16 | +- [ ] Added `ApiResponse` for HTTP 400 (Bad Request): |
| 17 | + - [ ] Response code: "400". |
| 18 | + - [ ] Description: "Malformed hmppsId." |
| 19 | + - [ ] Content: `Content(schema = Schema(ref = "#/components/schemas/BadRequest"))`. |
| 20 | + |
| 21 | +**Controller Tests:** |
| 22 | + |
| 23 | +- [ ] Updated `hmppsId` variable to a non-encoded version (e.g., "A1234AA"). |
| 24 | +- [ ] Updated service calls to include `filters`. |
| 25 | +- [ ] Added a test case for the bad request error. |
| 26 | + |
| 27 | +**Service Logic:** |
| 28 | + |
| 29 | +- [ ] Added `filters` as a parameter to the service function and is nullable. |
| 30 | +- [ ] Updated the service call to use `getPersonService.getPersonWithPrisonFilter(hmppsId = hmppsId, filters = filters)` or `getPersonService.getNomisNumberWithPrisonFilter()` if we only need the NOMIS number in the service. |
| 31 | + |
| 32 | +**Service Tests:** |
| 33 | + |
| 34 | +- [ ] Updated `hmppsId` variable to a non-encoded version (e.g., "A1234AA"). |
| 35 | +- [ ] Modified mock to use `getPersonService.getPersonWithPrisonFilter(hmppsId = hmppsId, filters = filters)` instead of `getPersonService.execute`. |
| 36 | + |
| 37 | +**Integration Tests:** |
| 38 | + |
| 39 | +- [ ] Updated `globals.yml` with the modified endpoint in the `private-prisons` role. |
| 40 | +- [ ] Added the following integration tests: |
| 41 | + - [ ] Returns a 400 if the `hmppsId` is invalid. |
| 42 | + - [ ] Returns a 404 for a person in the wrong prison (using `callApiWithCN()` and passing `limitedPrisonsCn` and the path). |
| 43 | + - [ ] Returns a 404 when no prisons are present in the filter (using `callApiWithCN()` and passing `noPrisonsCn` and the path). |
| 44 | + |
0 commit comments