* @param expectedAuthType
* Expected auth type.
*/
private void coreAuthTest(final Object principal, final AuthenticationType expectedAuthType)
{
final PersonModelView retPerson = new PersonModelView();
retPerson.setEntityId(PERSON_ID);
final Date personLastAcceptedTOSDate = new Date();
retPerson.setLastAcceptedTermsOfService(personLastAcceptedTOSDate);
context.checking(new Expectations()
{
{
allowing(authentication).getPrincipal();
will(returnValue(principal));
allowing(getPersonModelViewByAccountIdMapper).execute(ACCOUNT_ID);
will(returnValue(retPerson));
allowing(toSAcceptanceStrategy).isValidTermsOfServiceAcceptanceDate(with(personLastAcceptedTOSDate));
will(returnValue(true));
allowing(systemAdminIdsMapper).execute(null);
will(returnValue(Collections.EMPTY_LIST));
}
});
PrincipalActionContext actionContext = TestContextCreator.createPrincipalActionContext(null, ACCOUNT_ID, 0);
PersonModelView result = (PersonModelView) sut.execute(actionContext);
context.assertIsSatisfied();
assertEquals(expectedAuthType, result.getAuthenticationType());
}