DefaultLdapUserDetailsService extends LdapUserDetailsService { @Override public UserDetails loadUserByUsername( String username ) throws UsernameNotFoundException { return super.loadUserByUsername( userNameUtils.getPrincipleName( username ) ); } DefaultLdapUserDetailsService( LdapUserSearch userSearch, LdapAuthoritiesPopulator authoritiesPopulator,
      ITenantedPrincipleNameResolver userNameUtils ); @Override UserDetails loadUserByUsername( String username );  }
@Test public void testLoadUserByUsername() throws Exception { DefaultLdapUserDetailsService service = spy( new DefaultLdapUserDetailsService( userSearch, authPop, usernameUtils ) ); when( usernameUtils.getPrincipleName( anyString() ) ).thenReturn( "admin" ); try { service.loadUserByUsername( "JOE" ); } catch ( NullPointerException npe ) { verify( usernameUtils ).getPrincipleName( "JOE" ); } }