From 450e7df8db367647ae472597df6c0262ee461803 Mon Sep 17 00:00:00 2001 From: AlexHerbertMadeTech Date: Fri, 9 Feb 2024 14:48:25 +0000 Subject: [PATCH 1/5] [HIA-662] Making base changes --- .../prisoneroffendersearch/POSPrisoner.kt | 31 ++++++++-------- .../probationoffendersearch/Offender.kt | 36 ++++++++++--------- 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/POSPrisoner.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/POSPrisoner.kt index acdd61777..b363b0812 100644 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/POSPrisoner.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/POSPrisoner.kt @@ -16,19 +16,20 @@ data class POSPrisoner( val pncNumber: String? = null, val croNumber: String? = null, ) { - fun toPerson(): Person = Person( - firstName = this.firstName, - lastName = this.lastName, - middleName = this.middleNames, - dateOfBirth = this.dateOfBirth, - gender = this.gender, - ethnicity = this.ethnicity, - aliases = this.aliases.map { it.toAlias() }, - identifiers = Identifiers( - nomisNumber = this.prisonerNumber, - croNumber = this.croNumber, - ), - pncId = this.pncNumber, - hmppsId = this.pncNumber, - ) + fun toPerson(): Person = + Person( + firstName = this.firstName, + lastName = this.lastName, + middleName = this.middleNames, + dateOfBirth = this.dateOfBirth, + gender = this.gender, + ethnicity = this.ethnicity, + aliases = this.aliases.map { it.toAlias() }, + identifiers = + Identifiers( + nomisNumber = this.prisonerNumber, + croNumber = this.croNumber, + ), + pncId = this.pncNumber, + ) } diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/probationoffendersearch/Offender.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/probationoffendersearch/Offender.kt index e5e4f341c..e6c3575d0 100755 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/probationoffendersearch/Offender.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/probationoffendersearch/Offender.kt @@ -15,21 +15,23 @@ data class Offender( val contactDetails: ContactDetailsWithEmailAndPhone? = null, val otherIds: OtherIds = OtherIds(), ) { - fun toPerson(): Person = Person( - firstName = this.firstName, - lastName = this.surname, - middleName = this.middleNames.joinToString(" ").ifEmpty { "" }, - dateOfBirth = this.dateOfBirth, - gender = this.gender, - ethnicity = this.offenderProfile.ethnicity, - aliases = this.offenderAliases.map { it.toAlias() }, - identifiers = Identifiers( - nomisNumber = otherIds.nomsNumber, - croNumber = otherIds.croNumber, - deliusCrn = otherIds.crn, - ), - pncId = otherIds.pncNumber, - hmppsId = otherIds.pncNumber, - contactDetails = this.contactDetails?.toContactdetails(), - ) + fun toPerson(): Person = + Person( + firstName = this.firstName, + lastName = this.surname, + middleName = this.middleNames.joinToString(" ").ifEmpty { "" }, + dateOfBirth = this.dateOfBirth, + gender = this.gender, + ethnicity = this.offenderProfile.ethnicity, + aliases = this.offenderAliases.map { it.toAlias() }, + identifiers = + Identifiers( + nomisNumber = otherIds.nomsNumber, + croNumber = otherIds.croNumber, + deliusCrn = otherIds.crn, + ), + pncId = otherIds.pncNumber, + hmppsId = otherIds.crn, + contactDetails = this.contactDetails?.toContactdetails(), + ) } From 146cffbe592c73585fb74b9615ed2296e2592683 Mon Sep 17 00:00:00 2001 From: AlexHerbertMadeTech Date: Fri, 9 Feb 2024 15:04:11 +0000 Subject: [PATCH 2/5] [HIA-662] Making test changes --- .../prisoneroffendersearch/PrisonerTest.kt | 33 ++++++------ .../probationoffendersearch/OffenderTest.kt | 50 ++++++++++--------- 2 files changed, 45 insertions(+), 38 deletions(-) diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/PrisonerTest.kt b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/PrisonerTest.kt index 683b9a5bc..305b1c85a 100644 --- a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/PrisonerTest.kt +++ b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/PrisonerTest.kt @@ -6,24 +6,27 @@ import io.kotest.matchers.shouldBe import io.kotest.matchers.types.shouldBeTypeOf import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Alias import java.time.LocalDate + class PrisonerTest : DescribeSpec( { describe("#toPerson") { it("maps one-to-one attributes to person attributes") { - val prisoner = POSPrisoner( - firstName = "First Name", - lastName = "Last Name", - middleNames = "Middle Name", - dateOfBirth = LocalDate.parse("2023-03-01"), - gender = "Gender", - ethnicity = "Ethnicity", - prisonerNumber = "prisonerNumber", - pncNumber = "pncNumber", - croNumber = "croNumber", - aliases = listOf( - POSPrisonerAlias(firstName = "Alias First Name", lastName = "Alias Last Name"), - ), - ) + val prisoner = + POSPrisoner( + firstName = "First Name", + lastName = "Last Name", + middleNames = "Middle Name", + dateOfBirth = LocalDate.parse("2023-03-01"), + gender = "Gender", + ethnicity = "Ethnicity", + prisonerNumber = "prisonerNumber", + pncNumber = "pncNumber", + croNumber = "croNumber", + aliases = + listOf( + POSPrisonerAlias(firstName = "Alias First Name", lastName = "Alias Last Name"), + ), + ) val person = prisoner.toPerson() @@ -38,7 +41,7 @@ class PrisonerTest : DescribeSpec( person.identifiers.croNumber.shouldBe(prisoner.croNumber) person.identifiers.deliusCrn.shouldBeNull() person.pncId.shouldBe(prisoner.pncNumber) - person.hmppsId.shouldBe(prisoner.pncNumber) +// person.hmppsId.shouldBe(prisoner.pncNumber) } } }, diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/probationoffendersearch/OffenderTest.kt b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/probationoffendersearch/OffenderTest.kt index afb7b0213..559c041e3 100644 --- a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/probationoffendersearch/OffenderTest.kt +++ b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/probationoffendersearch/OffenderTest.kt @@ -11,23 +11,26 @@ class OffenderTest : DescribeSpec( { describe("#toPerson") { it("maps one-to-one attributes to person attributes") { - val offender = Offender( - firstName = "First Name", - surname = "Surname", - middleNames = listOf("Middle Name"), - dateOfBirth = LocalDate.parse("2023-03-01"), - gender = "Gender", - offenderProfile = OffenderProfile(ethnicity = "Ethnicity"), - offenderAliases = listOf( - OffenderAlias(firstName = "Alias First Name", surname = "Alias Surname"), - ), - otherIds = OtherIds( - pncNumber = "pncNumber", - nomsNumber = "nomsNumber", - croNumber = "croNumber", - crn = "crn", - ), - ) + val offender = + Offender( + firstName = "First Name", + surname = "Surname", + middleNames = listOf("Middle Name"), + dateOfBirth = LocalDate.parse("2023-03-01"), + gender = "Gender", + offenderProfile = OffenderProfile(ethnicity = "Ethnicity"), + offenderAliases = + listOf( + OffenderAlias(firstName = "Alias First Name", surname = "Alias Surname"), + ), + otherIds = + OtherIds( + pncNumber = "pncNumber", + nomsNumber = "nomsNumber", + croNumber = "croNumber", + crn = "crn", + ), + ) val person = offender.toPerson() @@ -42,15 +45,16 @@ class OffenderTest : DescribeSpec( person.identifiers.croNumber.shouldBe(offender.otherIds.croNumber) person.identifiers.deliusCrn.shouldBe(offender.otherIds.crn) person.pncId.shouldBe(offender.otherIds.pncNumber) - person.hmppsId.shouldBe(offender.otherIds.pncNumber) + person.hmppsId.shouldBe(offender.otherIds.crn) } it("returns null when no middle names") { - val prisoner = Offender( - firstName = "First Name", - surname = "Surname", - middleNames = listOf(), - ) + val prisoner = + Offender( + firstName = "First Name", + surname = "Surname", + middleNames = listOf(), + ) val person = prisoner.toPerson() From c30ff9fd5b42a189750313a3c6c8042ff6103205 Mon Sep 17 00:00:00 2001 From: AlexHerbertMadeTech Date: Mon, 12 Feb 2024 09:40:27 +0000 Subject: [PATCH 3/5] [HIA-662] Lint formatting --- .../prisoneroffendersearch/POSPrisoner.kt | 8 ++++---- .../models/probationoffendersearch/Offender.kt | 10 +++++----- .../prisoneroffendersearch/PrisonerTest.kt | 6 +++--- .../probationoffendersearch/OffenderTest.kt | 18 +++++++++--------- 4 files changed, 21 insertions(+), 21 deletions(-) mode change 100644 => 100755 src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/POSPrisoner.kt mode change 100644 => 100755 src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/PrisonerTest.kt mode change 100644 => 100755 src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/probationoffendersearch/OffenderTest.kt diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/POSPrisoner.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/POSPrisoner.kt old mode 100644 new mode 100755 index b363b0812..2ac24e248 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/POSPrisoner.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/POSPrisoner.kt @@ -26,10 +26,10 @@ data class POSPrisoner( ethnicity = this.ethnicity, aliases = this.aliases.map { it.toAlias() }, identifiers = - Identifiers( - nomisNumber = this.prisonerNumber, - croNumber = this.croNumber, - ), + Identifiers( + nomisNumber = this.prisonerNumber, + croNumber = this.croNumber, + ), pncId = this.pncNumber, ) } diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/probationoffendersearch/Offender.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/probationoffendersearch/Offender.kt index e6c3575d0..a8fcd4988 100755 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/probationoffendersearch/Offender.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/probationoffendersearch/Offender.kt @@ -25,11 +25,11 @@ data class Offender( ethnicity = this.offenderProfile.ethnicity, aliases = this.offenderAliases.map { it.toAlias() }, identifiers = - Identifiers( - nomisNumber = otherIds.nomsNumber, - croNumber = otherIds.croNumber, - deliusCrn = otherIds.crn, - ), + Identifiers( + nomisNumber = otherIds.nomsNumber, + croNumber = otherIds.croNumber, + deliusCrn = otherIds.crn, + ), pncId = otherIds.pncNumber, hmppsId = otherIds.crn, contactDetails = this.contactDetails?.toContactdetails(), diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/PrisonerTest.kt b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/PrisonerTest.kt old mode 100644 new mode 100755 index 305b1c85a..26dad6ab8 --- a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/PrisonerTest.kt +++ b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/PrisonerTest.kt @@ -23,9 +23,9 @@ class PrisonerTest : DescribeSpec( pncNumber = "pncNumber", croNumber = "croNumber", aliases = - listOf( - POSPrisonerAlias(firstName = "Alias First Name", lastName = "Alias Last Name"), - ), + listOf( + POSPrisonerAlias(firstName = "Alias First Name", lastName = "Alias Last Name"), + ), ) val person = prisoner.toPerson() diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/probationoffendersearch/OffenderTest.kt b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/probationoffendersearch/OffenderTest.kt old mode 100644 new mode 100755 index 559c041e3..3f17c60db --- a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/probationoffendersearch/OffenderTest.kt +++ b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/probationoffendersearch/OffenderTest.kt @@ -20,16 +20,16 @@ class OffenderTest : DescribeSpec( gender = "Gender", offenderProfile = OffenderProfile(ethnicity = "Ethnicity"), offenderAliases = - listOf( - OffenderAlias(firstName = "Alias First Name", surname = "Alias Surname"), - ), + listOf( + OffenderAlias(firstName = "Alias First Name", surname = "Alias Surname"), + ), otherIds = - OtherIds( - pncNumber = "pncNumber", - nomsNumber = "nomsNumber", - croNumber = "croNumber", - crn = "crn", - ), + OtherIds( + pncNumber = "pncNumber", + nomsNumber = "nomsNumber", + croNumber = "croNumber", + crn = "crn", + ), ) val person = offender.toPerson() From db4d8dd0b9255d2c5f88a57ff0862a813d5c042c Mon Sep 17 00:00:00 2001 From: AlexHerbertMadeTech Date: Mon, 12 Feb 2024 15:02:08 +0000 Subject: [PATCH 4/5] [HIA-662] Removing unnecessary commented code --- .../models/prisoneroffendersearch/PrisonerTest.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/PrisonerTest.kt b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/PrisonerTest.kt index 26dad6ab8..080459989 100755 --- a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/PrisonerTest.kt +++ b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/PrisonerTest.kt @@ -23,9 +23,9 @@ class PrisonerTest : DescribeSpec( pncNumber = "pncNumber", croNumber = "croNumber", aliases = - listOf( - POSPrisonerAlias(firstName = "Alias First Name", lastName = "Alias Last Name"), - ), + listOf( + POSPrisonerAlias(firstName = "Alias First Name", lastName = "Alias Last Name"), + ), ) val person = prisoner.toPerson() @@ -41,7 +41,6 @@ class PrisonerTest : DescribeSpec( person.identifiers.croNumber.shouldBe(prisoner.croNumber) person.identifiers.deliusCrn.shouldBeNull() person.pncId.shouldBe(prisoner.pncNumber) -// person.hmppsId.shouldBe(prisoner.pncNumber) } } }, From baff5edfa1ac74df2794d0ff65db9e6b2b78ad9c Mon Sep 17 00:00:00 2001 From: AlexHerbertMadeTech Date: Mon, 12 Feb 2024 15:06:04 +0000 Subject: [PATCH 5/5] [HIA-662] One last format --- .../models/prisoneroffendersearch/PrisonerTest.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/PrisonerTest.kt b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/PrisonerTest.kt index 080459989..c1f298dc5 100755 --- a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/PrisonerTest.kt +++ b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/PrisonerTest.kt @@ -23,9 +23,9 @@ class PrisonerTest : DescribeSpec( pncNumber = "pncNumber", croNumber = "croNumber", aliases = - listOf( - POSPrisonerAlias(firstName = "Alias First Name", lastName = "Alias Last Name"), - ), + listOf( + POSPrisonerAlias(firstName = "Alias First Name", lastName = "Alias Last Name"), + ), ) val person = prisoner.toPerson()