Skip to content

Commit 7da9345

Browse files
refactor endpoints to use hmppsId
1 parent ed84cf6 commit 7da9345

File tree

1 file changed

+9
-12
lines changed
  • src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/controllers/v1/person/sentences

1 file changed

+9
-12
lines changed

src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/controllers/v1/person/sentences/AddressControllerTest.kt

+9-12
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApi
2222
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApiError
2323
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.services.GetAddressesForPersonService
2424
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.services.internal.AuditService
25-
import java.net.URLEncoder
26-
import java.nio.charset.StandardCharsets
2725

2826
@WebMvcTest(controllers = [AddressController::class])
2927
@ActiveProfiles("test")
@@ -33,32 +31,31 @@ internal class AddressControllerTest(
3331
@MockBean val auditService: AuditService,
3432
) : DescribeSpec(
3533
{
36-
val hmppsId = "2003/13116M"
37-
val encodedHmppsId = URLEncoder.encode(hmppsId, StandardCharsets.UTF_8)
34+
val hmppsId = "A123123"
3835
val basePath = "/v1/persons"
3936
val mockMvc = IntegrationAPIMockMvc(springMockMvc)
4037

41-
describe("GET $basePath/{encodedHmppsId}/addresses") {
38+
describe("GET $basePath/{hmppsId}/addresses") {
4239
beforeTest {
4340
Mockito.reset(getAddressesForPersonService)
4441
Mockito.reset(auditService)
4542
whenever(getAddressesForPersonService.execute(hmppsId)).thenReturn(Response(data = listOf(generateTestAddress())))
4643
}
4744

4845
it("returns a 200 OK status code") {
49-
val result = mockMvc.performAuthorised("$basePath/$encodedHmppsId/addresses")
46+
val result = mockMvc.performAuthorised("$basePath/$hmppsId/addresses")
5047

5148
result.response.status.shouldBe(HttpStatus.OK.value())
5249
}
5350

5451
it("gets the addresses for a person with the matching ID") {
55-
mockMvc.performAuthorised("$basePath/$encodedHmppsId/addresses")
52+
mockMvc.performAuthorised("$basePath/$hmppsId/addresses")
5653

5754
verify(getAddressesForPersonService, VerificationModeFactory.times(1)).execute(hmppsId)
5855
}
5956

6057
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")
6259
result.response.contentAsString.shouldBe(
6360
"""
6461
{
@@ -94,7 +91,7 @@ internal class AddressControllerTest(
9491
}
9592

9693
it("logs audit") {
97-
mockMvc.performAuthorised("$basePath/$encodedHmppsId/addresses")
94+
mockMvc.performAuthorised("$basePath/$hmppsId/addresses")
9895
verify(
9996
auditService,
10097
VerificationModeFactory.times(1),
@@ -119,7 +116,7 @@ internal class AddressControllerTest(
119116
),
120117
)
121118

122-
val result = mockMvc.performAuthorised("$basePath/$encodedHmppsId/addresses")
119+
val result = mockMvc.performAuthorised("$basePath/$hmppsId/addresses")
123120

124121
result.response.status.shouldBe(HttpStatus.NOT_FOUND.value())
125122
}
@@ -138,7 +135,7 @@ internal class AddressControllerTest(
138135
),
139136
)
140137

141-
val result = mockMvc.performAuthorised("$basePath/$encodedHmppsId/addresses")
138+
val result = mockMvc.performAuthorised("$basePath/$hmppsId/addresses")
142139

143140
result.response.status.shouldBe(HttpStatus.OK.value())
144141
}
@@ -149,7 +146,7 @@ internal class AddressControllerTest(
149146
WebClientResponseException(500, "MockError", null, null, null, null),
150147
)
151148

152-
val result = mockMvc.performAuthorised("$basePath/$encodedHmppsId/addresses")
149+
val result = mockMvc.performAuthorised("$basePath/$hmppsId/addresses")
153150
assert(result.response.status == 500)
154151
assert(
155152
result.response.contentAsString.equals(

0 commit comments

Comments
 (0)