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