Search in sources :

Example 1 with ClaimReport

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);
        }
    }
}
Also used : CaseInstance(org.jbpm.casemgmt.api.model.instance.CaseInstance) HashMap(java.util.HashMap) ClaimReport(org.jbpm.casemgmt.demo.insurance.ClaimReport) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.api.runtime.query.QueryContext) Date(java.util.Date) AbstractCaseServicesBaseTest(org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest) Test(org.junit.Test)

Example 2 with ClaimReport

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);
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) HashMap(java.util.HashMap) TaskSummary(org.kie.api.task.model.TaskSummary) ClaimReport(org.jbpm.casemgmt.demo.insurance.ClaimReport)

Example 3 with ClaimReport

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);
}
Also used : CaseFileInstance(org.jbpm.casemgmt.api.model.instance.CaseFileInstance) HashMap(java.util.HashMap) ClaimReport(org.jbpm.casemgmt.demo.insurance.ClaimReport) Date(java.util.Date)

Aggregations

HashMap (java.util.HashMap)3 ClaimReport (org.jbpm.casemgmt.demo.insurance.ClaimReport)3 Date (java.util.Date)2 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)1 CaseInstance (org.jbpm.casemgmt.api.model.instance.CaseInstance)1 AbstractCaseServicesBaseTest (org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest)1 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)1 Test (org.junit.Test)1 QueryContext (org.kie.api.runtime.query.QueryContext)1 TaskSummary (org.kie.api.task.model.TaskSummary)1 QueryFilter (org.kie.internal.query.QueryFilter)1