Search in sources :

Example 1 with STATE_COMPLETED

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);
}
Also used : Arrays(java.util.Arrays) CaseInstanceCustomVars(org.kie.server.api.model.cases.CaseInstanceCustomVars) BeforeClass(org.junit.BeforeClass) ProcessInstance(org.kie.server.api.model.instance.ProcessInstance) STATE_ACTIVE(org.kie.api.runtime.process.ProcessInstance.STATE_ACTIVE) CaseStage(org.kie.server.api.model.cases.CaseStage) HashMap(java.util.HashMap) CaseFile(org.kie.server.api.model.cases.CaseFile) CaseInstance(org.kie.server.api.model.cases.CaseInstance) ArrayList(java.util.ArrayList) QueryParamFactory.list(org.kie.server.api.util.QueryParamFactory.list) Map(java.util.Map) KieServices(org.kie.api.KieServices) Assertions(org.assertj.core.api.Assertions) Assume(org.junit.Assume) CaseServicesClient(org.kie.server.client.CaseServicesClient) QueryParamFactory.equalsTo(org.kie.server.api.util.QueryParamFactory.equalsTo) TaskSummary(org.kie.server.api.model.instance.TaskSummary) CASE_ATTR_CORRELATION_KEY(org.jbpm.casemgmt.api.AdvanceCaseRuntimeDataService.CASE_ATTR_CORRELATION_KEY) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) QueryParam(org.kie.server.api.model.definition.QueryParam) SearchQueryFilterSpec(org.kie.server.api.model.definition.SearchQueryFilterSpec) KieServerDeployer(org.kie.server.integrationtests.shared.KieServerDeployer) Assertions.entry(org.assertj.core.api.Assertions.entry) STATE_COMPLETED(org.kie.api.runtime.process.ProcessInstance.STATE_COMPLETED) QueryParamFactory.likeTo(org.kie.server.api.util.QueryParamFactory.likeTo) List(java.util.List) CaseUserTaskWithVariables(org.kie.server.api.model.cases.CaseUserTaskWithVariables) Optional(java.util.Optional) ReleaseId(org.kie.server.api.model.ReleaseId) Collections(java.util.Collections) KieServerReflections(org.kie.server.integrationtests.shared.KieServerReflections) Assert.assertEquals(org.junit.Assert.assertEquals) JbpmKieServerBaseIntegrationTest(org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest) CaseStage(org.kie.server.api.model.cases.CaseStage) ProcessInstance(org.kie.server.api.model.instance.ProcessInstance) Test(org.junit.Test) JbpmKieServerBaseIntegrationTest(org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)

Aggregations

ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Assertions (org.assertj.core.api.Assertions)1 Assertions.entry (org.assertj.core.api.Assertions.entry)1 CASE_ATTR_CORRELATION_KEY (org.jbpm.casemgmt.api.AdvanceCaseRuntimeDataService.CASE_ATTR_CORRELATION_KEY)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertNotNull (org.junit.Assert.assertNotNull)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Assume (org.junit.Assume)1 BeforeClass (org.junit.BeforeClass)1 Test (org.junit.Test)1 KieServices (org.kie.api.KieServices)1 STATE_ACTIVE (org.kie.api.runtime.process.ProcessInstance.STATE_ACTIVE)1 STATE_COMPLETED (org.kie.api.runtime.process.ProcessInstance.STATE_COMPLETED)1 ReleaseId (org.kie.server.api.model.ReleaseId)1