@Test public void isValidNonExistingCandidateShouldReturnFalseWhenPhoneAlreadyExists() { final CandidateDTO actualCandidateDto = CandidateDTO.builder().email(CANDIDATE_NEW_EMAIL).phone(CANDIDATE_A_PHONE).build(); final CandidateDTO candidateDtoWithPhone = CandidateDTO.builder().email(CANDIDATE_A_EMAIL).phone(CANDIDATE_A_PHONE).build(); given(this.candidateService.getCandidateDtoByEmail(CANDIDATE_NEW_EMAIL)).willReturn(null); given(this.candidateService.getCandidateDtoByPhone(CANDIDATE_A_PHONE)) .willReturn(candidateDtoWithPhone); boolean result = this.candidateValidatorHelper.isValidNonExistingCandidate(actualCandidateDto); assertThat(result, is(false)); then(this.candidateService.getCandidateDtoByEmail(CANDIDATE_NEW_EMAIL)); then(this.candidateService.getCandidateDtoByPhone(CANDIDATE_A_PHONE)); }
public boolean isValidNonExistingCandidate(CandidateDTO candidateDTO) { this.preValidateNonExistingCandidate(candidateDTO); CandidateDTO candidateDTOByEmail = this.candidateService.getCandidateDtoByEmail(candidateDTO.getEmail()); CandidateDTO candidateDTOByPhone = this.candidateService.getCandidateDtoByPhone(candidateDTO.getPhone()); if (candidateDTOByEmail == null && candidateDTOByPhone == null) { return true; } return false; }
CandidateValidatorHelper { public boolean isValidNonExistingCandidate(CandidateDTO candidateDTO) { this.preValidateNonExistingCandidate(candidateDTO); CandidateDTO candidateDTOByEmail = this.candidateService.getCandidateDtoByEmail(candidateDTO.getEmail()); CandidateDTO candidateDTOByPhone = this.candidateService.getCandidateDtoByPhone(candidateDTO.getPhone()); if (candidateDTOByEmail == null && candidateDTOByPhone == null) { return true; } return false; } }
CandidateValidatorHelper { public boolean isValidNonExistingCandidate(CandidateDTO candidateDTO) { this.preValidateNonExistingCandidate(candidateDTO); CandidateDTO candidateDTOByEmail = this.candidateService.getCandidateDtoByEmail(candidateDTO.getEmail()); CandidateDTO candidateDTOByPhone = this.candidateService.getCandidateDtoByPhone(candidateDTO.getPhone()); if (candidateDTOByEmail == null && candidateDTOByPhone == null) { return true; } return false; }  }
CandidateValidatorHelper { public boolean isValidNonExistingCandidate(CandidateDTO candidateDTO) { this.preValidateNonExistingCandidate(candidateDTO); CandidateDTO candidateDTOByEmail = this.candidateService.getCandidateDtoByEmail(candidateDTO.getEmail()); CandidateDTO candidateDTOByPhone = this.candidateService.getCandidateDtoByPhone(candidateDTO.getPhone()); if (candidateDTOByEmail == null && candidateDTOByPhone == null) { return true; } return false; }  boolean isValidNonExistingCandidate(CandidateDTO candidateDTO); boolean isValidExistingCandidate(CandidateDTO candidateDTO); }
CandidateValidatorHelper { public boolean isValidNonExistingCandidate(CandidateDTO candidateDTO) { this.preValidateNonExistingCandidate(candidateDTO); CandidateDTO candidateDTOByEmail = this.candidateService.getCandidateDtoByEmail(candidateDTO.getEmail()); CandidateDTO candidateDTOByPhone = this.candidateService.getCandidateDtoByPhone(candidateDTO.getPhone()); if (candidateDTOByEmail == null && candidateDTOByPhone == null) { return true; } return false; }  boolean isValidNonExistingCandidate(CandidateDTO candidateDTO); boolean isValidExistingCandidate(CandidateDTO candidateDTO);  }