diff --git a/src/main/resources/camunda/judgement_paid_in_full.bpmn b/src/main/resources/camunda/judgement_paid_in_full.bpmn new file mode 100644 index 000000000..921fa504f --- /dev/null +++ b/src/main/resources/camunda/judgement_paid_in_full.bpmn @@ -0,0 +1,103 @@ + + + + + Flow_1if0h68 + + + + Flow_1hce35l + + + + + + + Flow_RPA_Continuous_Feed_Completed + Flow_1hce35l + + + + + + + Flow_1if0h68 + Flow_04rigbl + + + Flow_0h072ea + + + Flow_0h072ea + + + + + + + + SEND_JUDGMENT_DETAILS_CJES + + + Flow_04rigbl + Flow_RPA_Continuous_Feed_Completed + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/uk/gov/hmcts/reform/civil/bpmn/JudgementPaidInFullTest.java b/src/test/java/uk/gov/hmcts/reform/civil/bpmn/JudgementPaidInFullTest.java new file mode 100644 index 000000000..a375fd81f --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/civil/bpmn/JudgementPaidInFullTest.java @@ -0,0 +1,67 @@ +package uk.gov.hmcts.reform.civil.bpmn; + +import org.camunda.bpm.engine.externaltask.ExternalTask; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertFalse; + +class JudgementPaidInFullTest extends BpmnBaseTest { + + public static final String MESSAGE_NAME = "JUDGMENT_PAID_IN_FULL"; + public static final String PROCESS_ID = "JUDGMENT_PAID_IN_FULL"; + private static final String SEND_JUDGMENT_DETAILS_CJES = "SEND_JUDGMENT_DETAILS_CJES"; + private static final String SEND_JUDGMENT_DETAILS_CJES_ACTIVITY_ID = "SendJudgmentDetailsToCJES"; + + public JudgementPaidInFullTest() { + super("judgement_paid_in_full.bpmn", PROCESS_ID); + } + + @Test + void shouldSuccessfullyCompleteJudgmentPaidInFull_whenCalled() { + //assert process has started + assertFalse(processInstance.isEnded()); + + //assert message start event + assertThat(getProcessDefinitionByMessage(MESSAGE_NAME).getKey()).isEqualTo(PROCESS_ID); + + //complete the start business process + ExternalTask startBusiness = assertNextExternalTask(START_BUSINESS_TOPIC); + assertCompleteExternalTask( + startBusiness, + START_BUSINESS_TOPIC, + START_BUSINESS_EVENT, + START_BUSINESS_ACTIVITY + ); + + //complete the Robotics notification + ExternalTask forRobotics = assertNextExternalTask(PROCESS_CASE_EVENT); + assertCompleteExternalTask( + forRobotics, + PROCESS_CASE_EVENT, + SEND_JUDGMENT_DETAILS_CJES, + SEND_JUDGMENT_DETAILS_CJES_ACTIVITY_ID + ); + + //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(); + } +}