Пример #1
0
 public void testCancelWorkflowInstance() throws Exception {
   WorkflowDefinition workflowDef = getTestDefinition();
   workflowComponent.startWorkflow(workflowDef.getId(), null);
   List<WorkflowInstance> instances1 = workflowComponent.getActiveWorkflows(workflowDef.getId());
   assertNotNull(instances1);
   assertEquals(1, instances1.size());
   List<WorkflowTask> tasks =
       taskComponent.getAssignedTasks(
           AuthenticationUtil.getAdminUserName(), WorkflowTaskState.IN_PROGRESS);
   assertNotNull(tasks);
   assertTrue(tasks.size() > 0);
   WorkflowInstance cancelledInstance =
       workflowComponent.cancelWorkflow(instances1.get(0).getId());
   assertNotNull(cancelledInstance);
   assertFalse(cancelledInstance.isActive());
   List<WorkflowInstance> instances2 = workflowComponent.getActiveWorkflows(workflowDef.getId());
   assertNotNull(instances2);
   assertEquals(0, instances2.size());
   List<WorkflowTask> tasks1 =
       taskComponent.getAssignedTasks(
           AuthenticationUtil.getAdminUserName(), WorkflowTaskState.IN_PROGRESS);
   assertNotNull(tasks1);
   tasks1 = filterTasksByWorkflowInstance(tasks1, cancelledInstance.getId());
   assertEquals(0, tasks1.size());
 }
Пример #2
0
 private void checkInstanceExists(String instanceId, String defId, boolean expected) {
   boolean match = false;
   List<WorkflowInstance> activeWfs = workflowComponent.getActiveWorkflows(defId);
   for (WorkflowInstance instance : activeWfs) {
     if (instance.getId().equals(instanceId)) {
       match = true;
       break;
     }
   }
   assertEquals(expected, match);
 }
Пример #3
0
 public void testGetWorkflowInstances() {
   WorkflowDefinition workflowDef = getTestDefinition();
   workflowComponent.startWorkflow(workflowDef.getId(), null);
   workflowComponent.startWorkflow(workflowDef.getId(), null);
   List<WorkflowInstance> instances = workflowComponent.getActiveWorkflows(workflowDef.getId());
   assertNotNull(instances);
   assertEquals(2, instances.size());
   for (WorkflowInstance instance : instances) {
     assertEquals(workflowDef.getId(), instance.getDefinition().getId());
   }
 }
Пример #4
0
 public void testGetPositions() {
   WorkflowDefinition workflowDef = getTestDefinition();
   workflowComponent.startWorkflow(workflowDef.getId(), null);
   List<WorkflowInstance> instances = workflowComponent.getActiveWorkflows(workflowDef.getId());
   assertNotNull(instances);
   assertEquals(1, instances.size());
   List<WorkflowPath> paths = workflowComponent.getWorkflowPaths(instances.get(0).getId());
   assertNotNull(paths);
   assertEquals(1, paths.size());
   assertEquals(instances.get(0).getId(), paths.get(0).getInstance().getId());
   assertTrue(paths.get(0).getId().endsWith("-@"));
 }