Skip to content

Commit

Permalink
Merge pull request #2538 from ministryofjustice/feature/APS-1482__avo…
Browse files Browse the repository at this point in the history
…id_offences_breaking_change

Change case-detail offence id data type (due to AP and Delius changes)
  • Loading branch information
gregkhawkins authored Nov 20, 2024
2 parents 4ab7219 + 0bc6ba8 commit c922778
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -49,14 +50,14 @@ class CaseDetailFactory : Factory<CaseDetail> {
}

class CaseDetailOffenceFactory : Factory<Offence> {
var id: Yielded<Long> = { randomLong() }
var id: Yielded<String> = { randomStringMultiCaseWithNumbers(9) }
var description: Yielded<String> = { randomStringLowerCase(10) }
var date: Yielded<LocalDate> = { LocalDate.now() }
var main: Yielded<Boolean> = { false }
var eventNumber: Yielded<String> = { randomStringLowerCase(10) }
var eventId: Yielded<Long> = { randomLong() }

fun withId(id: Long) = apply {
fun withId(id: String) = apply {
this.id = { id }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -76,7 +76,7 @@ class OffenceTransformerTest {
ActiveOffence(
deliusEventNumber = "5",
offenceDescription = "A Description",
offenceId = "1",
offenceId = "M1",
convictionId = 12345,
offenceDate = LocalDate.parse("2022-12-06"),
),
Expand All @@ -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")
Expand All @@ -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"),
),
Expand Down

0 comments on commit c922778

Please sign in to comment.