示例#1
0
  @Test
  public void findAllActiveCandidatesByCompanyId() {
    Candidate notTestedCandidate =
        new CandidateBuilder()
            .withCompany(savedCompany)
            .withStatus(Candidate.Status.NOT_TESTED)
            .build();
    Candidate sentExamCandidate =
        new CandidateBuilder()
            .withCompany(savedCompany)
            .withStatus(Candidate.Status.SENT_EXAM)
            .build();
    Candidate archivedCandidate =
        new CandidateBuilder().withCompany(savedCompany).withStatus(Candidate.Status.HIRED).build();
    candidateDao.save(notTestedCandidate);
    candidateDao.save(sentExamCandidate);
    candidateDao.save(archivedCandidate);

    List<Candidate> result =
        candidateDao.findAllActiveCandidatesByCompanyId(savedCompany.getId(), page1With50PerPage);

    assertEquals(2, result.size());
    assertTrue(result.contains(notTestedCandidate));
    assertTrue(result.contains(sentExamCandidate));
    assertFalse(result.contains(archivedCandidate));
  }
示例#2
0
  @Test
  public void findAllByCompanyIdAndStatus() {

    Candidate notTestedCandidate =
        new CandidateBuilder()
            .withCompany(savedCompany)
            .withStatus(Candidate.Status.NOT_TESTED)
            .build();

    Candidate hiredCandidate =
        new CandidateBuilder().withCompany(savedCompany).withStatus(Candidate.Status.HIRED).build();

    candidateDao.save(notTestedCandidate);
    candidateDao.save(hiredCandidate);

    List<Candidate> result =
        candidateDao.findAllByCompanyIdAndStatus(
            savedCompany.getId(), Candidate.Status.NOT_TESTED, page1With50PerPage);

    assertEquals(1, result.size());
    assertEquals(notTestedCandidate.getId(), result.get(0).getId());

    result =
        candidateDao.findAllByCompanyIdAndStatus(
            savedCompany.getId(), Candidate.Status.HIRED, page1With50PerPage);
    assertEquals(1, result.size());
    assertEquals(hiredCandidate.getId(), result.get(0).getId());
  }
示例#3
0
  @Test
  public void testFindByDate() {

    Company company = new CompanyBuilder().build();

    Candidate candidate1 =
        new CandidateBuilder()
            .withName(new Name("Candidate1"))
            .withEmail("*****@*****.**")
            .withCompany(company)
            .build();
    Candidate candidate2 =
        new CandidateBuilder().withName(new Name("Candidate2")).withCompany(company).build();
    Candidate candidate3 =
        new CandidateBuilder().withName(new Name("Candidate3")).withCompany(company).build();

    companyDao.save(company);
    candidateDao.save(candidate1);
    candidateDao.save(candidate2);
    candidateDao.save(candidate3);

    GregorianCalendar start = new GregorianCalendar();
    start.add(Calendar.HOUR_OF_DAY, -24);
    GregorianCalendar end = new GregorianCalendar();

    List<Candidate> results = candidateDao.findByCompanyIDandDateRange(company.getId(), start, end);
    assertEquals(3, results.size());
  }
示例#4
0
  @Test
  public void findAllArchivedCandidatesByCompanyid() {
    Candidate archivedCandidate1 =
        new CandidateBuilder().withStatus(Candidate.Status.HIRED).withCompany(savedCompany).build();
    Candidate archivedCandidate2 =
        new CandidateBuilder()
            .withStatus(Candidate.Status.BENCHMARKED)
            .withCompany(savedCompany)
            .build();
    Candidate activeCandidate =
        new CandidateBuilder()
            .withStatus(Candidate.Status.READY_FOR_GRADING)
            .withCompany(savedCompany)
            .build();
    candidateDao.save(archivedCandidate1);
    candidateDao.save(archivedCandidate2);
    candidateDao.save(activeCandidate);

    List<Candidate> result =
        candidateDao.findAllArchivedCandidatesByCompanyId(savedCompany.getId(), page1With50PerPage);

    assertEquals(2, result.size());
    assertTrue(result.contains(archivedCandidate1));
    assertTrue(result.contains(archivedCandidate2));
    assertFalse(result.contains(activeCandidate));
  }
示例#5
0
  @Test
  public void save_blankPhoneNumber() {
    Candidate candidate = new CandidateBuilder().withCellPhoneNumber(null).build();
    candidate = candidateDao.save(candidate);
    candidate = candidateDao.findByGuid(candidate.getGuid());

    assertTrue(candidate.getCellPhoneNumber().isBlank());
  }
示例#6
0
  @Test
  public void save_phoneNumber() {
    PhoneNumber phoneNumber = new PhoneNumberBuilder().build();
    Candidate candidate = new CandidateBuilder().withWorkPhoneNumber(phoneNumber).build();

    candidate = candidateDao.save(candidate);
    candidate = candidateDao.findByGuid(candidate.getGuid());

    assertEquals(phoneNumber, candidate.getWorkPhoneNumber());
  }
示例#7
0
  @Test
  public void findByEmailOrNull() {
    String email = TestUtils.uniqueEmail();

    Candidate candidate = new CandidateBuilder().withCompany(savedCompany).withEmail(email).build();

    candidate = candidateDao.save(candidate);

    Candidate found = candidateDao.findByEmailOrNull(email);

    assertEquals(found.getId(), candidate.getId());
  }
示例#8
0
  @Test
  public void save_addNote() {
    Candidate candidate =
        new CandidateBuilder()
            .withCompany(savedCompany)
            .withNotes(new NoteBuilder().withUser(savedUser).build())
            .build();

    candidate = candidateDao.save(candidate);

    candidate = candidateDao.findByGuid(candidate.getGuid());
    assertEquals(1, candidate.getNotes().size());
  }
示例#9
0
  @Test
  public void save_name() {
    Candidate candidate =
        new CandidateBuilder()
            .withCompany(savedCompany)
            .withName(new NameBuilder().build())
            .build();

    candidate = candidateDao.save(candidate);

    Candidate found = candidateDao.findByGuid(candidate.getGuid());
    assertEquals(found.getName(), candidate.getName());
  }
示例#10
0
  @Test
  public void findByEmailAndCompanyIdOrNull() {
    Candidate candidate = new CandidateBuilder().withCompany(savedCompany).build();

    candidate = candidateDao.save(candidate);

    Candidate found =
        candidateDao.findByEmailAndCompanyIdOrNull(candidate.getEmail(), savedCompany.getId());
    assertEquals(candidate.getId(), found.getId());

    assertNull(
        candidateDao.findByEmailAndCompanyIdOrNull(TestUtils.uniqueEmail(), savedCompany.getId()));
  }
示例#11
0
  @Test
  public void findAllByCompanyId() {
    Candidate candidate1 = new CandidateBuilder().withCompany(savedCompany).build();

    Candidate candidate2 = new CandidateBuilder().withCompany(savedCompany).build();

    candidateDao.save(candidate1);
    candidateDao.save(candidate2);

    Long companyId = savedCompany.getId();

    List<Candidate> found = candidateDao.findAllByCompanyId(companyId, page1With50PerPage);
    assertEquals(2, found.size());
  }
示例#12
0
  @Test
  public void beforeSave_completeLastName() {
    Candidate candidate =
        new CandidateBuilder()
            .withStatus(Candidate.Status.INCOMPLETE)
            .withName(new NameBuilder().withFirst("").withMiddle("").withLast("").build())
            .build();
    candidate = candidateDao.save(candidate);

    assertEquals(Candidate.Status.INCOMPLETE, candidate.getStatus());

    candidate.getName().setLast("Prince");
    candidate = candidateDao.save(candidate);

    assertTrue(Candidate.Status.INCOMPLETE != candidate.getStatus());
  }
示例#13
0
  @Test
  public void save_addResume() {
    Candidate candidate =
        new CandidateBuilder()
            .withCompany(savedCompany)
            .withResume(new ResumeBuilder().build())
            .build();

    candidate = candidateDao.save(candidate);
    Resume resume = candidate.getResume();

    assertNotNull(resume.getId());

    candidate = candidateDao.findByGuid(candidate.getGuid());
    assertEquals(resume.getId(), candidate.getResume().getId());
  }
示例#14
0
  @Test
  public void save_addCoverLetter() {
    Candidate candidate =
        new CandidateBuilder()
            .withCompany(savedCompany)
            .withCoverLetter(new CoverLetterBuilder().build())
            .build();

    candidate = candidateDao.save(candidate);
    CoverLetter coverLetter = candidate.getCoverLetter();

    assertNotNull(coverLetter.getId());

    candidate = candidateDao.findByGuid(candidate.getGuid());
    assertEquals(coverLetter.getId(), candidate.getCoverLetter().getId());
  }
示例#15
0
  @Test
  public void save_removeResume() {
    Candidate candidate =
        new CandidateBuilder()
            .withCompany(savedCompany)
            .withResume(new ResumeBuilder().build())
            .build();
    candidate = candidateDao.save(candidate);
    Resume resume = candidate.getResume();

    candidate.setResume(null);
    candidateDao.save(candidate);

    assertNotNull(fileAttachmentDao.findByGuid(resume.getGuid()));

    candidate = candidateDao.findByGuid(candidate.getGuid());
    assertNull(candidate.getResume());
  }
示例#16
0
  @Test
  public void save_removeCoverLetter() {
    Candidate candidate =
        new CandidateBuilder()
            .withCompany(savedCompany)
            .withCoverLetter(new CoverLetterBuilder().build())
            .build();

    candidate = candidateDao.save(candidate);
    CoverLetter coverLetter = candidate.getCoverLetter();

    candidate.setCoverLetter(null);
    candidateDao.save(candidate);

    assertNotNull(fileAttachmentDao.findByGuid(coverLetter.getGuid()));

    candidate = candidateDao.findByGuid(candidate.getGuid());
    assertNull(candidate.getCoverLetter());
  }
示例#17
0
 @Test
 public void findByEmailOrNull_failed() {
   Candidate result = candidateDao.findByEmailOrNull(TestUtils.uniqueEmail());
   assertNull(result);
 }