Skip to content

Commit 4660ea3

Browse files
Added tests.
1 parent 8901851 commit 4660ea3

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

src/main/resources/application-integration-test.yml

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ authorisation:
6868
- "/v1/persons/.*/cell-location"
6969
- "/v1/epf/person-details/.*/[^/]*$"
7070
- "/v1/hmpps/id/nomis-number/[^/]*$"
71+
- "/v1/hmpps/id/.*/nomis-number"
7172
- "/health"
7273
- "/health/ping"
7374
- "/health/readiness"

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

+52
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,56 @@ class HmppsIdIntegrationTest : IntegrationTestBase() {
1717
),
1818
)
1919
}
20+
21+
@Test
22+
fun `gets the nomis Id for a HMPPSID where the id is a crn`() {
23+
callApi("/v1/hmpps/id/$crn/nomis-number")
24+
.andExpect(status().isOk)
25+
.andExpect(
26+
content().json(
27+
"""
28+
{"data":{"nomisNumber":"G5555TT"}}
29+
""",
30+
),
31+
)
32+
}
33+
34+
@Test
35+
fun `gets the nomis Id for a HMPPSID where the id is a NOMIS id`() {
36+
callApi("/v1/hmpps/id/$nomsId/nomis-number")
37+
.andExpect(status().isOk)
38+
.andExpect(
39+
content().json(
40+
"""
41+
{"data":{"nomisNumber":"G2996UX"}}
42+
""",
43+
),
44+
)
45+
}
46+
47+
@Test
48+
fun `gets the nomis Id for a HMPPSID where the id is invalid`() {
49+
callApi("/v1/hmpps/id/invalidId/nomis-number")
50+
.andExpect(status().is4xxClientError)
51+
.andExpect(
52+
content().json(
53+
"""
54+
{"userMessage":"Invalid HMPPS ID: invalidId","developerMessage":"Validation failure: Invalid HMPPS ID: invalidId"}
55+
""",
56+
),
57+
)
58+
}
59+
60+
@Test
61+
fun `gets the nomis Id for a HMPPSID where the id not found`() {
62+
callApi("/v1/hmpps/id/invalidId/nomis-number")
63+
.andExpect(status().is4xxClientError)
64+
.andExpect(
65+
content().json(
66+
"""
67+
{"userMessage":"Invalid HMPPS ID: invalidId","developerMessage":"Validation failure: Invalid HMPPS ID: invalidId","moreInfo":null}
68+
""",
69+
),
70+
)
71+
}
2072
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ abstract class IntegrationTestBase {
2727
final val basePath = "/v1/persons"
2828
final val pnc = URLEncoder.encode("2004/13116M", StandardCharsets.UTF_8)
2929
final val nomsId = "G2996UX"
30-
final val crn = "ABC123"
30+
final val crn = "AB123123"
3131

3232
companion object {
3333
private val hmppsAuthMockServer = HmppsAuthMockServer()

0 commit comments

Comments
 (0)