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 69a59cffa0..bb6ce4096d 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 @@ -81,10 +81,6 @@ internal class IntegrationTest { OffenderDeltaGenerator.generate(sourceTable = "MANAGEMENT_TIER_EVENT", sourceId = 99), listOf("OFFENDER_MANAGEMENT_TIER_CALCULATION_REQUIRED") ), - Arguments.of( - OffenderDeltaGenerator.generate(sourceTable = "MANAGEMENT_TIER_EVENT", action = "DELETE", sourceId = 99), - emptyList() - ), Arguments.of( OffenderDeltaGenerator.generate(sourceTable = "MERGE_HISTORY", sourceId = 99), listOf("OFFENDER_MERGED") 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 1bd47250d9..03037bce8f 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 @@ -2,10 +2,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.offender import org.springframework.beans.factory.annotation.Value import org.springframework.data.domain.Pageable -import org.springframework.data.repository.findByIdOrNull import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional -import uk.gov.justice.digital.hmpps.integrations.delius.tier.ManagementTierEventRepository import uk.gov.justice.digital.hmpps.message.MessageAttributes import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.publisher.NotificationPublisher @@ -15,7 +13,6 @@ class OffenderDeltaService( @Value("\${offender-events.batch-size:50}") private val batchSize: Int, private val repository: OffenderDeltaRepository, - private val managementTierEventRepository: ManagementTierEventRepository, private val notificationPublisher: NotificationPublisher ) { @Transactional @@ -33,7 +30,7 @@ class OffenderDeltaService( "DEREGISTRATION" -> "OFFENDER_REGISTRATION_DEREGISTERED" "DISPOSAL" -> "SENTENCE_CHANGED" "EVENT" -> "CONVICTION_CHANGED" - "MANAGEMENT_TIER_EVENT" -> if (managementTierMessageIgnored()) null else "OFFENDER_MANAGEMENT_TIER_CALCULATION_REQUIRED" + "MANAGEMENT_TIER_EVENT" -> "OFFENDER_MANAGEMENT_TIER_CALCULATION_REQUIRED" "MERGE_HISTORY" -> "OFFENDER_MERGED" "OFFENDER" -> "OFFENDER_DETAILS_CHANGED" "OFFICER" -> "OFFENDER_OFFICER_CHANGED" @@ -57,7 +54,4 @@ class OffenderDeltaService( listOf() } } - - private fun OffenderDelta.managementTierMessageIgnored() = action == "DELETE" || - managementTierEventRepository.findByIdOrNull(sourceRecordId)?.reason?.code in listOf("ROSH", "MAP", "REG", "DEREG") } diff --git a/projects/offender-events-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/offender/OffenderDeltaServiceTest.kt b/projects/offender-events-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/offender/OffenderDeltaServiceTest.kt index 4da876619d..b7623512a4 100644 --- a/projects/offender-events-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/offender/OffenderDeltaServiceTest.kt +++ b/projects/offender-events-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/offender/OffenderDeltaServiceTest.kt @@ -3,7 +3,6 @@ package uk.gov.justice.digital.hmpps.integrations.delius.offender import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.equalTo import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments @@ -11,17 +10,12 @@ import org.junit.jupiter.params.provider.MethodSource import org.mockito.Mock import org.mockito.junit.jupiter.MockitoExtension import org.mockito.kotlin.any -import org.mockito.kotlin.never -import org.mockito.kotlin.verify import org.mockito.kotlin.whenever import org.springframework.data.domain.PageImpl import org.springframework.data.domain.Pageable import uk.gov.justice.digital.hmpps.data.generator.OffenderDeltaGenerator -import uk.gov.justice.digital.hmpps.integrations.delius.tier.ManagementTierEvent import uk.gov.justice.digital.hmpps.integrations.delius.tier.ManagementTierEventRepository -import uk.gov.justice.digital.hmpps.integrations.delius.tier.ReferenceData import uk.gov.justice.digital.hmpps.publisher.NotificationPublisher -import java.util.Optional @ExtendWith(MockitoExtension::class) class OffenderDeltaServiceTest { @@ -39,7 +33,7 @@ class OffenderDeltaServiceTest { @BeforeEach fun setup() { - service = OffenderDeltaService(50, repository, managementTierEventRepository, publisher) + service = OffenderDeltaService(50, repository, publisher) } @ParameterizedTest @@ -51,18 +45,6 @@ class OffenderDeltaServiceTest { assertThat(expectedCounts, equalTo(counts)) } - @Test - fun `do not publish registration management tier events`() { - val mteId = 1L - whenever(managementTierEventRepository.findById(mteId)) - .thenReturn(Optional.of(ManagementTierEvent(mteId, ReferenceData("REG", 1L)))) - val deltas = listOf(OffenderDeltaGenerator.generate(sourceId = mteId, sourceTable = "MANAGEMENT_TIER_EVENT")) - whenever(repository.findAll(any())).thenReturn(PageImpl(deltas)) - val counts = service.checkAndSendEvents() - assertThat(counts.first, equalTo(0)) - verify(publisher, never()).publish(any()) - } - companion object { @JvmStatic private fun deltas() = listOf(