use of org.kie.api.task.model.TaskSummary in project jbpm by kiegroup.
the class CarInsuranceClaimCaseTest method attachAndAssertPoliceReport.
protected void attachAndAssertPoliceReport() {
caseService.triggerAdHocFragment(CAR_INS_CASE_ID, "Submit police report", null);
List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter());
assertNotNull(tasks);
assertEquals(2, tasks.size());
assertTask(tasks.get(0), null, "Submit police report", Status.Ready);
assertTask(tasks.get(1), null, "File property damage claim", Status.Ready);
byte[] docContent = "police report content".getBytes();
DocumentImpl document = new DocumentImpl(UUID.randomUUID().toString(), "car-accident-police-report.txt", docContent.length, new Date());
document.setContent(docContent);
Map<String, Object> params = new HashMap<>();
params.put("policeReport_", document);
userTaskService.completeAutoProgress(tasks.get(0).getId(), "john", params);
// police report should be stored in case file data
CaseFileInstance caseFile = caseService.getCaseFileInstance(CAR_INS_CASE_ID);
assertNotNull(caseFile);
Document policeReport = (Document) caseFile.getData("policeReport");
assertNotNull(policeReport);
assertEquals("car-accident-police-report.txt", policeReport.getName());
}
use of org.kie.api.task.model.TaskSummary in project jbpm by kiegroup.
the class CarInsuranceClaimCaseTest method assertTasksForBothRoles.
protected long assertTasksForBothRoles(String taskName, String actor1, String actor2, Status status) {
List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(actor1, new QueryFilter());
assertNotNull(tasks);
assertEquals(1, tasks.size());
assertTask(tasks.get(0), null, taskName, status);
// the same task can be claimed by insuranceRepresentative in case claim is reported over phone
tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(actor2, new QueryFilter());
assertNotNull(tasks);
assertEquals(1, tasks.size());
assertTask(tasks.get(0), null, taskName, status);
return tasks.get(0).getId();
}
use of org.kie.api.task.model.TaskSummary in project jbpm by kiegroup.
the class CarInsuranceClaimCaseTest method assertAndProvideAdditionalDetails.
protected void assertAndProvideAdditionalDetails() {
List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter());
assertNotNull(tasks);
assertEquals(1, tasks.size());
assertTask(tasks.get(0), "john", "Please provide additional details", Status.Reserved);
long taskId = tasks.get(0).getId();
Map<String, Object> inputs = userTaskService.getTaskInputContentByTaskId(taskId);
assertNotNull(inputs);
assertEquals("How did it happen?", inputs.get("reason"));
Map<String, Object> params = new HashMap<>();
params.put("caseFile_answer", "It just happened in a split second, don't remember anything else");
userTaskService.completeAutoProgress(taskId, "john", params);
CaseFileInstance caseFile = caseService.getCaseFileInstance(CAR_INS_CASE_ID);
assertNotNull(caseFile);
String answer = (String) caseFile.getData("answer");
assertNotNull(answer);
assertEquals("It just happened in a split second, don't remember anything else", answer);
}
use of org.kie.api.task.model.TaskSummary in project jbpm by kiegroup.
the class CarInsuranceClaimCaseTest method assertAndRunClaimAssessment.
private void assertAndRunClaimAssessment() {
List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("krisv", new QueryFilter());
assertNotNull(tasks);
assertEquals(1, tasks.size());
assertTask(tasks.get(0), "krisv", "Assessor evaluation", Status.Reserved);
long taskId = tasks.get(0).getId();
Map<String, Object> taskInput = userTaskService.getTaskInputContentByTaskId(taskId);
assertNotNull(taskInput);
assertTrue(taskInput.containsKey("_claimReport"));
ClaimReport claimReport = (ClaimReport) taskInput.get("_claimReport");
claimReport.setAmount(20000.0);
claimReport.setCalculated(Boolean.TRUE);
Map<String, Object> params = new HashMap<>();
params.put("claimReport_", claimReport);
userTaskService.completeAutoProgress(taskId, "krisv", params);
}
use of org.kie.api.task.model.TaskSummary in project jbpm by kiegroup.
the class CarInsuranceClaimCaseTest method attachAndAssertPoliceReport.
protected void attachAndAssertPoliceReport(boolean callback, String callbackAfter) {
List<TaskSummary> tasks = runtimeDataService.getTasksOwned("mary", new QueryFilter());
assertNotNull(tasks);
assertEquals(1, tasks.size());
assertTask(tasks.get(0), "mary", "Contacted by insured", Status.Reserved);
Map<String, Object> params = new HashMap<>();
params.put("callback_", callback);
if (callback) {
params.put("callbackAfter_", callbackAfter);
}
userTaskService.completeAutoProgress(tasks.get(0).getId(), "mary", params);
if (callback) {
CountDownListenerFactory.getExisting("carInsuranceCase").waitTillCompleted();
tasks = runtimeDataService.getTasksOwned("mary", new QueryFilter());
assertNotNull(tasks);
assertEquals(1, tasks.size());
assertTask(tasks.get(0), "mary", "Requested callback", Status.Reserved);
userTaskService.completeAutoProgress(tasks.get(0).getId(), "mary", null);
}
}
Aggregations