EnrolmentStatusConverter extends AbstractConverter<EnrolmentStatus, EnrolmentStatusResource> { @Override public EnrolmentStatusResource convert(final EnrolmentStatus source, final EnrolmentStatusResource target) { target.setId(source.getId()); target.setIsState(source.getIsState()); target.setIsContract(source.getIsContract()); if (source.getEnrolment() != null) { target.setEnrolmentId(source.getEnrolment().getId()); } if (source.getSpecOfferWave() != null) { target.setSpecOfferWaveId(source.getSpecOfferWave().getId()); } if (source.getEnrolmentStatusType() != null) { target.setEnrolmentStatusTypeId(source.getEnrolmentStatusType().getId()); } return target; }  @Override EnrolmentStatusResource convert(final EnrolmentStatus source, final EnrolmentStatusResource target); @Override EnrolmentStatusResource convert(final EnrolmentStatus source);  }
@Test public void testConvert() throws Exception { Integer isState = 1; Integer isContract = 1; Long enrolmentId = 1L; Enrolment enrolment = new Enrolment(); enrolment.setId(enrolmentId); Long specOfferWaveId = 2L; SpecOfferWave specOfferWave = new SpecOfferWave(); specOfferWave.setId(specOfferWaveId); Long enrolmentStatusTypeId = 3L; EnrolmentStatusType enrolmentStatusType = new EnrolmentStatusType(); enrolmentStatusType.setId(enrolmentStatusTypeId); EnrolmentStatus source = new EnrolmentStatus(); source.setEnrolment(enrolment); source.setSpecOfferWave(specOfferWave); source.setEnrolmentStatusType(enrolmentStatusType); source.setIsContract(isContract); source.setIsState(isState); EnrolmentStatusResource expected = new EnrolmentStatusResource(); expected.setEnrolmentId(enrolmentId); expected.setSpecOfferWaveId(specOfferWaveId); expected.setEnrolmentStatusTypeId(enrolmentStatusTypeId); expected.setIsContract(isContract); expected.setIsState(isState); EnrolmentStatusResource actual = unit.convert(source); assertEquals(expected, actual); }
@Test public void testConvertWithEmptyFields() throws Exception { EnrolmentStatus source = new EnrolmentStatus(); EnrolmentStatusResource expected = new EnrolmentStatusResource(); EnrolmentStatusResource actual = unit.convert(source); assertEquals(expected, actual); }