DefaultUserAuthService implements UserAuthService { @Override public boolean authenticatedUserIsAdmin() { return retriever.hasAdminRole(); } DefaultUserAuthService(UserService userService, AuthenticationInfoRetriever retriever); @Override User getAuthenticatedUser(); @Override String getAuthenticatedUserId(); @Override boolean authenticatedUserIsAdmin(); @Override boolean userIsEffectivelyAManager(User user);  }
@Test public void authenticatedUserIsAdminReturnsTrueWhenUserHasAdminRole() { given(retrieverMock.hasAdminRole()).willReturn(true); boolean actualIsAdmin = userAuthService.authenticatedUserIsAdmin(); assertThat(actualIsAdmin).isTrue(); }
@Test public void authenticatedUserIsAdminReturnsFalseWhenDoesNotHaveAdminRole() { given(retrieverMock.hasAdminRole()).willReturn(false); boolean actualIsAdmin = userAuthService.authenticatedUserIsAdmin(); assertThat(actualIsAdmin).isFalse(); }