@Test
 public void testSaveAndProceedNext_UnverifiedAddRoles() {
   getAccountConfigurationData().getRoles().add(INVESTIGATOR);
   setUpGridSessionInformation(INVESTIGATOR.getGroupName());
   FirebirdWebTestUtility.setCurrentUser(action, user);
   assertEquals(
       VerificationPageFlowAction.FUNCTIONALITY_WARNING_RETURN, action.saveAndProceedNext());
 }
 @Test
 public void testSaveAndProceedNext_ExistingUser()
     throws ValidationException, GridInvocationException {
   FirebirdWebTestUtility.setCurrentUser(action, user);
   assertEquals(VerificationPageFlowAction.MY_ACCOUNT_RETURN, action.saveAndProceedNext());
   verify(mockAccountService).addRoles(user, action.getAccountConfigurationData());
   verify(getMockSession()).setAttribute(FirebirdUIConstants.ROLES_UPDATED, true);
 }
 @Test
 public void testSaveAndProceedNext_GridInvocationException()
     throws ValidationException, GridInvocationException {
   FirebirdWebTestUtility.setCurrentUser(action, user);
   GridInvocationException mockGridInvocationException = mock(GridInvocationException.class);
   doThrow(mockGridInvocationException)
       .when(mockAccountService)
       .addRoles(eq(user), any(AccountConfigurationData.class));
   assertEquals(ActionSupport.INPUT, action.saveAndProceedNext());
   assertTrue(action.hasActionErrors());
 }
  @Test
  public void testPrepare() {
    FirebirdUser user = FirebirdUserFactory.getInstance().create();
    Organization annualRegistrationSponsor = OrganizationFactory.getInstance().create();
    Organization verifiedSponsor = OrganizationFactory.getInstance().create();
    Organization unverifiedSponsor = OrganizationFactory.getInstance().create();
    SponsorRole verifiedRole = user.addSponsorRepresentativeRole(verifiedSponsor);
    SponsorRole unverifiedRole = user.addSponsorRepresentativeRole(unverifiedSponsor);
    user.addSponsorRepresentativeRole(annualRegistrationSponsor);
    FirebirdWebTestUtility.setCurrentUser(action, user);
    UserSessionInformation userSessionInformation =
        UserSessionInformationFactory.getInstance()
            .create(user.getUsername(), verifiedRole.getVerifiedSponsorGroupName());
    FirebirdWebTestUtility.setUpGridSessionInformation(action, userSessionInformation);
    when(mockSponsorService.getSponsorOrganizationWithAnnualRegistrations())
        .thenReturn(annualRegistrationSponsor);

    action.prepare();

    assertEquals(1, action.getUnverifiedSponsorRoles().size());
    assertEquals(unverifiedRole, action.getUnverifiedSponsorRoles().get(0));
  }
 public void setUpGridSessionInformation(String... groupNames) {
   UserSessionInformation sessionInformation =
       UserSessionInformationFactory.getInstance().create(user.getUsername(), groupNames);
   FirebirdWebTestUtility.setUpGridSessionInformation(action, sessionInformation);
 }