@Test
  public void testValidateSubmission_shouldCallAllRegisteredActions() {
    TestRepeatControllerAction action = new TestRepeatControllerAction();

    final int NUM_ACTIONS = 5;
    for (int i = 0; i < NUM_ACTIONS; i++) {
      action.addAction(new TestAction(i));
    }

    Collection<FormSubmissionError> errors =
        action.validateSubmission(formEntryContext, new MockHttpServletRequest());

    // Validate all returned errors are merged together
    int i = 0;
    for (FormSubmissionError error : errors) {
      Assert.assertEquals(String.valueOf(i), error.getId());
      i++;
    }

    Assert.assertEquals(NUM_ACTIONS, errors.size());

    // Validate all validation functions are called
    Assert.assertEquals(NUM_ACTIONS, validationCalledActionIds.size());

    action.handleSubmission(formEntrySession, new MockHttpServletRequest());

    // Validate all submission functions are called
    Assert.assertEquals(NUM_ACTIONS, submissionCalledActionIds.size());
  }
 @Test
 public void testBeforeAfterValidateSubmission_shouldCallBeforeAfterHandlers() {
   TestRepeatControllerAction action = new TestRepeatControllerAction();
   action.validateSubmission(formEntryContext, new MockHttpServletRequest());
   Assert.assertTrue(action.beforeValidateSubmissionCalled);
   Assert.assertTrue(action.afterValidateSubmissionCalled);
 }