Search in sources :

Example 21 with CaseInstance

use of org.kie.server.api.model.cases.CaseInstance in project droolsjbpm-integration by kiegroup.

the class CaseServiceIntegrationTest method testCreateCloseAndReopenCaseWithEmptyCaseFile.

@Test
public void testCreateCloseAndReopenCaseWithEmptyCaseFile() {
    String caseId = startCarInsuranceClaimCase(USER_YODA, USER_JOHN, USER_YODA);
    Assertions.assertThat(caseId).isNotNull();
    Assertions.assertThat(caseId).startsWith(CLAIM_CASE_ID_PREFIX);
    CaseInstance caseInstance = caseClient.getCaseInstance(CONTAINER_ID, caseId);
    assertCarInsuranceCaseInstance(caseInstance, caseId, USER_YODA);
    caseClient.closeCaseInstance(CONTAINER_ID, caseId, "work done at the moment");
    CaseInstance closed = caseClient.getCaseInstance(CONTAINER_ID, caseId);
    Assertions.assertThat(closed.getCaseStatus()).isEqualTo(2);
    Assertions.assertThat(closed.getCompletionMessage()).isEqualTo("work done at the moment");
    Map<String, Object> data = new HashMap<>();
    data.put("additionalComment", "reopening the case");
    caseClient.reopenCase(caseId, CONTAINER_ID, CLAIM_CASE_DEF_ID, data);
    caseInstance = caseClient.getCaseInstance(CONTAINER_ID, caseId);
    Assertions.assertThat(caseInstance).isNotNull();
    Assertions.assertThat(caseInstance.getCaseId()).isEqualTo(caseId);
    Object additionalComment = caseClient.getCaseInstanceData(CONTAINER_ID, caseId, "additionalComment");
    Assertions.assertThat(additionalComment).isNotNull();
    Assertions.assertThat(additionalComment).isEqualTo("reopening the case");
}
Also used : CaseInstance(org.kie.server.api.model.cases.CaseInstance) HashMap(java.util.HashMap) Test(org.junit.Test) JbpmKieServerBaseIntegrationTest(org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)

Example 22 with CaseInstance

use of org.kie.server.api.model.cases.CaseInstance in project droolsjbpm-integration by kiegroup.

the class CaseServiceIntegrationTest method testCreateCaseWithEmptyCaseFileWithContainerAlias.

@Test
public void testCreateCaseWithEmptyCaseFileWithContainerAlias() {
    String caseId = startCarInsuranceClaimCase(USER_YODA, USER_JOHN, USER_YODA);
    Assertions.assertThat(caseId).isNotNull();
    Assertions.assertThat(caseId).startsWith(CLAIM_CASE_ID_PREFIX);
    CaseInstance caseInstance = caseClient.getCaseInstance(CONTAINER_ALIAS, caseId);
    assertCarInsuranceCaseInstance(caseInstance, caseId, USER_YODA);
    List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
    Assertions.assertThat(tasks).hasSize(1);
}
Also used : CaseInstance(org.kie.server.api.model.cases.CaseInstance) TaskSummary(org.kie.server.api.model.instance.TaskSummary) Test(org.junit.Test) JbpmKieServerBaseIntegrationTest(org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)

Example 23 with CaseInstance

use of org.kie.server.api.model.cases.CaseInstance in project droolsjbpm-integration by kiegroup.

the class CaseServiceIntegrationTest method testQueryByVariable.

@Test
public void testQueryByVariable() {
    Assume.assumeTrue(configuration.isRest());
    String caseId = startCarInsuranceClaimCase(USER_YODA, USER_JOHN, USER_YODA);
    Assertions.assertThat(caseId).isNotNull();
    Assertions.assertThat(caseId).startsWith(CLAIM_CASE_ID_PREFIX);
    CaseInstance caseInstance = caseClient.getCaseInstance(CONTAINER_ID, caseId);
    assertCarInsuranceCaseInstance(caseInstance, caseId, USER_YODA);
    caseClient.closeCaseInstance(CONTAINER_ID, caseId, "work done at the moment");
    CaseInstance closed = caseClient.getCaseInstance(CONTAINER_ID, caseId);
    Assertions.assertThat(closed.getCaseStatus()).isEqualTo(2);
    Assertions.assertThat(closed.getCompletionMessage()).isEqualTo("work done at the moment");
    Map<String, Object> data = new HashMap<>();
    data.put("additionalComment", "reopening the case");
    caseClient.reopenCase(caseId, CONTAINER_ID, CLAIM_CASE_DEF_ID, data);
    caseInstance = caseClient.getCaseInstance(CONTAINER_ID, caseId);
    Assertions.assertThat(caseInstance).isNotNull();
    Assertions.assertThat(caseInstance.getCaseId()).isEqualTo(caseId);
    Object additionalComment = caseClient.getCaseInstanceData(CONTAINER_ID, caseId, "additionalComment");
    Assertions.assertThat(additionalComment).isNotNull();
    Assertions.assertThat(additionalComment).isEqualTo("reopening the case");
    List<QueryParam> attrs = list(equalsTo(CASE_ATTR_CORRELATION_KEY, caseId));
    SearchQueryFilterSpec filter = new SearchQueryFilterSpec();
    filter.setAttributesQueryParams(attrs);
    List<CaseInstanceCustomVars> caseInstanceCustomVarsList = caseClient.queryCasesByVariables(filter, 0, 2);
    assertNotNull(caseInstanceCustomVarsList);
    Assertions.assertThat(caseInstanceCustomVarsList).hasSize(2);
    attrs = list(likeTo(CASE_ATTR_CORRELATION_KEY, false, CLAIM_CASE_ID_PREFIX + "%"));
    filter = new SearchQueryFilterSpec();
    filter.setAttributesQueryParams(attrs);
    caseInstanceCustomVarsList = caseClient.queryCasesByVariables(filter, 0, 2);
    assertNotNull(caseInstanceCustomVarsList);
    caseInstanceCustomVarsList.stream().forEach(e -> assertTrue(e.getCaseId().startsWith(CLAIM_CASE_ID_PREFIX)));
    List<CaseUserTaskWithVariables> caseUserTaskWithVariablesList = caseClient.queryUserTaskByVariables(new SearchQueryFilterSpec(), 0, 2);
    assertNotNull(caseUserTaskWithVariablesList);
    Assertions.assertThat(caseUserTaskWithVariablesList.size()).isGreaterThan(0);
}
Also used : CaseInstance(org.kie.server.api.model.cases.CaseInstance) HashMap(java.util.HashMap) QueryParam(org.kie.server.api.model.definition.QueryParam) SearchQueryFilterSpec(org.kie.server.api.model.definition.SearchQueryFilterSpec) CaseInstanceCustomVars(org.kie.server.api.model.cases.CaseInstanceCustomVars) CaseUserTaskWithVariables(org.kie.server.api.model.cases.CaseUserTaskWithVariables) Test(org.junit.Test) JbpmKieServerBaseIntegrationTest(org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)

Example 24 with CaseInstance

use of org.kie.server.api.model.cases.CaseInstance in project droolsjbpm-integration by kiegroup.

the class CaseServiceIntegrationTest method testDestroyCaseInstance.

@Test
public void testDestroyCaseInstance() {
    Map<String, Object> caseData = new HashMap<>();
    caseData.put("car", "ford");
    CaseFile caseFile = CaseFile.builder().data(caseData).addUserAssignments(CASE_INSURED_ROLE, USER_YODA).addUserAssignments(CASE_INS_REP_ROLE, USER_JOHN).addUserAssignments(CASE_ASSESSOR_ROLE, USER_YODA).build();
    String caseId = caseClient.startCase(CONTAINER_ID, CLAIM_CASE_DEF_ID, caseFile);
    Assertions.assertThat(caseId).isNotNull();
    CaseInstance caseInstance = caseClient.getCaseInstance(CONTAINER_ID, caseId);
    assertCarInsuranceCaseInstance(caseInstance, caseId, USER_YODA);
    caseClient.destroyCaseInstance(CONTAINER_ID, caseId);
    CaseInstance closed = caseClient.getCaseInstance(CONTAINER_ID, caseId);
    Assertions.assertThat(closed.getCaseStatus()).isEqualTo(3);
    // Should throw exception because destroyed case cannot be reopen.
    assertClientException(() -> caseClient.reopenCase(caseId, CONTAINER_ID, CLAIM_CASE_DEF_ID), 404, caseId);
}
Also used : CaseInstance(org.kie.server.api.model.cases.CaseInstance) HashMap(java.util.HashMap) CaseFile(org.kie.server.api.model.cases.CaseFile) Test(org.junit.Test) JbpmKieServerBaseIntegrationTest(org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)

Example 25 with CaseInstance

use of org.kie.server.api.model.cases.CaseInstance in project droolsjbpm-integration by kiegroup.

the class CarInsuranceClaimCaseIntegrationTest method assertCaseInstance.

private void assertCaseInstance(String caseId) {
    CaseInstance cInstance = caseClient.getCaseInstance(CONTAINER_ID, caseId);
    assertNotNull(cInstance);
    assertEquals(caseId, cInstance.getCaseId());
    assertEquals(CLAIM_CASE_DEF_ID, cInstance.getCaseDefinitionId());
}
Also used : CaseInstance(org.kie.server.api.model.cases.CaseInstance)

Aggregations

CaseInstance (org.kie.server.api.model.cases.CaseInstance)30 Test (org.junit.Test)17 JbpmKieServerBaseIntegrationTest (org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)17 CaseStatus (org.jbpm.casemgmt.api.model.CaseStatus)9 CaseInstanceList (org.kie.server.api.model.cases.CaseInstanceList)9 HashMap (java.util.HashMap)8 TaskSummary (org.kie.server.api.model.instance.TaskSummary)7 CaseFile (org.kie.server.api.model.cases.CaseFile)5 ArrayList (java.util.ArrayList)4 CaseRoleAssignment (org.kie.server.api.model.cases.CaseRoleAssignment)4 CaseStage (org.kie.server.api.model.cases.CaseStage)3 NodeInstance (org.kie.server.api.model.instance.NodeInstance)3 Arrays (java.util.Arrays)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 Iterator (java.util.Iterator)2 List (java.util.List)2 Map (java.util.Map)2 BiFunction (java.util.function.BiFunction)2 Function (java.util.function.Function)2