Search in sources :

Example 96 with QueryFilter

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

the class StageCompletionConditionTest method testCaseFileVariableWithProcessVariable.

@Test
public void testCaseFileVariableWithProcessVariable() {
    Map<String, Object> data = new HashMap<>();
    data.put("continue", false);
    CaseFileInstance caseFile = caseService.newCaseFileInstance(deploymentUnit.getIdentifier(), STAGE_WITH_TASK_CASE_FILE_AND_PROCESS_VARIABLE, data, Collections.emptyMap());
    String caseId = caseService.startCase(deploymentUnit.getIdentifier(), STAGE_WITH_TASK_CASE_FILE_AND_PROCESS_VARIABLE, caseFile);
    assertThat(caseId).isNotNull().isEqualTo(FIRST_CASE_ID);
    assertCaseInstanceActive(caseId);
    CaseInstance caseInstance = caseService.getCaseInstance(caseId);
    assertThat(caseInstance).isNotNull();
    Long processInstanceId = ((CaseInstanceImpl) caseInstance).getProcessInstanceId();
    processService.setProcessVariable(processInstanceId, "continue", true);
    assertCaseInstanceActive(caseId);
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER, new QueryFilter());
    assertThat(tasks).hasSize(1);
    TaskSummary insideTask = tasks.get(0);
    assertThat(insideTask.getName()).isEqualTo(INSIDE_TASK);
    userTaskService.completeAutoProgress(insideTask.getId(), USER, null);
    assertCaseInstanceActive(caseId);
    caseService.addDataToCaseFile(caseId, "continue", true);
    assertCaseInstanceActive(caseId);
    caseInstance = caseService.getCaseInstance(caseId, false, false, false, true);
    assertThat(caseInstance).isNotNull();
    assertThat(caseInstance.getCaseStages()).hasSize(1);
    String stageId = caseInstance.getCaseStages().iterator().next().getId();
    TaskSpecification dynamicTaskSpecification = caseService.newHumanTaskSpec(DYNAMIC_TASK, "", USER, null, Collections.emptyMap());
    caseService.addDynamicTaskToStage(caseId, stageId, dynamicTaskSpecification);
    tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER, new QueryFilter());
    assertThat(tasks).hasSize(1);
    TaskSummary dynamicTask = tasks.get(0);
    assertThat(dynamicTask.getName()).isEqualTo(DYNAMIC_TASK);
    userTaskService.completeAutoProgress(dynamicTask.getId(), USER, null);
    assertCaseInstanceNotActive(caseId);
}
Also used : CaseFileInstance(org.jbpm.casemgmt.api.model.instance.CaseFileInstance) CaseInstance(org.jbpm.casemgmt.api.model.instance.CaseInstance) TaskSpecification(org.jbpm.casemgmt.api.dynamic.TaskSpecification) QueryFilter(org.kie.internal.query.QueryFilter) CaseInstanceImpl(org.jbpm.casemgmt.impl.model.instance.CaseInstanceImpl) HashMap(java.util.HashMap) TaskSummary(org.kie.api.task.model.TaskSummary) AbstractCaseServicesBaseTest(org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest) Test(org.junit.Test)

Example 97 with QueryFilter

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

the class StageCompletionConditionTest method testAutoCompleteNoAutoStartTaskAdHocInStage.

@Test
public void testAutoCompleteNoAutoStartTaskAdHocInStage() {
    String caseId = caseService.startCase(deploymentUnit.getIdentifier(), STAGE_WITH_TASK_NO_AUTOSTART);
    assertThat(caseId).isNotNull().isEqualTo(FIRST_CASE_ID);
    assertCaseInstanceActive(caseId);
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER, new QueryFilter());
    assertThat(tasks).isEmpty();
    CaseDefinition caseDef = caseRuntimeDataService.getCase(deploymentUnit.getIdentifier(), STAGE_WITH_TASK_NO_AUTOSTART);
    Collection<CaseStage> stages = caseDef.getCaseStages();
    assertThat(stages).hasSize(1);
    String stageId = stages.iterator().next().getId();
    caseService.triggerAdHocFragment(caseId, stageId, INSIDE_TASK, null);
    assertCaseInstanceActive(caseId);
    tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER, new QueryFilter());
    assertThat(tasks).hasSize(1);
    TaskSummary insideTask = tasks.get(0);
    assertThat(insideTask.getName()).isEqualTo(INSIDE_TASK);
    userTaskService.completeAutoProgress(insideTask.getId(), USER, null);
    assertCaseInstanceNotActive(caseId);
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) CaseStage(org.jbpm.casemgmt.api.model.CaseStage) CaseDefinition(org.jbpm.casemgmt.api.model.CaseDefinition) TaskSummary(org.kie.api.task.model.TaskSummary) AbstractCaseServicesBaseTest(org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest) Test(org.junit.Test)

Example 98 with QueryFilter

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

the class StageCompletionConditionTest method testAutoCompleteDynamicTask.

@Test
public void testAutoCompleteDynamicTask() {
    String caseId = caseService.startCase(deploymentUnit.getIdentifier(), STAGE_WITH_TASK_AUTOCOMPLETE);
    assertThat(caseId).isNotNull().isEqualTo(FIRST_CASE_ID);
    assertCaseInstanceActive(caseId);
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER, new QueryFilter());
    assertThat(tasks).hasSize(1);
    TaskSummary insideTask = tasks.get(0);
    assertThat(insideTask.getName()).isEqualTo(INSIDE_TASK);
    CaseInstance caseInstance = caseService.getCaseInstance(caseId, false, false, false, true);
    assertThat(caseInstance).isNotNull();
    assertThat(caseInstance.getCaseStages()).hasSize(1);
    String stageId = caseInstance.getCaseStages().iterator().next().getId();
    TaskSpecification dynamicTaskSpecification = caseService.newHumanTaskSpec(DYNAMIC_TASK, "", USER, null, Collections.emptyMap());
    caseService.addDynamicTaskToStage(caseId, stageId, dynamicTaskSpecification);
    userTaskService.completeAutoProgress(insideTask.getId(), USER, null);
    assertCaseInstanceActive(caseId);
    tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER, new QueryFilter());
    assertThat(tasks).hasSize(1);
    TaskSummary dynamicTask = tasks.get(0);
    assertThat(dynamicTask.getName()).isEqualTo(DYNAMIC_TASK);
    userTaskService.completeAutoProgress(dynamicTask.getId(), USER, null);
    assertCaseInstanceNotActive(caseId);
}
Also used : CaseInstance(org.jbpm.casemgmt.api.model.instance.CaseInstance) TaskSpecification(org.jbpm.casemgmt.api.dynamic.TaskSpecification) QueryFilter(org.kie.internal.query.QueryFilter) TaskSummary(org.kie.api.task.model.TaskSummary) AbstractCaseServicesBaseTest(org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest) Test(org.junit.Test)

Example 99 with QueryFilter

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

the class StageCompletionConditionTest method testCaseFileVariable.

@Test
public void testCaseFileVariable() {
    Map<String, Object> data = new HashMap<>();
    data.put("continue", false);
    CaseFileInstance caseFile = caseService.newCaseFileInstance(deploymentUnit.getIdentifier(), STAGE_WITH_TASK_CASE_FILE_VARIABLE, data, Collections.emptyMap());
    String caseId = caseService.startCase(deploymentUnit.getIdentifier(), STAGE_WITH_TASK_CASE_FILE_VARIABLE, caseFile);
    assertThat(caseId).isNotNull().isEqualTo(FIRST_CASE_ID);
    assertCaseInstanceActive(caseId);
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER, new QueryFilter());
    assertThat(tasks).hasSize(1);
    TaskSummary insideTask = tasks.get(0);
    assertThat(insideTask.getName()).isEqualTo(INSIDE_TASK);
    userTaskService.completeAutoProgress(insideTask.getId(), USER, null);
    assertCaseInstanceActive(caseId);
    caseService.addDataToCaseFile(caseId, "continue", true);
    assertCaseInstanceActive(caseId);
    CaseInstance caseInstance = caseService.getCaseInstance(caseId, false, false, false, true);
    assertThat(caseInstance).isNotNull();
    assertThat(caseInstance.getCaseStages()).hasSize(1);
    String stageId = caseInstance.getCaseStages().iterator().next().getId();
    TaskSpecification dynamicTaskSpecification = caseService.newHumanTaskSpec(DYNAMIC_TASK, "", USER, null, Collections.emptyMap());
    caseService.addDynamicTaskToStage(caseId, stageId, dynamicTaskSpecification);
    tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER, new QueryFilter());
    assertThat(tasks).hasSize(1);
    TaskSummary dynamicTask = tasks.get(0);
    assertThat(dynamicTask.getName()).isEqualTo(DYNAMIC_TASK);
    userTaskService.completeAutoProgress(dynamicTask.getId(), USER, null);
    assertCaseInstanceNotActive(caseId);
}
Also used : CaseFileInstance(org.jbpm.casemgmt.api.model.instance.CaseFileInstance) CaseInstance(org.jbpm.casemgmt.api.model.instance.CaseInstance) TaskSpecification(org.jbpm.casemgmt.api.dynamic.TaskSpecification) 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 100 with QueryFilter

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

the class StageCompletionConditionTest method testAutoCompleteNoAutoStartTaskNotExistingAdHocInStage.

@Test
public void testAutoCompleteNoAutoStartTaskNotExistingAdHocInStage() {
    String caseId = caseService.startCase(deploymentUnit.getIdentifier(), STAGE_WITH_TASK_NO_AUTOSTART);
    assertThat(caseId).isNotNull().isEqualTo(FIRST_CASE_ID);
    assertCaseInstanceActive(caseId);
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER, new QueryFilter());
    assertThat(tasks).isEmpty();
    CaseDefinition caseDef = caseRuntimeDataService.getCase(deploymentUnit.getIdentifier(), STAGE_WITH_TASK_NO_AUTOSTART);
    Collection<CaseStage> stages = caseDef.getCaseStages();
    assertThat(stages).hasSize(1);
    String stageId = stages.iterator().next().getId();
    assertThatExceptionOfType(AdHocFragmentNotFoundException.class).isThrownBy(() -> {
        caseService.triggerAdHocFragment(caseId, stageId, "not existing", null);
    }).withMessageContaining("AdHoc fragment 'not existing' not found in case " + caseId + " and stage " + stageId);
    assertCaseInstanceActive(caseId);
    tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER, new QueryFilter());
    assertThat(tasks).hasSize(0);
    caseService.cancelCase(caseId);
    assertCaseInstanceNotActive(caseId);
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) CaseStage(org.jbpm.casemgmt.api.model.CaseStage) CaseDefinition(org.jbpm.casemgmt.api.model.CaseDefinition) TaskSummary(org.kie.api.task.model.TaskSummary) 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