コード例 #1
0
  /** Completes the actions of the test workflow and checks the action status and the comments. */
  @Test
  public void testWorkflowCompleteChain() {
    // complete action 1 with decision 1
    WorkflowAction action1 = getAction(ACTIONCODES.ACTION1.name());
    assertTrue("Action 1 should be active", action1.isActive());
    final WorkflowDecision decision1 = getDecision(DECISIONCODES.DECISION1.name(), action1);
    action1.setSelectedDecision(decision1);
    assertEquals("Expected number of decisions of action 1", 2, action1.getDecisionsCount());
    action1.decide();

    // test action 1
    action1 = getAction(ACTIONCODES.ACTION1.name());
    assertTrue("Action 1 should be completed", action1.isCompleted());
    assertEquals(
        "Excpected number of comments of action 1", 1, action1.getWorkflowActionComments().size());

    // test action 2
    final WorkflowAction action2 = getAction(ACTIONCODES.ACTION2.name());
    assertFalse("Action 2 should not be disabled", action2.isDisabled());
    assertFalse("Action 2 should not be completed", action2.isCompleted());
    assertTrue("Action 2 should be active", action2.isActive());
    assertEquals(
        "Excpected number of comments of action 2", 0, action2.getWorkflowActionComments().size());

    // test action 3
    final WorkflowAction action3 = getAction(ACTIONCODES.ACTION3.name());
    assertFalse("Action 3 should not be disabled", action3.isDisabled());
    assertFalse("Action 3 should not be completed", action3.isCompleted());
    assertFalse("Action 3 should be inactive", action3.isActive());
    assertEquals(
        "Excpected number of comments of action 3", 0, action3.getWorkflowActionComments().size());

    // test action 4
    final WorkflowAction action4 = getAction(ACTIONCODES.ACTION4.name());
    assertFalse("Action 4 should not be disabled", action4.isDisabled());
    assertFalse("Action 4 should not be completed", action4.isCompleted());
    assertFalse("Action 4 should be inactive", action4.isActive());
    assertEquals(
        "Excpected number of comments of action 4", 0, action4.getWorkflowActionComments().size());

    // test action 5
    final WorkflowAction action5 = getAction(ACTIONCODES.ACTION5.name());
    assertFalse("Action 5 should not be disabled", action5.isDisabled());
    assertFalse("Action 5 should not be completed", action5.isCompleted());
    assertFalse("Action 5 should be inactive", action5.isActive());
    assertEquals(
        "Excpected number of comments of action 5", 0, action5.getWorkflowActionComments().size());

    // test action 6
    final WorkflowAction action6 = getAction(ACTIONCODES.ACTION6.name());
    assertFalse("Action 6 should not be disabled", action6.isDisabled());
    assertFalse("Action 6 should not be completed", action6.isCompleted());
    assertFalse("Action 6 should be inactive", action6.isActive());
    assertEquals(
        "Excpected number of comments of action 6", 0, action6.getWorkflowActionComments().size());

    // complete action 2 with decision 3
    final WorkflowDecision decision3 = getDecision(DECISIONCODES.DECISION3.name(), action2);
    action2.setSelectedDecision(decision3);
    action2.decide();

    assertTrue("Action 1 should be completed", action1.isCompleted());
    assertEquals(
        "Excpected number of comments of action 1", 1, action1.getWorkflowActionComments().size());
    assertTrue("Action 2 should be completed", action2.isCompleted());
    assertEquals(
        "Excpected number of comments of action 2", 1, action2.getWorkflowActionComments().size());
    assertTrue("Action 3 should be active", action3.isActive());
    assertEquals(
        "Excpected number of comments of action 3", 1, action3.getWorkflowActionComments().size());
    assertFalse("Action 4 should be inactive", action4.isActive());
    assertEquals(
        "Excpected number of comments of action 4", 0, action4.getWorkflowActionComments().size());
    assertFalse("Action 5 should be inactive", action5.isActive());
    assertEquals(
        "Excpected number of comments of action 5", 0, action5.getWorkflowActionComments().size());
    assertFalse("Action 6 should be inactive", action6.isActive());
    assertEquals(
        "Excpected number of comments of action 6", 0, action6.getWorkflowActionComments().size());
    assertFalse("Workflow should not be finished", testWorkflow.isFinished());

    // complete action 3 with decision 5
    final WorkflowDecision decision5 = getDecision(DECISIONCODES.DECISION5.name(), action3);
    action3.setSelectedDecision(decision5);
    action3.decide();
    assertTrue("Action 1 should be completed", action1.isCompleted());
    assertEquals(
        "Excpected number of comments of action 1", 1, action1.getWorkflowActionComments().size());
    assertTrue("Action 2 should be completed", action2.isCompleted());
    assertEquals(
        "Excpected number of comments of action 2", 1, action2.getWorkflowActionComments().size());
    assertTrue("Action 3 should be completed", action3.isCompleted());
    assertEquals(
        "Excpected number of comments of action 3", 2, action3.getWorkflowActionComments().size());
    assertFalse("Action 4 should be inactive", action4.isActive());
    assertEquals(
        "Excpected number of comments of action 4", 0, action4.getWorkflowActionComments().size());
    assertTrue("Action 5 should be ended by workflow", action5.isEndedByWorkflow());
    assertEquals(
        "Excpected number of comments of action 5", 0, action5.getWorkflowActionComments().size());
    assertFalse("Action 6 should be inactive", action6.isActive());
    assertEquals(
        "Excpected number of comments of action 6", 1, action6.getWorkflowActionComments().size());
    assertTrue("Workflow should be finished", testWorkflow.isFinished());
  }