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(); + } +}