diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/model/deliuscontext/CaseDetail.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/model/deliuscontext/CaseDetail.kt index 086e896318..5ac69c3a4b 100644 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/model/deliuscontext/CaseDetail.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/model/deliuscontext/CaseDetail.kt @@ -62,7 +62,7 @@ data class Profile( ) data class Offence( - val id: Long, + val id: String, val description: String, val date: LocalDate?, val main: Boolean, diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/transformer/OffenceTransformer.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/transformer/OffenceTransformer.kt index 9168c48e10..d9ba769599 100644 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/transformer/OffenceTransformer.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/transformer/OffenceTransformer.kt @@ -22,7 +22,7 @@ class OffenceTransformer { ActiveOffence( deliusEventNumber = it.eventNumber, offenceDescription = it.description, - offenceId = it.id.toString(), + offenceId = it.id, convictionId = it.eventId, offenceDate = it.date, ) diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/factory/CaseDetailFactory.kt b/src/test/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/factory/CaseDetailFactory.kt index f0f79bd758..20339a8ea5 100644 --- a/src/test/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/factory/CaseDetailFactory.kt +++ b/src/test/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/factory/CaseDetailFactory.kt @@ -14,6 +14,7 @@ import uk.gov.justice.digital.hmpps.approvedpremisesapi.model.deliuscontext.Regi import uk.gov.justice.digital.hmpps.approvedpremisesapi.model.deliuscontext.Team import uk.gov.justice.digital.hmpps.approvedpremisesapi.util.randomLong import uk.gov.justice.digital.hmpps.approvedpremisesapi.util.randomStringLowerCase +import uk.gov.justice.digital.hmpps.approvedpremisesapi.util.randomStringMultiCaseWithNumbers import uk.gov.justice.digital.hmpps.approvedpremisesapi.util.randomStringUpperCase import java.time.LocalDate import java.time.ZonedDateTime @@ -49,14 +50,14 @@ class CaseDetailFactory : Factory { } class CaseDetailOffenceFactory : Factory { - var id: Yielded = { randomLong() } + var id: Yielded = { randomStringMultiCaseWithNumbers(9) } var description: Yielded = { randomStringLowerCase(10) } var date: Yielded = { LocalDate.now() } var main: Yielded = { false } var eventNumber: Yielded = { randomStringLowerCase(10) } var eventId: Yielded = { randomLong() } - fun withId(id: Long) = apply { + fun withId(id: String) = apply { this.id = { id } } diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/integration/PersonOffencesTest.kt b/src/test/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/integration/PersonOffencesTest.kt index 2caf620dcc..2aefb85df9 100644 --- a/src/test/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/integration/PersonOffencesTest.kt +++ b/src/test/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/integration/PersonOffencesTest.kt @@ -148,7 +148,7 @@ class PersonOffencesTest : InitialiseDatabasePerClassTestBase() { .withOffences( listOf( CaseDetailOffenceFactory() - .withId(1) + .withId("M1") .withDescription("Test Offence 1") .withDate(LocalDate.now().minusMonths(1)) .withEventNumber("123") diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/unit/transformer/OffenceTransformerTest.kt b/src/test/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/unit/transformer/OffenceTransformerTest.kt index b452dba772..90d709df29 100644 --- a/src/test/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/unit/transformer/OffenceTransformerTest.kt +++ b/src/test/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi/unit/transformer/OffenceTransformerTest.kt @@ -63,7 +63,7 @@ class OffenceTransformerTest { .withOffences( listOf( OffenceFactory() - .withOffenceId("1") + .withOffenceId("M1") .withMainCategoryDescription("A Description") .withSubCategoryDescription("A Description") .withOffenceDate(LocalDateTime.parse("2022-12-06T00:00:00")) @@ -76,7 +76,7 @@ class OffenceTransformerTest { ActiveOffence( deliusEventNumber = "5", offenceDescription = "A Description", - offenceId = "1", + offenceId = "M1", convictionId = 12345, offenceDate = LocalDate.parse("2022-12-06"), ), @@ -89,14 +89,14 @@ class OffenceTransformerTest { .withOffences( listOf( CaseDetailOffenceFactory() - .withId(10) + .withId("M10") .withDescription("A first offence") .withDate(LocalDate.parse("2024-11-01")) .withEventNumber("20") .withEventId(30) .produce(), CaseDetailOffenceFactory() - .withId(100) + .withId("A100") .withDescription("A second offence") .withDate(LocalDate.parse("2024-11-11")) .withEventNumber("200") @@ -110,14 +110,14 @@ class OffenceTransformerTest { ActiveOffence( deliusEventNumber = "20", offenceDescription = "A first offence", - offenceId = "10", + offenceId = "M10", convictionId = 30, offenceDate = LocalDate.parse("2024-11-01"), ), ActiveOffence( deliusEventNumber = "200", offenceDescription = "A second offence", - offenceId = "100", + offenceId = "A100", convictionId = 300, offenceDate = LocalDate.parse("2024-11-11"), ),