Skip to content

Commit

Permalink
Merge branch 'main' into MAN-28-sentence-license-condition-long-notes
Browse files Browse the repository at this point in the history
  • Loading branch information
achimber-moj authored Oct 21, 2024
2 parents 3cf72ea + d9bfdb0 commit 9f7fbbc
Show file tree
Hide file tree
Showing 59 changed files with 172 additions and 4,256 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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<HmppsDomainEvent>("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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -24,13 +23,12 @@ class Handler(
override val converter: NotificationConverter<HmppsDomainEvent>,
private val ordsClient: OrdsClient,
private val assessmentSubmitted: AssessmentSubmitted,
private val featureFlags: FeatureFlags,
private val telemetryService: TelemetryService
) : NotificationHandler<HmppsDomainEvent> {
@Publish(messages = [Message(title = AssessmentSummaryProduced, payload = Schema(HmppsDomainEvent::class))])
override fun handle(notification: Notification<HmppsDomainEvent>) {
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)) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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())
Expand All @@ -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
)
Expand Down
1 change: 0 additions & 1 deletion projects/court-case-and-delius/deploy/values-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ generic-service:
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK_SET_URI: http://hmpps-auth.hmpps-auth-dev.svc.cluster.local/auth/.well-known/jwks.json
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUER_URI: https://sign-in-dev.hmpps.service.justice.gov.uk/auth/issuer
SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_HMPPS-AUTH_TOKEN-URI: http://hmpps-auth.hmpps-auth-dev.svc.cluster.local/auth/oauth/token
COMMUNITY-API_URL: https://community-api.test.probation.service.justice.gov.uk
INTEGRATIONS_ALFRESCO_URL: https://hmpps-delius-alfresco-test.apps.live.cloud-platform.service.justice.gov.uk/alfresco/service/noms-spg/

generic-prometheus-alerts:
Expand Down
1 change: 0 additions & 1 deletion projects/court-case-and-delius/deploy/values-preprod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ generic-service:
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK_SET_URI: http://hmpps-auth.hmpps-auth-preprod.svc.cluster.local/auth/.well-known/jwks.json
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUER_URI: https://sign-in-preprod.hmpps.service.justice.gov.uk/auth/issuer
SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_HMPPS-AUTH_TOKEN-URI: http://hmpps-auth.hmpps-auth-preprod.svc.cluster.local/auth/oauth/token
COMMUNITY-API_URL: https://community-api.pre-prod.delius.probation.hmpps.dsd.io
INTEGRATIONS_ALFRESCO_URL: https://alfresco.pre-prod.delius.probation.hmpps.dsd.io/alfresco/service/noms-spg/

generic-prometheus-alerts:
Expand Down
1 change: 0 additions & 1 deletion projects/court-case-and-delius/deploy/values-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ generic-service:
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK_SET_URI: http://hmpps-auth.hmpps-auth-prod.svc.cluster.local/auth/.well-known/jwks.json
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUER_URI: https://sign-in.hmpps.service.justice.gov.uk/auth/issuer
SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_HMPPS-AUTH_TOKEN-URI: http://hmpps-auth.hmpps-auth-prod.svc.cluster.local/auth/oauth/token
COMMUNITY-API_URL: https://community-api.probation.service.justice.gov.uk
INTEGRATIONS_ALFRESCO_URL: https://alfresco.probation.service.justice.gov.uk/alfresco/service/noms-spg/

This file was deleted.

Loading

0 comments on commit 9f7fbbc

Please sign in to comment.