Search in sources :

Example 6 with CaseFile

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

the class CaseAdminServiceIntegrationTest method startCarInsuranceClaimCase.

private String startCarInsuranceClaimCase(String insured, String insuranceRep, String assessor) {
    Map<String, Object> data = new HashMap<>();
    data.put("s", "first case started");
    CaseFile caseFile = CaseFile.builder().addUserAssignments(CASE_INSURED_ROLE, insured).addUserAssignments(CASE_INS_REP_ROLE, insuranceRep).addUserAssignments(CASE_ASSESSOR_ROLE, assessor).data(data).build();
    String caseId = caseClient.startCase(CONTAINER_ID, CLAIM_CASE_DEF_ID, caseFile);
    assertNotNull(caseId);
    return caseId;
}
Also used : HashMap(java.util.HashMap) CaseFile(org.kie.server.api.model.cases.CaseFile)

Example 7 with CaseFile

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

the class CaseAdminServiceIntegrationTest method startUserTaskCase.

private String startUserTaskCase(String owner, String contact) {
    Map<String, Object> data = new HashMap<>();
    data.put("s", "first case started");
    CaseFile caseFile = CaseFile.builder().addUserAssignments(CASE_OWNER_ROLE, owner).addUserAssignments(CASE_CONTACT_ROLE, contact).data(data).build();
    String caseId = caseClient.startCase(CONTAINER_ID, CASE_HR_DEF_ID, caseFile);
    assertNotNull(caseId);
    return caseId;
}
Also used : HashMap(java.util.HashMap) CaseFile(org.kie.server.api.model.cases.CaseFile)

Example 8 with CaseFile

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

the class CaseServiceIntegrationTest method testCreateCaseWithEmptyCaseFileButWithRoleAssignments.

@Test
public void testCreateCaseWithEmptyCaseFileButWithRoleAssignments() {
    CaseFile caseFile = CaseFile.builder().addUserAssignments(CASE_INSURED_ROLE, USER_YODA).addUserAssignments(CASE_INS_REP_ROLE, USER_JOHN).build();
    String caseId = caseClient.startCase(CONTAINER_ID, CLAIM_CASE_DEF_ID, caseFile);
    Assertions.assertThat(caseId).isNotNull();
    Assertions.assertThat(caseId).startsWith(CLAIM_CASE_ID_PREFIX);
    CaseInstance caseInstance = caseClient.getCaseInstance(CONTAINER_ID, caseId);
    assertCarInsuranceCaseInstance(caseInstance, caseId, USER_YODA);
    List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
    assertEquals(1, tasks.size());
    TaskSummary task = tasks.get(0);
    Assertions.assertThat(task).isNotNull();
    Assertions.assertThat(task.getName()).isEqualTo(ACCIDENT_TASK_NAME);
    Assertions.assertThat(task.getActualOwner()).isNull();
    Assertions.assertThat(task.getStatus()).isEqualTo("Ready");
}
Also used : CaseInstance(org.kie.server.api.model.cases.CaseInstance) CaseFile(org.kie.server.api.model.cases.CaseFile) TaskSummary(org.kie.server.api.model.instance.TaskSummary) Test(org.junit.Test) JbpmKieServerBaseIntegrationTest(org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)

Example 9 with CaseFile

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

the class CaseServiceIntegrationTest method startCarInsuranceClaimCase.

private String startCarInsuranceClaimCase(String insured, String insuranceRep, String assessor, Map<String, Object> data) {
    CaseFile caseFile = CaseFile.builder().addUserAssignments(CASE_INSURED_ROLE, insured).addUserAssignments(CASE_INS_REP_ROLE, insuranceRep).addUserAssignments(CASE_ASSESSOR_ROLE, assessor).data(data).build();
    String caseId = caseClient.startCase(CONTAINER_ID, CLAIM_CASE_DEF_ID, caseFile);
    assertNotNull(caseId);
    return caseId;
}
Also used : CaseFile(org.kie.server.api.model.cases.CaseFile)

Example 10 with CaseFile

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

the class CaseServiceIntegrationTest method testCreateCaseWithCaseFile.

@Test
public void testCreateCaseWithCaseFile() {
    Map<String, Object> caseData = new HashMap<>();
    caseData.put("car", "ford");
    CaseFile caseFile = CaseFile.builder().addUserAssignments(CASE_INSURED_ROLE, USER_YODA).addUserAssignments(CASE_INS_REP_ROLE, USER_JOHN).data(caseData).build();
    String caseId = caseClient.startCase(CONTAINER_ID, CLAIM_CASE_DEF_ID, caseFile);
    Assertions.assertThat(caseId).isNotNull();
    Assertions.assertThat(caseId).startsWith(CLAIM_CASE_ID_PREFIX);
    caseData = caseClient.getCaseInstanceData(CONTAINER_ID, caseId);
    Assertions.assertThat(caseData).isNotNull();
    Assertions.assertThat(caseData).hasSize(1);
    Assertions.assertThat(caseData.get("car")).isEqualTo("ford");
    caseClient.putCaseInstanceData(CONTAINER_ID, caseId, "car", "fiat");
    Object carCaseData = caseClient.getCaseInstanceData(CONTAINER_ID, caseId, "car");
    Assertions.assertThat(carCaseData).isNotNull();
    Assertions.assertThat(carCaseData).isInstanceOf(String.class);
    Assertions.assertThat(carCaseData).isEqualTo("fiat");
    List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
    Assertions.assertThat(tasks).hasSize(1);
    TaskSummary task = tasks.get(0);
    Assertions.assertThat(task).isNotNull();
    Assertions.assertThat(task.getName()).isEqualTo(ACCIDENT_TASK_NAME);
    Assertions.assertThat(task.getStatus()).isEqualTo("Ready");
    Assertions.assertThat(task.getActualOwner()).isNull();
    Map<String, Object> output = new HashMap<>();
    Object claimReport = createInstance(CLAIM_REPORT_CLASS_NAME);
    KieServerReflections.setValue(claimReport, "name", "John Doe");
    output.put("claimReport_", claimReport);
    taskClient.completeAutoProgress(CONTAINER_ID, task.getId(), USER_YODA, output);
    caseData = caseClient.getCaseInstanceData(CONTAINER_ID, caseId);
    Assertions.assertThat(caseData).isNotNull();
    Assertions.assertThat(caseData).hasSize(2);
    Assertions.assertThat(caseData.get("car")).isEqualTo("fiat");
    Object caseClaimReport = caseData.get("claimReport");
    Assertions.assertThat(caseClaimReport).isNotNull();
    Assertions.assertThat(caseClaimReport.getClass().getName()).isEqualTo(CLAIM_REPORT_CLASS_NAME);
    caseClient.removeCaseInstanceData(CONTAINER_ID, caseId, "claimReport");
    caseData = caseClient.getCaseInstanceData(CONTAINER_ID, caseId);
    Assertions.assertThat(caseData).isNotNull();
    Assertions.assertThat(caseData).hasSize(1);
    Assertions.assertThat(caseData.get("car")).isEqualTo("fiat");
    Map<String, Object> data = new HashMap<>();
    data.put("owner", "john");
    data.put("report", caseClaimReport);
    caseClient.putCaseInstanceData(CONTAINER_ID, caseId, data);
    caseData = caseClient.getCaseInstanceData(CONTAINER_ID, caseId);
    Assertions.assertThat(caseData).isNotNull();
    Assertions.assertThat(caseData).hasSize(3);
    Assertions.assertThat(caseData.get("car")).isEqualTo("fiat");
    Assertions.assertThat(caseData.get("owner")).isEqualTo("john");
    caseClaimReport = caseData.get("report");
    Assertions.assertThat(caseClaimReport).isNotNull();
    Assertions.assertThat(caseClaimReport.getClass().getName()).isEqualTo(CLAIM_REPORT_CLASS_NAME);
    caseData = caseClient.getCaseInstanceData(CONTAINER_ID, caseId, Arrays.asList("car", "owner"));
    Assertions.assertThat(caseData).isNotNull();
    Assertions.assertThat(caseData).hasSize(2);
    Assertions.assertThat(caseData.get("car")).isEqualTo("fiat");
    Assertions.assertThat(caseData.get("owner")).isEqualTo("john");
}
Also used : HashMap(java.util.HashMap) CaseFile(org.kie.server.api.model.cases.CaseFile) TaskSummary(org.kie.server.api.model.instance.TaskSummary) Test(org.junit.Test) JbpmKieServerBaseIntegrationTest(org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)

Aggregations

CaseFile (org.kie.server.api.model.cases.CaseFile)23 HashMap (java.util.HashMap)17 Test (org.junit.Test)13 JbpmKieServerBaseIntegrationTest (org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)9 CaseInstance (org.kie.server.api.model.cases.CaseInstance)3 TaskSummary (org.kie.server.api.model.instance.TaskSummary)3 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Date (java.util.Date)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 WebTarget (javax.ws.rs.client.WebTarget)1 CaseDefinitionNotFoundException (org.jbpm.casemgmt.api.CaseDefinitionNotFoundException)1 CaseNotFoundException (org.jbpm.casemgmt.api.CaseNotFoundException)1 CaseRuntimeDataService (org.jbpm.casemgmt.api.CaseRuntimeDataService)1 CaseService (org.jbpm.casemgmt.api.CaseService)1 TaskSpecification (org.jbpm.casemgmt.api.dynamic.TaskSpecification)1