@Test(expected = UsernameNotFoundException.class)
public void loadUserByUsernameUserNotFound() throws Exception {

  AmbariKerberosAuthenticationProperties properties = new AmbariKerberosAuthenticationProperties();
  Configuration configuration = createMock(Configuration.class);
  expect(configuration.getKerberosAuthenticationProperties()).andReturn(properties).once();
  Users users = createMock(Users.class);
  expect(users.getUser("user1", UserType.LDAP)).andReturn(null).once();
  expect(users.getUser("user1", UserType.LOCAL)).andReturn(null).once();
  replayAll();
  UserDetailsService userdetailsService = new AmbariAuthToLocalUserDetailsService(configuration, users);
  userdetailsService.loadUserByUsername("user1@EXAMPLE.COM");
  verifyAll();
  Assert.fail("UsernameNotFoundException was not thrown");
}