Skip to content

Commit

Permalink
CIV-13109 Email notifications: Claimant/Defendant LR - set aside Judg…
Browse files Browse the repository at this point in the history
…ment made in error (#903)

* CIV-13109 Initial Commit

* CIV-13109: Updated Judgement to Judgment

* CIV-13109: Added prefix to event name

* CIV-13109: Updated the logic for Set Aside Judgment Notification

* CIV-13109: Updated flow as discussed

* CIV-13109: Fixed failing tests

* CIV-13109: Fixed checkstyle errors
  • Loading branch information
sjamihmcts authored Mar 27, 2024
1 parent fdd4232 commit b4963a6
Show file tree
Hide file tree
Showing 2 changed files with 313 additions and 0 deletions.
208 changes: 208 additions & 0 deletions src/main/resources/camunda/notify_set_aside_judgment_request.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0rn46su" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.19.0">
<bpmn:process id="NOTIFY_SET_ASIDE_JUDGMENT" isExecutable="true">
<bpmn:callActivity id="NotifySetAsideJudgementRequest" name="Start Business Process" calledElement="StartBusinessProcess">
<bpmn:extensionElements>
<camunda:in variables="all" />
<camunda:out variables="all" />
</bpmn:extensionElements>
<bpmn:incoming>Flow_1xqzkty</bpmn:incoming>
<bpmn:outgoing>Flow_0nvdd4d</bpmn:outgoing>
<bpmn:outgoing>Flow_1vs00o9</bpmn:outgoing>
</bpmn:callActivity>
<bpmn:boundaryEvent id="Event_065sy6f" name="Abort" attachedToRef="NotifySetAsideJudgementRequest">
<bpmn:errorEventDefinition id="ErrorEventDefinition_18nu2xn" />
</bpmn:boundaryEvent>
<bpmn:endEvent id="Event_0andzqc">
<bpmn:incoming>Flow_0nvdd4d</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_0nvdd4d" sourceRef="NotifySetAsideJudgementRequest" targetRef="Event_0andzqc" />
<bpmn:startEvent id="Event_0x1swz2" name="Start">
<bpmn:outgoing>Flow_1xqzkty</bpmn:outgoing>
<bpmn:messageEventDefinition id="MessageEventDefinition_1kwntce" messageRef="Message_3cbr28q" />
</bpmn:startEvent>
<bpmn:sequenceFlow id="Flow_1xqzkty" sourceRef="Event_0x1swz2" targetRef="NotifySetAsideJudgementRequest" />
<bpmn:callActivity id="Activity_0pqcpvc" name="End Business Process" calledElement="EndBusinessProcess">
<bpmn:extensionElements>
<camunda:in variables="all" />
</bpmn:extensionElements>
<bpmn:incoming>Flow_0gpaflx</bpmn:incoming>
<bpmn:incoming>Flow_0y6slka</bpmn:incoming>
<bpmn:incoming>Flow_0f2hml4</bpmn:incoming>
<bpmn:outgoing>Flow_1og0z75</bpmn:outgoing>
</bpmn:callActivity>
<bpmn:endEvent id="Event_0jlhskg">
<bpmn:incoming>Flow_1og0z75</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_1og0z75" sourceRef="Activity_0pqcpvc" targetRef="Event_0jlhskg" />
<bpmn:sequenceFlow id="Flow_1vs00o9" sourceRef="NotifySetAsideJudgementRequest" targetRef="NotifyClaimSetAsideJudgmentClaimant" />
<bpmn:serviceTask id="NotifyClaimSetAsideJudgmentClaimant" name="Notify Claim Set Aside Judgment Claimant" camunda:type="external" camunda:topic="processCaseEvent">
<bpmn:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="caseEvent">NOTIFY_CLAIM_SET_ASIDE_JUDGMENT_CLAIMANT</camunda:inputParameter>
</camunda:inputOutput>
</bpmn:extensionElements>
<bpmn:incoming>Flow_1vs00o9</bpmn:incoming>
<bpmn:outgoing>Flow_0posdss</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="Flow_0posdss" sourceRef="NotifyClaimSetAsideJudgmentClaimant" targetRef="Gateway_00bae9b" />
<bpmn:serviceTask id="NotifyClaimSetAsideJudgmentDefendant1" name="Notify Claim Set Aside Judgment Defendant1" camunda:type="external" camunda:topic="processCaseEvent">
<bpmn:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="caseEvent">NOTIFY_CLAIM_SET_ASIDE_JUDGMENT_DEFENDANT1</camunda:inputParameter>
</camunda:inputOutput>
</bpmn:extensionElements>
<bpmn:incoming>Flow_0l3rt07</bpmn:incoming>
<bpmn:outgoing>Flow_0qjr8zn</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="Flow_0qjr8zn" sourceRef="NotifyClaimSetAsideJudgmentDefendant1" targetRef="Gateway_19b5dvl" />
<bpmn:exclusiveGateway id="Gateway_19b5dvl">
<bpmn:incoming>Flow_0qjr8zn</bpmn:incoming>
<bpmn:outgoing>Flow_0gpaflx</bpmn:outgoing>
<bpmn:outgoing>Flow_0r8cqwr</bpmn:outgoing>
</bpmn:exclusiveGateway>
<bpmn:sequenceFlow id="Flow_0gpaflx" name="No" sourceRef="Gateway_19b5dvl" targetRef="Activity_0pqcpvc">
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${!empty flowFlags.ONE_RESPONDENT_REPRESENTATIVE &amp;&amp; flowFlags.ONE_RESPONDENT_REPRESENTATIVE}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:serviceTask id="NotifyClaimSetAsideJudgmentDefendant2" name="Notify Claim Set Aside Judgment Defendant2" camunda:type="external" camunda:topic="processCaseEvent">
<bpmn:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="caseEvent">NOTIFY_CLAIM_SET_ASIDE_JUDGMENT_DEFENDANT2</camunda:inputParameter>
</camunda:inputOutput>
</bpmn:extensionElements>
<bpmn:incoming>Flow_0r8cqwr</bpmn:incoming>
<bpmn:outgoing>Flow_0y6slka</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="Flow_0r8cqwr" name="Yes" sourceRef="Gateway_19b5dvl" targetRef="NotifyClaimSetAsideJudgmentDefendant2">
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${!empty flowFlags.TWO_RESPONDENT_REPRESENTATIVES &amp;&amp; flowFlags.TWO_RESPONDENT_REPRESENTATIVES}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:sequenceFlow id="Flow_0y6slka" sourceRef="NotifyClaimSetAsideJudgmentDefendant2" targetRef="Activity_0pqcpvc" />
<bpmn:exclusiveGateway id="Gateway_00bae9b">
<bpmn:incoming>Flow_0posdss</bpmn:incoming>
<bpmn:outgoing>Flow_0l3rt07</bpmn:outgoing>
<bpmn:outgoing>Flow_0f2hml4</bpmn:outgoing>
</bpmn:exclusiveGateway>
<bpmn:sequenceFlow id="Flow_0l3rt07" name="Not LiP Defendant" sourceRef="Gateway_00bae9b" targetRef="NotifyClaimSetAsideJudgmentDefendant1">
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${empty flowFlags.UNREPRESENTED_DEFENDANT_ONE || (!empty flowFlags.UNREPRESENTED_DEFENDANT_ONE &amp;&amp; !flowFlags.UNREPRESENTED_DEFENDANT_ONE)}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:sequenceFlow id="Flow_0f2hml4" name="LiP Defendant" sourceRef="Gateway_00bae9b" targetRef="Activity_0pqcpvc">
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${!empty flowFlags.UNREPRESENTED_DEFENDANT_ONE &amp;&amp; flowFlags.UNREPRESENTED_DEFENDANT_ONE}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
</bpmn:process>
<bpmn:message id="Message_0slk3de" />
<bpmn:error id="Error_0t2ju7k" name="StartBusinessAbort" errorCode="ABORT" />
<bpmn:error id="Error_1237qii" name="StartBusinessAbort" errorCode="ABORT" />
<bpmn:message id="Message_0htno5u" />
<bpmn:message id="Message_00airaq" />
<bpmn:message id="Message_1koptmo" name="DECISION_ON_RECONSIDERATION_REQUEST" />
<bpmn:message id="Message_3q7mgmn" name="NOTIFY_JUDGMENT_VARIED_DETERMINATION_OF_MEANS" />
<bpmn:message id="Message_3cbr28q" name="NOTIFY_SET_ASIDE_JUDGMENT" />
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="NOTIFY_SET_ASIDE_JUDGMENT">
<bpmndi:BPMNShape id="Activity_0x0o0ha_di" bpmnElement="NotifySetAsideJudgementRequest">
<dc:Bounds x="220" y="180" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0andzqc_di" bpmnElement="Event_0andzqc">
<dc:Bounds x="252" y="82" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0x1swz2_di" bpmnElement="Event_0x1swz2">
<dc:Bounds x="132" y="202" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="139" y="245" width="24" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0nyrqab_di" bpmnElement="NotifyClaimSetAsideJudgmentClaimant">
<dc:Bounds x="360" y="180" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0jlhskg_di" bpmnElement="Event_0jlhskg">
<dc:Bounds x="1152" y="212" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_0e1o9i1" bpmnElement="NotifyClaimSetAsideJudgmentDefendant2">
<dc:Bounds x="940" y="50" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_19b5dvl_di" bpmnElement="Gateway_19b5dvl" isMarkerVisible="true">
<dc:Bounds x="815" y="195" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0txb7dk_di" bpmnElement="NotifyClaimSetAsideJudgmentDefendant1">
<dc:Bounds x="660" y="180" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_0hdpgwf" bpmnElement="Gateway_00bae9b" isMarkerVisible="true">
<dc:Bounds x="525" y="195" width="50" height="50" />
<bpmndi:BPMNLabel>
<dc:Bounds x="738" y="412" width="87" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0pqcpvc_di" bpmnElement="Activity_0pqcpvc">
<dc:Bounds x="950" y="190" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_065sy6f_di" bpmnElement="Event_065sy6f">
<dc:Bounds x="252" y="162" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="288" y="143" width="26" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_0nvdd4d_di" bpmnElement="Flow_0nvdd4d">
<di:waypoint x="270" y="180" />
<di:waypoint x="270" y="118" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1xqzkty_di" bpmnElement="Flow_1xqzkty">
<di:waypoint x="168" y="220" />
<di:waypoint x="220" y="220" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1og0z75_di" bpmnElement="Flow_1og0z75">
<di:waypoint x="1050" y="230" />
<di:waypoint x="1152" y="230" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1vs00o9_di" bpmnElement="Flow_1vs00o9">
<di:waypoint x="320" y="220" />
<di:waypoint x="360" y="220" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0posdss_di" bpmnElement="Flow_0posdss">
<di:waypoint x="460" y="220" />
<di:waypoint x="525" y="220" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0qjr8zn_di" bpmnElement="Flow_0qjr8zn">
<di:waypoint x="760" y="220" />
<di:waypoint x="815" y="220" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0gpaflx_di" bpmnElement="Flow_0gpaflx">
<di:waypoint x="865" y="220" />
<di:waypoint x="950" y="220" />
<bpmndi:BPMNLabel>
<dc:Bounds x="920" y="202" width="15" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0r8cqwr_di" bpmnElement="Flow_0r8cqwr">
<di:waypoint x="840" y="195" />
<di:waypoint x="840" y="90" />
<di:waypoint x="940" y="90" />
<bpmndi:BPMNLabel>
<dc:Bounds x="846" y="140" width="18" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0y6slka_di" bpmnElement="Flow_0y6slka">
<di:waypoint x="990" y="130" />
<di:waypoint x="990" y="190" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0l3rt07_di" bpmnElement="Flow_0l3rt07">
<di:waypoint x="575" y="220" />
<di:waypoint x="660" y="220" />
<bpmndi:BPMNLabel>
<dc:Bounds x="592" y="186" width="52" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0f2hml4_di" bpmnElement="Flow_0f2hml4">
<di:waypoint x="550" y="245" />
<di:waypoint x="550" y="380" />
<di:waypoint x="1000" y="380" />
<di:waypoint x="1000" y="270" />
<bpmndi:BPMNLabel>
<dc:Bounds x="740" y="362" width="71" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
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 NotifySetAsideJudgmentTest extends BpmnBaseTest {

public static final String MESSAGE_NAME = "NOTIFY_SET_ASIDE_JUDGMENT";
public static final String PROCESS_ID = "NOTIFY_SET_ASIDE_JUDGMENT";

public NotifySetAsideJudgmentTest() {
super("notify_set_aside_judgment_request.bpmn", "NOTIFY_SET_ASIDE_JUDGMENT");
}

@ParameterizedTest
@CsvSource({"true,false", "false,false", "true,true", "false,true"})
void shouldSuccessfullyNotifySetAsideJudgmentRequest(boolean twoRepresentatives, boolean isLiPDefendant) {

//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(FLOW_FLAGS, Map.of(
ONE_RESPONDENT_REPRESENTATIVE, !twoRepresentatives,
TWO_RESPONDENT_REPRESENTATIVES, twoRepresentatives,
UNREPRESENTED_DEFENDANT_ONE, isLiPDefendant
));

//complete the start business process
ExternalTask startBusiness = assertNextExternalTask(START_BUSINESS_TOPIC);
assertCompleteExternalTask(
startBusiness,
START_BUSINESS_TOPIC,
START_BUSINESS_EVENT,
START_BUSINESS_ACTIVITY,
variables
);

//complete the notification to Claimant
ExternalTask claimantNotification = assertNextExternalTask(PROCESS_CASE_EVENT);
assertCompleteExternalTask(
claimantNotification,
PROCESS_CASE_EVENT,
"NOTIFY_CLAIM_SET_ASIDE_JUDGMENT_CLAIMANT",
"NotifyClaimSetAsideJudgmentClaimant"
);

if (!isLiPDefendant) {
//complete the notification to Respondent
ExternalTask respondent1Notification = assertNextExternalTask(PROCESS_CASE_EVENT);
assertCompleteExternalTask(
respondent1Notification,
PROCESS_CASE_EVENT,
"NOTIFY_CLAIM_SET_ASIDE_JUDGMENT_DEFENDANT1",
"NotifyClaimSetAsideJudgmentDefendant1",
variables
);

if (twoRepresentatives) {
//complete the notification to Respondent2
ExternalTask respondent2Notification = assertNextExternalTask(PROCESS_CASE_EVENT);
assertCompleteExternalTask(
respondent2Notification,
PROCESS_CASE_EVENT,
"NOTIFY_CLAIM_SET_ASIDE_JUDGMENT_DEFENDANT2",
"NotifyClaimSetAsideJudgmentDefendant2",
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();
}
}

0 comments on commit b4963a6

Please sign in to comment.