EnrolmentStatusResourceConverter extends AbstractConverter<EnrolmentStatusResource, EnrolmentStatus> { @Override public EnrolmentStatus convert(final EnrolmentStatusResource source, final EnrolmentStatus target) { target.setIsContract(source.getIsContract()); target.setIsState(source.getIsState()); if (source.getEnrolmentId() != null) { Enrolment enrolment = new Enrolment(); enrolment.setId(source.getEnrolmentId()); target.setEnrolment(enrolment); } if (source.getSpecOfferWaveId() != null) { SpecOfferWave specOfferWave = new SpecOfferWave(); specOfferWave.setId(source.getSpecOfferWaveId()); target.setSpecOfferWave(specOfferWave); } if (source.getEnrolmentStatusTypeId() != null) { EnrolmentStatusType enrolmentStatusType = new EnrolmentStatusType(); enrolmentStatusType.setId(source.getEnrolmentStatusTypeId()); target.setEnrolmentStatusType(enrolmentStatusType); } return target; }  @Override EnrolmentStatus convert(final EnrolmentStatusResource source, final EnrolmentStatus target); @Override EnrolmentStatus convert(final EnrolmentStatusResource source);  }
@Test public void testConvert() throws Exception { Integer isContract = 1; Integer isState = 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 expected = new EnrolmentStatus(); expected.setEnrolment(enrolment); expected.setSpecOfferWave(specOfferWave); expected.setEnrolmentStatusType(enrolmentStatusType); expected.setIsContract(isContract); expected.setIsState(isState); EnrolmentStatusResource source = new EnrolmentStatusResource(); source.setEnrolmentId(enrolmentId); source.setSpecOfferWaveId(specOfferWaveId); source.setEnrolmentStatusTypeId(enrolmentStatusTypeId); source.setIsContract(isContract); source.setIsState(isState); EnrolmentStatus actual = unit.convert(source); assertEquals(expected, actual); }
@Test public void testConvertWithEmptyFields() throws Exception { EnrolmentStatus expected = new EnrolmentStatus(); EnrolmentStatusResource source = new EnrolmentStatusResource(); EnrolmentStatus actual = unit.convert(source); assertEquals(expected, actual); }