From 126ddf2d6778259051a968c810a9faa7d8398972 Mon Sep 17 00:00:00 2001 From: Omaira-Melo-Hmcts <148855113+Omaira-Melo-Hmcts@users.noreply.github.com> Date: Thu, 28 Mar 2024 15:33:07 +0000 Subject: [PATCH] CIV-13171 Email notifications Judgment varied following Determination of Means (#908) * CIV-13171 * CIV-13171 New process to notify judgement varied determination of means * CIV-13171 Replace JUDGEMENT to JUDGMENT * CIV-13171 Refactor to notify to 2 defendants * CIV-13171 FlowState added to No option * CIV-13171 FlowState added to No option * CIV-13171 Adding tests to Camunda process * CIV-13171 Test Renamed * CIV-13171 Sonar Fix * CIV-13171 Comment added on the decision * CIV-13171: Updated Task Ids for 2 Defendants --------- Co-authored-by: Azam <106387766+Azam-Hmcts@users.noreply.github.com> Co-authored-by: JamiS --- ...udgment_varied_determination_of_means.bpmn | 185 ++++++++++++++++++ ...udgmentVariedDeterminationOfMeansTest.java | 101 ++++++++++ 2 files changed, 286 insertions(+) create mode 100644 src/main/resources/camunda/notify_judgment_varied_determination_of_means.bpmn create mode 100644 src/test/java/uk/gov/hmcts/reform/civil/bpmn/NotifyJudgmentVariedDeterminationOfMeansTest.java diff --git a/src/main/resources/camunda/notify_judgment_varied_determination_of_means.bpmn b/src/main/resources/camunda/notify_judgment_varied_determination_of_means.bpmn new file mode 100644 index 000000000..e8b39d071 --- /dev/null +++ b/src/main/resources/camunda/notify_judgment_varied_determination_of_means.bpmn @@ -0,0 +1,185 @@ + + + + + + + + + Flow_1xqzkty + Flow_0nvdd4d + Flow_1vs00o9 + + + + + + Flow_0nvdd4d + + + + Flow_1xqzkty + + + + + + + + Flow_0gpaflx + Flow_0y6slka + Flow_1og0z75 + + + Flow_1og0z75 + + + + + + + NOTIFY_CLAIMANT_JUDGMENT_VARIED_DETERMINATION_OF_MEANS + + + Flow_1vs00o9 + Flow_0posdss + + + + + + NOTIFY_SOLICITOR1_DEFENDANT_JUDGMENT_VARIED_DETERMINATION_OF_MEANS + + + Flow_0posdss + Flow_0qjr8zn + + + + Flow_0qjr8zn + Flow_0gpaflx + Flow_0r8cqwr + + + ${(!empty flowFlags.UNREPRESENTED_DEFENDANT_ONE && flowFlags.UNREPRESENTED_DEFENDANT_ONE) || (!empty flowFlags.ONE_RESPONDENT_REPRESENTATIVE && flowFlags.ONE_RESPONDENT_REPRESENTATIVE)} + + + + + NOTIFY_SOLICITOR2_DEFENDANT_JUDGMENT_VARIED_DETERMINATION_OF_MEANS + + + Flow_0r8cqwr + Flow_0y6slka + + + ${(!empty flowFlags.TWO_RESPONDENT_REPRESENTATIVES && flowFlags.TWO_RESPONDENT_REPRESENTATIVES) || (!empty flowFlags.UNREPRESENTED_DEFENDANT_TWO && flowFlags.UNREPRESENTED_DEFENDANT_TWO)} + + + + Two Respondent Representatives? + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/uk/gov/hmcts/reform/civil/bpmn/NotifyJudgmentVariedDeterminationOfMeansTest.java b/src/test/java/uk/gov/hmcts/reform/civil/bpmn/NotifyJudgmentVariedDeterminationOfMeansTest.java new file mode 100644 index 000000000..c3aa987c5 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/civil/bpmn/NotifyJudgmentVariedDeterminationOfMeansTest.java @@ -0,0 +1,101 @@ +package uk.gov.hmcts.reform.civil.bpmn; + +import org.camunda.bpm.engine.externaltask.ExternalTask; +import org.camunda.bpm.engine.variable.VariableMap; +import org.camunda.bpm.engine.variable.Variables; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +import java.util.Map; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertFalse; + +class NotifyJudgmentVariedDeterminationOfMeansTest extends BpmnBaseTest { + + public static final String MESSAGE_NAME = "NOTIFY_JUDGMENT_VARIED_DETERMINATION_OF_MEANS"; + public static final String PROCESS_ID = "NOTIFY_JUDGMENT_VARIED_DETERMINATION_OF_MEANS"; + + public NotifyJudgmentVariedDeterminationOfMeansTest() { + super("notify_judgment_varied_determination_of_means.bpmn", "NOTIFY_JUDGMENT_VARIED_DETERMINATION_OF_MEANS"); + } + + @ParameterizedTest + @CsvSource({"true", "false"}) + void shouldSuccessfullyNotifyJudgmentVariedDeterminationOfMeans(boolean twoRepresentatives) { + + //assert process has started + assertFalse(processInstance.isEnded()); + + //assert message start event + assertThat(getProcessDefinitionByMessage(MESSAGE_NAME).getKey()).isEqualTo(PROCESS_ID); + + VariableMap variables = Variables.createVariables(); + variables.put("flowFlags", Map.of( + ONE_RESPONDENT_REPRESENTATIVE, !twoRepresentatives, + TWO_RESPONDENT_REPRESENTATIVES, twoRepresentatives, + UNREPRESENTED_DEFENDANT_ONE, false)); + + //complete the start business process + ExternalTask startBusiness = assertNextExternalTask(START_BUSINESS_TOPIC); + assertCompleteExternalTask( + startBusiness, + START_BUSINESS_TOPIC, + START_BUSINESS_EVENT, + START_BUSINESS_ACTIVITY + ); + + //complete the notification to Claimant + ExternalTask claimantNotification = assertNextExternalTask(PROCESS_CASE_EVENT); + assertCompleteExternalTask( + claimantNotification, + PROCESS_CASE_EVENT, + "NOTIFY_CLAIMANT_JUDGMENT_VARIED_DETERMINATION_OF_MEANS", + "NotifyClaimantJudgmentVariedDeterminationOfMeans" + ); + + //complete the notification to Respondent + ExternalTask respondent1Notification = assertNextExternalTask(PROCESS_CASE_EVENT); + assertCompleteExternalTask( + respondent1Notification, + PROCESS_CASE_EVENT, + "NOTIFY_SOLICITOR1_DEFENDANT_JUDGMENT_VARIED_DETERMINATION_OF_MEANS", + "NotifyDefendantVariedDeterminationOfMeans1", + variables + ); + + if (twoRepresentatives) { + //complete the notification to Respondent2 + ExternalTask respondent2Notification = assertNextExternalTask(PROCESS_CASE_EVENT); + assertCompleteExternalTask( + respondent2Notification, + PROCESS_CASE_EVENT, + "NOTIFY_SOLICITOR2_DEFENDANT_JUDGMENT_VARIED_DETERMINATION_OF_MEANS", + "NotifyDefendantVariedDeterminationOfMeans2", + variables + ); + } + + //end business process + ExternalTask endBusinessProcess = assertNextExternalTask(END_BUSINESS_PROCESS); + completeBusinessProcess(endBusinessProcess); + + assertNoExternalTasksLeft(); + } + + @Test + void shouldAbort_whenStartBusinessProcessThrowsAnError() { + //assert process has started + assertFalse(processInstance.isEnded()); + + //assert message start event + assertThat(getProcessDefinitionByMessage(MESSAGE_NAME).getKey()).isEqualTo(PROCESS_ID); + + //fail the start business process + ExternalTask startBusiness = assertNextExternalTask(START_BUSINESS_TOPIC); + assertFailExternalTask(startBusiness, START_BUSINESS_TOPIC, START_BUSINESS_EVENT, START_BUSINESS_ACTIVITY); + + assertNoExternalTasksLeft(); + } +}