private PlayerProfile setupUpdateEmailAddress(String emailAddress) { PlayerProfile userProfile = getUserProfile(); when(lobbySessionCache.getActiveSession(request)).thenReturn(getLobbySession(userProfile)); PlayerProfile finalUserProfile = getUserProfileWithEmailAddress(emailAddress); when(lobbySessionCache.getActiveSession(request)).thenReturn(getLobbySession(finalUserProfile)); when(playerProfileService.findByPlayerId(userProfile.getPlayerId())) .thenReturn(finalUserProfile); return finalUserProfile; }
private PlayerProfile setupUpdateDisplayName(String displayName) { PlayerProfile userProfile = getUserProfile(); when(lobbySessionCache.getActiveSession(request)).thenReturn(getLobbySession(userProfile)); PlayerProfile finalUserProfile = getUserProfileWithDisplayName(displayName); when(lobbySessionCache.getActiveSession(request)).thenReturn(getLobbySession(finalUserProfile)); when(playerProfileService.findByPlayerId(userProfile.getPlayerId())) .thenReturn(finalUserProfile); return finalUserProfile; }
@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 PlayerProfile setUpUserProfileInfo( final String avatarUrl, final String gender, final String country, final DateTime dateOfBirth) { PlayerProfile userProfile = getUserProfile(); when(lobbySessionCache.getActiveSession(request)).thenReturn(getLobbySession(userProfile)); PlayerProfile finalUserProfile = PlayerProfile.copy(userProfile) .withGender(Gender.getById(gender)) .withCountry(country) .withDateOfBirth(dateOfBirth) .asProfile(); when(lobbySessionCache.getActiveSession(request)).thenReturn(getLobbySession(finalUserProfile)); when(playerProfileService.findByPlayerId(userProfile.getPlayerId())) .thenReturn(finalUserProfile); return finalUserProfile; }
private String[] getIdsToExcludeFromInvitations(final BigDecimal playerId) { LOG.debug("getIdsToExcludeFromInvitations {}", playerId); final List<String> relatedExternalIds = new ArrayList<String>(); final Map<BigDecimal, Relationship> relationships = playerService.getRelationships(playerId); if (relationships != null) { for (final BigDecimal relatedPlayerId : relationships.keySet()) { try { relatedExternalIds.add( playerProfileService.findByPlayerId(relatedPlayerId).getExternalId()); } catch (final Exception e) { LOG.warn("Couldn't get external ID for player: {}", relatedPlayerId); } } } final String[] arr = new String[relatedExternalIds.size()]; for (int i = 0; i < relatedExternalIds.size(); i++) { arr[i] = relatedExternalIds.get(i); } return arr; }
private PlayerProfile setUpPlayerProfile() { PlayerProfile userProfile = getUserProfile(); when(lobbySessionCache.getActiveSession(request)).thenReturn(getLobbySession(userProfile)); when(playerProfileService.findByPlayerId(userProfile.getPlayerId())).thenReturn(userProfile); return userProfile; }
private void setupYazinoLogin(PasswordChangeRequest passwordChangeForm) { when(authenticationService.authenticateYazinoUser( "anEmail", passwordChangeForm.getCurrentPassword())) .thenReturn(new PlayerProfileAuthenticationResponse(PLAYER_ID)); when(playerProfileService.findLoginEmailByPlayerId(PLAYER_ID)).thenReturn("anEmail"); }