### Question:
AuthenticationUtilService { public AuthenticatedUserType getAuthenticatedUserType() { if (httpRequest.getUserPrincipal() == null) { return null; } if (httpRequest.isUserInRole(Role.CONTRIBUTOR)) { return AuthenticatedUserType.CONTRIBUTOR; } else if (httpRequest.isUserInRole(Role.PROVIDER)) { return AuthenticatedUserType.PROVIDER; } else { return null; } }  boolean isAuthenticatedUser(); Principal getAuthenticatedUserPrincipal(); boolean isUserInRole(String role); boolean isUserInAnyOfRoles(boolean acceptAdmin, String... roles); boolean isUserInAnyOfRoles(boolean acceptAdmin, Collection<String> roles); String getAuthenticatedProvider(); void checkProviderManagementPermission(String providerName); String getAuthenticatedContributor(boolean forceCreate); boolean updateAuthenticatedContributorProfile(); AuthenticatedUserType getAuthenticatedUserType(); Set<String> getUserRoles(); boolean isAuthenticatedUserOfType(AuthenticatedUserType userType);  }### Answer:
@Test public void getAuthenticatedUserType() { AuthenticationUtilService tested = getTested(); { Mockito.when(tested.httpRequest.getUserPrincipal()).thenReturn(null); Assert.assertNull(tested.getAuthenticatedUserType()); } Principal p = Mockito.mock(Principal.class); { Mockito.reset(tested.httpRequest); Mockito.when(tested.httpRequest.getUserPrincipal()).thenReturn(p); Mockito.when(tested.httpRequest.isUserInRole(Role.PROVIDER)).thenReturn(true); Mockito.when(tested.httpRequest.isUserInRole(Role.CONTRIBUTOR)).thenReturn(false); Assert.assertEquals(AuthenticatedUserType.PROVIDER, tested.getAuthenticatedUserType()); } { Mockito.reset(tested.httpRequest); Mockito.when(tested.httpRequest.getUserPrincipal()).thenReturn(p); Mockito.when(tested.httpRequest.isUserInRole(Role.PROVIDER)).thenReturn(false); Mockito.when(tested.httpRequest.isUserInRole(Role.CONTRIBUTOR)).thenReturn(true); Assert.assertEquals(AuthenticatedUserType.CONTRIBUTOR, tested.getAuthenticatedUserType()); } { Mockito.reset(tested.httpRequest); Mockito.when(tested.httpRequest.getUserPrincipal()).thenReturn(p); Mockito.when(tested.httpRequest.isUserInRole(Role.PROVIDER)).thenReturn(false); Mockito.when(tested.httpRequest.isUserInRole(Role.CONTRIBUTOR)).thenReturn(false); Assert.assertEquals(null, tested.getAuthenticatedUserType()); } }