use of org.kie.api.runtime.process.ProcessInstance.STATE_COMPLETED in project droolsjbpm-integration by kiegroup.
the class CaseServiceIntegrationTest method testAddDynamicSubProcessToStage.
@Test
public void testAddDynamicSubProcessToStage() {
String caseId = startCarInsuranceClaimCase(USER_YODA, USER_JOHN, USER_YODA);
Assertions.assertThat(caseId).isNotNull();
List<CaseStage> caseStages = caseClient.getStages(CONTAINER_ID, caseId, false, 0, 50);
String activeStageId = caseStages.stream().filter(stage -> STAGE_ACTIVE_STATE.equals(stage.getStatus())).findFirst().orElseThrow(() -> new IllegalStateException("No active stage found.")).getIdentifier();
List<ProcessInstance> instances = caseClient.getProcessInstances(CONTAINER_ID, caseId, Arrays.asList(1, 2, 3), 0, 10);
Assertions.assertThat(instances).hasSize(1);
final long originalCaseProcessInstanceId = instances.get(0).getId();
caseClient.addDynamicSubProcessToStage(CONTAINER_ID, caseId, activeStageId, DATA_VERIFICATION_DEF_ID, Collections.emptyMap());
instances = caseClient.getProcessInstances(CONTAINER_ID, caseId, Arrays.asList(1, 2, 3), 0, 10);
Assertions.assertThat(instances).hasSize(2);
final ProcessInstance newlyCreatedProcessInstance = instances.stream().filter((pi) -> pi.getId() != originalCaseProcessInstanceId).findFirst().get();
Assertions.assertThat(newlyCreatedProcessInstance.getProcessId()).isEqualTo(DATA_VERIFICATION_DEF_ID);
Assertions.assertThat(newlyCreatedProcessInstance.getState()).isEqualTo(STATE_COMPLETED);
}
Aggregations