EnrolmentEnrolmentSubjectConverter extends AbstractConverter<EnrolmentEnrolmentSubject, EnrolmentEnrolmentSubjectResource> { @Override public EnrolmentEnrolmentSubjectResource convert( final EnrolmentEnrolmentSubject source, final EnrolmentEnrolmentSubjectResource target) { target.setId(source.getId()); target.setMark(source.getMark()); if (source.getEnrolment() != null) { target.setEnrolmentId(source.getEnrolment().getId()); } if (source.getEnrolmentSubject() != null) { target.setEnrolmentSubjectId(source.getEnrolmentSubject().getId()); } if (source.getPersonEnrolmentSubject() != null) { target.setPersonEnrolmentSubjectId(source.getPersonEnrolmentSubject().getId()); } return target; }  @Override EnrolmentEnrolmentSubjectResource convert(
	    final EnrolmentEnrolmentSubject source,
	    final EnrolmentEnrolmentSubjectResource target); @Override EnrolmentEnrolmentSubjectResource convert(
	    final EnrolmentEnrolmentSubject source);  }
@Test public void testConvert() throws Exception { Long enrolmentId = 1L; Enrolment enrolment= new Enrolment(); enrolment.setId(enrolmentId); Long enrolmentSubjectId = 2L; EnrolmentSubject enrolmentSubject=new EnrolmentSubject(); enrolmentSubject.setId(enrolmentSubjectId); Long personEnrolmentSubjectId = 3L; PersonEnrolmentSubject personEnrolmentSubject = new PersonEnrolmentSubject(); personEnrolmentSubject.setId(personEnrolmentSubjectId); Double mark = 1.2; EnrolmentEnrolmentSubjectResource expected = new EnrolmentEnrolmentSubjectResource(); expected.setEnrolmentId(enrolmentId); expected.setEnrolmentSubjectId(enrolmentSubjectId); expected.setPersonEnrolmentSubjectId(personEnrolmentSubjectId); expected.setMark(mark); EnrolmentEnrolmentSubject source = new EnrolmentEnrolmentSubject(); source.setEnrolment(enrolment); source.setEnrolmentSubject(enrolmentSubject); source.setPersonEnrolmentSubject(personEnrolmentSubject); source.setMark(mark); EnrolmentEnrolmentSubjectResource actual = unit.convert(source); assertEquals(expected, actual); }
@Test public void testConvertWithNoRelations() throws Exception { Double mark = 1.2; EnrolmentEnrolmentSubjectResource expected = new EnrolmentEnrolmentSubjectResource(); expected.setMark(mark); EnrolmentEnrolmentSubject source = new EnrolmentEnrolmentSubject(); source.setMark(mark); EnrolmentEnrolmentSubjectResource actual = unit.convert(source); assertEquals(expected, actual); }