Search in sources :

Example 36 with TaskSummary

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());
}
Also used : CaseFileInstance(org.jbpm.casemgmt.api.model.instance.CaseFileInstance) QueryFilter(org.kie.internal.query.QueryFilter) HashMap(java.util.HashMap) TaskSummary(org.kie.api.task.model.TaskSummary) Document(org.jbpm.document.Document) DocumentImpl(org.jbpm.document.service.impl.DocumentImpl) Date(java.util.Date)

Example 37 with TaskSummary

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();
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) TaskSummary(org.kie.api.task.model.TaskSummary)

Example 38 with TaskSummary

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

Example 39 with TaskSummary

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);
}
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 40 with TaskSummary

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

Aggregations

TaskSummary (org.kie.api.task.model.TaskSummary)371 Test (org.junit.Test)327 HashMap (java.util.HashMap)132 QueryFilter (org.kie.internal.query.QueryFilter)126 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)100 Task (org.kie.api.task.model.Task)91 ArrayList (java.util.ArrayList)87 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)86 KieSession (org.kie.api.runtime.KieSession)84 TaskService (org.kie.api.task.TaskService)66 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)58 StringReader (java.io.StringReader)55 AbstractCaseServicesBaseTest (org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest)49 QueryContext (org.kie.api.runtime.query.QueryContext)49 Status (org.kie.api.task.model.Status)47 InternalTask (org.kie.internal.task.api.model.InternalTask)47 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)41 CaseInstance (org.jbpm.casemgmt.api.model.instance.CaseInstance)38 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)36 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)28