Skip to content

Commit 481754c

Browse files
committed
additonal risk category integration tests and endpoint schema update
1 parent a45a5f2 commit 481754c

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/controllers/v1/person/RiskCategoriesController.kt

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class RiskCategoriesController(
3535
responses = [
3636
ApiResponse(responseCode = "200", useReturnTypeSchema = true, description = "Successfully found risk categories for a person with the provided HMPPS ID."),
3737
ApiResponse(responseCode = "404", content = [Content(schema = Schema(ref = "#/components/schemas/PersonNotFound"))]),
38+
ApiResponse(responseCode = "400", content = [Content(schema = Schema(ref = "#/components/schemas/BadRequest"))]),
3839
ApiResponse(responseCode = "500", content = [Content(schema = Schema(ref = "#/components/schemas/InternalServerError"))]),
3940
],
4041
)

src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/integration/person/RisksIntegrationTest.kt

+21
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,25 @@ class RisksIntegrationTest : IntegrationTestBase() {
1414
.andExpect(status().isOk)
1515
.andExpect(content().json(getExpectedResponse("person-risk-$path")))
1616
}
17+
18+
@ParameterizedTest
19+
@ValueSource(strings = ["categories"])
20+
fun `return a 404 when prison not in filter`(path: String) {
21+
callApiWithCN("$basePath/$crn/risks/$path", limitedPrisonsCn)
22+
.andExpect(status().isNotFound)
23+
}
24+
25+
@ParameterizedTest
26+
@ValueSource(strings = ["categories"])
27+
fun `returns a 404 for prisoner in wrong prison`(path: String) {
28+
callApiWithCN("$basePath/$crn/risks/$path", noPrisonsCn)
29+
.andExpect(status().isNotFound)
30+
}
31+
32+
@ParameterizedTest
33+
@ValueSource(strings = ["categories"])
34+
fun `return a 400 when invalid hmpps submitted`(path: String) {
35+
callApi("$basePath/invalid=invalid/risks/$path")
36+
.andExpect(status().isBadRequest)
37+
}
1738
}

0 commit comments

Comments
 (0)