From a8425e1a28c968729e07ce29a6322d31321e21a8 Mon Sep 17 00:00:00 2001 From: popey2700 Date: Thu, 27 Jun 2024 19:20:35 +0100 Subject: [PATCH 1/4] Update openApi spec --- openapi.yml | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/openapi.yml b/openapi.yml index f96d9a5b1..620255177 100644 --- a/openapi.yml +++ b/openapi.yml @@ -1659,21 +1659,21 @@ components: dtoPostRecallRelease: $ref: "#/components/schemas/SentenceKeyDate" earlyTerm: - $ref: "#/components/schemas/SentenceKeyDate" + $ref: "#/components/schemas/SentenceKeyDateWithCalculatedDate" homeDetentionCurfew: $ref: "#/components/schemas/HomeDetentionCurfewDate" lateTerm: - $ref: "#/components/schemas/SentenceKeyDate" + $ref: "#/components/schemas/SentenceKeyDateWithCalculatedDate" licenceExpiry: - $ref: "#/components/schemas/SentenceKeyDate" + $ref: "#/components/schemas/SentenceKeyDateWithCalculatedDate" midTerm: - $ref: "#/components/schemas/SentenceKeyDate" + $ref: "#/components/schemas/SentenceKeyDateWithCalculatedDate" nonDto: $ref: "#/components/schemas/NonDtoDate" nonParole: $ref: "#/components/schemas/SentenceKeyDate" paroleEligibility: - $ref: "#/components/schemas/SentenceKeyDate" + $ref: "#/components/schemas/SentenceKeyDateWithCalculatedDate" postRecallRelease: $ref: "#/components/schemas/SentenceKeyDate" release: @@ -2256,7 +2256,7 @@ components: type: integer example: 13 description: Number of tagged bail days - SentenceKeyDate: + SentenceKeyDateWithCalculatedDate: type: object properties: date: @@ -2274,6 +2274,19 @@ components: format: date example: 2023-03-01 description: release calculated date for offender + SentenceKeyDate: + type: object + properties: + date: + type: string + format: date + example: 2023-03-01 + description: release date for offender + overrideDate: + type: string + format: date + example: 2023-03-01 + description: release override date for offender HomeDetentionCurfewDate: type: object properties: From ee41fb88082f4067e7b33f1683446adc42995485 Mon Sep 17 00:00:00 2001 From: popey2700 Date: Thu, 27 Jun 2024 19:49:37 +0100 Subject: [PATCH 2/4] Implement JsonInclude for SentencekeyDate --- .../models/hmpps/SentenceKeyDate.kt | 2 + ...nceKeyDatesAndAdjustmentsControllerTest.kt | 193 +++++++++--------- .../GetLatestSentenceKeyDatesForPersonTest.kt | 5 - ...DatesAndAdjustmentsForPersonServiceTest.kt | 5 - 4 files changed, 96 insertions(+), 109 deletions(-) diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/SentenceKeyDate.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/SentenceKeyDate.kt index 3ae8f6eeb..8ddd1f1f2 100644 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/SentenceKeyDate.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/SentenceKeyDate.kt @@ -1,7 +1,9 @@ package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps +import com.fasterxml.jackson.annotation.JsonInclude import java.time.LocalDate +@JsonInclude(JsonInclude.Include.NON_NULL) data class SentenceKeyDate( val date: LocalDate? = null, val overrideDate: LocalDate? = null, diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/controllers/v1/person/sentences/LatestSentenceKeyDatesAndAdjustmentsControllerTest.kt b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/controllers/v1/person/sentences/LatestSentenceKeyDatesAndAdjustmentsControllerTest.kt index fad286121..0ba65ddd0 100644 --- a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/controllers/v1/person/sentences/LatestSentenceKeyDatesAndAdjustmentsControllerTest.kt +++ b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/controllers/v1/person/sentences/LatestSentenceKeyDatesAndAdjustmentsControllerTest.kt @@ -157,106 +157,101 @@ internal class LatestSentenceKeyDatesAndAdjustmentsControllerTest( result.response.contentAsString.shouldContain( """ - { - "data": { - "adjustments": { - "additionalDaysAwarded": 7, - "unlawfullyAtLarge": 10, - "lawfullyAtLarge": 2, - "restoredAdditionalDaysAwarded": 0, - "specialRemission": 11, - "recallSentenceRemand": 1, - "recallSentenceTaggedBail": 3, - "remand": 6, - "taggedBail": 3, - "unusedRemand": 6 - }, - "automaticRelease": { - "date": "2023-04-01", - "overrideDate": "2023-04-01", - "calculatedDate": null - }, - "conditionalRelease": { - "date": "2023-05-01", - "overrideDate": "2023-05-01", - "calculatedDate": null - }, - "dtoPostRecallRelease": { - "date": "2024-01-02", - "overrideDate": "2024-01-02", - "calculatedDate": null - }, - "earlyTerm": { - "date": "2021-11-02", - "overrideDate": "2021-11-02", - "calculatedDate": "2021-11-02" - }, - "homeDetentionCurfew": { - "actualDate": "2022-04-01", - "eligibilityCalculatedDate": "2022-04-01", - "eligibilityDate": "2022-04-01", - "eligibilityOverrideDate": "2022-04-01", - "endDate": "2022-04-01" - }, - "lateTerm": { - "date": "2022-01-01", - "overrideDate": "2022-01-01", - "calculatedDate": "2022-01-01" - }, - "licenceExpiry": { - "date": "2025-02-01", - "overrideDate": "2025-02-01", - "calculatedDate": "2025-02-01" - }, - "midTerm": { - "date": "2024-02-01", - "overrideDate": "2024-02-01", - "calculatedDate": "2024-02-01" - }, - "nonDto": { - "date": "2024-02-01", - "releaseDateType": "CRD" - }, - "nonParole": { - "date": "2026-11-02", - "overrideDate": "2026-11-02", - "calculatedDate": null - }, - "paroleEligibility": { - "date": "2027-02-01", - "overrideDate": "2027-02-01", - "calculatedDate": "2027-02-01" - }, - "postRecallRelease": { - "date": "2028-02-01", - "overrideDate": "2028-02-01", - "calculatedDate": null - }, - "release": { - "date": "2030-02-01", - "confirmedDate": "2030-02-01" - }, - "sentence": { - "effectiveEndDate": "2025-02-01", - "expiryCalculatedDate": "2025-02-01", - "expiryDate": "2025-02-01", - "expiryOverrideDate": "2025-02-01", - "startDate": "2025-02-01" - }, - "topupSupervision": { - "expiryCalculatedDate": "2022-04-01", - "expiryDate": "2022-04-01", - "expiryOverrideDate": "2022-04-01", - "startDate": "2022-04-01" - }, - "actualParoleDate": "2031-02-01", - "earlyRemovalSchemeEligibilityDate": "2031-02-01", - "releaseOnTemporaryLicenceDate": "2031-02-01", - "tariffDate": "2031-02-01", - "tariffEarlyRemovalSchemeEligibilityDate": "2031-02-01" + { + "data": { + "adjustments": { + "additionalDaysAwarded": 7, + "unlawfullyAtLarge": 10, + "lawfullyAtLarge": 2, + "restoredAdditionalDaysAwarded": 0, + "specialRemission": 11, + "recallSentenceRemand": 1, + "recallSentenceTaggedBail": 3, + "remand": 6, + "taggedBail": 3, + "unusedRemand": 6 + }, + "automaticRelease": { + "date": "2023-04-01", + "overrideDate": "2023-04-01" + }, + "conditionalRelease": { + "date": "2023-05-01", + "overrideDate": "2023-05-01" + }, + "dtoPostRecallRelease": { + "date": "2024-01-02", + "overrideDate": "2024-01-02" + }, + "earlyTerm": { + "date": "2021-11-02", + "overrideDate": "2021-11-02", + "calculatedDate": "2021-11-02" + }, + "homeDetentionCurfew": { + "actualDate": "2022-04-01", + "eligibilityCalculatedDate": "2022-04-01", + "eligibilityDate": "2022-04-01", + "eligibilityOverrideDate": "2022-04-01", + "endDate": "2022-04-01" + }, + "lateTerm": { + "date": "2022-01-01", + "overrideDate": "2022-01-01", + "calculatedDate": "2022-01-01" + }, + "licenceExpiry": { + "date": "2025-02-01", + "overrideDate": "2025-02-01", + "calculatedDate": "2025-02-01" + }, + "midTerm": { + "date": "2024-02-01", + "overrideDate": "2024-02-01", + "calculatedDate": "2024-02-01" + }, + "nonDto": { + "date": "2024-02-01", + "releaseDateType": "CRD" + }, + "nonParole": { + "date": "2026-11-02", + "overrideDate": "2026-11-02" + }, + "paroleEligibility": { + "date": "2027-02-01", + "overrideDate": "2027-02-01", + "calculatedDate": "2027-02-01" + }, + "postRecallRelease": { + "date": "2028-02-01", + "overrideDate": "2028-02-01" + }, + "release": { + "date": "2030-02-01", + "confirmedDate": "2030-02-01" + }, + "sentence": { + "effectiveEndDate": "2025-02-01", + "expiryCalculatedDate": "2025-02-01", + "expiryDate": "2025-02-01", + "expiryOverrideDate": "2025-02-01", + "startDate": "2025-02-01" + }, + "topupSupervision": { + "expiryCalculatedDate": "2022-04-01", + "expiryDate": "2022-04-01", + "expiryOverrideDate": "2022-04-01", + "startDate": "2022-04-01" + }, + "actualParoleDate": "2031-02-01", + "earlyRemovalSchemeEligibilityDate": "2031-02-01", + "releaseOnTemporaryLicenceDate": "2031-02-01", + "tariffDate": "2031-02-01", + "tariffEarlyRemovalSchemeEligibilityDate": "2031-02-01" + } } - } - """.removeWhitespaceAndNewlines(), + """.removeWhitespaceAndNewlines(), ) } diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/nomis/GetLatestSentenceKeyDatesForPersonTest.kt b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/nomis/GetLatestSentenceKeyDatesForPersonTest.kt index 002395bcc..01876fec1 100644 --- a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/nomis/GetLatestSentenceKeyDatesForPersonTest.kt +++ b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/nomis/GetLatestSentenceKeyDatesForPersonTest.kt @@ -111,15 +111,12 @@ class GetLatestSentenceKeyDatesForPersonTest( response.data?.automaticRelease?.date.shouldBe(LocalDate.parse("2023-03-01")) response.data?.automaticRelease?.overrideDate.shouldBe(LocalDate.parse("2023-03-01")) - response.data?.automaticRelease?.calculatedDate.shouldBe(null) response.data?.conditionalRelease?.date.shouldBe(LocalDate.parse("2023-04-01")) response.data?.conditionalRelease?.overrideDate.shouldBe(LocalDate.parse("2023-04-01")) - response.data?.conditionalRelease?.calculatedDate.shouldBe(null) response.data?.dtoPostRecallRelease?.date.shouldBe(LocalDate.parse("2023-05-01")) response.data?.dtoPostRecallRelease?.overrideDate.shouldBe(LocalDate.parse("2023-05-01")) - response.data?.dtoPostRecallRelease?.calculatedDate.shouldBe(null) response.data?.earlyTerm?.date.shouldBe(LocalDate.parse("2021-04-01")) response.data?.earlyTerm?.overrideDate.shouldBe(LocalDate.parse("2021-04-01")) @@ -148,7 +145,6 @@ class GetLatestSentenceKeyDatesForPersonTest( response.data?.nonParole?.date.shouldBe(LocalDate.parse("2026-02-01")) response.data?.nonParole?.overrideDate.shouldBe(LocalDate.parse("2026-02-01")) - response.data?.nonParole?.calculatedDate.shouldBe(null) response.data?.paroleEligibility?.date.shouldBe(LocalDate.parse("2027-02-01")) response.data?.paroleEligibility?.overrideDate.shouldBe(LocalDate.parse("2027-02-01")) @@ -156,7 +152,6 @@ class GetLatestSentenceKeyDatesForPersonTest( response.data?.postRecallRelease?.date.shouldBe(LocalDate.parse("2028-02-01")) response.data?.postRecallRelease?.overrideDate.shouldBe(LocalDate.parse("2028-02-01")) - response.data?.postRecallRelease?.calculatedDate.shouldBe(null) response.data?.release?.date.shouldBe(LocalDate.parse("2030-02-01")) response.data?.release?.confirmedDate.shouldBe(LocalDate.parse("2030-02-01")) diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetLatestSentenceKeyDatesAndAdjustmentsForPersonServiceTest.kt b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetLatestSentenceKeyDatesAndAdjustmentsForPersonServiceTest.kt index 4ee30e5ff..65f305331 100644 --- a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetLatestSentenceKeyDatesAndAdjustmentsForPersonServiceTest.kt +++ b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetLatestSentenceKeyDatesAndAdjustmentsForPersonServiceTest.kt @@ -179,15 +179,12 @@ internal class GetLatestSentenceKeyDatesAndAdjustmentsForPersonServiceTest( response.data?.automaticRelease?.date.shouldBe(LocalDate.parse("2023-11-02")) response.data?.automaticRelease?.overrideDate.shouldBe(LocalDate.parse("2023-11-02")) - response.data?.automaticRelease?.calculatedDate.shouldBe(null) response.data?.conditionalRelease?.date.shouldBe(LocalDate.parse("2023-12-02")) response.data?.conditionalRelease?.overrideDate.shouldBe(LocalDate.parse("2023-12-02")) - response.data?.conditionalRelease?.calculatedDate.shouldBe(null) response.data?.dtoPostRecallRelease?.date.shouldBe(LocalDate.parse("2024-01-02")) response.data?.dtoPostRecallRelease?.overrideDate.shouldBe(LocalDate.parse("2024-01-02")) - response.data?.dtoPostRecallRelease?.calculatedDate.shouldBe(null) response.data?.earlyTerm?.date.shouldBe(LocalDate.parse("2021-11-02")) response.data?.earlyTerm?.overrideDate.shouldBe(LocalDate.parse("2021-11-02")) @@ -216,7 +213,6 @@ internal class GetLatestSentenceKeyDatesAndAdjustmentsForPersonServiceTest( response.data?.nonParole?.date.shouldBe(LocalDate.parse("2026-11-02")) response.data?.nonParole?.overrideDate.shouldBe(LocalDate.parse("2026-11-02")) - response.data?.nonParole?.calculatedDate.shouldBe(null) response.data?.paroleEligibility?.date.shouldBe(LocalDate.parse("2027-02-01")) response.data?.paroleEligibility?.overrideDate.shouldBe(LocalDate.parse("2027-02-01")) @@ -224,7 +220,6 @@ internal class GetLatestSentenceKeyDatesAndAdjustmentsForPersonServiceTest( response.data?.postRecallRelease?.date.shouldBe(LocalDate.parse("2028-02-01")) response.data?.postRecallRelease?.overrideDate.shouldBe(LocalDate.parse("2028-02-01")) - response.data?.postRecallRelease?.calculatedDate.shouldBe(null) response.data?.release?.date.shouldBe(LocalDate.parse("2030-02-01")) response.data?.release?.confirmedDate.shouldBe(LocalDate.parse("2030-02-01")) From 9248957f2730647089c390d483297797b8f7b44a Mon Sep 17 00:00:00 2001 From: popey2700 Date: Thu, 27 Jun 2024 19:52:04 +0100 Subject: [PATCH 3/4] Update smoke test --- .../smoke/person/SentencesSmokeTest.kt | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/smoke/person/SentencesSmokeTest.kt b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/smoke/person/SentencesSmokeTest.kt index cf9279703..fdd584275 100644 --- a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/smoke/person/SentencesSmokeTest.kt +++ b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/smoke/person/SentencesSmokeTest.kt @@ -97,18 +97,15 @@ class SentencesSmokeTest : DescribeSpec( }, "automaticRelease": { "date": "2020-02-03", - "overrideDate": "2020-02-03", - "calculatedDate": null + "overrideDate": "2020-02-03" }, "conditionalRelease": { "date": "2020-02-03", - "overrideDate": "2020-02-03", - "calculatedDate": null + "overrideDate": "2020-02-03" }, "dtoPostRecallRelease": { "date": "2020-02-03", - "overrideDate": "2020-04-01", - "calculatedDate": null + "overrideDate": "2020-04-01" }, "earlyTerm": { "date": "2020-02-03", @@ -143,8 +140,7 @@ class SentencesSmokeTest : DescribeSpec( }, "nonParole": { "date": "2020-02-03", - "overrideDate": "2020-02-03", - "calculatedDate": null + "overrideDate": "2020-02-03" }, "paroleEligibility": { "date": "2020-02-03", @@ -153,8 +149,7 @@ class SentencesSmokeTest : DescribeSpec( }, "postRecallRelease": { "date": "2020-02-03", - "overrideDate": "2020-04-01", - "calculatedDate": null + "overrideDate": "2020-04-01" }, "release": { "date": "2020-04-01", From 630315f77f07dfb71c58a9ef27caf6f28f0e3ab8 Mon Sep 17 00:00:00 2001 From: popey2700 Date: Fri, 28 Jun 2024 09:44:43 +0100 Subject: [PATCH 4/4] Trigger Build