### Question:
AuthenticationUtilService { public boolean isAuthenticatedUser() { return httpRequest.getUserPrincipal() != 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 isAuthenticatedUser() { AuthenticationUtilService tested = getTested(); { Mockito.when(tested.httpRequest.getUserPrincipal()).thenReturn(null); Assert.assertFalse(tested.isAuthenticatedUser()); } { Mockito.reset(tested.httpRequest); Principal p = Mockito.mock(Principal.class); Mockito.when(tested.httpRequest.getUserPrincipal()).thenReturn(p); Assert.assertTrue(tested.isAuthenticatedUser()); } }