Exemple #1
0
  public void testScript() throws IOException {
    // deploy test script definition
    ClassPathResource processDef = new ClassPathResource("jbpmresources/test_script.xml");
    assertFalse(
        workflowComponent.isDefinitionDeployed(
            processDef.getInputStream(), MimetypeMap.MIMETYPE_XML));
    WorkflowDeployment deployment =
        workflowComponent.deployDefinition(processDef.getInputStream(), MimetypeMap.MIMETYPE_XML);
    assertNotNull(deployment);

    WorkflowDefinition workflowDef = deployment.getDefinition();
    Map<QName, Serializable> parameters = new HashMap<QName, Serializable>();
    parameters.put(QName.createQName(NamespaceService.DEFAULT_URI, "testNode"), rootNodeRef);
    parameters.put(
        QName.createQName(NamespaceService.BPM_MODEL_1_0_URI, "package"),
        packageComponent.createPackage(null));
    WorkflowPath path = workflowComponent.startWorkflow(workflowDef.getId(), parameters);
    assertNotNull(path);
    List<WorkflowTask> tasks1 = workflowComponent.getTasksForWorkflowPath(path.getId());
    assertNotNull(tasks1);
    assertEquals(1, tasks1.size());
    assertEquals(WorkflowTaskState.IN_PROGRESS, tasks1.get(0).getState());
    WorkflowTask updatedTask = taskComponent.endTask(tasks1.get(0).getId(), null);
    assertNotNull(updatedTask);
  }
Exemple #2
0
 public void testDeployWorkflow() throws Exception {
   ClassPathResource processDef =
       new ClassPathResource("jbpmresources/test_processdefinition.xml");
   WorkflowDeployment deployment =
       workflowComponent.deployDefinition(processDef.getInputStream(), MimetypeMap.MIMETYPE_XML);
   testWorkflowDef = deployment.getDefinition();
   assertNotNull(testWorkflowDef);
   assertEquals("jbpm$test", testWorkflowDef.getName());
   assertEquals("2", testWorkflowDef.getVersion());
 }
Exemple #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);
  }