EnrolmentBenefitResourceConverter extends AbstractConverter<EnrolmentBenefitResource, EnrolmentBenefit> { @Override public EnrolmentBenefit convert(final EnrolmentBenefitResource source, final EnrolmentBenefit target) { if (source.getEnrolmentId() != null) { Enrolment enrolment = new Enrolment(); enrolment.setId(source.getEnrolmentId()); target.setEnrolment(enrolment); } if (source.getBenefitId() != null) { Benefit benefit = new Benefit(); benefit.setId(source.getBenefitId()); target.setBenefit(benefit); } if (source.getPersonPaperId() != null) { PersonPaper personpaper = new PersonPaper(); personpaper.setId(source.getPersonPaperId()); target.setPersonPaper(personpaper); } return target; }  @Override EnrolmentBenefit convert(final EnrolmentBenefitResource source, final EnrolmentBenefit target); @Override EnrolmentBenefit convert(final EnrolmentBenefitResource source);  }
@Test public void testConvert() throws Exception { Long enrolmentId = 1L; Enrolment enrolment = new Enrolment(); enrolment.setId(enrolmentId); Long benefitId = 2L; Benefit benefit = new Benefit(); benefit.setId(benefitId); Long personpaperId = 3L; PersonPaper personpaper = new PersonPaper(); personpaper.setId(personpaperId); EnrolmentBenefit expected = new EnrolmentBenefit(); expected.setEnrolment(enrolment); expected.setBenefit(benefit); expected.setPersonPaper(personpaper); EnrolmentBenefitResource source = new EnrolmentBenefitResource(); source.setBenefitId(benefitId); source.setEnrolmentId(enrolmentId); source.setPersonPaperId(personpaperId); EnrolmentBenefit actual = unit.convert(source); assertEquals(expected, actual); }
@Test public void testConvertWithEmptyFields() throws Exception { EnrolmentBenefit expected = new EnrolmentBenefit(); EnrolmentBenefitResource source = new EnrolmentBenefitResource(); EnrolmentBenefit actual = unit.convert(source); assertEquals(expected, actual); }