diff --git a/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/message/HmppsDomainEvent.kt b/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/message/HmppsDomainEvent.kt index eb945b6137..b18a90ec1d 100644 --- a/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/message/HmppsDomainEvent.kt +++ b/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/message/HmppsDomainEvent.kt @@ -1,5 +1,6 @@ package uk.gov.justice.digital.hmpps.message +import com.fasterxml.jackson.annotation.JsonAlias import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import java.time.ZonedDateTime @@ -10,9 +11,11 @@ data class HmppsDomainEvent( val detailUrl: String? = null, val occurredAt: ZonedDateTime = ZonedDateTime.now(), val description: String? = null, - val additionalInformation: AdditionalInformation = AdditionalInformation(), + @JsonAlias("additionalInformation") private val nullableAdditionalInformation: AdditionalInformation? = AdditionalInformation(), val personReference: PersonReference = PersonReference() -) +) { + val additionalInformation = nullableAdditionalInformation ?: AdditionalInformation() +} data class PersonReference(val identifiers: List = listOf()) { fun findCrn() = get("CRN") @@ -30,6 +33,7 @@ data class AdditionalInformation( operator fun set(key: String, value: Any) { info[key] = value } + fun containsKey(key: String): Boolean { return info.containsKey(key) } diff --git a/libs/messaging/src/test/kotlin/uk/gov/justice/digital/hmpps/converter/HmppsDomainEventConverterTest.kt b/libs/messaging/src/test/kotlin/uk/gov/justice/digital/hmpps/converter/HmppsDomainEventConverterTest.kt index a71c2a5b76..e30d4fca29 100644 --- a/libs/messaging/src/test/kotlin/uk/gov/justice/digital/hmpps/converter/HmppsDomainEventConverterTest.kt +++ b/libs/messaging/src/test/kotlin/uk/gov/justice/digital/hmpps/converter/HmppsDomainEventConverterTest.kt @@ -88,7 +88,7 @@ class HmppsDomainEventConverterTest { message, equalTo( """ - |{"Message":"{\"eventType\":\"message.event.type\",\"version\":1,\"detailUrl\":\"http://detail/url\",\"occurredAt\":\"2022-07-27T15:22:08.509+01:00\",\"description\":\"A description for the event\",\"additionalInformation\":{\"specialId\":\"6aafe304-861f-4479-8380-fec5f90f6d17\"},\"personReference\":{\"identifiers\":[{\"type\":\"CRN\",\"value\":\"X123456\"}]}}", + |{"Message":"{\"eventType\":\"message.event.type\",\"version\":1,\"detailUrl\":\"http://detail/url\",\"occurredAt\":\"2022-07-27T15:22:08.509+01:00\",\"description\":\"A description for the event\",\"personReference\":{\"identifiers\":[{\"type\":\"CRN\",\"value\":\"X123456\"}]},\"additionalInformation\":{\"specialId\":\"6aafe304-861f-4479-8380-fec5f90f6d17\"}}", |"MessageAttributes":{"eventType":{"Type":"String","Value":"attribute.event.type"}},"MessageId":"${hmppsEvent.id}"} """.trimMargin().replace("\\n".toRegex(), "") ) diff --git a/projects/domain-events-and-delius/src/dev/resources/messages/probation-case.engagement.created.json b/projects/domain-events-and-delius/src/dev/resources/messages/probation-case.engagement.created.json index e5884c7d90..2a94aae10e 100644 --- a/projects/domain-events-and-delius/src/dev/resources/messages/probation-case.engagement.created.json +++ b/projects/domain-events-and-delius/src/dev/resources/messages/probation-case.engagement.created.json @@ -4,6 +4,7 @@ "description": "A new probation case has been created", "detailUrl": "https://example.com", "occurredAt": "2023-09-20T16:05:59.442+01:00", + "additionalInformation": null, "personReference": { "identifiers": [ { diff --git a/projects/prison-case-notes-to-probation/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt b/projects/prison-case-notes-to-probation/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt index 5746d2e246..d8708cf6ae 100644 --- a/projects/prison-case-notes-to-probation/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt +++ b/projects/prison-case-notes-to-probation/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt @@ -103,7 +103,7 @@ internal class HandlerTest { @Test fun `get case note from NOMIS has null caseNoteId`() { val message = prepMessage(CaseNoteMessageGenerator.EXISTS_IN_DELIUS).message - val prisonOffenderEvent = Notification(message = message.copy(additionalInformation = AdditionalInformation())) + val prisonOffenderEvent = Notification(message = message.copy(nullableAdditionalInformation = AdditionalInformation())) handler.handle(prisonOffenderEvent) verify(deliusService, times(0)).mergeCaseNote(any()) verify(prisonCaseNotesClient, times(0)).getCaseNote(any()) diff --git a/projects/prison-custody-status-to-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt b/projects/prison-custody-status-to-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt index 5bfabf9c89..6c43bb7e61 100644 --- a/projects/prison-custody-status-to-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt +++ b/projects/prison-custody-status-to-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt @@ -72,7 +72,7 @@ internal class HandlerTest { 1, "https//detail/url", ZonedDateTime.now(), - additionalInformation = AdditionalInformation( + nullableAdditionalInformation = AdditionalInformation( mutableMapOf( "nomsNumber" to "Z0001ZZ", "prisonId" to "ZZZ", @@ -249,7 +249,7 @@ internal class HandlerTest { whenever(featureFlags.enabled("messages_released_hospital")).thenReturn(false) val hospitalNotification = notification.copy( message = notification.message.copy( - additionalInformation = AdditionalInformation( + nullableAdditionalInformation = AdditionalInformation( mutableMapOf( "nomsNumber" to "Z0001ZZ", "prisonId" to "OUT", diff --git a/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/FeedbackSubmittedTest.kt b/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/FeedbackSubmittedTest.kt index c747f15195..4ce5e24713 100644 --- a/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/FeedbackSubmittedTest.kt +++ b/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/FeedbackSubmittedTest.kt @@ -49,7 +49,7 @@ internal class FeedbackSubmittedTest { DomainEventType.InitialAppointmentSubmitted.name, 1, "https://interventions-service/referral/$referralId/supplier-assessment", - additionalInformation = AdditionalInformation( + nullableAdditionalInformation = AdditionalInformation( mutableMapOf( "serviceUserCRN" to crn, "referralId" to referralId.toString(), diff --git a/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/ReferAndMonitorHandlerTest.kt b/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/ReferAndMonitorHandlerTest.kt index 6ba171abe3..a8cf60501d 100644 --- a/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/ReferAndMonitorHandlerTest.kt +++ b/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/ReferAndMonitorHandlerTest.kt @@ -144,7 +144,7 @@ internal class ReferAndMonitorHandlerTest { 1, occurredAt = ZonedDateTime.now(), detailUrl = "DetailUrl", - additionalInformation = AdditionalInformation(mutableMapOf("referralId" to UUID.randomUUID().toString())), + nullableAdditionalInformation = AdditionalInformation(mutableMapOf("referralId" to UUID.randomUUID().toString())), personReference = PersonReference(listOf(PersonIdentifier("CRN", "T123456"))) ), MessageAttributes(SessionAppointmentSubmitted.name) diff --git a/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/ReferralEndSubmittedTest.kt b/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/ReferralEndSubmittedTest.kt index eb8c1d04dd..605611c765 100644 --- a/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/ReferralEndSubmittedTest.kt +++ b/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/ReferralEndSubmittedTest.kt @@ -42,7 +42,7 @@ internal class ReferralEndSubmittedTest { DomainEventType.ReferralEnded.name, 1, "https://fake.org/url", - additionalInformation = AdditionalInformation(mutableMapOf("referralId" to UUID.randomUUID().toString())), + nullableAdditionalInformation = AdditionalInformation(mutableMapOf("referralId" to UUID.randomUUID().toString())), personReference = PersonReference(listOf(PersonIdentifier("CRN", "T123456"))) ) @@ -73,7 +73,7 @@ internal class ReferralEndSubmittedTest { 1, "https://fake.org/url", personReference = PersonReference(listOf(PersonIdentifier("CRN", "T123456"))), - additionalInformation = AdditionalInformation( + nullableAdditionalInformation = AdditionalInformation( mutableMapOf( "referralURN" to UUID.randomUUID().toString(), "deliveryState" to "CANCELLED",