Search in sources :

Example 56 with QueryFilter

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

the class UserTaskAdminServiceImplTest method testReassignNotStartedAndCancel.

@Test(timeout = 10000)
public void testReassignNotStartedAndCancel() throws Exception {
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    Assertions.assertThat(processInstanceId).isNotNull();
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
    Assertions.assertThat(tasks).hasSize(1);
    TaskSummary task = tasks.get(0);
    Collection<TaskReassignment> reassignments = userTaskAdminService.getTaskReassignments(task.getId(), false);
    Assertions.assertThat(reassignments).isNotNull();
    Assertions.assertThat(reassignments).hasSize(0);
    Long reassignmentId = userTaskAdminService.reassignWhenNotStarted(task.getId(), "2s", factory.newUser("john"));
    reassignments = userTaskAdminService.getTaskReassignments(task.getId(), true);
    Assertions.assertThat(reassignments).isNotNull();
    Assertions.assertThat(reassignments).hasSize(1);
    userTaskAdminService.cancelReassignment(task.getId(), reassignmentId);
    reassignments = userTaskAdminService.getTaskReassignments(task.getId(), true);
    Assertions.assertThat(reassignments).isNotNull();
    Assertions.assertThat(reassignments).hasSize(0);
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) TaskReassignment(org.jbpm.services.api.admin.TaskReassignment) TaskSummary(org.kie.api.task.model.TaskSummary) KModuleDeploymentServiceTest(org.jbpm.kie.services.test.KModuleDeploymentServiceTest) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 57 with QueryFilter

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

the class UserTaskAdminServiceImplTest method testReassignNotCompleted.

@Test(timeout = 10000)
public void testReassignNotCompleted() throws Exception {
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    Assertions.assertThat(processInstanceId).isNotNull();
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
    Assertions.assertThat(tasks).hasSize(1);
    TaskSummary task = tasks.get(0);
    userTaskService.start(task.getId(), "salaboy");
    Collection<TaskReassignment> reassignments = userTaskAdminService.getTaskReassignments(task.getId(), false);
    Assertions.assertThat(reassignments).isNotNull();
    Assertions.assertThat(reassignments).hasSize(0);
    userTaskAdminService.reassignWhenNotCompleted(task.getId(), "2s", factory.newUser("john"));
    reassignments = userTaskAdminService.getTaskReassignments(task.getId(), true);
    Assertions.assertThat(reassignments).isNotNull();
    Assertions.assertThat(reassignments).hasSize(1);
    CountDownListenerFactory.getExistingTask("userTaskAdminService").waitTillCompleted();
    tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
    Assertions.assertThat(tasks).hasSize(0);
    tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter());
    Assertions.assertThat(tasks).hasSize(1);
    reassignments = userTaskAdminService.getTaskReassignments(task.getId(), true);
    Assertions.assertThat(reassignments).isNotNull();
    Assertions.assertThat(reassignments).hasSize(0);
    reassignments = userTaskAdminService.getTaskReassignments(task.getId(), false);
    Assertions.assertThat(reassignments).isNotNull();
    Assertions.assertThat(reassignments).hasSize(1);
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) TaskReassignment(org.jbpm.services.api.admin.TaskReassignment) TaskSummary(org.kie.api.task.model.TaskSummary) KModuleDeploymentServiceTest(org.jbpm.kie.services.test.KModuleDeploymentServiceTest) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 58 with QueryFilter

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

the class UserTaskAdminServiceImplTest method testRemoveOutputData.

@Test
public void testRemoveOutputData() {
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    Assertions.assertThat(processInstanceId).isNotNull();
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
    Assertions.assertThat(tasks).hasSize(1);
    TaskSummary task = tasks.get(0);
    Map<String, Object> output = new HashMap<>();
    output.put("added-output", "draft");
    userTaskService.saveContent(task.getId(), output);
    Map<String, Object> outputData = userTaskService.getTaskOutputContentByTaskId(task.getId());
    Assertions.assertThat(outputData).containsKey("added-output");
    Assertions.assertThat(outputData.get("added-output")).isEqualTo("draft");
    userTaskAdminService.removeTaskOutputs(task.getId(), "added-output");
    outputData = userTaskService.getTaskOutputContentByTaskId(task.getId());
    Assertions.assertThat(outputData).doesNotContainKey("added-output");
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) HashMap(java.util.HashMap) TaskSummary(org.kie.api.task.model.TaskSummary) KModuleDeploymentServiceTest(org.jbpm.kie.services.test.KModuleDeploymentServiceTest) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 59 with QueryFilter

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

the class UserTaskAdminServiceImplTest method testRemoveBusinessAdmin.

@Test
public void testRemoveBusinessAdmin() {
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    Assertions.assertThat(processInstanceId).isNotNull();
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsBusinessAdministrator("Administrator", new QueryFilter());
    Assertions.assertThat(tasks).hasSize(1);
    TaskSummary task = tasks.get(0);
    userTaskAdminService.removeBusinessAdmins(task.getId(), factory.newUser("Administrator"));
    List<TaskEvent> events = runtimeDataService.getTaskEvents(task.getId(), new QueryFilter());
    Assertions.assertThat(events).hasSize(2);
    TaskEvent updatedEvent = events.get(1);
    Assertions.assertThat(updatedEvent.getMessage()).isEqualTo("Business administrators [Administrator] have been removed");
    List<Status> readyStatuses = Arrays.asList(new Status[] { org.kie.api.task.model.Status.Ready });
    tasks = runtimeDataService.getTasksAssignedAsBusinessAdministratorByStatus("Administrator", readyStatuses, new QueryFilter());
    Assertions.assertThat(tasks).hasSize(0);
}
Also used : Status(org.kie.api.task.model.Status) QueryFilter(org.kie.internal.query.QueryFilter) TaskSummary(org.kie.api.task.model.TaskSummary) TaskEvent(org.kie.internal.task.api.model.TaskEvent) KModuleDeploymentServiceTest(org.jbpm.kie.services.test.KModuleDeploymentServiceTest) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 60 with QueryFilter

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

the class UserTaskAdminServiceImplTest method testReassignNotStarted.

@Test(timeout = 10000)
public void testReassignNotStarted() throws Exception {
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    Assertions.assertThat(processInstanceId).isNotNull();
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
    Assertions.assertThat(tasks).hasSize(1);
    TaskSummary task = tasks.get(0);
    userTaskAdminService.reassignWhenNotStarted(task.getId(), "2s", factory.newUser("john"));
    CountDownListenerFactory.getExistingTask("userTaskAdminService").waitTillCompleted();
    tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
    Assertions.assertThat(tasks).hasSize(0);
    tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter());
    Assertions.assertThat(tasks).hasSize(1);
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) TaskSummary(org.kie.api.task.model.TaskSummary) KModuleDeploymentServiceTest(org.jbpm.kie.services.test.KModuleDeploymentServiceTest) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) 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