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);
}
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);
}
Aggregations