diff --git a/src/main/java/uk/gov/hmcts/reform/civil/callback/CaseEvent.java b/src/main/java/uk/gov/hmcts/reform/civil/callback/CaseEvent.java index e1c11623be3..e98d2923cd1 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/callback/CaseEvent.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/callback/CaseEvent.java @@ -478,7 +478,9 @@ public enum CaseEvent { CREATE_DASHBOARD_NOTIFICATION_DECISION_RECONSIDERATION_CLAIMANT1(CAMUNDA), CREATE_DASHBOARD_NOTIFICATION_DECISION_RECONSIDERATION_DEFENDANT1(CAMUNDA), NOTIFY_CLAIMANT_UPLOADED_DOCUMENT_ORDER_NOTICE(CAMUNDA), - NOTIFY_DEFENDANT_UPLOADED_DOCUMENT_ORDER_NOTICE(CAMUNDA); + NOTIFY_DEFENDANT_UPLOADED_DOCUMENT_ORDER_NOTICE(CAMUNDA), + NOTIFY_VALIDATION_DICONTINUANCE_FAILURE_CLAIMANT(CAMUNDA), + UPDATE_VISIBILITY_NOTICE_OF_DISCONTINUANCE(CAMUNDA); private final UserType userType; diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/NotifyClaimantLrValidationDiscontinuanceFailureHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/NotifyClaimantLrValidationDiscontinuanceFailureHandler.java new file mode 100644 index 00000000000..4740849676f --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/NotifyClaimantLrValidationDiscontinuanceFailureHandler.java @@ -0,0 +1,86 @@ +package uk.gov.hmcts.reform.civil.handler.callback.camunda.notification; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; +import uk.gov.hmcts.reform.ccd.client.model.CallbackResponse; +import uk.gov.hmcts.reform.civil.callback.Callback; +import uk.gov.hmcts.reform.civil.callback.CallbackHandler; +import uk.gov.hmcts.reform.civil.callback.CallbackParams; +import uk.gov.hmcts.reform.civil.callback.CaseEvent; +import uk.gov.hmcts.reform.civil.model.CaseData; +import uk.gov.hmcts.reform.civil.notify.NotificationService; +import uk.gov.hmcts.reform.civil.notify.NotificationsProperties; +import uk.gov.hmcts.reform.civil.service.OrganisationService; + +import java.util.List; +import java.util.Map; + +import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_VALIDATION_DICONTINUANCE_FAILURE_CLAIMANT; +import static uk.gov.hmcts.reform.civil.utils.NotificationUtils.getApplicantLegalOrganizationName; + +@Service +@RequiredArgsConstructor +public class NotifyClaimantLrValidationDiscontinuanceFailureHandler extends CallbackHandler + implements NotificationData { + + private static final List EVENTS = List.of(NOTIFY_VALIDATION_DICONTINUANCE_FAILURE_CLAIMANT); + public static final String TASK_ID = "NotifyValidationFailureClaimant"; + private static final String REFERENCE_TEMPLATE = + "claimant-notify-validation-failure-%s"; + + private final NotificationService notificationService; + private final NotificationsProperties notificationsProperties; + private final OrganisationService organisationService; + + @Override + protected Map callbacks() { + return Map.of( + callbackKey(ABOUT_TO_SUBMIT), + this::notifyClaimantValidationFailure + ); + } + + @Override + public String camundaActivityId(CallbackParams callbackParams) { + return TASK_ID; + } + + @Override + public List handledEvents() { + return EVENTS; + } + + private CallbackResponse notifyClaimantValidationFailure(CallbackParams callbackParams) { + CaseData caseData = callbackParams.getCaseData(); + + if (!caseData.isApplicantLiP()) { + notificationService.sendMail( + caseData.getApplicantSolicitor1UserDetails().getEmail(), + getTemplate(), + addProperties(caseData), + getReferenceTemplate(caseData) + ); + } + + return AboutToStartOrSubmitCallbackResponse.builder().build(); + } + + @Override + public Map addProperties(CaseData caseData) { + return Map.of( + CLAIM_REFERENCE_NUMBER, caseData.getLegacyCaseReference(), + LEGAL_ORG_NAME, getApplicantLegalOrganizationName(caseData, organisationService) + ); + } + + private String getTemplate() { + return notificationsProperties.getNotifyClaimantLrValidationDiscontinuanceFailureTemplate(); + } + + private String getReferenceTemplate(CaseData caseData) { + return String.format(REFERENCE_TEMPLATE, caseData.getLegacyCaseReference()); + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/UpdateVisibilityNoticeOfDiscontinuanceHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/UpdateVisibilityNoticeOfDiscontinuanceHandler.java new file mode 100644 index 00000000000..ad0509131f1 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/UpdateVisibilityNoticeOfDiscontinuanceHandler.java @@ -0,0 +1,62 @@ +package uk.gov.hmcts.reform.civil.handler.callback.camunda.notification; + +import lombok.RequiredArgsConstructor; +import org.camunda.bpm.engine.RuntimeService; +import org.springframework.stereotype.Service; +import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; +import uk.gov.hmcts.reform.ccd.client.model.CallbackResponse; +import uk.gov.hmcts.reform.civil.callback.Callback; +import uk.gov.hmcts.reform.civil.callback.CallbackHandler; +import uk.gov.hmcts.reform.civil.callback.CallbackParams; +import uk.gov.hmcts.reform.civil.callback.CaseEvent; +import uk.gov.hmcts.reform.civil.enums.settlediscontinue.ConfirmOrderGivesPermission; +import uk.gov.hmcts.reform.civil.model.CaseData; + +import java.util.List; +import java.util.Map; + +import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.UPDATE_VISIBILITY_NOTICE_OF_DISCONTINUANCE; + +@Service +@RequiredArgsConstructor +public class UpdateVisibilityNoticeOfDiscontinuanceHandler extends CallbackHandler { + + private static final List EVENTS = List.of(UPDATE_VISIBILITY_NOTICE_OF_DISCONTINUANCE); + public static final String TASK_ID = "UpdateVisibilityNoticeOfDiscontinuance"; + + private final RuntimeService runTimeService; + + @Override + protected Map callbacks() { + return Map.of( + callbackKey(ABOUT_TO_SUBMIT), + this::updateVisibilityNoticeDiscontinuance + ); + } + + @Override + public String camundaActivityId(CallbackParams callbackParams) { + return TASK_ID; + } + + @Override + public List handledEvents() { + return EVENTS; + } + + private CallbackResponse updateVisibilityNoticeDiscontinuance(CallbackParams callbackParams) { + CaseData caseData = callbackParams.getCaseData(); + //TODO add update visibility implementation here + updateCamundaVars(caseData); + return AboutToStartOrSubmitCallbackResponse.builder().build(); + } + + private void updateCamundaVars(CaseData caseData) { + runTimeService.setVariable( + caseData.getBusinessProcess().getProcessInstanceId(), + "discontinuanceValidationSuccess", + ConfirmOrderGivesPermission.YES.equals(caseData.getConfirmOrderGivesPermission()) + ); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/ValidateDiscontinueClaimClaimantCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/ValidateDiscontinueClaimClaimantCallbackHandler.java index 7650477f8ef..00c56f1c00f 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/ValidateDiscontinueClaimClaimantCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/ValidateDiscontinueClaimClaimantCallbackHandler.java @@ -15,6 +15,7 @@ import uk.gov.hmcts.reform.civil.enums.settlediscontinue.DiscontinuanceTypeList; import uk.gov.hmcts.reform.civil.enums.settlediscontinue.SettleDiscontinueYesOrNoList; import uk.gov.hmcts.reform.civil.helpers.settlediscontinue.DiscontinueClaimHelper; +import uk.gov.hmcts.reform.civil.model.BusinessProcess; import uk.gov.hmcts.reform.civil.model.CaseData; import java.util.List; @@ -84,6 +85,8 @@ private CallbackResponse submitChanges(CallbackParams callbackParams) { } } + caseDataBuilder.businessProcess(BusinessProcess.ready(VALIDATE_DISCONTINUE_CLAIM_CLAIMANT)); + return aboutToStartOrSubmitCallbackResponseBuilder.data(caseDataBuilder.build().toMap(objectMapper)).build(); } @@ -107,4 +110,5 @@ private static String getHeader(CaseData caseData) { public List handledEvents() { return EVENTS; } + } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/notify/NotificationsProperties.java b/src/main/java/uk/gov/hmcts/reform/civil/notify/NotificationsProperties.java index 986e040caf7..7eeec1f913b 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/notify/NotificationsProperties.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/notify/NotificationsProperties.java @@ -616,4 +616,7 @@ public class NotificationsProperties { @NotEmpty private String notifyLiPOrderTranslatedTemplate; + @NotEmpty + private String notifyClaimantLrValidationDiscontinuanceFailureTemplate; + } diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index cd0c4345779..127caff19ae 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -442,6 +442,8 @@ notifications: notifyDefendantLIPJudgmentByAdmissionTemplate: "734f9bb6-2e13-4364-8c25-b90a611b91a5" notifyLiPOrderTranslatedTemplate: "d81749f7-cef5-4159-8d99-146eb572a690" + notifyClaimantLrValidationDiscontinuanceFailureTemplate: "25398d9e-bb5f-4778-b76f-625c355f7c06" + sendgrid: api-key: ${SENDGRID_API_KEY:false} @@ -745,7 +747,7 @@ idam: id: civil-service redirect_uri: https://localhost:3000/oauth2/callback secret: ${CIVIL_CLIENT_SECRET:OOOOOOOOOOOOOOOO} - + caseFlags: logging: enabled: ${CASE_FLAGS_LOGGING_ENABLED:false} diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/NotifyClaimantLrValidationDiscontinuanceFailureHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/NotifyClaimantLrValidationDiscontinuanceFailureHandlerTest.java new file mode 100644 index 00000000000..cb89f5ffdf9 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/NotifyClaimantLrValidationDiscontinuanceFailureHandlerTest.java @@ -0,0 +1,103 @@ +package uk.gov.hmcts.reform.civil.handler.callback.camunda.notification; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import uk.gov.hmcts.reform.ccd.client.model.CallbackRequest; +import uk.gov.hmcts.reform.civil.callback.CallbackParams; +import uk.gov.hmcts.reform.civil.callback.CaseEvent; +import uk.gov.hmcts.reform.civil.enums.YesOrNo; +import uk.gov.hmcts.reform.civil.handler.callback.BaseCallbackHandlerTest; +import uk.gov.hmcts.reform.civil.model.CaseData; +import uk.gov.hmcts.reform.civil.notify.NotificationService; +import uk.gov.hmcts.reform.civil.notify.NotificationsProperties; +import uk.gov.hmcts.reform.civil.prd.model.Organisation; +import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; +import uk.gov.hmcts.reform.civil.service.OrganisationService; +import java.util.Map; +import java.util.Optional; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.notification.NotificationData.CLAIM_REFERENCE_NUMBER; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.notification.NotificationData.LEGAL_ORG_NAME; + +@SpringBootTest(classes = { + NotifyClaimantLrValidationDiscontinuanceFailureHandler.class, + NotificationsProperties.class, + JacksonAutoConfiguration.class +}) +class NotifyClaimantLrValidationDiscontinuanceFailureHandlerTest extends BaseCallbackHandlerTest { + + public static final String TEMPLATE_ID = "template-id"; + + private static final String REFERENCE_NUMBER = "8372942374"; + + @MockBean + private NotificationService notificationService; + + @MockBean + private NotificationsProperties notificationsProperties; + + @MockBean + private OrganisationService organisationService; + + @Autowired + private NotifyClaimantLrValidationDiscontinuanceFailureHandler handler; + + @Nested + class AboutToSubmitCallback { + + @BeforeEach + void setup() { + when(notificationsProperties.getNotifyClaimantLrValidationDiscontinuanceFailureTemplate()).thenReturn( + TEMPLATE_ID); + } + + @Test + void shouldNotifyClaimantLrValidationDiscontinuanceFailure_whenInvoked() { + + CaseData caseData = CaseDataBuilder.builder() + .legacyCaseReference(REFERENCE_NUMBER) + .atStateClaimDraft() + .applicant1Represented(YesOrNo.YES) + .build(); + + CallbackParams params = CallbackParams.builder() + .caseData(caseData) + .type(ABOUT_TO_SUBMIT) + .request(CallbackRequest.builder() + .eventId(CaseEvent.NOTIFY_VALIDATION_DICONTINUANCE_FAILURE_CLAIMANT.name()) + .build()) + .build(); + + handler.handle(params); + + verify(notificationService, times(1)).sendMail( + "applicantsolicitor@example.com", + TEMPLATE_ID, + getNotificationDataMap(caseData), + "claimant-notify-validation-failure-8372942374" + ); + } + } + + public Map getNotificationDataMap(CaseData caseData) { + return Map.of( + CLAIM_REFERENCE_NUMBER, caseData.getLegacyCaseReference(), + LEGAL_ORG_NAME, getApplicantLegalOrganizationName(caseData) + ); + } + + public String getApplicantLegalOrganizationName(CaseData caseData) { + String id = caseData.getApplicant1OrganisationPolicy().getOrganisation().getOrganisationID(); + Optional organisation = organisationService.findOrganisationById(id); + return organisation.isPresent() ? organisation.get().getName() : + caseData.getApplicantSolicitor1ClaimStatementOfTruth().getName(); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/UpdateVisibilityNoticeOfDiscontinuanceHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/UpdateVisibilityNoticeOfDiscontinuanceHandlerTest.java new file mode 100644 index 00000000000..c9bf555f44f --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/UpdateVisibilityNoticeOfDiscontinuanceHandlerTest.java @@ -0,0 +1,62 @@ +package uk.gov.hmcts.reform.civil.handler.callback.camunda.notification; + +import org.camunda.bpm.engine.RuntimeService; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import uk.gov.hmcts.reform.ccd.client.model.CallbackRequest; +import uk.gov.hmcts.reform.civil.callback.CallbackParams; +import uk.gov.hmcts.reform.civil.callback.CaseEvent; +import uk.gov.hmcts.reform.civil.enums.settlediscontinue.ConfirmOrderGivesPermission; +import uk.gov.hmcts.reform.civil.handler.callback.BaseCallbackHandlerTest; +import uk.gov.hmcts.reform.civil.model.BusinessProcess; +import uk.gov.hmcts.reform.civil.model.CaseData; +import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; +import static org.mockito.Mockito.verify; +import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; + +@SpringBootTest(classes = { + UpdateVisibilityNoticeOfDiscontinuanceHandler.class, + JacksonAutoConfiguration.class +}) +class UpdateVisibilityNoticeOfDiscontinuanceHandlerTest extends BaseCallbackHandlerTest { + + @MockBean + private RuntimeService runTimeService; + + @Autowired + private UpdateVisibilityNoticeOfDiscontinuanceHandler handler; + + private static final String processId = "process-id"; + + @Nested + class AboutToSubmitCallback { + + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void shouldUpdateCamundaVariables_whenInvoked(Boolean toggleState) { + //Given + CaseData caseData = CaseDataBuilder.builder() + .businessProcess(BusinessProcess.builder().processInstanceId(processId).build()).build(); + caseData.setConfirmOrderGivesPermission( + toggleState ? ConfirmOrderGivesPermission.YES : ConfirmOrderGivesPermission.NO); + + CallbackParams params = CallbackParams.builder() + .caseData(caseData) + .type(ABOUT_TO_SUBMIT) + .request(CallbackRequest.builder() + .eventId(CaseEvent.UPDATE_VISIBILITY_NOTICE_OF_DISCONTINUANCE.name()) + .build()) + .build(); + //When + handler.handle(params); + //Then + verify(runTimeService).setVariable(processId, "discontinuanceValidationSuccess", toggleState); + } + } + +} diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/ValidateDiscontinueClaimClaimantCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/ValidateDiscontinueClaimClaimantCallbackHandlerTest.java index 88ed4e1ad30..493fdb9f68d 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/ValidateDiscontinueClaimClaimantCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/ValidateDiscontinueClaimClaimantCallbackHandlerTest.java @@ -27,6 +27,7 @@ import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_START; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; import static uk.gov.hmcts.reform.civil.callback.CallbackType.SUBMITTED; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.VALIDATE_DISCONTINUE_CLAIM_CLAIMANT; @SpringBootTest(classes = { ValidateDiscontinueClaimClaimantCallbackHandler.class, @@ -63,6 +64,7 @@ void shouldHandleNullValues_WhenAboutToStartIsInvoked() { .isNull(); assertThat(response.getData()).extracting("permissionGrantedDateCopy") .isNull(); + } @Test @@ -97,9 +99,30 @@ void shouldDoNothing_WhenTypeOfDiscontinuanceIsNullAndAboutToSubmitIsInvoked() { AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler .handle(params); //Then - assertThat(response.getData()).extracting("confirmOrderGivesPermission") - .isNull(); + CaseData updatedData = objectMapper.convertValue(response.getData(), CaseData.class); + assertThat(response.getState()).isNull(); + assertThat(updatedData.getConfirmOrderGivesPermission()).isNull(); + assertThat(updatedData.getBusinessProcess().getCamundaEvent()) + .isEqualTo(VALIDATE_DISCONTINUE_CLAIM_CLAIMANT.name()); + } + + @Test + void shouldNotChangeCaseState_When1v2FullDiscontAgainstBothDefButNoPermissionAndAboutToSubmitIsInvoked() { + //Given + CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft() + .respondent2(Party.builder().partyName("Resp2").type(Party.Type.INDIVIDUAL).build()).build(); + caseData.setTypeOfDiscontinuance(DiscontinuanceTypeList.FULL_DISCONTINUANCE); + caseData.setIsDiscontinuingAgainstBothDefendants(SettleDiscontinueYesOrNoList.YES); + caseData.setConfirmOrderGivesPermission(ConfirmOrderGivesPermission.NO); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + //When + AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler + .handle(params); + //Then + CaseData updatedData = objectMapper.convertValue(response.getData(), CaseData.class); assertThat(response.getState()).isNull(); + assertThat(updatedData.getBusinessProcess().getCamundaEvent()) + .isEqualTo(VALIDATE_DISCONTINUE_CLAIM_CLAIMANT.name()); } @Test @@ -114,17 +137,18 @@ void shouldUpdateCaseWithoutStateChange_WhenPartDiscontinuanceAndAboutToSubmitIs AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler .handle(params); //Then - assertThat(response.getData()).extracting("confirmOrderGivesPermission") - .isEqualTo("YES"); + CaseData updatedData = objectMapper.convertValue(response.getData(), CaseData.class); assertThat(response.getState()).isNull(); + assertThat(updatedData.getConfirmOrderGivesPermission()).isEqualTo(ConfirmOrderGivesPermission.YES); + assertThat(updatedData.getBusinessProcess().getCamundaEvent()) + .isEqualTo(VALIDATE_DISCONTINUE_CLAIM_CLAIMANT.name()); } @Test void shouldUpdateCaseWithoutStateChange_When1v2FullDiscontinuanceAgainstOneDefAndAboutToSubmitIsInvoked() { //Given CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft() - .respondent2(Party.builder().partyName("Resp2").type(Party.Type.INDIVIDUAL).build()) - .build(); + .respondent2(Party.builder().partyName("Resp2").type(Party.Type.INDIVIDUAL).build()).build(); caseData.setTypeOfDiscontinuance(DiscontinuanceTypeList.FULL_DISCONTINUANCE); caseData.setIsDiscontinuingAgainstBothDefendants(SettleDiscontinueYesOrNoList.NO); caseData.setConfirmOrderGivesPermission(ConfirmOrderGivesPermission.YES); @@ -133,17 +157,18 @@ void shouldUpdateCaseWithoutStateChange_When1v2FullDiscontinuanceAgainstOneDefAn AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler .handle(params); //Then - assertThat(response.getData()).extracting("confirmOrderGivesPermission") - .isEqualTo("YES"); + CaseData updatedData = objectMapper.convertValue(response.getData(), CaseData.class); assertThat(response.getState()).isNull(); + assertThat(updatedData.getConfirmOrderGivesPermission()).isEqualTo(ConfirmOrderGivesPermission.YES); + assertThat(updatedData.getBusinessProcess().getCamundaEvent()) + .isEqualTo(VALIDATE_DISCONTINUE_CLAIM_CLAIMANT.name()); } @Test void shouldDiscontinueCase_When1v2FullDiscontinuanceAgainstBothDefAndAboutToSubmitIsInvoked() { //Given CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft() - .respondent2(Party.builder().partyName("Resp2").type(Party.Type.INDIVIDUAL).build()) - .build(); + .respondent2(Party.builder().partyName("Resp2").type(Party.Type.INDIVIDUAL).build()).build(); caseData.setTypeOfDiscontinuance(DiscontinuanceTypeList.FULL_DISCONTINUANCE); caseData.setIsDiscontinuingAgainstBothDefendants(SettleDiscontinueYesOrNoList.YES); caseData.setConfirmOrderGivesPermission(ConfirmOrderGivesPermission.YES); @@ -152,7 +177,10 @@ void shouldDiscontinueCase_When1v2FullDiscontinuanceAgainstBothDefAndAboutToSubm AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler .handle(params); //Then + CaseData updatedData = objectMapper.convertValue(response.getData(), CaseData.class); assertThat(response.getState()).isEqualTo(CaseState.CASE_DISCONTINUED.name()); + assertThat(updatedData.getBusinessProcess().getCamundaEvent()) + .isEqualTo(VALIDATE_DISCONTINUE_CLAIM_CLAIMANT.name()); } @Test @@ -166,7 +194,10 @@ void shouldDiscontinueCase_When1v1FullDiscontinuanceAndAboutToSubmitIsInvoked() AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler .handle(params); //Then + CaseData updatedData = objectMapper.convertValue(response.getData(), CaseData.class); assertThat(response.getState()).isEqualTo(CaseState.CASE_DISCONTINUED.name()); + assertThat(updatedData.getBusinessProcess().getCamundaEvent()) + .isEqualTo(VALIDATE_DISCONTINUE_CLAIM_CLAIMANT.name()); } }