Skip to content

Commit d766476

Browse files
WIP - api current returns empty array, fixing
1 parent 1d05b19 commit d766476

File tree

9 files changed

+57
-14
lines changed

9 files changed

+57
-14
lines changed

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import uk.gov.justice.digital.hmpps.hmppsintegrationapi.extensions.decodeUrlChar
1010
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.PageCaseNote
1111
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApi
1212
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApiError
13-
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.services.GetCaseNoteForPersonService
13+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.services.GetCaseNotesForPersonService
1414
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.services.internal.AuditService
1515

1616
@RestController
1717
@RequestMapping("/v1/persons")
18-
class CaseNoteController(
19-
@Autowired val getCaseNoteForPersonService: GetCaseNoteForPersonService,
18+
class CaseNotesController(
19+
@Autowired val getCaseNoteForPersonService: GetCaseNotesForPersonService,
2020
@Autowired val auditService: AuditService,
2121
) {
2222
@GetMapping("{encodedHmppsId}/case-notes")

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetCaseNoteForPersonService.kt src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetCaseNotesForPersonService.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.PageCaseNot
77
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Response
88

99
@Service
10-
class GetCaseNoteForPersonService(
10+
class GetCaseNotesForPersonService(
1111
@Autowired val caseNotesGateway: CaseNotesGateway,
1212
@Autowired val getPersonService: GetPersonService,
1313
) {

src/main/resources/application-dev.yml

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ authorisation:
3939
- "/v1/persons/.*/risks"
4040
- "/v1/persons/.*/adjudications"
4141
- "/v1/persons/.*/licences/conditions"
42+
- "/v1/persons/.*/case-notes"
4243
ctrlo:
4344
- "/v1/epf/person-details/.*/.*"
4445
kubernetes-health-check-client:

src/main/resources/application-local-docker.yml

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ authorisation:
3636
- "/v1/persons/.*/needs"
3737
- "/v1/persons/.*/risks"
3838
- "/v1/persons/.*/reported-adjudications"
39+
- "/v1/persons/.*/case-notes"
3940
- "/v1/epf/person-details/.*/.*"
4041
- "/health"
4142
- "/health/ping"

src/main/resources/application-local.yml

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ authorisation:
4242
- "/v1/persons/.*/needs"
4343
- "/v1/persons/.*/risks"
4444
- "/v1/persons/.*/reported-adjudications"
45+
- "/v1/persons/.*/case-notes"
4546
- "/v1/epf/person-details/.*/.*"
4647
- "/health"
4748
- "/health/ping"

src/main/resources/application-test.yml

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ authorisation:
5454
- "/v1/epf/person-details/.*/.*"
5555
- "/v1/persons/.*/adjudications"
5656
- "/v1/persons/.*/licences/conditions"
57+
- "/v1/persons/.*/case-notes"
5758
- "/health"
5859
- "/health/ping"
5960
- "/health/readiness"

src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/controllers/v1/person/CaseNoteControllerTest.kt src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/controllers/v1/person/CaseNotesControllerTest.kt

+7-7
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ import uk.gov.justice.digital.hmpps.hmppsintegrationapi.helpers.IntegrationAPIMo
1818
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.CaseNote
1919
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.PageCaseNote
2020
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Response
21-
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.services.GetCaseNoteForPersonService
21+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.services.GetCaseNotesForPersonService
2222
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.services.internal.AuditService
2323
import java.net.URLEncoder
2424
import java.nio.charset.StandardCharsets
2525

26-
@WebMvcTest(controllers = [CaseNoteController::class])
26+
@WebMvcTest(controllers = [CaseNotesController::class])
2727
@ActiveProfiles("test")
28-
class CaseNoteControllerTest(
28+
class CaseNotesControllerTest(
2929
@Autowired var springMockMvc: MockMvc,
30-
@MockBean val getCaseNoteForPersonService: GetCaseNoteForPersonService,
30+
@MockBean val getCaseNotesForPersonService: GetCaseNotesForPersonService,
3131
@MockBean val auditService: AuditService,
3232
) : DescribeSpec(
3333
{
@@ -43,9 +43,9 @@ class CaseNoteControllerTest(
4343
)
4444
describe("GET $path") {
4545
beforeTest {
46-
Mockito.reset(getCaseNoteForPersonService)
46+
Mockito.reset(getCaseNotesForPersonService)
4747
Mockito.reset(auditService)
48-
whenever(getCaseNoteForPersonService.execute(hmppsId)).thenReturn(
48+
whenever(getCaseNotesForPersonService.execute(hmppsId)).thenReturn(
4949
Response(
5050
data = pageCaseNote,
5151
errors = emptyList(),
@@ -62,7 +62,7 @@ class CaseNoteControllerTest(
6262
it("gets the case notes for a person with the matching ID") {
6363
mockMvc.performAuthorised(path)
6464

65-
verify(getCaseNoteForPersonService, VerificationModeFactory.times(1)).execute(hmppsId)
65+
verify(getCaseNotesForPersonService, VerificationModeFactory.times(1)).execute(hmppsId)
6666
}
6767

6868
it("returns the case notes for a person with the matching ID") {

src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetCaseNoteForPersonServiceTest.kt src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetCaseNotesForPersonServiceTest.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Response
1818

1919
@ContextConfiguration(
2020
initializers = [ConfigDataApplicationContextInitializer::class],
21-
classes = [GetCaseNoteForPersonService::class],
21+
classes = [GetCaseNotesForPersonService::class],
2222
)
23-
class GetCaseNoteForPersonServiceTest(
23+
class GetCaseNotesForPersonServiceTest(
2424
@MockBean val caseNotesGateway: CaseNotesGateway,
2525
@MockBean val getPersonService: GetPersonService,
26-
private val getCaseNoteForPersonService: GetCaseNoteForPersonService,
26+
private val getCaseNoteForPersonService: GetCaseNotesForPersonService,
2727
) : DescribeSpec(
2828
{
2929
val hmppsId = "1234/56789B"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.smoke.person
2+
3+
import io.kotest.assertions.json.shouldEqualJson
4+
import io.kotest.core.spec.style.DescribeSpec
5+
import io.kotest.matchers.shouldBe
6+
import org.springframework.http.HttpStatus
7+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.extensions.removeWhitespaceAndNewlines
8+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.helpers.IntegrationAPIHttpClient
9+
import java.net.URLEncoder
10+
import java.nio.charset.StandardCharsets
11+
12+
class CaseNotesSmokeTest : DescribeSpec(
13+
{
14+
val hmppsId = "ABC123"
15+
val encodedHmppsId = URLEncoder.encode(hmppsId, StandardCharsets.UTF_8)
16+
val basePath = "v1/persons/$encodedHmppsId/case-notes"
17+
val httpClient = IntegrationAPIHttpClient()
18+
19+
it("returns case notes for a person") {
20+
val response = httpClient.performAuthorised(basePath)
21+
response.statusCode().shouldBe(HttpStatus.OK.value())
22+
response.body().shouldEqualJson(
23+
"""
24+
{
25+
"data":
26+
{
27+
"caseNotes": [
28+
{
29+
"caseNoteId": "12311312"
30+
}
31+
]
32+
}
33+
}
34+
35+
""".removeWhitespaceAndNewlines(),
36+
)
37+
}
38+
},
39+
)

0 commit comments

Comments
 (0)