Search in sources :

Example 26 with QueryFilter

use of org.kie.internal.query.QueryFilter 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 27 with QueryFilter

use of org.kie.internal.query.QueryFilter 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)

Example 28 with QueryFilter

use of org.kie.internal.query.QueryFilter in project jbpm by kiegroup.

the class CaseDynamicNodesTest method testAddDynamicUserTaskToEmptyStage.

@Test
public void testAddDynamicUserTaskToEmptyStage() {
    Map<String, Object> data = new HashMap<>();
    data.put("continue", false);
    CaseFileInstance caseFile = caseService.newCaseFileInstance(deploymentUnit.getIdentifier(), EMPTY_CASE_STAGE, data, Collections.emptyMap());
    String caseId = caseService.startCase(deploymentUnit.getIdentifier(), EMPTY_CASE_STAGE, caseFile);
    assertThat(caseId).isNotNull().isEqualTo(FIRST_CASE_ID);
    CaseInstance caseInstance = caseService.getCaseInstance(caseId, false, false, false, true);
    assertThat(caseInstance).isNotNull();
    assertThat(caseInstance.getCaseStages()).hasSize(1);
    String stageId = caseInstance.getCaseStages().iterator().next().getId();
    caseService.addDynamicTaskToStage(caseId, stageId, createUserTask());
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER, new QueryFilter());
    assertThat(tasks).hasSize(1);
    TaskSummary insideTask = tasks.get(0);
    assertThat(insideTask.getName()).isEqualTo(DYNAMIC_TASK);
    userTaskService.completeAutoProgress(insideTask.getId(), USER, null);
    tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER, new QueryFilter());
    assertThat(tasks).isEmpty();
}
Also used : CaseFileInstance(org.jbpm.casemgmt.api.model.instance.CaseFileInstance) CaseInstance(org.jbpm.casemgmt.api.model.instance.CaseInstance) QueryFilter(org.kie.internal.query.QueryFilter) HashMap(java.util.HashMap) TaskSummary(org.kie.api.task.model.TaskSummary) AbstractCaseServicesBaseTest(org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest) Test(org.junit.Test)

Example 29 with QueryFilter

use of org.kie.internal.query.QueryFilter in project jbpm by kiegroup.

the class CaseDynamicNodesTest method testAddMultipleDynamicTasksToStage.

@Test
public void testAddMultipleDynamicTasksToStage() {
    Map<String, Object> data = new HashMap<>();
    data.put("continue", false);
    CaseFileInstance caseFile = caseService.newCaseFileInstance(deploymentUnit.getIdentifier(), EMPTY_CASE_STAGE, data, Collections.emptyMap());
    String caseId = caseService.startCase(deploymentUnit.getIdentifier(), EMPTY_CASE_STAGE, caseFile);
    assertThat(caseId).isNotNull().isEqualTo(FIRST_CASE_ID);
    CaseInstance caseInstance = caseService.getCaseInstance(caseId, false, false, false, true);
    assertThat(caseInstance).isNotNull();
    assertThat(caseInstance.getCaseStages()).hasSize(1);
    String stageId = caseInstance.getCaseStages().iterator().next().getId();
    caseService.addDynamicTaskToStage(caseId, stageId, createUserTask());
    caseService.addDynamicTaskToStage(caseId, stageId, createUserTask());
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER, new QueryFilter());
    assertThat(tasks).hasSize(2);
    TaskSummary userTask1 = tasks.get(0);
    assertThat(userTask1.getName()).isEqualTo(DYNAMIC_TASK);
    userTaskService.completeAutoProgress(userTask1.getId(), USER, null);
    TaskSummary userTask2 = tasks.get(1);
    assertThat(userTask2.getName()).isEqualTo(DYNAMIC_TASK);
    userTaskService.completeAutoProgress(userTask2.getId(), USER, null);
    tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER, new QueryFilter());
    assertThat(tasks).isEmpty();
}
Also used : CaseFileInstance(org.jbpm.casemgmt.api.model.instance.CaseFileInstance) CaseInstance(org.jbpm.casemgmt.api.model.instance.CaseInstance) QueryFilter(org.kie.internal.query.QueryFilter) HashMap(java.util.HashMap) TaskSummary(org.kie.api.task.model.TaskSummary) AbstractCaseServicesBaseTest(org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest) Test(org.junit.Test)

Example 30 with QueryFilter

use of org.kie.internal.query.QueryFilter in project jbpm by kiegroup.

the class CaseDynamicNodesTest method testAddMultipleDynamicSubprocessesToCase.

@Test
public void testAddMultipleDynamicSubprocessesToCase() {
    String caseId = caseService.startCase(deploymentUnit.getIdentifier(), EMPTY_CASE_P_ID);
    assertThat(caseId).isNotNull().isEqualTo(FIRST_CASE_ID);
    Long subprocessId1 = caseService.addDynamicSubprocess(caseId, SUBPROCESS, Collections.emptyMap());
    ProcessInstanceDesc subprocessInstance1 = runtimeDataService.getProcessInstanceById(subprocessId1);
    assertThat(subprocessInstance1).isNotNull();
    assertThat(subprocessInstance1.getState()).isEqualTo(ProcessInstance.STATE_ACTIVE);
    Long subprocessId2 = caseService.addDynamicSubprocess(caseId, SUBPROCESS, Collections.emptyMap());
    ProcessInstanceDesc subprocessInstance2 = runtimeDataService.getProcessInstanceById(subprocessId2);
    assertThat(subprocessInstance2).isNotNull();
    assertThat(subprocessInstance2.getState()).isEqualTo(ProcessInstance.STATE_ACTIVE);
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER, new QueryFilter());
    assertThat(tasks).hasSize(2);
    TaskSummary userTask1 = tasks.get(0);
    assertThat(userTask1.getName()).isEqualTo(SUBPROCESS_TASK);
    userTaskService.completeAutoProgress(userTask1.getId(), USER, null);
    TaskSummary userTask2 = tasks.get(1);
    assertThat(userTask2.getName()).isEqualTo(SUBPROCESS_TASK);
    userTaskService.completeAutoProgress(userTask2.getId(), USER, null);
    tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER, new QueryFilter());
    assertThat(tasks).isEmpty();
    subprocessInstance1 = runtimeDataService.getProcessInstanceById(subprocessId1);
    assertThat(subprocessInstance1).isNotNull();
    assertThat(subprocessInstance1.getState()).isEqualTo(ProcessInstance.STATE_COMPLETED);
    subprocessInstance2 = runtimeDataService.getProcessInstanceById(subprocessId2);
    assertThat(subprocessInstance2).isNotNull();
    assertThat(subprocessInstance2.getState()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) TaskSummary(org.kie.api.task.model.TaskSummary) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) AbstractCaseServicesBaseTest(org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest) Test(org.junit.Test)

Aggregations

QueryFilter (org.kie.internal.query.QueryFilter)149 Test (org.junit.Test)127 TaskSummary (org.kie.api.task.model.TaskSummary)122 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)52 HashMap (java.util.HashMap)47 AbstractCaseServicesBaseTest (org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest)31 KModuleDeploymentServiceTest (org.jbpm.kie.services.test.KModuleDeploymentServiceTest)26 AuditTask (org.kie.internal.task.api.AuditTask)25 ArrayList (java.util.ArrayList)24 QueryContext (org.kie.api.runtime.query.QueryContext)24 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)23 CaseInstance (org.jbpm.casemgmt.api.model.instance.CaseInstance)21 Task (org.kie.api.task.model.Task)19 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)18 TaskFluent (org.jbpm.services.task.utils.TaskFluent)17 TaskEvent (org.kie.internal.task.api.model.TaskEvent)17 HumanTaskServicesBaseTest (org.jbpm.services.task.HumanTaskServicesBaseTest)14 Status (org.kie.api.task.model.Status)13 OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)11 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)10