use of org.jbpm.casemgmt.demo.insurance.ClaimReport in project jbpm by kiegroup.
the class CarInsuranceClaimCaseTest method testCarInsuranceClaimCaseCloseCaseFromRulesViaBusinessTask.
@Test
public void testCarInsuranceClaimCaseCloseCaseFromRulesViaBusinessTask() {
// let's assign users to roles so they can be participants in the case
String caseId = startAndAssertCaseInstance(deploymentUnit.getIdentifier(), "john", "mary");
try {
// let's verify case is created
assertCaseInstance(deploymentUnit.getIdentifier(), CAR_INS_CASE_ID);
// let's look at what stages are active
assertBuildClaimReportStage();
// since the first task assigned to insured is with auto start it should be already active
// the same task can be claimed by insuranceRepresentative in case claim is reported over phone
long taskId = assertBuildClaimReportAvailableForBothRoles();
// let's provide claim report with initial data
// claim report should be stored in case file data
ClaimReport claimReport = new ClaimReport();
claimReport.setName("John Doe");
claimReport.setAddress("Main street, NY");
claimReport.setAccidentDescription(null);
claimReport.setAccidentDate(new Date());
Map<String, Object> params = new HashMap<>();
params.put("claimReport_", claimReport);
userTaskService.completeAutoProgress(taskId, "john", params);
// let's complete the stage by explicitly stating that claimReport is done
caseService.addDataToCaseFile(CAR_INS_CASE_ID, "claimReportDone", true);
// there should be no process instances for the case
Collection<ProcessInstanceDesc> caseProcesInstances = caseRuntimeDataService.getProcessInstancesForCase(CAR_INS_CASE_ID, Arrays.asList(ProcessInstance.STATE_ACTIVE), new QueryContext());
assertEquals(0, caseProcesInstances.size());
CaseInstance cInstance = caseRuntimeDataService.getCaseInstanceById(caseId);
assertNotNull(cInstance);
assertEquals(deploymentUnit.getIdentifier(), cInstance.getDeploymentId());
assertEquals("Invalid case data", cInstance.getCompletionMessage());
caseId = null;
} catch (Exception e) {
logger.error("Unexpected error {}", e.getMessage(), e);
fail("Unexpected exception " + e.getMessage());
} finally {
if (caseId != null) {
caseService.cancelCase(caseId);
}
}
}
use of org.jbpm.casemgmt.demo.insurance.ClaimReport 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.jbpm.casemgmt.demo.insurance.ClaimReport in project jbpm by kiegroup.
the class CarInsuranceClaimCaseTest method provideAndAssertClaimReport.
protected void provideAndAssertClaimReport(Long taskId) {
ClaimReport claimReport = new ClaimReport();
claimReport.setName("John Doe");
claimReport.setAddress("Main street, NY");
claimReport.setAccidentDescription("It happened so sudden...");
claimReport.setAccidentDate(new Date());
Map<String, Object> params = new HashMap<>();
params.put("claimReport_", claimReport);
userTaskService.completeAutoProgress(taskId, "john", params);
// claim report should be stored in case file data
CaseFileInstance caseFile = caseService.getCaseFileInstance(CAR_INS_CASE_ID);
assertNotNull(caseFile);
ClaimReport caseClaimReport = (ClaimReport) caseFile.getData("claimReport");
assertNotNull(caseClaimReport);
}
Aggregations