### Question:
AuthenticationUtilService { public Principal getAuthenticatedUserPrincipal() { return httpRequest.getUserPrincipal(); }  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 getAuthenticatedUserPrincipal() { AuthenticationUtilService tested = getTested(); { Mockito.when(tested.httpRequest.getUserPrincipal()).thenReturn(null); Assert.assertNull(tested.getAuthenticatedUserPrincipal()); } { Mockito.reset(tested.httpRequest); Principal p = Mockito.mock(Principal.class); Mockito.when(tested.httpRequest.getUserPrincipal()).thenReturn(p); Assert.assertEquals(p, tested.getAuthenticatedUserPrincipal()); } }