Skip to content

Commit

Permalink
MAN-28 - update api so that empty list is returned where no lc note i…
Browse files Browse the repository at this point in the history
…s returned from db
  • Loading branch information
achimber-moj committed Oct 18, 2024
1 parent 14cf66e commit d71af94
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.withToken
import java.time.LocalDate
import uk.gov.justice.digital.hmpps.data.generator.LicenceConditionGenerator.LIC_COND_MAIN_CAT
import uk.gov.justice.digital.hmpps.data.generator.LicenceConditionGenerator.LIC_COND_SUB_CAT
import org.springframework.test.web.servlet.result.MockMvcResultHandlers.print

@AutoConfigureMockMvc
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
Expand All @@ -49,6 +50,7 @@ class SentenceIntegrationTest {
fun `get active sentences`() {
val response = mockMvc
.perform(MockMvcRequestBuilders.get("/sentence/${PersonGenerator.OVERVIEW.crn}").withToken())
.andDo(print())
.andExpect(MockMvcResultMatchers.status().isOk)
.andReturn().response.contentAsJson<SentenceOverview>()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ data class LicenceCondition(
val subTypeDescription: String? = null,
val imposedReleasedDate: LocalDate,
val actualStartDate: LocalDate? = null,
val notes: List<LicenceConditionNote>? = null
val notes: List<LicenceConditionNote> = listOf()
)

data class LicenceConditionNote(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class LicenceConditionService(
}
}

fun EntityLicenceCondition.toLicenceConditionNote(truncateNote: Boolean): List<LicenceConditionNote>? {
fun EntityLicenceCondition.toLicenceConditionNote(truncateNote: Boolean): List<LicenceConditionNote> {

return notes?.let {
val splitParam = "---------------------------------------------------------" + System.lineSeparator()
Expand Down Expand Up @@ -65,5 +65,5 @@ fun EntityLicenceCondition.toLicenceConditionNote(truncateNote: Boolean): List<L
}
)
}
}
} ?: listOf()
}

0 comments on commit d71af94

Please sign in to comment.