@Test
public void userShouldBeRegisteredUsingEncryptedPassword() throws Exception{
String password = "password";
RegisterUserDto registerUserDto = createRegisterUserDto("username", password, "email@email.em", null);
EncryptionService realEncryptionService = new EncryptionService(new Md5PasswordEncoder());
TransactionalAuthenticator authenticatorSpy = spy(new TransactionalAuthenticator(pluginLoader, userDao, groupDao,
realEncryptionService, mailService, avatarService, pluginService,
securityFacade, rememberMeServices, sessionStrategy, validator, authenticationManager));
authenticatorSpy.register(registerUserDto);
UserDto expected = new UserDto();
expected.setEmail("email@email.em");
expected.setUsername("username");
expected.setPassword(realEncryptionService.encryptPassword(password));
verify(authenticatorSpy).registerByPlugin(refEq(expected), eq(true), any(BindingResult.class));
verify(authenticatorSpy).storeRegisteredUser(refEq(expected));
}