Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CIV-15265 Order Review Obligation Check Scheduler #1165

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
105 changes: 105 additions & 0 deletions src/main/resources/camunda/confirm_order_review.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_18h9iji" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.12.0">
<bpmn:process id="CONFIRM_ORDER_REVIEW" name="Stay Lifted" isExecutable="true" camunda:historyTimeToLive="P90D">
<bpmn:serviceTask id="UpdateConfirmOrderReviewEvent" name="Update Confirm Order Review Event" camunda:type="external" camunda:topic="processConfirmOrderReview">
<bpmn:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="caseEvent">UPDATE_CONFIRM_REVIEW_ORDER_EVENT</camunda:inputParameter>
</camunda:inputOutput>
</bpmn:extensionElements>
<bpmn:incoming>Flow_78545522598879</bpmn:incoming>
<bpmn:outgoing>Flow_0dz1egj</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:startEvent id="stay_case_event" name="Start">
<bpmn:outgoing>Flow_87785545545544</bpmn:outgoing>
<bpmn:messageEventDefinition id="MessageEventDefinition_1dvrj2w" messageRef="Message_07sm7e9" />
</bpmn:startEvent>
<bpmn:endEvent id="Event_878884254666">
<bpmn:incoming>Flow_5845212254322</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_5845212254322" sourceRef="Activity_120199855233" targetRef="Event_878884254666" />
<bpmn:callActivity id="Activity_120199855233" name="End Business Process" calledElement="EndBusinessProcess">
<bpmn:extensionElements>
<camunda:properties>
<camunda:property name="variables" value="all" />
</camunda:properties>
<camunda:in variables="all" />
</bpmn:extensionElements>
<bpmn:incoming>Flow_0dz1egj</bpmn:incoming>
<bpmn:outgoing>Flow_5845212254322</bpmn:outgoing>
</bpmn:callActivity>
<bpmn:callActivity id="Activity_7842144454545" name="Start Business Process" calledElement="StartBusinessProcess">
<bpmn:extensionElements>
<camunda:in variables="all" />
<camunda:out variables="all" />
</bpmn:extensionElements>
<bpmn:incoming>Flow_87785545545544</bpmn:incoming>
<bpmn:outgoing>Flow_78545522598879</bpmn:outgoing>
</bpmn:callActivity>
<bpmn:endEvent id="Event_55878855778">
<bpmn:incoming>Flow_77875455488</bpmn:incoming>
</bpmn:endEvent>
<bpmn:boundaryEvent id="Event_0kza4it444" name="Abort" attachedToRef="Activity_7842144454545">
<bpmn:outgoing>Flow_77875455488</bpmn:outgoing>
<bpmn:errorEventDefinition id="ErrorEventDefinition_09jmy6o" />
</bpmn:boundaryEvent>
<bpmn:sequenceFlow id="Flow_77875455488" sourceRef="Event_0kza4it444" targetRef="Event_55878855778" />
<bpmn:sequenceFlow id="Flow_87785545545544" sourceRef="stay_case_event" targetRef="Activity_7842144454545" />
<bpmn:sequenceFlow id="Flow_78545522598879" sourceRef="Activity_7842144454545" targetRef="UpdateConfirmOrderReviewEvent" />
<bpmn:sequenceFlow id="Flow_0dz1egj" sourceRef="UpdateConfirmOrderReviewEvent" targetRef="Activity_120199855233" />
</bpmn:process>
<bpmn:error id="Error_0lou1w7" name="StartBusinessAbort" errorCode="ABORT" />
<bpmn:message id="Message_07sm7e9" name="CONFIRM_ORDER_REVIEW" />
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CONFIRM_ORDER_REVIEW">
<bpmndi:BPMNEdge id="Flow_0dz1egj_di" bpmnElement="Flow_0dz1egj">
<di:waypoint x="520" y="207" />
<di:waypoint x="620" y="207" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1a5jscb_di" bpmnElement="Flow_78545522598879">
<di:waypoint x="330" y="207" />
<di:waypoint x="420" y="207" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_116h4jn_di" bpmnElement="Flow_87785545545544">
<di:waypoint x="188" y="210" />
<di:waypoint x="230" y="210" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1y0ic2q_di" bpmnElement="Flow_77875455488">
<di:waypoint x="280" y="149" />
<di:waypoint x="280" y="115" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0x2wz2v_di" bpmnElement="Flow_5845212254322">
<di:waypoint x="720" y="207" />
<di:waypoint x="892" y="207" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Activity_0ipbyde_di" bpmnElement="UpdateConfirmOrderReviewEvent">
<dc:Bounds x="420" y="167" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0vk0w99_di" bpmnElement="stay_case_event">
<dc:Bounds x="152" y="192" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="158" y="235" width="25" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1j68eid_di" bpmnElement="Activity_120199855233">
<dc:Bounds x="620" y="167" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_15x2r24_di" bpmnElement="Activity_7842144454545">
<dc:Bounds x="230" y="167" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_1n2x861_di" bpmnElement="Event_55878855778">
<dc:Bounds x="262" y="79" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_1h61h5s_di" bpmnElement="Event_878884254666">
<dc:Bounds x="892" y="189" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0kza4it_di" bpmnElement="Event_0kza4it444">
<dc:Bounds x="262" y="149" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="296" y="130" width="27" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_02cs6jr" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.26.0">
<bpmn:process id="ORDER_REVIEW_OBLIGATION_CHECK_SCHEDULER" name="Order Review Obligation check scheduler" isExecutable="true" camunda:historyTimeToLive="P90D">
<bpmn:sequenceFlow id="Flow_03at42s" sourceRef="StartEvent_1" targetRef="Activity_13h4s1i11" />
<bpmn:sequenceFlow id="Flow_1m5i8op" sourceRef="Activity_13h4s1i11" targetRef="Event_1ifnpoe" />
<bpmn:serviceTask id="Activity_13h4s1i11" name="Order Review Obligation Check scheduler" camunda:type="external" camunda:topic="ORDER_REVIEW_OBLIGATION_CHECK">
<bpmn:incoming>Flow_03at42s</bpmn:incoming>
<bpmn:outgoing>Flow_1m5i8op</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_03at42s</bpmn:outgoing>
<bpmn:timerEventDefinition id="TimerEventDefinition_1oppfcm">
<bpmn:timeCycle xsi:type="bpmn:tFormalExpression">0 0 1 * * ?</bpmn:timeCycle>
</bpmn:timerEventDefinition>
</bpmn:startEvent>
<bpmn:endEvent id="Event_1ifnpoe">
<bpmn:incoming>Flow_1m5i8op</bpmn:incoming>
</bpmn:endEvent>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ORDER_REVIEW_OBLIGATION_CHECK_SCHEDULER">
<bpmndi:BPMNShape id="Activity_1qred84_di" bpmnElement="Activity_13h4s1i11">
<dc:Bounds x="270" y="77" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0lbh5uj_di" bpmnElement="StartEvent_1">
<dc:Bounds x="179" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_034z4bv_di" bpmnElement="Event_1ifnpoe">
<dc:Bounds x="432" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_03at42s_di" bpmnElement="Flow_03at42s">
<di:waypoint x="215" y="117" />
<di:waypoint x="270" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1m5i8op_di" bpmnElement="Flow_1m5i8op">
<di:waypoint x="370" y="117" />
<di:waypoint x="432" y="117" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public abstract class BpmnBaseTest {
public static final String CASE_PROGRESSION_ENABLED = "CASE_PROGRESSION_ENABLED";
public static final String IS_JO_LIVE_FEED_ACTIVE = "IS_JO_LIVE_FEED_ACTIVE";
public static final String DEFENDANT_NOC_ONLINE = "DEFENDANT_NOC_ONLINE";
public static final String PROCESS_CASE_EVENT_CONFIRM_ORDER_REVIEW = "processConfirmOrderReview";

public final String bpmnFileName;
public final String processId;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
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 static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertFalse;

public class ConfirmOrderReviewTest extends BpmnBaseTest {

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

//CCD CASE EVENT
public static final String UPDATE_CONFIRM_REVIEW_ORDER_EVENT
= "UPDATE_CONFIRM_REVIEW_ORDER_EVENT";

//ACTIVITY IDs
private static final String UPDATE_CONFIRM_REVIEW_ORDER_EVENT_ACTIVITY_ID
= "UpdateConfirmOrderReviewEvent";

public ConfirmOrderReviewTest() {
super("confirm_order_review.bpmn", PROCESS_ID);
}

@Test
void shouldSuccessfullyCompleteConfirmOrderReview() {
//assert process has started
assertFalse(processInstance.isEnded());

//assert message start event
assertThat(getProcessDefinitionByMessage(MESSAGE_NAME).getKey()).isEqualTo(PROCESS_ID);

VariableMap variables = Variables.createVariables();

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

ExternalTask notificationTask;

//complete the claimant notification
notificationTask = assertNextExternalTask(PROCESS_CASE_EVENT_CONFIRM_ORDER_REVIEW);
assertCompleteExternalTask(notificationTask, PROCESS_CASE_EVENT_CONFIRM_ORDER_REVIEW,
UPDATE_CONFIRM_REVIEW_ORDER_EVENT,
UPDATE_CONFIRM_REVIEW_ORDER_EVENT_ACTIVITY_ID,
variables
);

//end business process
ExternalTask endBusinessProcess = assertNextExternalTask(END_BUSINESS_PROCESS);
completeBusinessProcess(endBusinessProcess);

assertNoExternalTasksLeft();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package uk.gov.hmcts.reform.civil.bpmn;

import org.camunda.bpm.engine.externaltask.ExternalTask;
import org.camunda.bpm.engine.externaltask.LockedExternalTask;
import org.camunda.bpm.engine.impl.calendar.CronExpression;
import org.camunda.bpm.engine.management.JobDefinition;
import org.junit.jupiter.api.Test;

import java.text.ParseException;
import java.time.LocalDateTime;
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertFalse;

class OrderReviewObligationCheckSchedulerTest extends BpmnBaseTest {

public static final String TOPIC_NAME = "ORDER_REVIEW_OBLIGATION_CHECK";

public OrderReviewObligationCheckSchedulerTest() {
super("order_review_obligation_check_scheduler.bpmn", "ORDER_REVIEW_OBLIGATION_CHECK_SCHEDULER");
}

@Test
void schedulerShouldRaiseOrderReviewObligationExternalTask_whenStarted() throws ParseException {
//assert process has started
assertFalse(processInstance.isEnded());

//assert topic names
assertThat(getTopics()).containsOnly(TOPIC_NAME);

//get jobs
List<JobDefinition> jobDefinitions = getJobs();

//assert that job is as expected
assertThat(jobDefinitions).hasSize(1);
assertThat(jobDefinitions.get(0).getJobType()).isEqualTo("timer-start-event");

String cronString = "0 0 1 * * ?";
assertThat(jobDefinitions.get(0).getJobConfiguration()).isEqualTo("CYCLE: " + cronString);
assertCronTriggerFiresAtExpectedTime(
new CronExpression(cronString),
LocalDateTime.of(2024, 11, 30, 1, 0, 0),
LocalDateTime.of(2024, 12, 1, 1, 0, 0)
);

//get external tasks
List<ExternalTask> externalTasks = getExternalTasks();
assertThat(externalTasks).hasSize(1);

//fetch and complete task
List<LockedExternalTask> lockedExternalTasks = fetchAndLockTask(TOPIC_NAME);

assertThat(lockedExternalTasks).hasSize(1);
completeTask(lockedExternalTasks.get(0).getId());

//assert no external tasks left
List<ExternalTask> externalTasksAfter = getExternalTasks();
assertThat(externalTasksAfter).isEmpty();

//assert process is still active - timer event, so always running
assertFalse(processInstance.isEnded());
}
}
Loading