@@ -22,8 +22,6 @@ import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApi
22
22
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApiError
23
23
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.services.GetAddressesForPersonService
24
24
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.services.internal.AuditService
25
- import java.net.URLEncoder
26
- import java.nio.charset.StandardCharsets
27
25
28
26
@WebMvcTest(controllers = [AddressController ::class ])
29
27
@ActiveProfiles(" test" )
@@ -33,32 +31,31 @@ internal class AddressControllerTest(
33
31
@MockBean val auditService : AuditService ,
34
32
) : DescribeSpec(
35
33
{
36
- val hmppsId = " 2003/13116M"
37
- val encodedHmppsId = URLEncoder .encode(hmppsId, StandardCharsets .UTF_8 )
34
+ val hmppsId = " A123123"
38
35
val basePath = " /v1/persons"
39
36
val mockMvc = IntegrationAPIMockMvc (springMockMvc)
40
37
41
- describe("GET $basePath/{encodedHmppsId }/addresses") {
38
+ describe("GET $basePath/{hmppsId }/addresses") {
42
39
beforeTest {
43
40
Mockito .reset(getAddressesForPersonService)
44
41
Mockito .reset(auditService)
45
42
whenever(getAddressesForPersonService.execute(hmppsId)).thenReturn(Response (data = listOf(generateTestAddress())))
46
43
}
47
44
48
45
it("returns a 200 OK status code") {
49
- val result = mockMvc.performAuthorised("$basePath/$encodedHmppsId /addresses")
46
+ val result = mockMvc.performAuthorised("$basePath/$hmppsId /addresses")
50
47
51
48
result.response.status.shouldBe(HttpStatus .OK .value())
52
49
}
53
50
54
51
it("gets the addresses for a person with the matching ID ") {
55
- mockMvc.performAuthorised("$basePath/$encodedHmppsId /addresses")
52
+ mockMvc.performAuthorised("$basePath/$hmppsId /addresses")
56
53
57
54
verify(getAddressesForPersonService, VerificationModeFactory .times(1)).execute(hmppsId)
58
55
}
59
56
60
57
it("returns the addresses for a person with the matching ID ") {
61
- val result = mockMvc.performAuthorised("$basePath/$encodedHmppsId /addresses")
58
+ val result = mockMvc.performAuthorised("$basePath/$hmppsId /addresses")
62
59
result.response.contentAsString.shouldBe(
63
60
"""
64
61
{
@@ -94,7 +91,7 @@ internal class AddressControllerTest(
94
91
}
95
92
96
93
it("logs audit") {
97
- mockMvc.performAuthorised("$basePath/$encodedHmppsId /addresses")
94
+ mockMvc.performAuthorised("$basePath/$hmppsId /addresses")
98
95
verify(
99
96
auditService,
100
97
VerificationModeFactory .times(1),
@@ -119,7 +116,7 @@ internal class AddressControllerTest(
119
116
),
120
117
)
121
118
122
- val result = mockMvc.performAuthorised("$basePath/$encodedHmppsId /addresses")
119
+ val result = mockMvc.performAuthorised("$basePath/$hmppsId /addresses")
123
120
124
121
result.response.status.shouldBe(HttpStatus .NOT_FOUND .value())
125
122
}
@@ -138,7 +135,7 @@ internal class AddressControllerTest(
138
135
),
139
136
)
140
137
141
- val result = mockMvc.performAuthorised("$basePath/$encodedHmppsId /addresses")
138
+ val result = mockMvc.performAuthorised("$basePath/$hmppsId /addresses")
142
139
143
140
result.response.status.shouldBe(HttpStatus .OK .value())
144
141
}
@@ -149,7 +146,7 @@ internal class AddressControllerTest(
149
146
WebClientResponseException (500, "MockError ", null, null, null, null),
150
147
)
151
148
152
- val result = mockMvc.performAuthorised("$basePath/$encodedHmppsId /addresses")
149
+ val result = mockMvc.performAuthorised("$basePath/$hmppsId /addresses")
153
150
assert (result.response.status == 500)
154
151
assert (
155
152
result.response.contentAsString.equals(
0 commit comments