use of org.kie.internal.query.QueryFilter in project jbpm by kiegroup.
the class StageCompletionConditionTest method testProcessVariable.
@Test
public void testProcessVariable() {
Map<String, Object> data = new HashMap<>();
data.put("continue", false);
CaseFileInstance caseFile = caseService.newCaseFileInstance(deploymentUnit.getIdentifier(), STAGE_WITH_TASK_PROCESS_VARIABLE, data, Collections.emptyMap());
String caseId = caseService.startCase(deploymentUnit.getIdentifier(), STAGE_WITH_TASK_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", false);
caseService.addDataToCaseFile(caseId, "continue", true);
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);
processService.setProcessVariable(processInstanceId, "continue", true);
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);
}
use of org.kie.internal.query.QueryFilter in project jbpm by kiegroup.
the class SubCaseServiceImplTest method testStartProcessWithSubCaseDestroySubCase.
@Test
public void testStartProcessWithSubCaseDestroySubCase() {
Long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), PROCESS_TO_CASE_P_ID);
assertNotNull(processInstanceId);
try {
// check if case was created from within the process
CaseInstance cInstance = caseService.getCaseInstance(HR_CASE_ID);
assertNotNull(cInstance);
assertEquals(deploymentUnit.getIdentifier(), cInstance.getDeploymentId());
Map<String, Object> processVariables = processService.getProcessInstanceVariables(processInstanceId);
assertNull(processVariables.get("CaseId"));
assertNull(processVariables.get("outcome"));
List<TaskSummary> tasks = caseRuntimeDataService.getCaseTasksAssignedAsPotentialOwner(HR_CASE_ID, "john", null, new QueryContext());
assertNotNull(tasks);
assertEquals(1, tasks.size());
assertEquals("Hello1", tasks.get(0).getName());
caseService.destroyCase(HR_CASE_ID);
processVariables = processService.getProcessInstanceVariables(processInstanceId);
assertEquals(HR_CASE_ID, processVariables.get("CaseId"));
assertEquals("process2case", processVariables.get("outcome"));
tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter());
assertNotNull(tasks);
assertEquals(1, tasks.size());
assertEquals("Verify case results", tasks.get(0).getName());
Map<String, Object> taskInputs = userTaskService.getTaskInputContentByTaskId(tasks.get(0).getId());
assertEquals(HR_CASE_ID, taskInputs.get("CaseId"));
assertEquals("process2case", taskInputs.get("outcome"));
userTaskService.completeAutoProgress(tasks.get(0).getId(), "john", null);
ProcessInstanceDesc piLog = runtimeDataService.getProcessInstanceById(processInstanceId);
assertNotNull(piLog);
assertEquals(ProcessInstance.STATE_COMPLETED, piLog.getState().intValue());
processInstanceId = null;
} catch (Exception e) {
logger.error("Unexpected error {}", e.getMessage(), e);
fail("Unexpected exception " + e.getMessage());
} finally {
if (processInstanceId != null) {
processService.abortProcessInstance(processInstanceId);
}
}
}
use of org.kie.internal.query.QueryFilter 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());
}
use of org.kie.internal.query.QueryFilter 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();
}
use of org.kie.internal.query.QueryFilter 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);
}
Aggregations