Skip to content

Commit

Permalink
Merge pull request #12 from hmcts/merge-with-master
Browse files Browse the repository at this point in the history
feat: merge with latest civil-damages master
  • Loading branch information
pd-dudkiewicz authored May 17, 2021
2 parents 07942cb + 6497c6b commit 295b357
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 30 deletions.
53 changes: 35 additions & 18 deletions src/main/resources/camunda/case_proceeds_in_caseman.bpmn
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?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="4.5.0">
<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="4.6.0">
<bpmn:process id="CASE_PROCEEDS_IN_CASEMAN" isExecutable="true">
<bpmn:startEvent id="Event_StartClaimTakenOffline" name="Start">
<bpmn:outgoing>Flow_NextStartBusinessProcess</bpmn:outgoing>
Expand Down Expand Up @@ -33,14 +33,14 @@
</bpmn:boundaryEvent>
<bpmn:sequenceFlow id="Flow_StartBusinessProcessAbort" sourceRef="Event_1fn0bf1" targetRef="Event_1nsmt51" />
<bpmn:sequenceFlow id="Flow_NextStartBusinessProcess" sourceRef="Event_StartClaimTakenOffline" targetRef="Activity_StartBusinessProcess" />
<bpmn:sequenceFlow id="Flow_NextNotifyRpa" sourceRef="Activity_StartBusinessProcess" targetRef="CaseProceedsInCasemanNotifyRespondentSolicitor1" />
<bpmn:sequenceFlow id="Flow_NextNotifyRpa" sourceRef="Activity_StartBusinessProcess" targetRef="NotifyRoboticsOnCaseHandedOffline" />
<bpmn:serviceTask id="CaseProceedsInCasemanNotifyRespondentSolicitor1" name="Notify respondent solicitor 1" camunda:type="external" camunda:topic="processCaseEvent">
<bpmn:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="caseEvent">NOTIFY_RESPONDENT_SOLICITOR1_FOR_CASE_PROCEEDS_IN_CASEMAN</camunda:inputParameter>
</camunda:inputOutput>
</bpmn:extensionElements>
<bpmn:incoming>Flow_NextNotifyRpa</bpmn:incoming>
<bpmn:incoming>Flow_0w2xd7v</bpmn:incoming>
<bpmn:outgoing>Flow_1hq815y</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="Flow_1hq815y" sourceRef="CaseProceedsInCasemanNotifyRespondentSolicitor1" targetRef="CaseProceedsInCasemanNotifyApplicantSolicitor1" />
Expand All @@ -54,11 +54,29 @@
<bpmn:outgoing>Flow_0uljtsx</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="Flow_0uljtsx" sourceRef="CaseProceedsInCasemanNotifyApplicantSolicitor1" targetRef="Activity_EndBusinessProcess" />
<bpmn:serviceTask id="NotifyRoboticsOnCaseHandedOffline" name="Notify RPA on case handed offline" camunda:type="external" camunda:topic="processCaseEvent">
<bpmn:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="caseEvent">NOTIFY_RPA_ON_CASE_HANDED_OFFLINE</camunda:inputParameter>
</camunda:inputOutput>
</bpmn:extensionElements>
<bpmn:incoming>Flow_NextNotifyRpa</bpmn:incoming>
<bpmn:outgoing>Flow_0w2xd7v</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="Flow_0w2xd7v" sourceRef="NotifyRoboticsOnCaseHandedOffline" targetRef="CaseProceedsInCasemanNotifyRespondentSolicitor1" />
</bpmn:process>
<bpmn:message id="Message_0slk3de" name="CASE_PROCEEDS_IN_CASEMAN" />
<bpmn:error id="Error_0t2ju7k" name="StartBusinessAbort" errorCode="ABORT" />
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CASE_PROCEEDS_IN_CASEMAN">
<bpmndi:BPMNEdge id="Flow_0uljtsx_di" bpmnElement="Flow_0uljtsx">
<di:waypoint x="750" y="210" />
<di:waypoint x="780" y="210" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1hq815y_di" bpmnElement="Flow_1hq815y">
<di:waypoint x="600" y="210" />
<di:waypoint x="650" y="210" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_14aod2o_di" bpmnElement="Flow_NextNotifyRpa">
<di:waypoint x="330" y="210" />
<di:waypoint x="370" y="210" />
Expand All @@ -71,17 +89,13 @@
<di:waypoint x="280" y="152" />
<di:waypoint x="280" y="118" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1hq815y_di" bpmnElement="Flow_1hq815y">
<di:waypoint x="470" y="210" />
<di:waypoint x="510" y="210" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1hce35l_di" bpmnElement="Flow_NextEndEvent">
<di:waypoint x="750" y="210" />
<di:waypoint x="782" y="210" />
<di:waypoint x="880" y="210" />
<di:waypoint x="972" y="210" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0uljtsx_di" bpmnElement="Flow_0uljtsx">
<di:waypoint x="610" y="210" />
<di:waypoint x="650" y="210" />
<bpmndi:BPMNEdge id="Flow_0w2xd7v_di" bpmnElement="Flow_0w2xd7v">
<di:waypoint x="470" y="210" />
<di:waypoint x="500" y="210" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Event_1m02c2o_di" bpmnElement="Event_StartClaimTakenOffline">
<dc:Bounds x="152" y="192" width="36" height="36" />
Expand All @@ -95,17 +109,20 @@
<bpmndi:BPMNShape id="Event_1nsmt51_di" bpmnElement="Event_1nsmt51">
<dc:Bounds x="262" y="82" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0lrzkzm_di" bpmnElement="CaseProceedsInCasemanNotifyRespondentSolicitor1">
<dc:Bounds x="370" y="170" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0r8yo0r_di" bpmnElement="Event_EndClaimTakenOffline">
<dc:Bounds x="782" y="192" width="36" height="36" />
<dc:Bounds x="972" y="192" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1x5rl4x_di" bpmnElement="Activity_EndBusinessProcess">
<dc:Bounds x="650" y="170" width="100" height="80" />
<dc:Bounds x="780" y="170" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0lrzkzm_di" bpmnElement="CaseProceedsInCasemanNotifyRespondentSolicitor1">
<dc:Bounds x="500" y="170" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1huplho_di" bpmnElement="CaseProceedsInCasemanNotifyApplicantSolicitor1">
<dc:Bounds x="510" y="170" width="100" height="80" />
<dc:Bounds x="650" y="170" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1kdqyo6_di" bpmnElement="NotifyRoboticsOnCaseHandedOffline">
<dc:Bounds x="370" y="170" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_1fn0bf1_di" bpmnElement="Event_1fn0bf1">
<dc:Bounds x="262" y="152" width="36" height="36" />
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/camunda/claim_dismissed_scheduler.bpmn
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_03at42s</bpmn:outgoing>
<bpmn:timerEventDefinition id="TimerEventDefinition_1oppfcm">
<bpmn:timeCycle xsi:type="bpmn:tFormalExpression">5 16 * * * ?</bpmn:timeCycle>
<bpmn:timeCycle xsi:type="bpmn:tFormalExpression">0 5 16 * * ?</bpmn:timeCycle>
</bpmn:timerEventDefinition>
</bpmn:startEvent>
<bpmn:endEvent id="Event_1ifnnom">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_0pqxboc</bpmn:outgoing>
<bpmn:timerEventDefinition id="TimerEventDefinition_19uik9q">
<bpmn:timeCycle xsi:type="bpmn:tFormalExpression">5 0 * * * ?</bpmn:timeCycle>
<bpmn:timeCycle xsi:type="bpmn:tFormalExpression">0 5 0 * * ?</bpmn:timeCycle>
</bpmn:timerEventDefinition>
</bpmn:startEvent>
<bpmn:sequenceFlow id="Flow_0pqxboc" sourceRef="StartEvent_1" targetRef="Activity_1wq7ps2" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<bpmn:startEvent id="Event_16siul2">
<bpmn:outgoing>Flow_1gnbmqe</bpmn:outgoing>
<bpmn:timerEventDefinition id="TimerEventDefinition_0g5qu8x">
<bpmn:timeCycle xsi:type="bpmn:tFormalExpression">0 0/30 * * * ?</bpmn:timeCycle>
<bpmn:timeCycle xsi:type="bpmn:tFormalExpression">0 0/5 * * * ?</bpmn:timeCycle>
</bpmn:timerEventDefinition>
</bpmn:startEvent>
</bpmn:process>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_03at42s</bpmn:outgoing>
<bpmn:timerEventDefinition id="TimerEventDefinition_1oppfcm">
<bpmn:timeCycle xsi:type="bpmn:tFormalExpression">5 16 * * * ?</bpmn:timeCycle>
<bpmn:timeCycle xsi:type="bpmn:tFormalExpression">0 5 16 * * ?</bpmn:timeCycle>
</bpmn:timerEventDefinition>
</bpmn:startEvent>
<bpmn:endEvent id="Event_1ifnnom">
Expand Down
13 changes: 13 additions & 0 deletions src/test/java/uk/gov/hmcts/reform/civil/bpmn/BpmnBaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.camunda.bpm.engine.ProcessEngineConfiguration;
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.camunda.bpm.engine.repository.Deployment;
import org.camunda.bpm.engine.repository.ProcessDefinition;
Expand All @@ -14,10 +15,14 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static org.camunda.bpm.engine.ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration;
import static org.junit.jupiter.api.Assertions.assertEquals;

public abstract class BpmnBaseTest {

Expand Down Expand Up @@ -252,6 +257,14 @@ public void completeBusinessProcess(ExternalTask externalTask) {
completeTask(lockedEndBusinessProcessTask.get(0).getId());
}

public void assertCronTriggerFiresAtExpectedTime(CronExpression expression,
LocalDateTime now,
LocalDateTime nextDate) {
Date startTime = Date.from(now.atZone(ZoneId.systemDefault()).toInstant());
Date next = expression.getTimeAfter(startTime);
assertEquals(next, Date.from(nextDate.atZone(ZoneId.systemDefault()).toInstant()));
}

private void assertExternalTask(
ExternalTask externalTask,
String topicName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

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;
Expand All @@ -19,7 +22,7 @@ public CaseDismissedSchedulerTest() {
}

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

Expand All @@ -33,7 +36,13 @@ void claimDismissedSchedulerShouldFireCaseDismissedExternalTask_whenStarted() {
assertThat(jobDefinitions).hasSize(1);
assertThat(jobDefinitions.get(0).getJobType()).isEqualTo("timer-start-event");

assertThat(jobDefinitions.get(0).getJobConfiguration()).isEqualTo("CYCLE: 5 16 * * * ?");
String cronString = "0 5 16 * * ?";
assertThat(jobDefinitions.get(0).getJobConfiguration()).isEqualTo("CYCLE: " + cronString);
assertCronTriggerFiresAtExpectedTime(
new CronExpression(cronString),
LocalDateTime.of(2020, 1, 1, 0, 0, 0),
LocalDateTime.of(2020, 1, 1, 16, 5, 0)
);

//get external tasks
List<ExternalTask> externalTasks = getExternalTasks();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ void shouldSuccessfullyCompleteNotifyClaim_whenCalled() {
START_BUSINESS_ACTIVITY
);

//complete the RPA notification
ExternalTask rpaNotification = assertNextExternalTask(PROCESS_CASE_EVENT);
assertCompleteExternalTask(
rpaNotification,
PROCESS_CASE_EVENT,
"NOTIFY_RPA_ON_CASE_HANDED_OFFLINE",
"NotifyRoboticsOnCaseHandedOffline"
);

//complete the notification to respondent
ExternalTask respondentNotification = assertNextExternalTask(PROCESS_CASE_EVENT);
assertCompleteExternalTask(respondentNotification,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

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;
Expand All @@ -19,7 +22,7 @@ public NotifyClaimDeadlineSchedulerTest() {
}

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

Expand All @@ -33,7 +36,13 @@ void notifyClaimDeadlineSchedulerShouldFireCaseDismissedExternalTask_whenStarted
assertThat(jobDefinitions).hasSize(1);
assertThat(jobDefinitions.get(0).getJobType()).isEqualTo("timer-start-event");

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

//get external tasks
List<ExternalTask> externalTasks = getExternalTasks();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

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;
Expand All @@ -19,7 +22,7 @@ public PollingEventEmitterSchedulerTest() {
}

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

Expand All @@ -32,7 +35,14 @@ void pollingEventBmpnShouldFirePollingEventEmmiterExternalTask_whenStarted() {
//assert that job is as expected
assertThat(jobDefinitions).hasSize(1);
assertThat(jobDefinitions.get(0).getJobType()).isEqualTo("timer-start-event");
assertThat(jobDefinitions.get(0).getJobConfiguration()).isEqualTo("CYCLE: 0 0/30 * * * ?");

String cronString = "0 0/5 * * * ?";
assertThat(jobDefinitions.get(0).getJobConfiguration()).isEqualTo("CYCLE: " + cronString);
assertCronTriggerFiresAtExpectedTime(
new CronExpression(cronString),
LocalDateTime.of(2020, 1, 1, 0, 0, 0),
LocalDateTime.of(2020, 1, 1, 0, 5, 0)
);

//get external tasks
List<ExternalTask> externalTasks = getExternalTasks();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

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;
Expand All @@ -19,7 +22,7 @@ public TakeCaseOfflineSchedulerTest() {
}

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

Expand All @@ -33,7 +36,13 @@ void schedulerShouldRaiseTakeCaseOfflineExternalTask_whenStarted() {
assertThat(jobDefinitions).hasSize(1);
assertThat(jobDefinitions.get(0).getJobType()).isEqualTo("timer-start-event");

assertThat(jobDefinitions.get(0).getJobConfiguration()).isEqualTo("CYCLE: 5 16 * * * ?");
String cronString = "0 5 16 * * ?";
assertThat(jobDefinitions.get(0).getJobConfiguration()).isEqualTo("CYCLE: " + cronString);
assertCronTriggerFiresAtExpectedTime(
new CronExpression(cronString),
LocalDateTime.of(2020, 1, 1, 0, 0, 0),
LocalDateTime.of(2020, 1, 1, 16, 5, 0)
);

//get external tasks
List<ExternalTask> externalTasks = getExternalTasks();
Expand Down

0 comments on commit 295b357

Please sign in to comment.