From 4309ba86f47dd896ea8f3272b1199e9578261a8d Mon Sep 17 00:00:00 2001 From: Marcus Aspin Date: Mon, 21 Oct 2024 10:26:46 +0000 Subject: [PATCH] PI-2585 Remove unused feature flags --- .../justice/digital/hmpps/IntegrationTest.kt | 23 ++------- .../digital/hmpps/messaging/Handler.kt | 4 +- .../hmpps/service/AssessmentService.kt | 8 +-- .../hmpps/service/LicenceConditionApplier.kt | 50 +++++-------------- .../service/LicenceConditionApplierTest.kt | 47 +---------------- .../hmpps/ReferAndMonitorIntegrationTest.kt | 15 ++---- .../digital/hmpps/service/NsiService.kt | 6 +-- .../digital/hmpps/service/NsiServiceTest.kt | 4 -- .../service/RepositoryExtensionMethodTests.kt | 4 -- .../hmpps/AllocateEventIntegrationTest.kt | 48 +++++------------- .../hmpps/service/AllocateEventService.kt | 30 +---------- .../hmpps/service/AllocateEventServiceTest.kt | 4 -- 12 files changed, 39 insertions(+), 204 deletions(-) diff --git a/projects/assessment-summary-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/projects/assessment-summary-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index e2c6275a4f..796d2d5b9f 100644 --- a/projects/assessment-summary-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/projects/assessment-summary-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -7,7 +7,10 @@ import org.hamcrest.core.IsEqual.equalTo import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.ArgumentMatchers.anyMap -import org.mockito.kotlin.* +import org.mockito.kotlin.check +import org.mockito.kotlin.eq +import org.mockito.kotlin.timeout +import org.mockito.kotlin.verify import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Value import org.springframework.boot.test.context.SpringBootTest @@ -18,7 +21,6 @@ import uk.gov.justice.digital.hmpps.data.entity.IapsPersonRepository import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator import uk.gov.justice.digital.hmpps.data.generator.RegistrationGenerator -import uk.gov.justice.digital.hmpps.flags.FeatureFlags import uk.gov.justice.digital.hmpps.integrations.delius.assessment.entity.OasysAssessmentRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.entity.ContactRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.entity.ContactType @@ -64,28 +66,11 @@ internal class IntegrationTest { @MockBean lateinit var telemetryService: TelemetryService - @MockBean - lateinit var featureFlags: FeatureFlags - lateinit var transactionTemplate: TransactionTemplate @BeforeEach fun setUp() { transactionTemplate = TransactionTemplate(transactionManager) - whenever(featureFlags.enabled(any())).thenReturn(true) - } - - @Test - fun `contact date is set to current date when flag is off`() { - whenever(featureFlags.enabled("assessment-summary-contact-date")).thenReturn(false) - val message = notification("assessment-summary-produced-${PersonGenerator.NO_RISK.crn}") - channelManager.getChannel(queueName).publishAndWait(prepNotification(message, wireMockServer.port())) - - val person = personRepository.getByCrn(PersonGenerator.NO_RISK.crn) - - val contact = contactRepository.findAll() - .single { it.person.id == person.id && it.type.code == ContactType.Code.OASYS_ASSESSMENT.value } - assertThat(contact.date, equalTo(LocalDate.now())) } @Test diff --git a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index 6296bd801e..d919ac8d1c 100644 --- a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -7,7 +7,6 @@ import org.openfolder.kotlinasyncapi.annotation.channel.Publish import org.springframework.stereotype.Component import uk.gov.justice.digital.hmpps.converter.NotificationConverter import uk.gov.justice.digital.hmpps.exception.IgnorableMessageException -import uk.gov.justice.digital.hmpps.flags.FeatureFlags import uk.gov.justice.digital.hmpps.integrations.oasys.OrdsClient import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.Notification @@ -24,13 +23,12 @@ class Handler( override val converter: NotificationConverter, private val ordsClient: OrdsClient, private val assessmentSubmitted: AssessmentSubmitted, - private val featureFlags: FeatureFlags, private val telemetryService: TelemetryService ) : NotificationHandler { @Publish(messages = [Message(title = AssessmentSummaryProduced, payload = Schema(HmppsDomainEvent::class))]) override fun handle(notification: Notification) { try { - if (notification.message.eventType == AssessmentSummaryProduced && featureFlags.enabled("assessment-summary-produced")) { + if (notification.message.eventType == AssessmentSummaryProduced) { telemetryService.notificationReceived(notification) notification.message.detailUrl ?.let { ordsClient.getAssessmentSummary(URI.create(it)) } diff --git a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/AssessmentService.kt b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/AssessmentService.kt index 63548ded9d..427ba375ef 100644 --- a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/AssessmentService.kt +++ b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/AssessmentService.kt @@ -2,7 +2,6 @@ package uk.gov.justice.digital.hmpps.service import org.springframework.stereotype.Service import uk.gov.justice.digital.hmpps.exception.IgnorableMessageException -import uk.gov.justice.digital.hmpps.flags.FeatureFlags import uk.gov.justice.digital.hmpps.integrations.delius.assessment.entity.OasysAssessment import uk.gov.justice.digital.hmpps.integrations.delius.assessment.entity.OasysAssessmentRepository import uk.gov.justice.digital.hmpps.integrations.delius.assessment.entity.SentencePlan @@ -26,7 +25,6 @@ class AssessmentService( private val oasysAssessmentRepository: OasysAssessmentRepository, private val eventRepository: EventRepository, private val contactService: ContactService, - private val featureFlags: FeatureFlags, ) { fun recordAssessment(person: Person, summary: AssessmentSummary) { val previousAssessment = oasysAssessmentRepository.findByOasysId(summary.assessmentPk.toString()) @@ -36,14 +34,12 @@ class AssessmentService( ?: throw IgnorableMessageException("No single active custodial event") val event = eventRepository.getByNumber(person.id, eventNumber) val manager = checkNotNull(person.manager) { "Community Manager Not Found" } - val contactDate = - if (featureFlags.enabled("assessment-summary-contact-date")) summary.dateCompleted else LocalDate.now() val contact = previousAssessment?.contact?.withDateTeamAndStaff( - contactDate, + summary.dateCompleted, manager.teamId, manager.staffId ) ?: contactService.createContact( - summary.contactDetail(contactDate), + summary.contactDetail(summary.dateCompleted), person, event ) diff --git a/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/LicenceConditionApplier.kt b/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/LicenceConditionApplier.kt index 516a52c0c8..8148f08274 100644 --- a/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/LicenceConditionApplier.kt +++ b/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/LicenceConditionApplier.kt @@ -3,7 +3,6 @@ package uk.gov.justice.digital.hmpps.service import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional import uk.gov.justice.digital.hmpps.audit.service.OptimisationTables -import uk.gov.justice.digital.hmpps.flags.FeatureFlags import uk.gov.justice.digital.hmpps.integrations.cvl.ActivatedLicence import uk.gov.justice.digital.hmpps.integrations.cvl.AdditionalLicenceCondition import uk.gov.justice.digital.hmpps.integrations.cvl.telemetryProperties @@ -38,7 +37,6 @@ class LicenceConditionApplier( private val licenceConditionService: LicenceConditionService, private val contactService: ContactService, private val optimisationTables: OptimisationTables, - private val featureFlags: FeatureFlags ) { @Transactional fun applyLicenceConditions( @@ -58,41 +56,19 @@ class LicenceConditionApplier( ) optimisationTables.rebuild(com.person.id) - return when (featureFlags.enabled("cvl-multiple-sentences")) { - true -> - when (sentences.size) { - 0 -> listOf(ActionResult.Ignored("No Custodial Sentences", properties)) - else -> sentences.maxBy { it.disposal.expectedEndDate() } - .let { - applyLicenceConditions( - SentencedCase( - com, - it.disposal, - licenceConditionService.findByDisposalId(it.disposal.id) - ), - activatedLicence, - occurredAt - ) - } - } - - false -> when (sentences.size) { - 0 -> listOf(ActionResult.Ignored("No Custodial Sentences", properties)) - 1 -> sentences.flatMap { - applyLicenceConditions( - SentencedCase(com, it.disposal, licenceConditionService.findByDisposalId(it.disposal.id)), - activatedLicence, - occurredAt - ) - } - - else -> listOf( - ActionResult.Ignored( - "Multiple Custodial Sentences", - properties - ) - ) - } + return if (sentences.isEmpty()) { + listOf(ActionResult.Ignored("No Custodial Sentences", properties)) + } else { + val latestSentence = sentences.maxBy { it.disposal.expectedEndDate() } + applyLicenceConditions( + SentencedCase( + com, + latestSentence.disposal, + licenceConditionService.findByDisposalId(latestSentence.disposal.id) + ), + activatedLicence, + occurredAt + ) } } diff --git a/projects/create-and-vary-a-licence-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/LicenceConditionApplierTest.kt b/projects/create-and-vary-a-licence-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/LicenceConditionApplierTest.kt index c8a1f3e528..801d44da6f 100644 --- a/projects/create-and-vary-a-licence-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/LicenceConditionApplierTest.kt +++ b/projects/create-and-vary-a-licence-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/LicenceConditionApplierTest.kt @@ -16,7 +16,6 @@ import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.LC_STANDARD_CATEGORY import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.LC_STANDARD_SUB_CATEGORY import uk.gov.justice.digital.hmpps.data.generator.SentenceGenerator -import uk.gov.justice.digital.hmpps.flags.FeatureFlags import uk.gov.justice.digital.hmpps.integrations.cvl.ActivatedLicence import uk.gov.justice.digital.hmpps.integrations.cvl.ApConditions import uk.gov.justice.digital.hmpps.integrations.cvl.Conditions @@ -54,9 +53,6 @@ internal class LicenceConditionApplierTest { @Mock internal lateinit var optimisationTables: OptimisationTables - @Mock - internal lateinit var featureFlags: FeatureFlags - @InjectMocks internal lateinit var licenceConditionApplier: LicenceConditionApplier @@ -136,49 +132,9 @@ internal class LicenceConditionApplierTest { ) } - @Test - fun `when multiple active custodial sentence it is logged to telemetry feature flag set to false`() { - val crn = "M728831" - val person = PersonGenerator.generatePerson(crn) - val activatedLicence = ActivatedLicence( - crn, - LocalDate.now(), - Conditions(ApConditions(listOf(), listOf(), listOf())) - ) - val occurredAt = ZonedDateTime.now() - whenever(personManagerRepository.findByPersonCrn(crn)).thenReturn(PersonGenerator.DEFAULT_CM) - whenever(custodyRepository.findCustodialSentences(crn)).thenReturn( - listOf( - SentenceGenerator.generate(SentenceGenerator.generateEvent("1", person), endDate = LocalDate.now()), - SentenceGenerator.generate(SentenceGenerator.generateEvent("2", person), endDate = LocalDate.now()) - ) - ) - - whenever(featureFlags.enabled("cvl-multiple-sentences")).thenReturn(false) - - val ex = licenceConditionApplier.applyLicenceConditions( - crn, - activatedLicence, - occurredAt - ) - assertThat( - ex.first(), equalTo( - ActionResult.Ignored( - "Multiple Custodial Sentences", - mapOf( - "crn" to crn, - "startDate" to activatedLicence.startDate.toString(), - "occurredAt" to occurredAt.toString(), - "sentenceCount" to "2" - ) - ) - ) - ) - } - @ParameterizedTest @ValueSource(strings = ["endDate", "enteredEndDate"]) - fun `when multiple active custodial sentence create CVL where end date is populated feature flag set to true`(field: String) { + fun `when multiple active custodial sentence create CVL where end date is populated`(field: String) { val crn = "M728831" val person = PersonGenerator.generatePerson(crn) val activatedLicence = ActivatedLicence( @@ -188,7 +144,6 @@ internal class LicenceConditionApplierTest { ) val occurredAt = ZonedDateTime.now() whenever(personManagerRepository.findByPersonCrn(crn)).thenReturn(PersonGenerator.DEFAULT_CM) - whenever(featureFlags.enabled("cvl-multiple-sentences")).thenReturn(true) var sentence2: Custody? = null var sentence4: Custody? = null diff --git a/projects/refer-and-monitor-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ReferAndMonitorIntegrationTest.kt b/projects/refer-and-monitor-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ReferAndMonitorIntegrationTest.kt index cac0f96210..3399dedb6b 100644 --- a/projects/refer-and-monitor-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ReferAndMonitorIntegrationTest.kt +++ b/projects/refer-and-monitor-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ReferAndMonitorIntegrationTest.kt @@ -4,10 +4,12 @@ import com.github.tomakehurst.wiremock.WireMockServer import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.containsString import org.hamcrest.Matchers.equalTo -import org.junit.jupiter.api.* import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.MethodOrderer +import org.junit.jupiter.api.Order +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.TestMethodOrder import org.mockito.kotlin.verify -import org.mockito.kotlin.whenever import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Value import org.springframework.boot.test.context.SpringBootTest @@ -16,7 +18,6 @@ import uk.gov.justice.digital.hmpps.data.generator.ContactGenerator import uk.gov.justice.digital.hmpps.data.generator.NsiGenerator import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator import uk.gov.justice.digital.hmpps.datetime.EuropeLondon -import uk.gov.justice.digital.hmpps.flags.FeatureFlags import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.EnforcementRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.entity.Contact @@ -64,14 +65,6 @@ internal class ReferAndMonitorIntegrationTest { @Autowired lateinit var eventRepository: EventRepository - @MockBean - lateinit var featureFlags: FeatureFlags - - @BeforeEach - fun setup() { - whenever(featureFlags.enabled("referral-withdrawal-reason")).thenReturn(true) - } - @Test @Order(1) fun `session appointment feedback submitted failed to comply`() { diff --git a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/NsiService.kt b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/NsiService.kt index c2e8222517..f3c6a19f14 100644 --- a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/NsiService.kt +++ b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/NsiService.kt @@ -6,7 +6,6 @@ import uk.gov.justice.digital.hmpps.api.model.ReferralStarted import uk.gov.justice.digital.hmpps.audit.service.AuditableService import uk.gov.justice.digital.hmpps.audit.service.AuditedInteractionService import uk.gov.justice.digital.hmpps.exception.ReferralNotFoundException -import uk.gov.justice.digital.hmpps.flags.FeatureFlags import uk.gov.justice.digital.hmpps.integrations.delius.audit.BusinessInteractionCode.MANAGE_NSI import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactOutcomeRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactRepository @@ -40,7 +39,6 @@ class NsiService( private val contactTypeRepository: ContactTypeRepository, private val contactOutcomeRepository: ContactOutcomeRepository, private val createNsi: CreateNsi, - private val featureFlags: FeatureFlags, ) : AuditableService(auditedInteractionService) { @Transactional @@ -77,9 +75,7 @@ class NsiService( fun terminateNsi(termination: NsiTermination) = audit(MANAGE_NSI) { audit -> val nsi = findNsi(termination) val status = nsiStatusRepository.getByCode(END.value) - val outcomeCode = termination.withdrawalOutcome?.name - ?.takeIf { featureFlags.enabled("referral-withdrawal-reason") } - ?: termination.endType.outcome + val outcomeCode = termination.withdrawalOutcome?.name ?: termination.endType.outcome val outcome = nsiOutcomeRepository.nsiOutcome(outcomeCode) audit["offenderId"] = nsi.person.id diff --git a/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/NsiServiceTest.kt b/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/NsiServiceTest.kt index a55cae257b..d6b332ecee 100644 --- a/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/NsiServiceTest.kt +++ b/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/NsiServiceTest.kt @@ -13,7 +13,6 @@ import uk.gov.justice.digital.hmpps.api.model.ReferralStarted import uk.gov.justice.digital.hmpps.audit.service.AuditedInteractionService import uk.gov.justice.digital.hmpps.data.generator.ContactGenerator import uk.gov.justice.digital.hmpps.data.generator.NsiGenerator -import uk.gov.justice.digital.hmpps.flags.FeatureFlags import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactOutcomeRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactTypeRepository @@ -59,9 +58,6 @@ internal class NsiServiceTest { @Mock lateinit var telemetryService: TelemetryService - @Mock - lateinit var featureFlags: FeatureFlags - @InjectMocks lateinit var nsiService: NsiService diff --git a/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/RepositoryExtensionMethodTests.kt b/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/RepositoryExtensionMethodTests.kt index bdb1aa4ab3..8c009316e5 100644 --- a/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/RepositoryExtensionMethodTests.kt +++ b/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/RepositoryExtensionMethodTests.kt @@ -15,7 +15,6 @@ import uk.gov.justice.digital.hmpps.data.generator.NsiGenerator import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator import uk.gov.justice.digital.hmpps.exception.NotFoundException import uk.gov.justice.digital.hmpps.exception.ReferralNotFoundException -import uk.gov.justice.digital.hmpps.flags.FeatureFlags import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactOutcomeRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactTypeRepository @@ -62,9 +61,6 @@ internal class RepositoryExtensionMethodTests { @Mock lateinit var telemetryService: TelemetryService - @Mock - lateinit var featureFlags: FeatureFlags - @InjectMocks lateinit var nsiService: NsiService diff --git a/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocateEventIntegrationTest.kt b/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocateEventIntegrationTest.kt index faa5e96f0c..87a9036bf4 100644 --- a/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocateEventIntegrationTest.kt +++ b/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocateEventIntegrationTest.kt @@ -8,7 +8,6 @@ import org.junit.jupiter.api.Test import org.mockito.kotlin.any import org.mockito.kotlin.eq import org.mockito.kotlin.verify -import org.mockito.kotlin.whenever import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Value import org.springframework.boot.test.context.SpringBootTest @@ -17,7 +16,6 @@ import org.springframework.data.repository.findByIdOrNull import uk.gov.justice.digital.hmpps.data.generator.EventGenerator import uk.gov.justice.digital.hmpps.data.generator.OrderManagerGenerator import uk.gov.justice.digital.hmpps.data.generator.StaffGenerator -import uk.gov.justice.digital.hmpps.flags.FeatureFlags import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactTypeCode import uk.gov.justice.digital.hmpps.integrations.delius.event.Event @@ -47,9 +45,6 @@ class AllocateEventIntegrationTest { @MockBean private lateinit var telemetryService: TelemetryService - @MockBean - private lateinit var featureFlags: FeatureFlags - @Autowired private lateinit var contactRepository: ContactRepository @@ -65,7 +60,6 @@ class AllocateEventIntegrationTest { event, 1, StaffGenerator.SPO_STAFF.id, - false ) verify(telemetryService).trackEvent( @@ -103,7 +97,6 @@ class AllocateEventIntegrationTest { event, 2, StaffGenerator.STAFF_WITH_USER.id, - false ) val insertedPm = orderManagerRepository.findActiveManagerAtDate(event.id, ZonedDateTime.now().minusDays(2)) @@ -122,10 +115,7 @@ class AllocateEventIntegrationTest { } @Test - fun `spo contact is created when feature flag is enabled`() { - - whenever(featureFlags.enabled("produce-spod03-contact")).thenReturn(true) - + fun `spo contact is created`() { val event = EventGenerator.DEFAULT val firstOm = orderManagerRepository.save( @@ -141,7 +131,6 @@ class AllocateEventIntegrationTest { event, 1, StaffGenerator.STAFF_WITH_USER.id, - true ) verify(telemetryService).trackEvent( @@ -162,8 +151,7 @@ class AllocateEventIntegrationTest { existingOm: OrderManager, event: Event, originalOmCount: Int, - staffId: Long, - spoEnabled: Boolean + staffId: Long ) { val allocationEvent = prepMessage(messageName, wireMockServer.port()) channelManager.getChannel(queueName).publishAndWait(allocationEvent) @@ -176,28 +164,16 @@ class AllocateEventIntegrationTest { val updatedOmCount = orderManagerRepository.findAll().count { it.eventId == event.id } assertThat(updatedOmCount, equalTo(originalOmCount + 1)) - if (spoEnabled) { - val spoContact = contactRepository.findAll() - .firstOrNull { it.eventId == oldOm.eventId && it.type.code == ContactTypeCode.CASE_ALLOCATION_SPO_OVERSIGHT.value } + val spoContact = contactRepository.findAll() + .firstOrNull { it.eventId == oldOm.eventId && it.type.code == ContactTypeCode.CASE_ALLOCATION_SPO_OVERSIGHT.value } - assertNotNull(spoContact) - assertThat(spoContact!!.staffId, equalTo(staffId)) - assertThat( - spoContact.isSensitive, - equalTo((allocationDetail as AllocationDetail.EventAllocation).sensitiveOversightNotes) - ) - assertThat(spoContact.notes, equalTo(allocationDetail.spoOversightNotes)) - } else { - val cadeContact = contactRepository.findAll() - .firstOrNull { it.eventId == oldOm.eventId && it.type.code == ContactTypeCode.CASE_ALLOCATION_DECISION_EVIDENCE.value } - - assertNotNull(cadeContact) - assertThat(cadeContact!!.staffId, equalTo(staffId)) - assertThat( - cadeContact.isSensitive, - equalTo((allocationDetail as AllocationDetail.EventAllocation).sensitive) - ) - assertThat(cadeContact.notes, equalTo(allocationDetail.notes)) - } + assertNotNull(spoContact) + assertThat(spoContact!!.staffId, equalTo(staffId)) + assertThat( + spoContact.isSensitive, + equalTo((allocationDetail as AllocationDetail.EventAllocation).sensitiveOversightNotes) + ) + assertThat(spoContact.notes, equalTo(allocationDetail.spoOversightNotes)) + } } } diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/AllocateEventService.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/AllocateEventService.kt index ae14877b76..4aca8a7bd4 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/AllocateEventService.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/AllocateEventService.kt @@ -7,7 +7,6 @@ import uk.gov.justice.digital.hmpps.audit.service.OptimisationTables import uk.gov.justice.digital.hmpps.exception.IgnorableMessageException import uk.gov.justice.digital.hmpps.exception.NotActiveException import uk.gov.justice.digital.hmpps.exception.NotFoundException -import uk.gov.justice.digital.hmpps.flags.FeatureFlags import uk.gov.justice.digital.hmpps.integrations.delius.allocations.AllocationValidator import uk.gov.justice.digital.hmpps.integrations.delius.allocations.ManagerService import uk.gov.justice.digital.hmpps.integrations.delius.audit.BusinessInteractionCode @@ -29,7 +28,6 @@ class AllocateEventService( private val transferReasonRepository: TransferReasonRepository, private val optimisationTables: OptimisationTables, private val staffRepository: StaffRepository, - private val featureFlags: FeatureFlags ) : ManagerService(auditedInteractionService, orderManagerRepository) { @Transactional @@ -90,39 +88,13 @@ class AllocateEventService( ) ) - if (featureFlags.enabled("produce-spod03-contact")) { - createSPOContact(allocationDetail, event, newOrderManager, spoStaff) - } else { - createCadeContact(allocationDetail, event, newOrderManager, spoStaff) - } + createSPOContact(allocationDetail, event, newOrderManager, spoStaff) if (event.hasAccreditedProgrammeRequirement()) { eventRepository.updateIaps(event.id) } } - fun createCadeContact( - allocationDetail: EventAllocation, - event: Event, - orderManager: OrderManager, - spoStaff: Staff? - ) { - contactRepository.save( - Contact( - type = contactTypeRepository.findByCodeOrThrow(ContactTypeCode.CASE_ALLOCATION_DECISION_EVIDENCE.value), - personId = event.person.id, - eventId = event.id, - date = orderManager.startDate.toLocalDate(), - startTime = orderManager.startDate, - teamId = orderManager.team.id, - staffId = spoStaff?.id ?: orderManager.staff.id, - providerId = orderManager.provider.id, - notes = allocationDetail.notes, - isSensitive = allocationDetail.sensitive ?: false - ) - ) - } - fun createSPOContact( allocationDetail: EventAllocation, event: Event, diff --git a/projects/workforce-allocations-to-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/AllocateEventServiceTest.kt b/projects/workforce-allocations-to-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/AllocateEventServiceTest.kt index 53ab26430b..c7413b0747 100644 --- a/projects/workforce-allocations-to-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/AllocateEventServiceTest.kt +++ b/projects/workforce-allocations-to-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/AllocateEventServiceTest.kt @@ -22,7 +22,6 @@ import uk.gov.justice.digital.hmpps.data.generator.TransferReasonGenerator import uk.gov.justice.digital.hmpps.exception.IgnorableMessageException import uk.gov.justice.digital.hmpps.exception.NotActiveException import uk.gov.justice.digital.hmpps.exception.NotFoundException -import uk.gov.justice.digital.hmpps.flags.FeatureFlags import uk.gov.justice.digital.hmpps.integrations.delius.allocations.AllocationValidator import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactTypeRepository @@ -64,9 +63,6 @@ internal class AllocateEventServiceTest { @Mock private lateinit var staffRepository: StaffRepository - @Mock - private lateinit var featureFlags: FeatureFlags - @InjectMocks private lateinit var allocateEventService: AllocateEventService