@Test
public void resetPassword() throws Exception {

    User userAdmin = getUserAdmin();
    Principal principal = mock(Principal.class);
    when(principal.getUser()).thenReturn(userAdmin);
    when(authenticationManager.getCurrentPrincipal()).thenReturn(principal);
    final String randomPassword = sut.generateRandomPassword(RANDOM, RANDOM, RANDOM, RANDOM, RANDOM);
    doNothing().when(authManagerLdapTemplate).modifyAttributes(any(DirContext.class), eq(user), any(ModificationItem[].class));
    sut.resetPassword(user, RANDOM, RANDOM, RANDOM, RANDOM, RANDOM);
    verify(authManagerLdapTemplate).changePassword(user, randomPassword, userAdmin);
    verify(authManagerLdapTemplate, times(2)).getTemplate(userAdmin);
    verify(authManagerLdapTemplate).getCallback(user, randomPassword);
    verify(authManagerLdapTemplate).getCallback(user);
    verify(authManagerLdapTemplate).changeLdapUserPassword(any(DirContext.class), eq(randomPassword), eq(user));
    verify(authManagerLdapTemplate).setLdapUserPasswordResetFlag(any(DirContext.class), eq(user));
}