Search in sources :

Example 11 with CaseInstanceImpl

use of org.jbpm.casemgmt.impl.model.instance.CaseInstanceImpl in project jbpm by kiegroup.

the class StageCompletionConditionTest method testNoActiveTasksCondition.

@Test
public void testNoActiveTasksCondition() {
    String caseId = caseService.startCase(deploymentUnit.getIdentifier(), STAGE_WITH_TASK_COUNT);
    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, "taskCount", 0);
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER, new QueryFilter());
    assertThat(tasks).hasSize(1);
    userTaskService.completeAutoProgress(tasks.get(0).getId(), USER, null);
    assertCaseInstanceNotActive(caseId);
}
Also used : CaseInstance(org.jbpm.casemgmt.api.model.instance.CaseInstance) QueryFilter(org.kie.internal.query.QueryFilter) CaseInstanceImpl(org.jbpm.casemgmt.impl.model.instance.CaseInstanceImpl) TaskSummary(org.kie.api.task.model.TaskSummary) AbstractCaseServicesBaseTest(org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest) Test(org.junit.Test)

Example 12 with CaseInstanceImpl

use of org.jbpm.casemgmt.impl.model.instance.CaseInstanceImpl 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)

Aggregations

CaseInstanceImpl (org.jbpm.casemgmt.impl.model.instance.CaseInstanceImpl)12 CaseInstance (org.jbpm.casemgmt.api.model.instance.CaseInstance)11 AbstractCaseServicesBaseTest (org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest)11 Test (org.junit.Test)11 HashMap (java.util.HashMap)8 AdHocFragmentNotFoundException (org.jbpm.casemgmt.api.AdHocFragmentNotFoundException)8 CaseActiveException (org.jbpm.casemgmt.api.CaseActiveException)8 CaseCommentNotFoundException (org.jbpm.casemgmt.api.CaseCommentNotFoundException)8 CaseNotFoundException (org.jbpm.casemgmt.api.CaseNotFoundException)8 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)8 TaskNotFoundException (org.jbpm.services.api.TaskNotFoundException)8 TaskSummary (org.kie.api.task.model.TaskSummary)5 QueryFilter (org.kie.internal.query.QueryFilter)5 UserImpl (org.jbpm.services.task.impl.model.UserImpl)4 OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)3 TaskSpecification (org.jbpm.casemgmt.api.dynamic.TaskSpecification)2 CaseMilestoneInstance (org.jbpm.casemgmt.api.model.instance.CaseMilestoneInstance)2 CaseStageInstance (org.jbpm.casemgmt.api.model.instance.CaseStageInstance)2 NodeInstanceDesc (org.jbpm.services.api.model.NodeInstanceDesc)2 QueryContext (org.kie.api.runtime.query.QueryContext)2