service.setUserService(userService);
service.setSpringContextService(springContextService);
service.afterPropertiesSet();
when(userService.isUserLoggedIn()).thenReturn(false);
FederatedUser currentUser = service.getCurrentUser();
assertNull(currentUser);
when(userService.isUserLoggedIn()).thenReturn(true);
when(userService.getCurrentUser()).thenReturn(user);
when(userService.isUserAdmin()).thenReturn(true);
currentUser = service.getCurrentUser();
assertEquals(user.getEmail(), currentUser.getEmailAddress());
assertEquals(user.getAuthDomain(), currentUser.getAuthenticationDomain());
assertEquals(OpenIdProvider.GOOGLE, currentUser.getOpenIdProvider()); // because auth domain is "google.com"
assertEquals(user.getUserId(), currentUser.getUserId());
assertEquals(user.getFederatedIdentity(), currentUser.getFederatedIdentity());
assertTrue(currentUser.isAdmin());
when(userService.isUserLoggedIn()).thenReturn(true);
when(userService.getCurrentUser()).thenReturn(user);
when(userService.isUserAdmin()).thenReturn(false);
currentUser = service.getCurrentUser();
assertEquals(user.getEmail(), currentUser.getEmailAddress());
assertEquals(user.getAuthDomain(), currentUser.getAuthenticationDomain());
assertEquals(OpenIdProvider.GOOGLE, currentUser.getOpenIdProvider()); // because auth domain is "google.com"
assertEquals(user.getUserId(), currentUser.getUserId());
assertEquals(user.getFederatedIdentity(), currentUser.getFederatedIdentity());
assertFalse(currentUser.isAdmin());
}