use of org.jbpm.services.task.utils.TaskFluent in project jbpm by kiegroup.
the class TaskAuditBaseTest method testVariableIndexInputAndOutputWitlLongTextTrimmed.
@Test
public void testVariableIndexInputAndOutputWitlLongTextTrimmed() {
System.setProperty("org.jbpm.task.var.log.length", "10");
try {
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"));
// the variable was longer that 10 so it had to be trimmed
assertEquals("string con", vars.get("firstVariable"));
assertEquals("1234", vars.get("number"));
taskService.claim(taskId, "Darth Vader");
allGroupAuditTasks = taskService.getTasksAssignedAsPotentialOwner("salaboy", null, null, null);
assertEquals(0, allGroupAuditTasks.size());
allGroupAuditTasks = taskService.getTasksAssignedAsPotentialOwner("Darth Vader", null, null, null);
assertEquals(1, allGroupAuditTasks.size());
assertTrue(allGroupAuditTasks.get(0).getStatusId().equals("Reserved"));
taskService.start(taskId, "Darth Vader");
Task task1 = taskService.getTaskById(taskId);
assertEquals(Status.InProgress, task1.getTaskData().getStatus());
assertEquals("Darth Vader", task1.getTaskData().getActualOwner().getId());
String reply = "Just a short part of the reply";
String veryLongReply = reply;
for (int i = 0; i < 15; i++) {
veryLongReply += reply;
}
Map<String, Object> outputVariables = new HashMap<String, Object>();
outputVariables.put("reply", veryLongReply);
outputVariables.put("age", 25);
// Check is Complete
taskService.complete(taskId, "Darth Vader", outputVariables);
List<TaskVariable> outputVars = taskAuditService.taskVariableQuery().taskId(taskId).intersect().type(VariableType.OUTPUT).build().getResultList();
assertNotNull(outputVars);
assertEquals(2, outputVars.size());
Map<String, String> outvars = collectVariableNameAndValue(outputVars);
assertTrue(outvars.containsKey("reply"));
assertTrue(outvars.containsKey("age"));
assertEquals("Just a sho", outvars.get("reply"));
assertEquals("25", outvars.get("age"));
} finally {
System.clearProperty("org.jbpm.task.var.log.length");
}
}
use of org.jbpm.services.task.utils.TaskFluent in project jbpm by kiegroup.
the class TaskAuditBaseTest method testForwardTaskWithMsgEvents.
@Test
public void testForwardTaskWithMsgEvents() {
Task task = new TaskFluent().setName("This is my task name").addPotentialGroup("Knights Templer").setAdminUser("Administrator").addPotentialUser("Administrator").getTask();
taskService.addTask(task, new HashMap<String, Object>());
long taskId = task.getId();
assertAuditTaskInfoGroup("Knights Templer", "Ready", taskId);
taskService.claim(taskId, "Administrator");
assertAuditTaskInfo("Administrator", "Reserved", taskId);
taskService.forward(taskId, "Administrator", "Darth Vader");
List<TaskEvent> taskEvents = taskAuditService.getAllTaskEvents(taskId, new QueryFilter());
Assertions.assertThat(taskEvents).hasSize(3);
Assertions.assertThat(taskEvents.get(0).getType()).isEqualTo(TaskEventType.ADDED);
Assertions.assertThat(taskEvents.get(0).getUserId()).isNull();
Assertions.assertThat(taskEvents.get(1).getType()).isEqualTo(TaskEventType.CLAIMED);
Assertions.assertThat(taskEvents.get(1).getUserId()).isEqualTo("Administrator");
Assertions.assertThat(taskEvents.get(2).getType()).isEqualTo(TaskEventType.FORWARDED);
Assertions.assertThat(taskEvents.get(2).getUserId()).isEqualTo("Administrator");
Assertions.assertThat(taskEvents.get(2).getMessage()).isNotNull();
Assertions.assertThat(taskEvents.get(2).getMessage()).contains("Darth Vader");
}
use of org.jbpm.services.task.utils.TaskFluent in project jbpm by kiegroup.
the class TaskAuditBaseTest method testAdminTasks.
@Test
public void testAdminTasks() {
Task task = new TaskFluent().setName("This is my task name").setAdminUser("salaboy").getTask();
taskService.addTask(task, new HashMap<String, Object>());
List<TaskSummary> allAdminTasks = taskService.getTasksAssignedAsBusinessAdministrator("salaboy", null);
assertEquals(1, allAdminTasks.size());
List<AuditTask> allAdminAuditTasksByUser = taskAuditService.getAllAdminAuditTasksByUser("salaboy", new QueryFilter(0, 0));
assertEquals(1, allAdminAuditTasksByUser.size());
}
use of org.jbpm.services.task.utils.TaskFluent in project jbpm by kiegroup.
the class TaskAuditBaseTest method testLifeCycleWithBAMEndWithExited.
@Test
public void testLifeCycleWithBAMEndWithExited() {
Task task = new TaskFluent().setName("This is my task name").addPotentialGroup("Knights Templer").setAdminUser("Administrator").getTask();
taskService.addTask(task, new HashMap<String, Object>());
long taskId = task.getId();
List<AuditTask> allGroupAuditTasks = taskAuditService.getAllGroupAuditTasksByUser("Knights Templer", new QueryFilter());
assertEquals(1, allGroupAuditTasks.size());
assertTrue(allGroupAuditTasks.get(0).getStatus().equals("Ready"));
assertBAMTask(taskId, "Ready");
taskService.claim(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
assertEquals(1, allGroupAuditTasks.size());
assertEquals("Reserved", allGroupAuditTasks.get(0).getStatus());
assertBAMTask(taskId, "Reserved");
taskService.release(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllGroupAuditTasksByUser("Knights Templer", new QueryFilter());
assertEquals(1, allGroupAuditTasks.size());
assertTrue(allGroupAuditTasks.get(0).getStatus().equals("Ready"));
assertBAMTask(taskId, "Ready");
taskService.claim(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
;
assertEquals(1, allGroupAuditTasks.size());
assertEquals("Reserved", allGroupAuditTasks.get(0).getStatus());
assertBAMTask(taskId, "Reserved");
// Go straight from Ready to Inprogress
taskService.start(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
;
assertEquals(1, allGroupAuditTasks.size());
assertEquals("InProgress", allGroupAuditTasks.get(0).getStatus());
assertBAMTask(taskId, "InProgress");
taskService.exit(taskId, "Administrator");
allGroupAuditTasks = taskAuditService.getAllAuditTasks(new QueryFilter());
;
assertEquals(1, allGroupAuditTasks.size());
assertEquals("Exited", allGroupAuditTasks.get(0).getStatus());
assertBAMTask(taskId, "Exited");
}
use of org.jbpm.services.task.utils.TaskFluent in project jbpm by kiegroup.
the class TaskAuditBaseTest method testLifeCycleWithBAMEndWithObsolete.
@Test
public void testLifeCycleWithBAMEndWithObsolete() {
Task task = new TaskFluent().setName("This is my task name").addPotentialGroup("Knights Templer").setAdminUser("Administrator").getTask();
((InternalTaskData) task.getTaskData()).setSkipable(true);
taskService.addTask(task, new HashMap<String, Object>());
long taskId = task.getId();
List<AuditTask> allGroupAuditTasks = taskAuditService.getAllGroupAuditTasksByUser("Knights Templer", new QueryFilter());
assertEquals(1, allGroupAuditTasks.size());
assertTrue(allGroupAuditTasks.get(0).getStatus().equals("Ready"));
assertBAMTask(taskId, "Ready");
taskService.claim(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
assertEquals(1, allGroupAuditTasks.size());
assertEquals("Reserved", allGroupAuditTasks.get(0).getStatus());
assertBAMTask(taskId, "Reserved");
taskService.release(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllGroupAuditTasksByUser("Knights Templer", new QueryFilter());
assertEquals(1, allGroupAuditTasks.size());
assertTrue(allGroupAuditTasks.get(0).getStatus().equals("Ready"));
assertBAMTask(taskId, "Ready");
taskService.claim(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
;
assertEquals(1, allGroupAuditTasks.size());
assertEquals("Reserved", allGroupAuditTasks.get(0).getStatus());
assertBAMTask(taskId, "Reserved");
// Go straight from Ready to Inprogress
taskService.start(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
;
assertEquals(1, allGroupAuditTasks.size());
assertEquals("InProgress", allGroupAuditTasks.get(0).getStatus());
assertBAMTask(taskId, "InProgress");
taskService.skip(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
;
assertEquals(1, allGroupAuditTasks.size());
assertEquals("Obsolete", allGroupAuditTasks.get(0).getStatus());
assertBAMTask(taskId, "Obsolete");
}
Aggregations