@Test public void shouldErrorIfCurrentPasswordDoesNotMatch() { final PasswordChangeRequest passwordChangeForm = new PasswordChangeFormTestBuilder() .withConfirmNewPassword(PasswordChangeFormTestBuilder.NEW_PASSWORD) .build(); passwordChangeForm.setCurrentPassword("incorrectPassword"); when(authenticationService.authenticateYazinoUser( "anEmail", passwordChangeForm.getCurrentPassword())) .thenReturn(new PlayerProfileAuthenticationResponse()); when(playerProfileService.findLoginEmailByPlayerId(PLAYER_ID)).thenReturn("anEmail"); getUnderTest().validate(passwordChangeForm, errors); verify(errors) .rejectValue( "currentPassword", ValidationTools.ERROR_CODE_NON_MATCHING, "incorrect password"); }
private void setupYazinoLogin(PasswordChangeRequest passwordChangeForm) { when(authenticationService.authenticateYazinoUser( "anEmail", passwordChangeForm.getCurrentPassword())) .thenReturn(new PlayerProfileAuthenticationResponse(PLAYER_ID)); when(playerProfileService.findLoginEmailByPlayerId(PLAYER_ID)).thenReturn("anEmail"); }