diff --git a/src/main/resources/camunda/end_general_application_business_process_without_WA_task.bpmn b/src/main/resources/camunda/end_general_application_business_process_without_WA_task.bpmn new file mode 100644 index 000000000..486f577d4 --- /dev/null +++ b/src/main/resources/camunda/end_general_application_business_process_without_WA_task.bpmn @@ -0,0 +1,45 @@ + + + + + + + + Flow_0nhnyjm + Flow_1jw9p2g + + + Flow_0nhnyjm + + + + + Flow_1jw9p2g + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/camunda/upload_translated_document_ga_lip_notify.bpmn b/src/main/resources/camunda/upload_translated_document_ga_lip_notify.bpmn new file mode 100644 index 000000000..e957e6a24 --- /dev/null +++ b/src/main/resources/camunda/upload_translated_document_ga_lip_notify.bpmn @@ -0,0 +1,121 @@ + + + + + Flow_0g2t112 + + + + Flow_0qmsc9o + + + + + + Flow_1r0joyl + Flow_0qmsc9o + + + + + + + Flow_0g2t112 + Flow_19mft34 + + + Flow_13dgz5v + + + Flow_13dgz5v + + + + + + + + + NOTIFY_RESPONDENT_TRANSLATED_DOCUMENT_UPLOADED_GA + + + Flow_02cu20h + Flow_1r0joyl + + + + + NOTIFY_APPLICANT_TRANSLATED_DOCUMENT_UPLOADED_GA + + + Flow_19mft34 + Flow_02cu20h + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/uk/gov/hmcts/reform/civil/bpmn/BpmnBaseGASpecTest.java b/src/test/java/uk/gov/hmcts/reform/civil/bpmn/BpmnBaseGASpecTest.java index 5a8700ec5..cfc150461 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/bpmn/BpmnBaseGASpecTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/bpmn/BpmnBaseGASpecTest.java @@ -262,6 +262,20 @@ public void completeBusinessProcess(ExternalTask externalTask) { completeTask(lockedEndBusinessProcessTask.get(0).getId()); } + /** + * Completes the external task with topic name END_BUSINESS_PROCESS. + * + * @param externalTask the id of the external task to complete. + */ + public void completeBusinessProcessForGADocUpload(ExternalTask externalTask) { + assertThat(externalTask.getTopicName()).isEqualTo("END_BUSINESS_PROCESS_GASPEC_WITHOUT_WA_TASK"); + + List lockedEndBusinessProcessTask = fetchAndLockTask("END_BUSINESS_PROCESS_GASPEC_WITHOUT_WA_TASK"); + + assertThat(lockedEndBusinessProcessTask).hasSize(1); + completeTask(lockedEndBusinessProcessTask.get(0).getId()); + } + /** * Completes the external task with topic name END_GA_HWF_NOTIFY_PROCESS. * diff --git a/src/test/java/uk/gov/hmcts/reform/civil/bpmn/NotifyGATranslatedUploadedDocumentsTest.java b/src/test/java/uk/gov/hmcts/reform/civil/bpmn/NotifyGATranslatedUploadedDocumentsTest.java new file mode 100644 index 000000000..cd07480a0 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/civil/bpmn/NotifyGATranslatedUploadedDocumentsTest.java @@ -0,0 +1,86 @@ +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.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.assertFalse; + +public class NotifyGATranslatedUploadedDocumentsTest extends BpmnBaseGASpecTest { + + public static final String NOTIFY_EVENT = "processExternalCaseEventGASpec"; + private static final String START_BUSINESS_TOPIC = "START_GA_BUSINESS_PROCESS"; + private static final String LIP_APPLICANT = "LIP_APPLICANT"; + private static final String LIP_RESPONDENT = "LIP_RESPONDENT"; + public static final String END_BUSINESS_PROCESS = "END_BUSINESS_PROCESS_GASPEC_WITHOUT_WA_TASK"; + + public NotifyGATranslatedUploadedDocumentsTest() { + super("upload_translated_document_ga_lip_notify.bpmn", "UPLOAD_TRANSLATED_DOCUMENT_GA_LIP_ID"); + } + + @BeforeEach + void setup() { + //deploy process + startBusinessProcessDeployment = engine.getRepositoryService() + .createDeployment() + .addClasspathResource(String.format(DIAGRAM_PATH, + "start_business_process_in_general_application.bpmn")) + .deploy(); + endBusinessProcessDeployment = engine.getRepositoryService() + .createDeployment() + .addClasspathResource(String.format(DIAGRAM_PATH, "end_general_application_business_process_without_WA_task.bpmn")) + .deploy(); + deployment = engine.getRepositoryService() + .createDeployment() + .addClasspathResource(String.format(DIAGRAM_PATH, bpmnFileName)) + .deploy(); + processInstance = engine.getRuntimeService().startProcessInstanceByKey(processId); + } + + @Test + void shouldNotifyTranslatedDocumentUploaded() { + VariableMap variables = Variables.createVariables(); + variables.put("flowFlags", Map.of( + LIP_APPLICANT, false, + LIP_RESPONDENT, false)); + + //assert process has started + assertFalse(processInstance.isEnded()); + //complete the start business process + ExternalTask startBusiness = assertNextExternalTask(START_BUSINESS_TOPIC); + assertCompleteExternalTask( + startBusiness, + START_BUSINESS_TOPIC, + START_GA_BUSINESS_EVENT, + START_GA_BUSINESS_ACTIVITY, + variables + ); + //complete the applicant notification + ExternalTask notificationApplicantTask = assertNextExternalTask(NOTIFY_EVENT); + assertCompleteExternalTask( + notificationApplicantTask, + NOTIFY_EVENT, + "NOTIFY_APPLICANT_TRANSLATED_DOCUMENT_UPLOADED_GA", + "NotifyTranslatedDocumentUploadedToApplicantGA", + variables + ); + //complete the respondent notification + ExternalTask notificationRespondentTask = assertNextExternalTask(NOTIFY_EVENT); + assertCompleteExternalTask( + notificationRespondentTask, + NOTIFY_EVENT, + "NOTIFY_RESPONDENT_TRANSLATED_DOCUMENT_UPLOADED_GA", + "NotifyTranslatedDocumentUploadedToRespondentGA", + variables + ); + + //end business process + ExternalTask endBusinessProcess = assertNextExternalTask(END_BUSINESS_PROCESS); + completeBusinessProcessForGADocUpload(endBusinessProcess); + assertNoExternalTasksLeft(); + } +}