You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HMAI-306 - Add Prisons filter to /v1/persons/{encodedHmppsId}/reported-adjudications so can be used by kilco (#746)
* update controller and service to take filters
* Fix path adjudications controller
* update controller, service, and integration tests
* fix error in hmppsid integration test
---------
Co-authored-by: wcdkj <will.clark@digital.justice.gov.uk>
Copy file name to clipboardexpand all lines: src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/controllers/v1/person/AdjudicationsController.kt
ApiResponse(responseCode ="404", description ="Failed to find adjudications for the person with the provided hmppsId.", content = [Content(schema =Schema(ref ="#/components/schemas/PersonNotFound"))]),
@Parameter(description ="A URL-encoded HMPPS identifier", example ="2008%2F0545166T") @PathVariable encodedHmppsId:String,
45
+
@Parameter(description ="The HMPPS ID of the person") @PathVariable hmppsId:String,
42
46
@Parameter(description ="The page number (starting from 1)", schema =Schema(minimum ="1")) @RequestParam(required =false, defaultValue ="1", name ="page") page:Int,
43
47
@Parameter(description ="The maximum number of results for a page", schema =Schema(minimum ="1")) @RequestParam(required =false, defaultValue ="8", name ="perPage") perPage:Int,
48
+
@RequestAttribute filters:ConsumerFilters?,
44
49
): PaginatedResponse<Adjudication> {
45
-
val hmppsId = encodedHmppsId.decodeUrlCharacters()
46
-
val response = getAdjudicationsForPersonService.execute(hmppsId)
50
+
val response = getAdjudicationsForPersonService.execute(hmppsId, filters)
47
51
48
52
if (response.hasError(UpstreamApiError.Type.ENTITY_NOT_FOUND)) {
49
53
throwEntityNotFoundException("Could not find person with id: $hmppsId")
50
54
}
55
+
56
+
if (response.hasError(UpstreamApiError.Type.BAD_REQUEST)) {
57
+
throwValidationException("Invalid or missing HMPPS ID: $hmppsId")
58
+
}
51
59
auditService.createEvent("GET_PERSON_ADJUDICATIONS", mapOf("hmppsId" to hmppsId))
Copy file name to clipboardexpand all lines: src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetAdjudicationsForPersonService.kt
Copy file name to clipboardexpand all lines: src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/controllers/v1/person/AdjudicationsControllerTest.kt
Copy file name to clipboardexpand all lines: src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/integration/person/AdjudicationsIntegrationTest.kt
+18
Original file line number
Diff line number
Diff line change
@@ -13,4 +13,22 @@ class AdjudicationsIntegrationTest : IntegrationTestBase() {
Copy file name to clipboardexpand all lines: src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetAdjudicationsForPersonServiceTest.kt
+9-8
Original file line number
Diff line number
Diff line change
@@ -28,26 +28,27 @@ internal class GetAdjudicationsForPersonServiceTest(
0 commit comments