@Test
  public void testDetectsNullBeingReturnedFromAuthenticationDao() {
    when(mockUserDetailService.login(
            TEST_VISTA_ID,
            TEST_DIVISION,
            TEST_ACCESS,
            TEST_VERIFY,
            null,
            null,
            TEST_REMOTE_ADDRESS,
            TEST_REMOTE_HOSTNAME))
        .thenReturn(null);

    VistaAuthenticationToken token =
        new VistaAuthenticationToken(
            TEST_VISTA_ID,
            TEST_DIVISION,
            TEST_ACCESS,
            TEST_VERIFY,
            TEST_REMOTE_ADDRESS,
            TEST_REMOTE_HOSTNAME);

    try {
      provider.authenticate(token);
      fail("Should have thrown AuthenticationServiceException");
    } catch (AuthenticationServiceException expected) {
      assertEquals(
          "VistaUserDetailsService returned null, which is an interface contract violation; it should either return an authenticated VistaUserDetails instance or throw an AuthenticationException",
          expected.getMessage());
    }
  }