### Question:
AuthenticationProviderManager extends AbstractService implements IAuthenticationProviderManager { @Override public org.springframework.security.core.userdetails.UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { try { UserDetails localUser = this.extractUser(username, null, false); if (null == localUser) { throw new UsernameNotFoundException("User " + username + " not found"); } org.springframework.security.core.userdetails.User user = new org.springframework.security.core.userdetails.User(username, "", !localUser.isDisabled(), localUser.isAccountNotExpired(), localUser.isCredentialsNotExpired(), true, localUser.getAuthorizations()); return user; } catch (ApsSystemException ex) { logger.error("Error extracting user {}", username, ex); throw new UsernameNotFoundException("Error extracting user " + username, ex); } }  @Override void init(); @Override UserDetails getUser(String username); @Override UserDetails getUser(String username, String password); @Override Authentication authenticate(Authentication authentication); @Override org.springframework.security.core.userdetails.UserDetails loadUserByUsername(String username); void setUserManager(IUserManager userManager); void setAuthorizationManager(IAuthorizationManager authorizationManager); void setTokenManager(IApiOAuth2TokenManager tokenManager);  }### Answer:
@Test public void loadUserByUsername() throws Exception { UserDetails activeUser = this.createMockUser("admin", true, false, false); when(this.userManager.getUser(Mockito.anyString())).thenReturn(activeUser); when(this.authorizationManager.getUserAuthorizations("admin")).thenReturn(this.createMockAuthorization()); org.springframework.security.core.userdetails.UserDetails userDetails = this.authenticationProviderManager.loadUserByUsername("admin"); Assert.assertNotNull(userDetails); Assert.assertEquals("admin", userDetails.getUsername()); Assert.assertEquals(2, userDetails.getAuthorities().size()); Mockito.verify(userManager, Mockito.times(1)).updateLastAccess(Mockito.any(UserDetails.class)); Mockito.verify(userManager, Mockito.times(0)).getUser(Mockito.anyString(), Mockito.anyString()); Mockito.verify(userManager, Mockito.times(1)).getUser(Mockito.anyString()); Mockito.verify(authorizationManager, Mockito.times(1)).getUserAuthorizations(Mockito.anyString()); Mockito.verifyZeroInteractions(this.tokenManager); }