### Question:
SAMLUserDetailsServiceImpl implements SAMLUserDetailsService { public Object loadUserBySAML(SAMLCredential credential) throws UsernameNotFoundException { String userID = credential.getNameID().getValue(); LOG.info(userID + " is logged in"); List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(); GrantedAuthority authority = new SimpleGrantedAuthority("ROLE_USER"); authorities.add(authority); return new User(userID, "<abc123>", true, true, true, true, authorities); }  Object loadUserBySAML(SAMLCredential credential);  }### Answer:
@Test public void testLoadUserBySAML() { NameID mockNameID = mock(NameID.class); when(mockNameID.getValue()).thenReturn(USER_NAME); SAMLCredential credentialsMock = mock(SAMLCredential.class); when(credentialsMock.getNameID()).thenReturn(mockNameID); Object actual = userDetailsService.loadUserBySAML(credentialsMock); assertNotNull(actual); assertTrue(actual instanceof User); User user = (User)actual; assertEquals(USER_NAME, user.getUsername()); assertEquals(USER_PASSWORD, user.getPassword()); assertTrue(user.isEnabled()); assertTrue(user.isAccountNonExpired()); assertTrue(user.isCredentialsNonExpired()); assertTrue(user.isAccountNonLocked()); assertEquals(1, user.getAuthorities().size()); List<GrantedAuthority> authorities = new ArrayList<>(user.getAuthorities()); Object authority = authorities.get(0); assertTrue(authority instanceof SimpleGrantedAuthority); assertEquals(USER_ROLE, ((SimpleGrantedAuthority)authority).getAuthority()); }