Search in sources :

Example 16 with TaskFluent

use of org.jbpm.services.task.utils.TaskFluent in project jbpm by kiegroup.

the class TotalCompletionTimeAssignmentStrategyTest method testMultipleUserWithGroup.

@Test
public void testMultipleUserWithGroup() {
    String[] expectedOwners = Arrays.array(BOBBA_FET, LUKE_CAGE, TONY_STARK);
    // added to the end of the potential owners list
    for (int x = 0; x < 3; x++) {
        TaskFluent task1 = new TaskFluent().setName("MultiUserLoadBalanceTask1").addPotentialUser(BOBBA_FET).addPotentialGroup("Crusaders").addPotentialUser(LUKE_CAGE).setDeploymentID(DEPLOYMENT_ID).setProcessId(PROCESS_ID).setAdminUser("Administrator");
        taskIds[x] = createAndAssertTask(task1, expectedOwners[x]);
    }
    // Complete Luke's task
    completeTask(taskIds[1], 1000);
    // Luke jumps to the front of the expected owners
    // because he has no active tasks
    expectedOwners = Arrays.array(LUKE_CAGE, BOBBA_FET, TONY_STARK);
    for (int x = 3; x < 6; x++) {
        TaskFluent task2 = new TaskFluent().setName("MultiUserLoadBalanceTask2").addPotentialUser(BOBBA_FET).addPotentialGroup("Crusaders").addPotentialUser(LUKE_CAGE).setDeploymentID(DEPLOYMENT_ID).setProcessId(PROCESS_ID).setAdminUser("Administrator");
        taskIds[x] = createAndAssertTask(task2, expectedOwners[x - 3]);
    }
    logger.info("testMultipleUserWithGroup completed");
}
Also used : TaskFluent(org.jbpm.services.task.utils.TaskFluent) Test(org.junit.Test)

Example 17 with TaskFluent

use of org.jbpm.services.task.utils.TaskFluent in project jbpm by kiegroup.

the class TotalCompletionTimeAssignmentStrategyTest method testMultipleUsersWithRemove.

@Test
public void testMultipleUsersWithRemove() {
    // First a set of tasks with our entire
    // crew of villains and heroes
    String[] expectedOwners = Arrays.array(BOBBA_FET, DARTH_VADER, LUKE_CAGE, TONY_STARK);
    for (int x = 0; x < 4; x++) {
        TaskFluent task1 = new TaskFluent().setName("MultiUserLoadBalanceTask1").addPotentialUser(BOBBA_FET).addPotentialUser(DARTH_VADER).addPotentialUser(LUKE_CAGE).addPotentialUser(TONY_STARK).setDeploymentID(DEPLOYMENT_ID).setProcessId(PROCESS_ID).setAdminUser("Administrator");
        taskIds[x] = createAndAssertTask(task1, expectedOwners[x]);
    }
    // Next we will complete Darth Vader's task
    completeTask(taskIds[1], 1500);
    // Now do a series of tasks without Darth Vader
    expectedOwners = Arrays.array(BOBBA_FET, LUKE_CAGE, TONY_STARK);
    for (int x = 4; x < 7; x++) {
        TaskFluent task2 = new TaskFluent().setName("MultiUserLoadBalanceTask2").addPotentialUser(BOBBA_FET).addPotentialUser(LUKE_CAGE).addPotentialUser(TONY_STARK).setDeploymentID(DEPLOYMENT_ID).setProcessId(PROCESS_ID).setAdminUser("Administrator");
        taskIds[x] = createAndAssertTask(task2, expectedOwners[x - 4]);
    }
    logger.info("testMultipleUsersWithRemove completed");
}
Also used : TaskFluent(org.jbpm.services.task.utils.TaskFluent) Test(org.junit.Test)

Example 18 with TaskFluent

use of org.jbpm.services.task.utils.TaskFluent in project jbpm by kiegroup.

the class TotalCompletionTimeAssignmentStrategyTest method testMultipleUserWithAdd.

@Test
public void testMultipleUserWithAdd() {
    String[] expectedOwners = Arrays.array(BOBBA_FET, DARTH_VADER, LUKE_CAGE, TONY_STARK);
    for (int x = 0; x < 3; x++) {
        TaskFluent task1 = new TaskFluent().setName("MultiUserLoadBalanceTask1").addPotentialUser(BOBBA_FET).addPotentialUser(DARTH_VADER).addPotentialUser(LUKE_CAGE).setDeploymentID(DEPLOYMENT_ID).setProcessId(PROCESS_ID).setAdminUser("Administrator");
        taskIds[x] = createAndAssertTask(task1, expectedOwners[x]);
    }
    // Complete Darth Vader's task
    completeTask(taskIds[1], 1000);
    // Create a new task and see if
    // Darth gets assigned
    TaskFluent task2 = new TaskFluent().setName("MultiUserLoadBalanceTask2").addPotentialUser(BOBBA_FET).addPotentialUser(DARTH_VADER).addPotentialUser(LUKE_CAGE).setDeploymentID(DEPLOYMENT_ID).setProcessId(PROCESS_ID).setAdminUser("Administrator");
    createAndAssertTask(task2, DARTH_VADER);
    // Add Tony Stark to the list of potential
    // owners and see him assigned to the new task
    TaskFluent task3 = new TaskFluent().setName("MultiUserLoadBalanceTask3").addPotentialUser(BOBBA_FET).addPotentialUser(DARTH_VADER).addPotentialUser(LUKE_CAGE).addPotentialUser(TONY_STARK).setDeploymentID(DEPLOYMENT_ID).setProcessId(PROCESS_ID).setAdminUser("Administrator");
    createAndAssertTask(task3, TONY_STARK);
    logger.info("testMultipleUserWithAdd completed");
}
Also used : TaskFluent(org.jbpm.services.task.utils.TaskFluent) Test(org.junit.Test)

Example 19 with TaskFluent

use of org.jbpm.services.task.utils.TaskFluent in project jbpm by kiegroup.

the class TaskAuditBaseTest method testSearchTasksByVariable.

@Test
public void testSearchTasksByVariable() {
    Task task = new TaskFluent().setName("This is my task name").addPotentialGroup("Knights Templer").setAdminUser("Administrator").getTask();
    Map<String, Object> inputVariables = new HashMap<String, Object>();
    inputVariables.put("firstVariable", "string content");
    inputVariables.put("number", 1234);
    taskService.addTask(task, inputVariables);
    long taskId = task.getId();
    List<TaskSummary> allGroupAuditTasks = taskService.getTasksAssignedAsPotentialOwner("salaboy", null, null, null);
    assertEquals(1, allGroupAuditTasks.size());
    assertTrue(allGroupAuditTasks.get(0).getStatusId().equals("Ready"));
    List<TaskVariable> inputVars = taskAuditService.taskVariableQuery().taskId(taskId).intersect().type(VariableType.INPUT).build().getResultList();
    assertNotNull(inputVars);
    assertEquals(2, inputVars.size());
    Map<String, String> vars = collectVariableNameAndValue(inputVars);
    assertTrue(vars.containsKey("firstVariable"));
    assertTrue(vars.containsKey("number"));
    assertEquals("string content", vars.get("firstVariable"));
    assertEquals("1234", vars.get("number"));
    List<TaskSummary> tasksByVariable = taskService.taskSummaryQuery("salaboy").variableName("firstVariable").build().getResultList();
    assertNotNull(tasksByVariable);
    assertEquals(1, tasksByVariable.size());
    // search by unauthorized user
    tasksByVariable = taskService.taskSummaryQuery("WinterMute").variableName("fistVariable").build().getResultList();
    assertNotNull(tasksByVariable);
    assertEquals(0, tasksByVariable.size());
    // search by not existing variable
    tasksByVariable = taskService.taskSummaryQuery("salaboy").variableName("notexistingVariable").build().getResultList();
    assertNotNull(tasksByVariable);
    assertEquals(0, tasksByVariable.size());
    // search by variable name with wildcard
    tasksByVariable = taskService.taskSummaryQuery("salaboy").regex().variableName("first*").build().getResultList();
    assertNotNull(tasksByVariable);
    assertNotNull(tasksByVariable);
    assertEquals(1, tasksByVariable.size());
}
Also used : Task(org.kie.api.task.model.Task) AuditTask(org.kie.internal.task.api.AuditTask) TaskFluent(org.jbpm.services.task.utils.TaskFluent) HashMap(java.util.HashMap) TaskSummary(org.kie.api.task.model.TaskSummary) TaskVariable(org.kie.internal.task.api.TaskVariable) HumanTaskServicesBaseTest(org.jbpm.services.task.HumanTaskServicesBaseTest) Test(org.junit.Test)

Example 20 with TaskFluent

use of org.jbpm.services.task.utils.TaskFluent in project jbpm by kiegroup.

the class TaskAuditBaseTest method testGroupTasks.

@Test
public void testGroupTasks() {
    Task task = new TaskFluent().setName("This is my task name").addPotentialUser("salaboy").addPotentialUser("krisv").addPotentialGroup("Knights Templer").setAdminUser("Administrator").getTask();
    taskService.addTask(task, new HashMap<String, Object>());
    List<TaskSummary> allGroupTasks = taskService.getTasksAssignedAsPotentialOwner("salaboy", null, null, null);
    assertEquals(1, allGroupTasks.size());
    assertTrue(allGroupTasks.get(0).getStatusId().equals("Ready"));
    List<AuditTask> allGroupAuditTasksByUser = taskAuditService.getAllGroupAuditTasksByUser("salaboy", new QueryFilter(0, 0));
    assertEquals(1, allGroupAuditTasksByUser.size());
    assertTrue(allGroupAuditTasksByUser.get(0).getStatus().equals("Ready"));
}
Also used : Task(org.kie.api.task.model.Task) AuditTask(org.kie.internal.task.api.AuditTask) QueryFilter(org.kie.internal.query.QueryFilter) TaskFluent(org.jbpm.services.task.utils.TaskFluent) TaskSummary(org.kie.api.task.model.TaskSummary) AuditTask(org.kie.internal.task.api.AuditTask) HumanTaskServicesBaseTest(org.jbpm.services.task.HumanTaskServicesBaseTest) Test(org.junit.Test)

Aggregations

TaskFluent (org.jbpm.services.task.utils.TaskFluent)31 Task (org.kie.api.task.model.Task)26 AuditTask (org.kie.internal.task.api.AuditTask)25 Test (org.junit.Test)24 HumanTaskServicesBaseTest (org.jbpm.services.task.HumanTaskServicesBaseTest)20 QueryFilter (org.kie.internal.query.QueryFilter)17 TaskSummary (org.kie.api.task.model.TaskSummary)14 HashMap (java.util.HashMap)9 TaskEvent (org.kie.internal.task.api.model.TaskEvent)8 TaskVariable (org.kie.internal.task.api.TaskVariable)7 ArrayList (java.util.ArrayList)4 I18NTextImpl (org.jbpm.services.task.impl.model.I18NTextImpl)2 I18NText (org.kie.api.task.model.I18NText)2 Calendar (java.util.Calendar)1 Date (java.util.Date)1 GregorianCalendar (java.util.GregorianCalendar)1 EntityManager (javax.persistence.EntityManager)1 ProcessInstanceLog (org.jbpm.process.audit.ProcessInstanceLog)1 StandaloneJtaStrategy (org.jbpm.process.audit.strategy.StandaloneJtaStrategy)1 JPATaskLifeCycleEventListener (org.jbpm.services.task.audit.JPATaskLifeCycleEventListener)1