From 9e5e7be5142ecc538752cb87499ca58eab0b12e6 Mon Sep 17 00:00:00 2001 From: miguelMolina3691 Date: Mon, 2 Dec 2024 12:56:30 +0000 Subject: [PATCH 1/5] CIV-15612 Confirm order review --- .../camunda/confirm_order_review.bpmn | 105 ++++++++++++++++++ .../civil/bpmn/ConfirmOrderReviewTest.java | 62 +++++++++++ 2 files changed, 167 insertions(+) create mode 100644 src/main/resources/camunda/confirm_order_review.bpmn create mode 100644 src/test/java/uk/gov/hmcts/reform/civil/bpmn/ConfirmOrderReviewTest.java diff --git a/src/main/resources/camunda/confirm_order_review.bpmn b/src/main/resources/camunda/confirm_order_review.bpmn new file mode 100644 index 000000000..c9abefb9e --- /dev/null +++ b/src/main/resources/camunda/confirm_order_review.bpmn @@ -0,0 +1,105 @@ + + + + + + + UPDATE_CONFIRM_REVIEW_ORDER_EVENT + + + Flow_78545522598879 + Flow_0dz1egj + + + Flow_87785545545544 + + + + Flow_5845212254322 + + + + + + + + + + Flow_0dz1egj + Flow_5845212254322 + + + + + + + Flow_87785545545544 + Flow_78545522598879 + + + Flow_77875455488 + + + Flow_77875455488 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/uk/gov/hmcts/reform/civil/bpmn/ConfirmOrderReviewTest.java b/src/test/java/uk/gov/hmcts/reform/civil/bpmn/ConfirmOrderReviewTest.java new file mode 100644 index 000000000..a30d2de44 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/civil/bpmn/ConfirmOrderReviewTest.java @@ -0,0 +1,62 @@ +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 java.util.Map; + +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); + assertCompleteExternalTask(notificationTask, PROCESS_CASE_EVENT, + 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(); + } +} From 2746b030a9b67c47a6da51b8e44a8f9b807a111c Mon Sep 17 00:00:00 2001 From: miguelMolina3691 Date: Mon, 2 Dec 2024 13:04:43 +0000 Subject: [PATCH 2/5] CIV-15612 update test --- .../java/uk/gov/hmcts/reform/civil/bpmn/BpmnBaseTest.java | 1 + .../gov/hmcts/reform/civil/bpmn/ConfirmOrderReviewTest.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/civil/bpmn/BpmnBaseTest.java b/src/test/java/uk/gov/hmcts/reform/civil/bpmn/BpmnBaseTest.java index cee361f42..4a5f9df6e 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/bpmn/BpmnBaseTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/bpmn/BpmnBaseTest.java @@ -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; diff --git a/src/test/java/uk/gov/hmcts/reform/civil/bpmn/ConfirmOrderReviewTest.java b/src/test/java/uk/gov/hmcts/reform/civil/bpmn/ConfirmOrderReviewTest.java index a30d2de44..a07b9936b 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/bpmn/ConfirmOrderReviewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/bpmn/ConfirmOrderReviewTest.java @@ -46,8 +46,8 @@ void shouldSuccessfullyCompleteConfirmOrderReview() { ExternalTask notificationTask; //complete the claimant notification - notificationTask = assertNextExternalTask(PROCESS_CASE_EVENT); - assertCompleteExternalTask(notificationTask, PROCESS_CASE_EVENT, + 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 From 14f4655cd3f07a584452ea1aa7a7debef5b4081f Mon Sep 17 00:00:00 2001 From: miguelMolina3691 Date: Mon, 2 Dec 2024 13:12:11 +0000 Subject: [PATCH 3/5] CIV-15612 lint --- .../uk/gov/hmcts/reform/civil/bpmn/ConfirmOrderReviewTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/civil/bpmn/ConfirmOrderReviewTest.java b/src/test/java/uk/gov/hmcts/reform/civil/bpmn/ConfirmOrderReviewTest.java index a07b9936b..aa75ccb79 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/bpmn/ConfirmOrderReviewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/bpmn/ConfirmOrderReviewTest.java @@ -5,8 +5,6 @@ import org.camunda.bpm.engine.variable.Variables; import org.junit.jupiter.api.Test; -import java.util.Map; - import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertFalse; From bbee6a4cafb4c5c0888d59831ae223ef04816820 Mon Sep 17 00:00:00 2001 From: VijayaKumarK Date: Mon, 9 Dec 2024 17:30:04 +0000 Subject: [PATCH 4/5] CIV-15625 order review obligation check scheduler --- ...der_review_obligation_check_scheduler.bpmn | 42 ++++++++++++ ...derReviewObligationCheckSchedulerTest.java | 64 +++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 src/main/resources/camunda/order_review_obligation_check_scheduler.bpmn create mode 100644 src/test/java/uk/gov/hmcts/reform/civil/bpmn/OrderReviewObligationCheckSchedulerTest.java diff --git a/src/main/resources/camunda/order_review_obligation_check_scheduler.bpmn b/src/main/resources/camunda/order_review_obligation_check_scheduler.bpmn new file mode 100644 index 000000000..996fd10ed --- /dev/null +++ b/src/main/resources/camunda/order_review_obligation_check_scheduler.bpmn @@ -0,0 +1,42 @@ + + + + + + + Flow_03at42s + Flow_1m5i8op + + + Flow_03at42s + + 0 0 0 * * ? + + + + Flow_1m5i8op + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/uk/gov/hmcts/reform/civil/bpmn/OrderReviewObligationCheckSchedulerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/bpmn/OrderReviewObligationCheckSchedulerTest.java new file mode 100644 index 000000000..a0f22006a --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/civil/bpmn/OrderReviewObligationCheckSchedulerTest.java @@ -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 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 0 * * ?"; + assertThat(jobDefinitions.get(0).getJobConfiguration()).isEqualTo("CYCLE: " + cronString); + assertCronTriggerFiresAtExpectedTime( + new CronExpression(cronString), + LocalDateTime.of(2024, 11, 30, 0, 0, 0), + LocalDateTime.of(2024, 12, 1, 0, 0, 0) + ); + + //get external tasks + List externalTasks = getExternalTasks(); + assertThat(externalTasks).hasSize(1); + + //fetch and complete task + List lockedExternalTasks = fetchAndLockTask(TOPIC_NAME); + + assertThat(lockedExternalTasks).hasSize(1); + completeTask(lockedExternalTasks.get(0).getId()); + + //assert no external tasks left + List externalTasksAfter = getExternalTasks(); + assertThat(externalTasksAfter).isEmpty(); + + //assert process is still active - timer event, so always running + assertFalse(processInstance.isEnded()); + } +} From cb461c80e6ab55a20768ce2d3425d92609a56ca6 Mon Sep 17 00:00:00 2001 From: VijayaKumarK Date: Tue, 10 Dec 2024 12:40:32 +0000 Subject: [PATCH 5/5] CIV-15625 update scheduler to run at 1 am --- .../camunda/order_review_obligation_check_scheduler.bpmn | 2 +- .../civil/bpmn/OrderReviewObligationCheckSchedulerTest.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/resources/camunda/order_review_obligation_check_scheduler.bpmn b/src/main/resources/camunda/order_review_obligation_check_scheduler.bpmn index 996fd10ed..c24df6639 100644 --- a/src/main/resources/camunda/order_review_obligation_check_scheduler.bpmn +++ b/src/main/resources/camunda/order_review_obligation_check_scheduler.bpmn @@ -10,7 +10,7 @@ Flow_03at42s - 0 0 0 * * ? + 0 0 1 * * ? diff --git a/src/test/java/uk/gov/hmcts/reform/civil/bpmn/OrderReviewObligationCheckSchedulerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/bpmn/OrderReviewObligationCheckSchedulerTest.java index a0f22006a..6162c652a 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/bpmn/OrderReviewObligationCheckSchedulerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/bpmn/OrderReviewObligationCheckSchedulerTest.java @@ -36,12 +36,12 @@ void schedulerShouldRaiseOrderReviewObligationExternalTask_whenStarted() throws assertThat(jobDefinitions).hasSize(1); assertThat(jobDefinitions.get(0).getJobType()).isEqualTo("timer-start-event"); - String cronString = "0 0 0 * * ?"; + String cronString = "0 0 1 * * ?"; assertThat(jobDefinitions.get(0).getJobConfiguration()).isEqualTo("CYCLE: " + cronString); assertCronTriggerFiresAtExpectedTime( new CronExpression(cronString), - LocalDateTime.of(2024, 11, 30, 0, 0, 0), - LocalDateTime.of(2024, 12, 1, 0, 0, 0) + LocalDateTime.of(2024, 11, 30, 1, 0, 0), + LocalDateTime.of(2024, 12, 1, 1, 0, 0) ); //get external tasks