From 9c255827c6b31edf0ea72a6f28db49107bd8cc8c Mon Sep 17 00:00:00 2001 From: pmcphee77 <150798161+pmcphee77@users.noreply.github.com> Date: Mon, 18 Mar 2024 09:11:30 +0000 Subject: [PATCH] PI-1991: Added address tel number and circ, dis and provision endpoints (#3480) * PI-1991: Added address tel number and circ, dis and provision endpoints * PI-1991: Added requires interpreter --- .../justice/digital/hmpps/data/DataLoader.kt | 1 + .../hmpps/data/generator/PersonGenerator.kt | 24 ++++-- .../personalDetails/PersonDetailsGenerator.kt | 68 ++++++++++++++--- .../hmpps/PersonalDetailsIntegrationTest.kt | 74 +++++++++++++++++-- .../controller/PersonalDetailsController.kt | 15 ++++ .../api/model/personalDetails/Address.kt | 3 + .../personalDetails/CircumstanceOverview.kt | 20 +++++ .../personalDetails/DisabiltyOverview.kt | 19 +++++ .../model/personalDetails/PersonalDetails.kt | 1 + .../personalDetails/ProvisionOverview.kt | 19 +++++ .../delius/overview/entity/Disability.kt | 8 ++ .../delius/overview/entity/Person.kt | 5 ++ .../overview/entity/PersonalCircumstance.kt | 31 +++++++- .../delius/overview/entity/Provision.kt | 8 ++ .../delius/personalDetails/entity/Address.kt | 2 +- .../digital/hmpps/service/OverviewService.kt | 2 +- .../hmpps/service/PersonalDetailsService.kt | 64 +++++++++++++++- .../PersonalDetailsControllerTest.kt | 70 +++++++++++++----- .../hmpps/service/OverviewServiceTest.kt | 2 +- .../service/PersonalDetailsServiceTest.kt | 43 +++++------ 20 files changed, 408 insertions(+), 71 deletions(-) create mode 100644 projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/CircumstanceOverview.kt create mode 100644 projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/DisabiltyOverview.kt create mode 100644 projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/ProvisionOverview.kt diff --git a/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt b/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt index 14c7af7b82..c01290ea12 100644 --- a/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt +++ b/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt @@ -103,6 +103,7 @@ class DataLoader( PersonDetailsGenerator.PROVISION_2, PersonDetailsGenerator.PERSONAL_CIRC_1, PersonDetailsGenerator.PERSONAL_CIRC_2, + PersonDetailsGenerator.PERSONAL_CIRC_PREV, PersonDetailsGenerator.RELATIONSHIP_TYPE, PersonDetailsGenerator.CONTACT_ADDRESS, PersonDetailsGenerator.PERSONAL_CONTACT_1, diff --git a/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/PersonGenerator.kt b/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/PersonGenerator.kt index 95b2dbdf2d..e7c7e34b13 100644 --- a/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/PersonGenerator.kt +++ b/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/PersonGenerator.kt @@ -1,5 +1,6 @@ package uk.gov.justice.digital.hmpps.data.generator +import uk.gov.justice.digital.hmpps.data.generator.UserGenerator.USER import uk.gov.justice.digital.hmpps.integrations.delius.overview.entity.* import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.entity.ReferenceData import java.time.LocalDate @@ -128,14 +129,16 @@ object PersonGenerator { OVERVIEW.id, ReferenceData(IdGenerator.getAndIncrement(), "D01", "Mental Illness"), LocalDate.now().minusDays(1), - LocalDate.now().minusDays(1) + LocalDate.now().minusDays(1), + USER ), Disability( IdGenerator.getAndIncrement(), OVERVIEW.id, ReferenceData(IdGenerator.getAndIncrement(), "D02", "Visual Impairment"), LocalDate.now(), - LocalDate.now().minusDays(1) + LocalDate.now().minusDays(1), + USER ) ) @@ -149,14 +152,21 @@ object PersonGenerator { "Full-time employed (30 or more hours per week" ), LocalDate.now(), - LocalDate.now().minusDays(1) - ), + USER, + null, + true, + LocalDate.now().minusDays(1), + + ), PersonalCircumstance( IdGenerator.getAndIncrement(), OVERVIEW.id, ReferenceData(IdGenerator.getAndIncrement(), "A02", "Accommodation"), PersonalCircumstanceSubType(IdGenerator.getAndIncrement(), "Friends/Family (settled)"), LocalDate.now(), + USER, + null, + true, LocalDate.now().minusDays(1) ) ) @@ -167,14 +177,16 @@ object PersonGenerator { OVERVIEW.id, ReferenceData(IdGenerator.getAndIncrement(), "FF01", "Flex refreshment breaks"), LocalDate.now(), - LocalDate.now().minusDays(1) + LocalDate.now().minusDays(1), + USER ), Provision( IdGenerator.getAndIncrement(), OVERVIEW.id, ReferenceData(IdGenerator.getAndIncrement(), "CC02", "Colour/visibility marking"), LocalDate.now(), - LocalDate.now().minusDays(1) + LocalDate.now().minusDays(1), + USER ) ) diff --git a/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/personalDetails/PersonDetailsGenerator.kt b/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/personalDetails/PersonDetailsGenerator.kt index b865ad8cb5..83b66a68ab 100644 --- a/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/personalDetails/PersonDetailsGenerator.kt +++ b/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/personalDetails/PersonDetailsGenerator.kt @@ -20,9 +20,19 @@ object PersonDetailsGenerator { val GENDER_IDENTITY_RD = ReferenceData(IdGenerator.getAndIncrement(), "GI", "Test Gender Identity") val PERSONAL_DETAILS = generatePersonDetails( - "X000005", "Caroline", - "Louise", "Bloggs", "Caz", GENDER_FEMALE, RELIGION_DEFAULT, - SEXUAL_ORIENTATION, LANGUAGE_RD, "Smith", GENDER_IDENTITY_RD, "Some gender description" + "X000005", + "Caroline", + "Louise", + "Bloggs", + "Caz", + GENDER_FEMALE, + RELIGION_DEFAULT, + SEXUAL_ORIENTATION, + LANGUAGE_RD, + "Smith", + GENDER_IDENTITY_RD, + "Some gender description", + requiresInterpreter = true ) val ALIAS_1 = generateAlias("Sam", "Edward", "Smith", PERSONAL_DETAILS.id) @@ -43,14 +53,16 @@ object PersonDetailsGenerator { PERSONAL_DETAILS.id, DISABILITY_1_RD, LocalDate.now().minusDays(1), - LocalDate.now().minusDays(1) + LocalDate.now().minusDays(1), + USER, ) val DISABILITY_2 = Disability( IdGenerator.getAndIncrement(), PERSONAL_DETAILS.id, DISABILITY_2_RD, LocalDate.now().minusDays(2), - LocalDate.now().minusDays(2) + LocalDate.now().minusDays(2), + USER, ) val PROVISION_1 = Provision( @@ -58,14 +70,16 @@ object PersonDetailsGenerator { PERSONAL_DETAILS.id, PROVISION_1_RD, LocalDate.now().minusDays(1), - LocalDate.now().minusDays(1) + LocalDate.now().minusDays(1), + USER, ) val PROVISION_2 = Provision( IdGenerator.getAndIncrement(), PERSONAL_DETAILS.id, PROVISION_2_RD, LocalDate.now().minusDays(2), - LocalDate.now().minusDays(2) + LocalDate.now().minusDays(2), + USER, ) val PERSONAL_CIRC_1 = PersonalCircumstance( @@ -74,6 +88,9 @@ object PersonDetailsGenerator { PERSONAL_CIRCUMSTANCE_1_RD, PERSONAL_CIRCUMSTANCE_SUBTYPE_1, LocalDate.now().minusDays(1), + USER, + notes = "Some Notes", + evidenced = true, LocalDate.now().minusDays(1) ) val PERSONAL_CIRC_2 = PersonalCircumstance( @@ -82,9 +99,25 @@ object PersonDetailsGenerator { PERSONAL_CIRCUMSTANCE_2_RD, PERSONAL_CIRCUMSTANCE_SUBTYPE_2, LocalDate.now().minusDays(1), + USER, + notes = "Some Notes", + evidenced = true, LocalDate.now().minusDays(1) ) + val PERSONAL_CIRC_PREV = PersonalCircumstance( + IdGenerator.getAndIncrement(), + PERSONAL_DETAILS.id, + PERSONAL_CIRCUMSTANCE_2_RD, + PERSONAL_CIRCUMSTANCE_SUBTYPE_2, + LocalDate.now().minusDays(1), + USER, + notes = "Previous circumstance Notes", + evidenced = true, + LocalDate.now().minusDays(8), + endDate = LocalDate.now().minusDays(3), + ) + val RELATIONSHIP_TYPE = ReferenceData(IdGenerator.getAndIncrement(), "FM01", "Family Member") val CONTACT_ADDRESS = generateContactAddress("31", "Test Steet", "Test town", "Test County", "NE1 56A") val PERSONAL_CONTACT_1 = PersonalContactEntity( @@ -153,6 +186,7 @@ object PersonDetailsGenerator { null, null, null, + telephoneNumber = null, LocalDate.now(), null, true, @@ -214,13 +248,24 @@ object PersonDetailsGenerator { status = status, type = type, typeVerified = verified, + telephoneNumber = "0191876865", lastUpdatedUser = USER ) fun generatePersonDetails( - crn: String, forename: String, secondName: String, surname: String, preferredName: String, - gender: ReferenceData, religion: ReferenceData, sexualOrientation: ReferenceData, language: ReferenceData, - previousSurname: String, genderIdentity: ReferenceData, genderIdentityDescription: String + crn: String, + forename: String, + secondName: String, + surname: String, + preferredName: String, + gender: ReferenceData, + religion: ReferenceData, + sexualOrientation: ReferenceData, + language: ReferenceData, + previousSurname: String, + genderIdentity: ReferenceData, + genderIdentityDescription: String, + requiresInterpreter: Boolean = false ) = Person( id = IdGenerator.getAndIncrement(), crn = crn, @@ -239,7 +284,8 @@ object PersonDetailsGenerator { language = language, previousSurname = previousSurname, genderIdentity = genderIdentity, - genderIdentityDescription = genderIdentityDescription + genderIdentityDescription = genderIdentityDescription, + requiresInterpreter = requiresInterpreter, ) fun generateDocument(personId: Long, alfrescoId: String, name: String, documentType: String) = PersonDocument( diff --git a/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PersonalDetailsIntegrationTest.kt b/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PersonalDetailsIntegrationTest.kt index 4b889c1700..ceed25d13b 100644 --- a/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PersonalDetailsIntegrationTest.kt +++ b/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PersonalDetailsIntegrationTest.kt @@ -15,15 +15,19 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status import org.springframework.util.ResourceUtils import uk.gov.justice.digital.hmpps.api.model.Name import uk.gov.justice.digital.hmpps.api.model.PersonSummary -import uk.gov.justice.digital.hmpps.api.model.personalDetails.AddressOverview -import uk.gov.justice.digital.hmpps.api.model.personalDetails.PersonalContact -import uk.gov.justice.digital.hmpps.api.model.personalDetails.PersonalDetails +import uk.gov.justice.digital.hmpps.api.model.personalDetails.* import uk.gov.justice.digital.hmpps.data.generator.personalDetails.PersonDetailsGenerator.ALIAS_1 +import uk.gov.justice.digital.hmpps.data.generator.personalDetails.PersonDetailsGenerator.DISABILITY_1 +import uk.gov.justice.digital.hmpps.data.generator.personalDetails.PersonDetailsGenerator.DISABILITY_2 +import uk.gov.justice.digital.hmpps.data.generator.personalDetails.PersonDetailsGenerator.PERSONAL_CIRC_1 +import uk.gov.justice.digital.hmpps.data.generator.personalDetails.PersonDetailsGenerator.PERSONAL_CIRC_2 +import uk.gov.justice.digital.hmpps.data.generator.personalDetails.PersonDetailsGenerator.PERSONAL_CIRC_PREV import uk.gov.justice.digital.hmpps.data.generator.personalDetails.PersonDetailsGenerator.PERSONAL_CONTACT_1 import uk.gov.justice.digital.hmpps.data.generator.personalDetails.PersonDetailsGenerator.PERSONAL_DETAILS import uk.gov.justice.digital.hmpps.data.generator.personalDetails.PersonDetailsGenerator.PREVIOUS_ADDRESS -import uk.gov.justice.digital.hmpps.service.toContact -import uk.gov.justice.digital.hmpps.service.toSummary +import uk.gov.justice.digital.hmpps.data.generator.personalDetails.PersonDetailsGenerator.PROVISION_1 +import uk.gov.justice.digital.hmpps.data.generator.personalDetails.PersonDetailsGenerator.PROVISION_2 +import uk.gov.justice.digital.hmpps.service.* import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.contentAsJson import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.withToken import java.time.LocalDate @@ -82,6 +86,7 @@ internal class PersonalDetailsIntegrationTest { assertThat(res.aliases[0].forename, equalTo(ALIAS_1.forename)) assertThat(res.genderIdentity, equalTo("Test Gender Identity")) assertThat(res.selfDescribedGender, equalTo("Some gender description")) + assertThat(res.requiresInterpreter, equalTo(true)) } @Test @@ -167,7 +172,6 @@ internal class PersonalDetailsIntegrationTest { @Test fun `addresses are returned`() { val person = PERSONAL_DETAILS - val contact = PERSONAL_CONTACT_1 val res = mockMvc .perform(get("/personal-details/${person.crn}/addresses").withToken()) .andExpect(status().isOk) @@ -185,4 +189,62 @@ internal class PersonalDetailsIntegrationTest { .perform(get("/personal-details/X999999/addresses").withToken()) .andExpect(status().isNotFound) } + + @Test + fun `circumstances are returned`() { + val person = PERSONAL_DETAILS + val res = mockMvc + .perform(get("/personal-details/${person.crn}/circumstances").withToken()) + .andExpect(status().isOk) + .andReturn().response.contentAsJson() + assertThat(res.personSummary, equalTo(person.toSummary())) + assertThat(res.circumstances[0], equalTo(PERSONAL_CIRC_1.toCircumstance())) + assertThat(res.circumstances[1], equalTo(PERSONAL_CIRC_2.toCircumstance())) + assertThat(res.circumstances[2], equalTo(PERSONAL_CIRC_PREV.toCircumstance())) + } + + @Test + fun `circumstances not found`() { + mockMvc + .perform(get("/personal-details/X999999/circumstances").withToken()) + .andExpect(status().isNotFound) + } + + @Test + fun `disabilities are returned`() { + val person = PERSONAL_DETAILS + val res = mockMvc + .perform(get("/personal-details/${person.crn}/disabilities").withToken()) + .andExpect(status().isOk) + .andReturn().response.contentAsJson() + assertThat(res.personSummary, equalTo(person.toSummary())) + assertThat(res.disabilities[0], equalTo(DISABILITY_1.toDisability())) + assertThat(res.disabilities[1], equalTo(DISABILITY_2.toDisability())) + } + + @Test + fun `disabilities not found`() { + mockMvc + .perform(get("/personal-details/X999999/disabilities").withToken()) + .andExpect(status().isNotFound) + } + + @Test + fun `provisions are returned`() { + val person = PERSONAL_DETAILS + val res = mockMvc + .perform(get("/personal-details/${person.crn}/provisions").withToken()) + .andExpect(status().isOk) + .andReturn().response.contentAsJson() + assertThat(res.personSummary, equalTo(person.toSummary())) + assertThat(res.provisions[0], equalTo(PROVISION_1.toProvision())) + assertThat(res.provisions[1], equalTo(PROVISION_2.toProvision())) + } + + @Test + fun `provisions not found`() { + mockMvc + .perform(get("/personal-details/X999999/provisions").withToken()) + .andExpect(status().isNotFound) + } } diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/controller/PersonalDetailsController.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/controller/PersonalDetailsController.kt index 3331992f5e..e4d6e72a94 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/controller/PersonalDetailsController.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/controller/PersonalDetailsController.kt @@ -40,4 +40,19 @@ class PersonalDetailsController(private val personalDetailsService: PersonalDeta @Operation(summary = "Person Addresses") fun getPersonAddresses(@PathVariable crn: String) = personalDetailsService.getPersonAddresses(crn) + + @GetMapping("/circumstances") + @Operation(summary = "Person Circumstances") + fun getPersonCircumstances(@PathVariable crn: String) = + personalDetailsService.getPersonCircumstances(crn) + + @GetMapping("/disabilities") + @Operation(summary = "Person Disabilities") + fun getPersonDisabilities(@PathVariable crn: String) = + personalDetailsService.getPersonDisabilities(crn) + + @GetMapping("/provisions") + @Operation(summary = "Person Provisions") + fun getPersonProvisions(@PathVariable crn: String) = + personalDetailsService.getPersonProvisions(crn) } diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/Address.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/Address.kt index dc27163afe..d4a63ba148 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/Address.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/Address.kt @@ -11,6 +11,7 @@ data class Address( val town: String?, val county: String?, val postcode: String?, + val telephoneNumber: String?, val from: LocalDate, val to: LocalDate?, val verified: Boolean?, @@ -28,6 +29,7 @@ data class Address( town: String? = null, county: String? = null, postcode: String? = null, + telephoneNumber: String?, from: LocalDate, to: LocalDate? = null, verified: Boolean? = null, @@ -50,6 +52,7 @@ data class Address( town, county, postcode, + telephoneNumber, from, to, verified, diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/CircumstanceOverview.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/CircumstanceOverview.kt new file mode 100644 index 0000000000..7c0772189d --- /dev/null +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/CircumstanceOverview.kt @@ -0,0 +1,20 @@ +package uk.gov.justice.digital.hmpps.api.model.personalDetails + +import uk.gov.justice.digital.hmpps.api.model.Name +import uk.gov.justice.digital.hmpps.api.model.PersonSummary +import java.time.LocalDate + +data class CircumstanceOverview( + val personSummary: PersonSummary, + val circumstances: List +) + +data class Circumstance( + val type: String, + val subType: String, + val notes: String?, + val verified: Boolean = false, + val startDate: LocalDate, + val lastUpdated: LocalDate, + val lastUpdatedBy: Name +) \ No newline at end of file diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/DisabiltyOverview.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/DisabiltyOverview.kt new file mode 100644 index 0000000000..dc195895c3 --- /dev/null +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/DisabiltyOverview.kt @@ -0,0 +1,19 @@ +package uk.gov.justice.digital.hmpps.api.model.personalDetails + +import uk.gov.justice.digital.hmpps.api.model.Name +import uk.gov.justice.digital.hmpps.api.model.PersonSummary +import java.time.LocalDate + +data class DisabilityOverview( + val personSummary: PersonSummary, + val disabilities: List + +) + +data class Disability( + val description: String, + val notes: String?, + val startDate: LocalDate, + val lastUpdated: LocalDate, + val lastUpdatedBy: Name +) \ No newline at end of file diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/PersonalDetails.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/PersonalDetails.kt index 0a538ecbc9..9e0234c67f 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/PersonalDetails.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/PersonalDetails.kt @@ -28,6 +28,7 @@ data class PersonalDetails( val sex: String, val religionOrBelief: String?, val sexualOrientation: String?, + val requiresInterpreter: Boolean? = false, val documents: List ) \ No newline at end of file diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/ProvisionOverview.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/ProvisionOverview.kt new file mode 100644 index 0000000000..f793942ce4 --- /dev/null +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/ProvisionOverview.kt @@ -0,0 +1,19 @@ +package uk.gov.justice.digital.hmpps.api.model.personalDetails + +import uk.gov.justice.digital.hmpps.api.model.Name +import uk.gov.justice.digital.hmpps.api.model.PersonSummary +import java.time.LocalDate + +data class ProvisionOverview( + val personSummary: PersonSummary, + val provisions: List, + + ) + +data class Provision( + val description: String, + val notes: String?, + val startDate: LocalDate, + val lastUpdated: LocalDate, + val lastUpdatedBy: Name +) \ No newline at end of file diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Disability.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Disability.kt index cef2a06835..312266bcdb 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Disability.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Disability.kt @@ -7,6 +7,7 @@ import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.entity.ReferenceData +import uk.gov.justice.digital.hmpps.integrations.delius.user.entity.User import java.time.LocalDate @Immutable @@ -31,6 +32,13 @@ class Disability( @Column(name = "last_updated_datetime") val lastUpdated: LocalDate, + @ManyToOne + @JoinColumn(name = "last_updated_user_id") + val lastUpdatedUser: User, + + @Column(name = "notes", columnDefinition = "clob") + val notes: String? = null, + val finishDate: LocalDate? = null, @Column(name = "soft_deleted", columnDefinition = "number") diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Person.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Person.kt index 836fdfb66a..c808b1fe49 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Person.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Person.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.overview.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.YesNoConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import uk.gov.justice.digital.hmpps.exception.NotFoundException @@ -76,6 +77,10 @@ class Person( val genderIdentityDescription: String?, + @Column(name = "Interpreter_required") + @Convert(converter = YesNoConverter::class) + val requiresInterpreter: Boolean? = false, + @Column(columnDefinition = "number") val softDeleted: Boolean = false diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/PersonalCircumstance.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/PersonalCircumstance.kt index 0741c2ca81..f52dd2b166 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/PersonalCircumstance.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/PersonalCircumstance.kt @@ -6,13 +6,15 @@ import org.hibernate.annotations.FetchMode import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction import org.springframework.data.jpa.repository.JpaRepository +import org.springframework.data.jpa.repository.Query import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.entity.ReferenceData +import uk.gov.justice.digital.hmpps.integrations.delius.user.entity.User import java.time.LocalDate @Immutable @Entity @Table(name = "personal_circumstance") -@SQLRestriction("soft_deleted = 0 and (end_date is null or end_date > current_date)") +@SQLRestriction("soft_deleted = 0") class PersonalCircumstance( @Id @Column(name = "personal_circumstance_id") @@ -34,6 +36,15 @@ class PersonalCircumstance( @Column(name = "last_updated_datetime") val lastUpdated: LocalDate, + @ManyToOne + @JoinColumn(name = "last_updated_user_id") + val lastUpdatedUser: User, + + @Column(name = "notes", columnDefinition = "clob") + val notes: String? = null, + + val evidenced: Boolean = false, + val startDate: LocalDate, val endDate: LocalDate? = null, @@ -44,7 +55,23 @@ class PersonalCircumstance( ) interface PersonCircumstanceRepository : JpaRepository { - fun findByPersonId(personId: Long): List + + @Query( + """ + select pc from PersonalCircumstance pc + where pc.personId = :personId + and (pc.endDate is null or pc.endDate > current_date ) + """ + ) + fun findCurrentCircumstances(personId: Long): List + + @Query( + """ + select pc from PersonalCircumstance pc + where pc.personId = :personId + """ + ) + fun findAllCircumstances(personId: Long): List } @Immutable diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Provision.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Provision.kt index 4660af5fbb..da7b912d83 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Provision.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Provision.kt @@ -7,6 +7,7 @@ import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.entity.ReferenceData +import uk.gov.justice.digital.hmpps.integrations.delius.user.entity.User import java.time.LocalDate @Immutable @@ -31,6 +32,13 @@ class Provision( @Column(name = "last_updated_datetime") val lastUpdated: LocalDate, + @ManyToOne + @JoinColumn(name = "last_updated_user_id") + val lastUpdatedUser: User, + + @Column(name = "notes", columnDefinition = "clob") + val notes: String? = null, + val finishDate: LocalDate? = null, @Column(name = "soft_deleted", columnDefinition = "number") diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/personalDetails/entity/Address.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/personalDetails/entity/Address.kt index cf0ecbdf55..b586b2405d 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/personalDetails/entity/Address.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/personalDetails/entity/Address.kt @@ -38,7 +38,7 @@ class PersonAddress( val town: String?, val county: String?, val postcode: String?, - + val telephoneNumber: String?, val startDate: LocalDate, val endDate: LocalDate? = null, diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/OverviewService.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/OverviewService.kt index bc5ff82a4d..b7a7524d95 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/OverviewService.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/OverviewService.kt @@ -26,7 +26,7 @@ class OverviewService( fun getOverview(crn: String): Overview { val person = personRepository.getPerson(crn) val provisions = provisionRepository.findByPersonId(person.id) - val personalCircumstances = personalCircumstanceRepository.findByPersonId(person.id) + val personalCircumstances = personalCircumstanceRepository.findCurrentCircumstances(person.id) val disabilities = disabilityRepository.findByPersonId(person.id) val personalDetails = person.toPersonalDetails(personalCircumstances, disabilities, provisions) val schedule = Schedule(contactRepository.firstAppointment(person.id)?.toNextAppointment()) diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/PersonalDetailsService.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/PersonalDetailsService.kt index f750bddd68..44de9ed56e 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/PersonalDetailsService.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/PersonalDetailsService.kt @@ -9,6 +9,8 @@ import uk.gov.justice.digital.hmpps.api.model.Name import uk.gov.justice.digital.hmpps.api.model.PersonSummary import uk.gov.justice.digital.hmpps.api.model.overview.PersonalCircumstance import uk.gov.justice.digital.hmpps.api.model.personalDetails.* +import uk.gov.justice.digital.hmpps.api.model.personalDetails.Disability +import uk.gov.justice.digital.hmpps.api.model.personalDetails.Provision import uk.gov.justice.digital.hmpps.integrations.delius.overview.entity.* import uk.gov.justice.digital.hmpps.integrations.delius.personalDetails.entity.* import uk.gov.justice.digital.hmpps.integrations.delius.personalDetails.entity.ContactAddress @@ -30,7 +32,7 @@ class PersonalDetailsService( fun getPersonalDetails(crn: String): PersonalDetails { val person = personRepository.getPerson(crn) val provisions = provisionRepository.findByPersonId(person.id) - val personalCircumstances = personalCircumstanceRepository.findByPersonId(person.id) + val personalCircumstances = personalCircumstanceRepository.findCurrentCircumstances(person.id) val disabilities = disabilityRepository.findByPersonId(person.id) val allAddresses = addressRepository.findByPersonId(person.id) val currentAddresses = allAddresses.filter { it.endDate == null } @@ -78,7 +80,8 @@ class PersonalDetailsService( previousSurname = person.previousSurname, aliases = aliases.map { Name(forename = it.forename, middleName = it.secondName, it.surname) }, genderIdentity = person.genderIdentity?.description, - selfDescribedGender = person.genderIdentityDescription + selfDescribedGender = person.genderIdentityDescription, + requiresInterpreter = person.requiresInterpreter ) } @@ -108,8 +111,64 @@ class PersonalDetailsService( previousAddresses = addresses.filter { it.endDate != null }.map(PersonAddress::toAddress).mapNotNull { it } ) } + + fun getPersonCircumstances(crn: String): CircumstanceOverview { + val person = personRepository.getSummary(crn) + val circumstances = personalCircumstanceRepository.findAllCircumstances(person.id) + + return CircumstanceOverview( + personSummary = person.toPersonSummary(), + circumstances = circumstances.map { it.toCircumstance() } + ) + } + + fun getPersonProvisions(crn: String): ProvisionOverview { + val person = personRepository.getSummary(crn) + val provisions = provisionRepository.findByPersonId(person.id) + + return ProvisionOverview( + personSummary = person.toPersonSummary(), + provisions = provisions.map { it.toProvision() } + ) + } + + fun getPersonDisabilities(crn: String): DisabilityOverview { + val person = personRepository.getSummary(crn) + val disabilities = disabilityRepository.findByPersonId(person.id) + + return DisabilityOverview( + personSummary = person.toPersonSummary(), + disabilities = disabilities.map { it.toDisability() } + ) + } } +fun uk.gov.justice.digital.hmpps.integrations.delius.overview.entity.PersonalCircumstance.toCircumstance() = + Circumstance( + type = type.description, + subType = subType.description, + notes = notes, verified = evidenced, + startDate = startDate, + lastUpdated = lastUpdated, + lastUpdatedBy = Name(forename = lastUpdatedUser.forename, surname = lastUpdatedUser.surname) + ) + +fun uk.gov.justice.digital.hmpps.integrations.delius.overview.entity.Provision.toProvision() = Provision( + description = type.description, + notes = notes, + startDate = startDate, + lastUpdated = lastUpdated, + lastUpdatedBy = Name(forename = lastUpdatedUser.forename, surname = lastUpdatedUser.surname) +) + +fun uk.gov.justice.digital.hmpps.integrations.delius.overview.entity.Disability.toDisability() = Disability( + description = type.description, + notes = notes, + startDate = startDate, + lastUpdated = lastUpdated, + lastUpdatedBy = Name(forename = lastUpdatedUser.forename, surname = lastUpdatedUser.surname) +) + fun PersonalContactEntity.toContact() = PersonalContact( personSummary = person.toSummary(), name = Name(forename, middleNames, surname), @@ -143,6 +202,7 @@ fun PersonAddress.toAddress() = Address.from( lastUpdated = lastUpdated, status = status.description, type = type.description, + telephoneNumber = telephoneNumber, lastUpdatedBy = Name(forename = lastUpdatedUser.forename, surname = lastUpdatedUser.surname) ) diff --git a/projects/manage-supervision-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/api/controller/PersonalDetailsControllerTest.kt b/projects/manage-supervision-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/api/controller/PersonalDetailsControllerTest.kt index 05b535258b..d7f34dd9d4 100644 --- a/projects/manage-supervision-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/api/controller/PersonalDetailsControllerTest.kt +++ b/projects/manage-supervision-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/api/controller/PersonalDetailsControllerTest.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.api.controller import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.equalTo import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.mockito.InjectMocks @@ -16,9 +17,7 @@ import uk.gov.justice.digital.hmpps.api.model.Name import uk.gov.justice.digital.hmpps.api.model.PersonSummary import uk.gov.justice.digital.hmpps.api.model.personalDetails.* import uk.gov.justice.digital.hmpps.data.generator.personalDetails.PersonDetailsGenerator -import uk.gov.justice.digital.hmpps.service.PersonalDetailsService -import uk.gov.justice.digital.hmpps.service.toAddress -import uk.gov.justice.digital.hmpps.service.toContact +import uk.gov.justice.digital.hmpps.service.* import java.time.LocalDate @ExtendWith(MockitoExtension::class) @@ -30,6 +29,17 @@ internal class PersonalDetailsControllerTest { @InjectMocks lateinit var controller: PersonalDetailsController + private lateinit var personSummary: PersonSummary + + @BeforeEach + fun setup() { + personSummary = PersonSummary( + Name(forename = "TestName", middleName = null, surname = "TestSurname"), pnc = "Test PNC", + crn = "CRN", + dateOfBirth = LocalDate.now(), + ) + } + @Test fun `calls personal details service to get data`() { val crn = "X000005" @@ -89,28 +99,17 @@ internal class PersonalDetailsControllerTest { @Test fun `calls get Person summary function `() { val crn = "X000005" - val expectedResponse = PersonSummary( - Name(forename = "TestName", middleName = null, surname = "TestSurname"), pnc = "Test PNC", - crn = "CRN", - dateOfBirth = LocalDate.now(), - ) - - whenever(personalDetailsService.getPersonSummary(crn)).thenReturn(expectedResponse) + whenever(personalDetailsService.getPersonSummary(crn)).thenReturn(personSummary) val res = controller.getPersonSummary(crn) - assertThat(res, equalTo(expectedResponse)) + assertThat(res, equalTo(personSummary)) } @Test fun `calls get addresses function `() { val crn = "X000005" - val expectedSummary = PersonSummary( - Name(forename = "TestName", middleName = null, surname = "TestSurname"), pnc = "Test PNC", - crn = "CRN", - dateOfBirth = LocalDate.now(), - ) val expectedResponse = AddressOverview( - personSummary = expectedSummary, mainAddress = PersonDetailsGenerator.PERSON_ADDRESS_1.toAddress(), + personSummary = personSummary, mainAddress = PersonDetailsGenerator.PERSON_ADDRESS_1.toAddress(), otherAddresses = listOfNotNull(PersonDetailsGenerator.PERSON_ADDRESS_2.toAddress()), previousAddresses = listOfNotNull(PersonDetailsGenerator.PREVIOUS_ADDRESS.toAddress()) ) @@ -118,4 +117,41 @@ internal class PersonalDetailsControllerTest { val res = controller.getPersonAddresses(crn) assertThat(res, equalTo(expectedResponse)) } + + @Test + fun `calls get circumstances function `() { + val crn = "X000005" + val expectedResponse = CircumstanceOverview( + personSummary = personSummary, + circumstances = listOfNotNull(PersonDetailsGenerator.PERSONAL_CIRC_1.toCircumstance()), + ) + whenever(personalDetailsService.getPersonCircumstances(crn)).thenReturn(expectedResponse) + val res = controller.getPersonCircumstances(crn) + assertThat(res, equalTo(expectedResponse)) + } + + @Test + fun `calls get disabilities function `() { + val crn = "X000005" + + val expectedResponse = DisabilityOverview( + personSummary = personSummary, + disabilities = listOfNotNull(PersonDetailsGenerator.DISABILITY_1.toDisability()), + ) + whenever(personalDetailsService.getPersonDisabilities(crn)).thenReturn(expectedResponse) + val res = controller.getPersonDisabilities(crn) + assertThat(res, equalTo(expectedResponse)) + } + + @Test + fun `calls get provisions function `() { + val crn = "X000005" + val expectedResponse = ProvisionOverview( + personSummary = personSummary, + provisions = listOfNotNull(PersonDetailsGenerator.PROVISION_1.toProvision()), + ) + whenever(personalDetailsService.getPersonProvisions(crn)).thenReturn(expectedResponse) + val res = controller.getPersonProvisions(crn) + assertThat(res, equalTo(expectedResponse)) + } } \ No newline at end of file diff --git a/projects/manage-supervision-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/OverviewServiceTest.kt b/projects/manage-supervision-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/OverviewServiceTest.kt index 79b5f7fca4..30eaa67535 100644 --- a/projects/manage-supervision-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/OverviewServiceTest.kt +++ b/projects/manage-supervision-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/OverviewServiceTest.kt @@ -59,7 +59,7 @@ internal class OverviewServiceTest { whenever(registrationRepository.findByPersonId(any())).thenReturn(emptyList()) whenever(provisionRepository.findByPersonId(any())).thenReturn(emptyList()) whenever(disabilityRepository.findByPersonId(any())).thenReturn(emptyList()) - whenever(personalCircumstanceRepository.findByPersonId(any())).thenReturn(PersonGenerator.PERSONAL_CIRCUMSTANCES) + whenever(personalCircumstanceRepository.findCurrentCircumstances(any())).thenReturn(PersonGenerator.PERSONAL_CIRCUMSTANCES) whenever(contactRepository.findFirstAppointment(any(), any(), any(), any())).thenReturn( listOf(FIRST_APPT_CONTACT) diff --git a/projects/manage-supervision-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/PersonalDetailsServiceTest.kt b/projects/manage-supervision-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/PersonalDetailsServiceTest.kt index 102714682b..bfa8b65143 100644 --- a/projects/manage-supervision-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/PersonalDetailsServiceTest.kt +++ b/projects/manage-supervision-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/PersonalDetailsServiceTest.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.service import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.equalTo import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.mockito.InjectMocks @@ -14,8 +15,6 @@ import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody import uk.gov.justice.digital.hmpps.alfresco.AlfrescoClient -import uk.gov.justice.digital.hmpps.api.model.Name -import uk.gov.justice.digital.hmpps.api.model.PersonSummary import uk.gov.justice.digital.hmpps.api.model.personalDetails.AddressOverview import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator import uk.gov.justice.digital.hmpps.data.generator.personalDetails.PersonDetailsGenerator @@ -58,6 +57,18 @@ internal class PersonalDetailsServiceTest { @InjectMocks lateinit var service: PersonalDetailsService + private lateinit var personSummary: Summary + + @BeforeEach + fun setup() { + val crn = "X000005" + personSummary = Summary( + id = 1, + forename = "TestName", + surname = "TestSurname", crn = "CRN", pnc = "PNC", dateOfBirth = LocalDate.now().minusYears(50) + ) + } + @Test fun `calls personal details function`() { val crn = "X000005" @@ -65,7 +76,7 @@ internal class PersonalDetailsServiceTest { whenever(personRepository.findByCrn(crn)).thenReturn(PersonDetailsGenerator.PERSONAL_DETAILS) whenever(provisionRepository.findByPersonId(any())).thenReturn(emptyList()) whenever(disabilityRepository.findByPersonId(any())).thenReturn(emptyList()) - whenever(personalCircumstanceRepository.findByPersonId(any())).thenReturn(PersonGenerator.PERSONAL_CIRCUMSTANCES) + whenever(personalCircumstanceRepository.findCurrentCircumstances(any())).thenReturn(PersonGenerator.PERSONAL_CIRCUMSTANCES) whenever(aliasRepository.findByPersonId(any())).thenReturn(emptyList()) whenever(personalContactRepository.findByPersonId(any())).thenReturn(emptyList()) @@ -116,27 +127,15 @@ internal class PersonalDetailsServiceTest { @Test fun `calls get summary function`() { val crn = "X000005" - - val expected = Summary( - id = 1, - forename = "TestName", - surname = "TestSurname", crn = "CRN", pnc = "PNC", dateOfBirth = LocalDate.now().minusYears(50) - ) - whenever(personRepository.findSummary(crn)).thenReturn(expected) + whenever(personRepository.findSummary(crn)).thenReturn(personSummary) val res = service.getPersonSummary(crn) - assertThat(res, equalTo(expected.toPersonSummary())) + assertThat(res, equalTo(personSummary.toPersonSummary())) } @Test fun `calls get addresses function`() { val crn = "X000005" - val summary = Summary( - id = 1, - forename = "TestName", - surname = "TestSurname", crn = "CRN", pnc = "PNC", dateOfBirth = LocalDate.now().minusYears(50) - ) - val addresses = listOf( PersonDetailsGenerator.PERSON_ADDRESS_1, PersonDetailsGenerator.PERSON_ADDRESS_2, @@ -144,18 +143,14 @@ internal class PersonalDetailsServiceTest { ) val expectedResponse = AddressOverview( - personSummary = PersonSummary( - Name(forename = summary.forename, middleName = null, surname = summary.surname), - pnc = summary.pnc, - crn = summary.crn, - dateOfBirth = summary.dateOfBirth - ), + personSummary = personSummary.toPersonSummary(), previousAddresses = listOfNotNull(PersonDetailsGenerator.PREVIOUS_ADDRESS.toAddress()), mainAddress = PersonDetailsGenerator.PERSON_ADDRESS_1.toAddress(), otherAddresses = listOfNotNull(PersonDetailsGenerator.PERSON_ADDRESS_2.toAddress()) ) - whenever(personRepository.findSummary(crn)).thenReturn(summary) + whenever(personRepository.findSummary(crn)).thenReturn(personSummary) + whenever(addressRepository.findByPersonId(1)).thenReturn(addresses) val res = service.getPersonAddresses(crn) assertThat(res, equalTo(expectedResponse))