@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()); }
@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()); }