Skip to content

Commit

Permalink
PI-1939 - add additional sentences to Conviction and update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
achimber-moj committed Mar 18, 2024
1 parent c62a4c3 commit 6f3509c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ object AdditionalSentenceGenerator {
val REF_FINE = generateReferenceDate("FINE", "Fine")

val SENTENCE_DISQ = generateSentence(length = 3, referenceData = REF_DISQ)
val SENTENCE_FINE = generateSentence(amount = 500, referenceData = REF_FINE)
val SENTENCE_FINE = generateSentence(amount = 500, referenceData = REF_FINE, notes = "fine notes")
fun generateSentence(
length: Long? = null,
amount: Long? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ class SentenceIntegrationTest {
Offence("Assault", 1)
)
),
Conviction("Hull Court", "Birmingham Court", LocalDate.now()),
listOf(AdditionalSentence(3, null, null, "Disqualified from Driving"))
Conviction("Hull Court", "Birmingham Court", LocalDate.now(), listOf(AdditionalSentence(3, null, null, "Disqualified from Driving")))
),
Sentence(
OffenceDetails(
Expand All @@ -51,8 +50,7 @@ class SentenceIntegrationTest {
"overview",
emptyList()
),
Conviction(null, null, null),
listOf()
Conviction(null, null, null, listOf())
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import java.time.LocalDate
data class Conviction(
val sentencingCourt: String?,
val responsibleCourt: String?,
val convictionDate: LocalDate?
val convictionDate: LocalDate?,
val additionalSentences: List<AdditionalSentence>
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package uk.gov.justice.digital.hmpps.api.model.sentence
data class Sentence(
val offence: OffenceDetails,
val conviction: Conviction? = null,
val additionalSentences: List<AdditionalSentence>

)
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ class SentenceService(
}
)
),
Conviction(sentencingCourt = courtAppearance?.court?.name, responsibleCourt = court?.name, convictionDate = convictionDate),
additionalSentences.map { it.toAdditionalSentence() }
Conviction(sentencingCourt = courtAppearance?.court?.name,
responsibleCourt = court?.name,
convictionDate = convictionDate,
additionalSentences.map { it.toAdditionalSentence() })
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.mockito.Mock
import org.mockito.junit.jupiter.MockitoExtension
import org.mockito.kotlin.*
import uk.gov.justice.digital.hmpps.api.model.sentence.*
import uk.gov.justice.digital.hmpps.data.generator.AdditionalSentenceGenerator
import uk.gov.justice.digital.hmpps.data.generator.CourtAppearanceGenerator
import uk.gov.justice.digital.hmpps.data.generator.CourtGenerator
import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator
Expand Down Expand Up @@ -71,6 +72,9 @@ class SentenceServiceTest {
.getFirstCourtAppearanceByEventIdOrderByDate(event.id))
.thenReturn(CourtAppearanceGenerator.generate(CourtGenerator.DEFAULT))

whenever(additionalSentenceRepository.getAllByEvent_Id(event.id))
.thenReturn(listOf(AdditionalSentenceGenerator.SENTENCE_DISQ, AdditionalSentenceGenerator.SENTENCE_FINE))

val response = service.getMostRecentActiveEvent(PersonGenerator.OVERVIEW.crn)

val expected = SentenceOverview(
Expand All @@ -86,9 +90,11 @@ class SentenceServiceTest {
),
Conviction("Hull Court",
null,
null
),
listOf()
null,
listOf(AdditionalSentence(3, null, null, "Disqualified from Driving"),
AdditionalSentence(null, 500, "fine notes", "Fine")
)
)
)
)
)
Expand Down

0 comments on commit 6f3509c

Please sign in to comment.