From c09de579724d23752b00375ea733e28e2b03014d Mon Sep 17 00:00:00 2001 From: Amardeep Chimber <amardeep.chimber@digital.justice.gov.uk> Date: Tue, 6 Aug 2024 12:46:18 +0100 Subject: [PATCH 1/2] PI-2370 - remove filter logic, as this is done in the nDeliusGateway api --- .../services/GetDynamicRisksForPersonService.kt | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetDynamicRisksForPersonService.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetDynamicRisksForPersonService.kt index 911c18b0b..ce4c9c2b1 100644 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetDynamicRisksForPersonService.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetDynamicRisksForPersonService.kt @@ -19,16 +19,8 @@ class GetDynamicRisksForPersonService( if (deliusCrn != null) { val allNDeliusDynamicRisks = nDeliusGateway.getDynamicRisksForPerson(deliusCrn) - val filteredNDeliusDynamicRisks = - allNDeliusDynamicRisks.data.filter { - it.code in - listOf( - "RCCO", "RCPR", "REG22", "RVLN", "ALT8", "STRG", "AVIS", "ALT1", "WEAP", - "RHRH", "RLRH", "RMRH", "RVHR", "RCHD", "REG15", "REG16", "REG17", - "ALT4", "AVS2", "ALT7", "ALSH", - ) - } - nDeliusDynamicRisks = Response(data = filteredNDeliusDynamicRisks, errors = allNDeliusDynamicRisks.errors) + + nDeliusDynamicRisks = Response(data = allNDeliusDynamicRisks.data, errors = allNDeliusDynamicRisks.errors) } return Response( From 917d580f37391fafa3ae06419599fd4dda8fd0bd Mon Sep 17 00:00:00 2001 From: Amardeep Chimber <amardeep.chimber@digital.justice.gov.uk> Date: Tue, 6 Aug 2024 13:04:23 +0100 Subject: [PATCH 2/2] PI-2370 - update unit tests --- .../GetDynamicRisksForPersonServiceTest.kt | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetDynamicRisksForPersonServiceTest.kt b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetDynamicRisksForPersonServiceTest.kt index 66eca0835..9f6ffc9ae 100644 --- a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetDynamicRisksForPersonServiceTest.kt +++ b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetDynamicRisksForPersonServiceTest.kt @@ -114,24 +114,11 @@ internal class GetDynamicRisksForPersonServiceTest( it("returns dynamic risks filtered data") { val response = getDynamicRisksForPersonService.execute(hmppsId) - response.data.shouldHaveSize(1) + response.data.shouldHaveSize(2) response.data[0].code shouldBe "RCCO" response.data[0].description shouldBe "Child Concerns" - } - - it("returns an error when the dynamic risk code is not in the allowed list") { - whenever(personService.execute(hmppsId = deliusCrn)).thenReturn(Response(person)) - whenever(personService.execute(hmppsId = hmppsId)).thenReturn(Response(person)) - whenever(nDeliusGateway.getDynamicRisksForPerson(deliusCrn)).thenReturn( - Response( - data = listOf(nonMatchingDynamicRisk), - ), - ) - - val response = getDynamicRisksForPersonService.execute(hmppsId) - - response.errors.shouldHaveSize(0) - response.data.shouldHaveSize(0) + response.data[1].code shouldBe "INVALID" + response.data[1].description shouldBe "Invalid Dynamic Risk!" } }, )