From e2508d5ff7979d2e03cd53198799efffa648f1e9 Mon Sep 17 00:00:00 2001 From: Marcus Aspin Date: Wed, 6 Nov 2024 11:42:02 +0000 Subject: [PATCH] Log offender-event notifications to Telemetry --- .../kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt | 6 +++--- .../integrations/delius/offender/OffenderDeltaService.kt | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/projects/offender-events-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/projects/offender-events-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index 82caf7b12e..b516699c74 100644 --- a/projects/offender-events-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/projects/offender-events-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -1,5 +1,7 @@ package uk.gov.justice.digital.hmpps +import org.hamcrest.MatcherAssert.assertThat +import org.hamcrest.Matchers.hasItems import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource @@ -16,8 +18,6 @@ import uk.gov.justice.digital.hmpps.integrations.delius.offender.OffenderDeltaRe import uk.gov.justice.digital.hmpps.integrations.delius.offender.OffenderDeltaService import uk.gov.justice.digital.hmpps.messaging.HmppsChannelManager import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import java.time.format.DateTimeFormatter.ISO_ZONED_DATE_TIME -import java.time.temporal.ChronoUnit @SpringBootTest internal class IntegrationTest { @@ -48,7 +48,7 @@ internal class IntegrationTest { expected.forEach { verify(telemetryService, timeout(30000)).trackEvent( eq("OffenderEventPublished"), - eq(it + ("occurredAt" to ISO_ZONED_DATE_TIME.format(delta.dateChanged.truncatedTo(ChronoUnit.SECONDS)))), + check { properties -> assertThat(properties.entries, hasItems(*it.entries.toTypedArray())) }, any() ) } diff --git a/projects/offender-events-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/offender/OffenderDeltaService.kt b/projects/offender-events-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/offender/OffenderDeltaService.kt index 0f3a07c0c2..7fa2763c1c 100644 --- a/projects/offender-events-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/offender/OffenderDeltaService.kt +++ b/projects/offender-events-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/offender/OffenderDeltaService.kt @@ -33,7 +33,8 @@ class OffenderDeltaService( mapOf( "crn" to it.message.crn, "eventType" to it.eventType!!, - "occurredAt" to ISO_ZONED_DATE_TIME.format(it.message.eventDatetime) + "occurredAt" to ISO_ZONED_DATE_TIME.format(it.message.eventDatetime), + "notification" to it.toString(), ) ) }