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;
}
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;
}
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");
}
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;
}
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");
}
Aggregations