Exemplo n.º 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());
 }
Exemplo n.º 2
0
  public void testGetWorkflowById() {
    WorkflowDefinition workflowDef = getTestDefinition();
    WorkflowPath path = workflowComponent.startWorkflow(workflowDef.getId(), null);
    assertNotNull(path);
    assertTrue(path.getId().endsWith("-@"));
    assertNotNull(path.getNode());
    assertNotNull(path.getInstance());
    assertEquals(workflowDef.getId(), path.getInstance().getDefinition().getId());
    WorkflowInstance instance = workflowComponent.getWorkflowById(path.getInstance().getId());
    assertNotNull(instance);
    assertEquals(path.getInstance().getId(), instance.getId());

    workflowComponent.cancelWorkflow(instance.getId());
    WorkflowInstance result = workflowComponent.getWorkflowById(instance.getId());
    assertNull("The workflow isntance should be null!", result);
  }
Exemplo n.º 3
0
  /**
   * See Alf-2764 in Jira.
   *
   * @throws Exception
   */
  public void testCancelForEachFork() throws Exception {
    // Deploy Parallel Loop Review process definition.
    ClassPathResource processDef =
        new ClassPathResource("test/alfresco/parallel_loop_review_processdefinition.xml");
    WorkflowDeployment deployment =
        workflowComponent.deployDefinition(processDef.getInputStream(), MimetypeMap.MIMETYPE_XML);
    WorkflowDefinition parallelDef = deployment.getDefinition();
    assertNotNull(parallelDef);

    // Set Current User to USER1.
    AuthenticationUtil.setFullyAuthenticatedUser(USER1);

    // Set up parameters
    QName approvePercentName =
        QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "requiredApprovePercent");
    NodeRef pckgNode = packageComponent.createPackage(null);
    List<NodeRef> assignees = Arrays.asList(person1, person2, person3);
    Map<QName, Serializable> parameters = new HashMap<QName, Serializable>();
    parameters.put(WorkflowModel.ASSOC_ASSIGNEES, (Serializable) assignees);
    parameters.put(WorkflowModel.ASSOC_PACKAGE, pckgNode);
    parameters.put(approvePercentName, 60f);

    // Start workflow
    WorkflowPath path = workflowComponent.startWorkflow(parallelDef.getId(), parameters);
    WorkflowTask startTask = workflowComponent.getTasksForWorkflowPath(path.getId()).get(0);
    taskComponent.endTask(startTask.getId(), null);
    checkInstanceExists(path.getInstance().getId(), parallelDef.getId(), true);

    // Set all users to reject document.
    ParallelReject(USER1);
    ParallelReject(USER2);
    ParallelReject(USER3);

    // Send review back round the loop.
    List<WorkflowTask> tasks = workflowComponent.getTasksForWorkflowPath(path.getId());
    assertEquals(1, tasks.size());
    taskComponent.endTask(tasks.get(0).getId(), "again");

    // Try to cancel workflow
    WorkflowInstance cancelledWf = workflowComponent.cancelWorkflow(path.getInstance().getId());
    checkInstanceExists(cancelledWf.getId(), parallelDef.getId(), false);
  }