Search in sources :

Example 61 with QueryFilter

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

the class UserTaskAdminServiceImplTest method testReassignNotStartedInvalidOrgEntities.

@Test(timeout = 10000)
public void testReassignNotStartedInvalidOrgEntities() 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);
    Assertions.assertThatThrownBy(() -> {
        userTaskAdminService.reassignWhenNotStarted(task.getId(), "2s", null);
    }).hasMessage("Invalid org entity");
}
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)

Example 62 with QueryFilter

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

the class UserTaskAdminServiceImplTest method testAddPotentialOwnersWrongDeploymentId.

@Test
public void testAddPotentialOwnersWrongDeploymentId() {
    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.release(task.getId(), "salaboy");
    assertThatExceptionOfType(TaskNotFoundException.class).isThrownBy(() -> {
        userTaskAdminService.addPotentialOwners("wrong-one", task.getId(), false, factory.newUser("john"));
    }).withMessageContaining("Task with id " + task.getId() + " is not associated with wrong-one");
    tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter());
    Assertions.assertThat(tasks).hasSize(0);
}
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)

Example 63 with QueryFilter

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

the class UserTaskAdminServiceImplTest method testNotifyNotCompleted.

@Test(timeout = 10000)
public void testNotifyNotCompleted() 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<TaskNotification> notifications = userTaskAdminService.getTaskNotifications(task.getId(), false);
    Assertions.assertThat(notifications).isNotNull();
    Assertions.assertThat(notifications).hasSize(0);
    userTaskService.start(task.getId(), "salaboy");
    List<OrganizationalEntity> recipients = new ArrayList<>();
    recipients.add(factory.newUser("john"));
    EmailNotification emailNotification = userTaskAdminService.buildEmailNotification("test", recipients, "Simple body", "Administrator", "");
    userTaskAdminService.notifyWhenNotCompleted(task.getId(), "2s", emailNotification);
    notifications = userTaskAdminService.getTaskNotifications(task.getId(), false);
    Assertions.assertThat(notifications).isNotNull();
    Assertions.assertThat(notifications).hasSize(1);
    CountDownListenerFactory.getExistingTask("userTaskAdminService").waitTillCompleted();
    tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
    Assertions.assertThat(tasks).hasSize(1);
    notifications = userTaskAdminService.getTaskNotifications(task.getId(), true);
    Assertions.assertThat(notifications).isNotNull();
    Assertions.assertThat(notifications).hasSize(0);
    notifications = userTaskAdminService.getTaskNotifications(task.getId(), false);
    Assertions.assertThat(notifications).isNotNull();
    Assertions.assertThat(notifications).hasSize(1);
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) TaskSummary(org.kie.api.task.model.TaskSummary) ArrayList(java.util.ArrayList) TaskNotification(org.jbpm.services.api.admin.TaskNotification) EmailNotification(org.kie.internal.task.api.model.EmailNotification) KModuleDeploymentServiceTest(org.jbpm.kie.services.test.KModuleDeploymentServiceTest) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 64 with QueryFilter

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

the class UserTaskAdminServiceImplTest method testRemovePotentialOwners.

@Test
public void testRemovePotentialOwners() {
    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.release(task.getId(), "salaboy");
    userTaskAdminService.removePotentialOwners(task.getId(), factory.newUser("salaboy"));
    List<TaskEvent> events = runtimeDataService.getTaskEvents(task.getId(), new QueryFilter());
    Assertions.assertThat(events).hasSize(3);
    TaskEvent updatedEvent = events.get(2);
    Assertions.assertThat(updatedEvent.getMessage()).isEqualTo("Potential owners [salaboy] have been removed");
    tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
    Assertions.assertThat(tasks).hasSize(0);
}
Also used : 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 65 with QueryFilter

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

the class UserTaskAdminServiceImplTest method testNotifyNotStartedAndCancel.

@Test(timeout = 10000)
public void testNotifyNotStartedAndCancel() 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<TaskNotification> notifications = userTaskAdminService.getTaskNotifications(task.getId(), false);
    Assertions.assertThat(notifications).isNotNull();
    Assertions.assertThat(notifications).hasSize(0);
    List<OrganizationalEntity> recipients = new ArrayList<>();
    recipients.add(factory.newUser("john"));
    EmailNotification emailNotification = userTaskAdminService.buildEmailNotification("test", recipients, "Simple body", "Administrator", "");
    long notificationId = userTaskAdminService.notifyWhenNotStarted(task.getId(), "2s", emailNotification);
    notifications = userTaskAdminService.getTaskNotifications(task.getId(), true);
    Assertions.assertThat(notifications).isNotNull();
    Assertions.assertThat(notifications).hasSize(1);
    userTaskAdminService.cancelNotification(task.getId(), notificationId);
    notifications = userTaskAdminService.getTaskNotifications(task.getId(), true);
    Assertions.assertThat(notifications).isNotNull();
    Assertions.assertThat(notifications).hasSize(0);
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) TaskSummary(org.kie.api.task.model.TaskSummary) ArrayList(java.util.ArrayList) TaskNotification(org.jbpm.services.api.admin.TaskNotification) EmailNotification(org.kie.internal.task.api.model.EmailNotification) 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