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