Skip to content

Commit

Permalink
CIV-0000 sprint branch CIV-15290, CIV-15086 (#1117)
Browse files Browse the repository at this point in the history
* CIV-15290 cosc set co sc application status to active on successful payment of application fee (#1111)

* add new cosc task

* add new cosc task

* add new cosc task

* remove the tasks

* added tests for initiate cosc application after payment

* fixed ga

---------

Co-authored-by: Sherlyn Khaw <[email protected]>
Co-authored-by: Azam <[email protected]>
Co-authored-by: sherlynkhaw <[email protected]>

* CIV-15086 COSC Proof of Debt Scheduler (#1112)

* Setup new cosc proof of debt scheduler to run daily at 16:00

* Added base process cosc process

* Updated test name

---------

Co-authored-by: GarethLancaster <[email protected]>

---------

Co-authored-by: LeonardoPalmeiro <[email protected]>
Co-authored-by: Sherlyn Khaw <[email protected]>
Co-authored-by: sherlynkhaw <[email protected]>
Co-authored-by: Gareth Lancaster <[email protected]>
Co-authored-by: GarethLancaster <[email protected]>
Co-authored-by: kalachandrasekar1 <[email protected]>
  • Loading branch information
7 people authored Oct 17, 2024
1 parent 3f0d5b5 commit 3cfb0e7
Show file tree
Hide file tree
Showing 7 changed files with 455 additions and 1 deletion.
52 changes: 52 additions & 0 deletions src/main/resources/camunda/ga_proof_of_debt_scheduler.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?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="4.12.0">
<bpmn:process id="GA_PROOF_OF_DEBT_SCHEDULER" name="Proof of debt scheduler" isExecutable="true">
<bpmn:endEvent id="Event_1ifnnox">
<bpmn:incoming>Flow_1m5i8op</bpmn:incoming>
</bpmn:endEvent>
<bpmn:serviceTask id="Activity_13h4s1c" name="GA Proof of Debt Processor" camunda:type="external" camunda:topic="CoscApplicationProcessor">
<bpmn:incoming>Flow_03at42s</bpmn:incoming>
<bpmn:outgoing>Flow_1m5i8op</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="Flow_1m5i8op" sourceRef="Activity_13h4s1c" targetRef="Event_1ifnnox" />
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_03at42s</bpmn:outgoing>
<bpmn:timerEventDefinition id="TimerEventDefinition_1oppfcm">
<bpmn:timeCycle xsi:type="bpmn:tFormalExpression">0 0 16 * * ?</bpmn:timeCycle>
</bpmn:timerEventDefinition>
</bpmn:startEvent>
<bpmn:sequenceFlow id="Flow_03at42s" sourceRef="StartEvent_1" targetRef="Activity_13h4s1c" />
<bpmn:textAnnotation id="TextAnnotation_044lgkw">
<bpmn:text>Run every day at 16:00</bpmn:text>
</bpmn:textAnnotation>
<bpmn:association id="Association_1hljol7" sourceRef="StartEvent_1" targetRef="TextAnnotation_044lgkw" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="GA_PROOF_OF_DEBT_SCHEDULER">
<bpmndi:BPMNShape id="TextAnnotation_044lgkw_di" bpmnElement="TextAnnotation_044lgkw">
<dc:Bounds x="150" y="80" width="100" height="40" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_1m5i8op_di" bpmnElement="Flow_1m5i8op">
<di:waypoint x="430" y="197" />
<di:waypoint x="492" y="197" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_03at42s_di" bpmnElement="Flow_03at42s">
<di:waypoint x="275" y="197" />
<di:waypoint x="330" y="197" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Activity_1qred84_di" bpmnElement="Activity_13h4s1c">
<dc:Bounds x="330" y="157" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0lbh5uj_di" bpmnElement="StartEvent_1">
<dc:Bounds x="239" y="179" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_034z4bv_di" bpmnElement="Event_1ifnnox">
<dc:Bounds x="492" y="179" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Association_1hljol7_di" bpmnElement="Association_1hljol7">
<di:waypoint x="248" y="182" />
<di:waypoint x="214" y="120" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?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" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_038vuuf" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.9.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.15.0">
<bpmn:message id="Message_0yl8iuc" name="INITIATE_COSC_APPLICATION_AFTER_PAYMENT" />
<bpmn:collaboration id="INITIATE_COSC_APPLICATION_AFTER_PAYMENT_ID">
<bpmn:extensionElements />
<bpmn:participant id="Participant_11shrki" name="Initiate Cosc Application After Payment" processRef="COSC_INITIATE_AFTER_PAYMENT_PROCESS_ID" />
</bpmn:collaboration>
<bpmn:process id="COSC_INITIATE_AFTER_PAYMENT_PROCESS_ID" name="COSC initiate after payment process" isExecutable="true">
<bpmn:sequenceFlow id="Flow_1lowlui" sourceRef="Event_19ttrus" targetRef="Activity_099a8bs" />
<bpmn:sequenceFlow id="Flow_0nufgia" sourceRef="Activity_099a8bs" targetRef="Event_0pltq59" />
<bpmn:sequenceFlow id="Flow_0n6ts4r" sourceRef="Activity_0eo8p2p" targetRef="Event_0ii7uzg" />
<bpmn:boundaryEvent id="Event_1r5gva6" name="Abort" attachedToRef="Activity_099a8bs">
<bpmn:errorEventDefinition id="ErrorEventDefinition_0cl9008" />
</bpmn:boundaryEvent>
<bpmn:endEvent id="Event_0pltq59">
<bpmn:incoming>Flow_0nufgia</bpmn:incoming>
</bpmn:endEvent>
<bpmn:callActivity id="Activity_099a8bs" name="Start Business Process" calledElement="GA_StartGeneralApplicationBusinessProcess">
<bpmn:extensionElements>
<camunda:in variables="all" />
<camunda:out variables="all" />
</bpmn:extensionElements>
<bpmn:incoming>Flow_1lowlui</bpmn:incoming>
<bpmn:outgoing>Flow_0nufgia</bpmn:outgoing>
<bpmn:outgoing>Flow_0ewf3pg</bpmn:outgoing>
</bpmn:callActivity>
<bpmn:sequenceFlow id="Flow_0ewf3pg" sourceRef="Activity_099a8bs" targetRef="CheckMarkPaidInFullAndAddSchedulerDeadline" />
<bpmn:serviceTask id="CheckMarkPaidInFullAndAddSchedulerDeadline" name="Check Mark paid in full and add scheduler deadline" camunda:type="external" camunda:topic="coscApplicationAfterPayment">
<bpmn:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="caseEvent">CHECK_PAID_IN_FULL_SCHED_DEADLINE</camunda:inputParameter>
</camunda:inputOutput>
</bpmn:extensionElements>
<bpmn:incoming>Flow_0ewf3pg</bpmn:incoming>
<bpmn:outgoing>Flow_0mb7441</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="Flow_0mb7441" sourceRef="CheckMarkPaidInFullAndAddSchedulerDeadline" targetRef="Activity_0eo8p2p" />
<bpmn:callActivity id="Activity_0eo8p2p" name="End Business Process" calledElement="GA_EndBusinessProcess">
<bpmn:extensionElements>
<camunda:in variables="all" />
</bpmn:extensionElements>
<bpmn:incoming>Flow_0mb7441</bpmn:incoming>
<bpmn:outgoing>Flow_0n6ts4r</bpmn:outgoing>
</bpmn:callActivity>
<bpmn:endEvent id="Event_0ii7uzg">
<bpmn:incoming>Flow_0n6ts4r</bpmn:incoming>
</bpmn:endEvent>
<bpmn:startEvent id="Event_19ttrus" name="Start">
<bpmn:outgoing>Flow_1lowlui</bpmn:outgoing>
<bpmn:messageEventDefinition id="MessageEventDefinition_024hrqa" messageRef="Message_0yl8iuc" />
</bpmn:startEvent>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="INITIATE_COSC_APPLICATION_AFTER_PAYMENT_ID">
<bpmndi:BPMNShape id="Participant_11shrki_di" bpmnElement="Participant_11shrki" isHorizontal="true">
<dc:Bounds x="160" y="120" width="1520" height="390" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_0mb7441_di" bpmnElement="Flow_0mb7441">
<di:waypoint x="590" y="288" />
<di:waypoint x="1470" y="288" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0ewf3pg_di" bpmnElement="Flow_0ewf3pg">
<di:waypoint x="390" y="288" />
<di:waypoint x="490" y="288" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0n6ts4r_di" bpmnElement="Flow_0n6ts4r">
<di:waypoint x="1570" y="288" />
<di:waypoint x="1622" y="288" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0nufgia_di" bpmnElement="Flow_0nufgia">
<di:waypoint x="340" y="248" />
<di:waypoint x="340" y="176" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1lowlui_di" bpmnElement="Flow_1lowlui">
<di:waypoint x="248" y="288" />
<di:waypoint x="290" y="288" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Event_0pltq59_di" bpmnElement="Event_0pltq59">
<dc:Bounds x="322" y="140" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_099a8bs_di" bpmnElement="Activity_099a8bs">
<dc:Bounds x="290" y="248" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1905nhf_di" bpmnElement="CheckMarkPaidInFullAndAddSchedulerDeadline">
<dc:Bounds x="490" y="248" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0eo8p2p_di" bpmnElement="Activity_0eo8p2p">
<dc:Bounds x="1470" y="248" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0ii7uzg_di" bpmnElement="Event_0ii7uzg">
<dc:Bounds x="1622" y="270" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_19ttrus_di" bpmnElement="Event_19ttrus">
<dc:Bounds x="212" y="270" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="219" y="313" width="24" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_1r5gva6_di" bpmnElement="Event_1r5gva6">
<dc:Bounds x="322" y="230" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="347" y="200" width="27" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,4 @@
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
</bpmn:definitions>
99 changes: 99 additions & 0 deletions src/main/resources/camunda/process_cosc_application.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?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="PROCESS_COSC_APPLICATION_PROCESS_ID" name="Process COSC Application" isExecutable="true">
<bpmn:startEvent id="Event_0vk0w88" name="Start">
<bpmn:outgoing>Flow_116h4jr</bpmn:outgoing>
<bpmn:messageEventDefinition id="MessageEventDefinition_1dvrj2w" messageRef="Message_07sm7e9" />
</bpmn:startEvent>
<bpmn:endEvent id="Event_1n2x832">
<bpmn:incoming>Flow_1y0ic2q</bpmn:incoming>
</bpmn:endEvent>
<bpmn:endEvent id="Event_1h61h5a">
<bpmn:incoming>Flow_0x2wz2</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_116h4jr" sourceRef="Event_0vk0w88" targetRef="Activity_15x2r20" />
<bpmn:callActivity id="Activity_0471ljz" 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_1a5jsca</bpmn:incoming>
<bpmn:outgoing>Flow_0x2wz2</bpmn:outgoing>
</bpmn:callActivity>
<bpmn:sequenceFlow id="Flow_0x2wz2" sourceRef="Activity_0471ljz" targetRef="Event_1h61h5a" />
<bpmn:callActivity id="Activity_15x2r20" name="Start Business Process" calledElement="StartBusinessProcess">
<bpmn:extensionElements>
<camunda:in variables="all" />
<camunda:out variables="all" />
</bpmn:extensionElements>
<bpmn:incoming>Flow_116h4jr</bpmn:incoming>
<bpmn:outgoing>Flow_1a5jsca</bpmn:outgoing>
</bpmn:callActivity>
<bpmn:sequenceFlow id="Flow_1a5jsca" sourceRef="Activity_15x2r20" targetRef="Activity_0471ljz" />
<bpmn:boundaryEvent id="Event_0kza4it" name="Abort" attachedToRef="Activity_15x2r20">
<bpmn:outgoing>Flow_1y0ic2q</bpmn:outgoing>
<bpmn:errorEventDefinition id="ErrorEventDefinition_09jmy6o" />
</bpmn:boundaryEvent>
<bpmn:sequenceFlow id="Flow_1y0ic2q" sourceRef="Event_0kza4it" targetRef="Event_1n2x832" />
<bpmn:textAnnotation id="TextAnnotation_1jdkgsi">
<bpmn:text>PROCESS_COSC_APPLICATION</bpmn:text>
</bpmn:textAnnotation>
<bpmn:association id="Association_0ct49aq" sourceRef="Event_0vk0w88" targetRef="TextAnnotation_1jdkgsi" />
</bpmn:process>
<bpmn:error id="Error_0lou1w7" name="StartBusinessAbort" errorCode="ABORT" />
<bpmn:message id="Message_07sm7e9" name="PROCESS_COSC_APPLICATION" />
<bpmn:message id="Message_1ysab1l" name="Message_19rb2d5" />
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="PROCESS_COSC_APPLICATION_PROCESS_ID">
<bpmndi:BPMNShape id="TextAnnotation_1jdkgsi_di" bpmnElement="TextAnnotation_1jdkgsi">
<dc:Bounds x="160" y="82" width="213" height="33" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_1a5jscb_di" bpmnElement="Flow_1a5jsca">
<di:waypoint x="480" y="207" />
<di:waypoint x="540" y="207" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_116h4jn_di" bpmnElement="Flow_116h4jr">
<di:waypoint x="338" y="210" />
<di:waypoint x="380" y="210" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1y0ic2q_di" bpmnElement="Flow_1y0ic2q">
<di:waypoint x="430" y="149" />
<di:waypoint x="430" y="115" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0x2wz2v_di" bpmnElement="Flow_0x2wz2">
<di:waypoint x="640" y="207" />
<di:waypoint x="692" y="207" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Event_0vk0w99_di" bpmnElement="Event_0vk0w88">
<dc:Bounds x="302" y="192" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="308" y="235" width="24" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_15x2r24_di" bpmnElement="Activity_15x2r20">
<dc:Bounds x="380" y="167" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_1n2x861_di" bpmnElement="Event_1n2x832">
<dc:Bounds x="412" y="79" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_1h61h5s_di" bpmnElement="Event_1h61h5a">
<dc:Bounds x="692" y="189" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1j68eid_di" bpmnElement="Activity_0471ljz">
<dc:Bounds x="540" y="167" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Association_0ct49aq_di" bpmnElement="Association_0ct49aq">
<di:waypoint x="308" y="197" />
<di:waypoint x="228" y="115" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Event_0kza4it_di" bpmnElement="Event_0kza4it">
<dc:Bounds x="412" y="149" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="446" 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,66 @@
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 GAProofOfDebtSchedulerTest extends BpmnBaseTest {

public static final String TOPIC_NAME = "CoscApplicationProcessor";

public static final String PROCESS_ID = "GA_PROOF_OF_DEBT_SCHEDULER";

public GAProofOfDebtSchedulerTest() {
super("ga_proof_of_debt_scheduler.bpmn", PROCESS_ID);
}

@Test
void schedulerShouldRaiseTakeCaseOfflineExternalTask_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 16 * * ?";
assertThat(jobDefinitions.get(0).getJobConfiguration()).isEqualTo("CYCLE: " + cronString);
assertCronTriggerFiresAtExpectedTime(
new CronExpression(cronString),
LocalDateTime.of(2024, 1, 1, 0, 0, 0),
LocalDateTime.of(2024, 1, 1, 16, 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

0 comments on commit 3cfb0e7

Please sign in to comment.