EnrolmentSubjectConverter extends AbstractConverter<EnrolmentSubject, EnrolmentSubjectResource> { @Override public EnrolmentSubjectResource convert(final EnrolmentSubject source, final EnrolmentSubjectResource target) { target.setId(source.getId()); target.setAbbrName(source.getAbbrName()); target.setIsTesting(source.getIsTesting()); target.setName(source.getName()); if (source.getParent() != null) { target.setParentId(source.getParent().getId()); } return target; }  @Override EnrolmentSubjectResource convert(final EnrolmentSubject source, final EnrolmentSubjectResource target); @Override EnrolmentSubjectResource convert(final EnrolmentSubject source);  }
@Test public void testConvert() throws Exception { String abbrName = "abbr name"; String name = "name"; Integer isTesting = 1; Long parentId = 1L; EnrolmentSubject parent = new EnrolmentSubject(); parent.setId(parentId); EnrolmentSubjectResource expected = new EnrolmentSubjectResource(); expected.setAbbrName(abbrName); expected.setName(name); expected.setIsTesting(isTesting); expected.setParentId(parentId); EnrolmentSubject source = new EnrolmentSubject(); source.setAbbrName(abbrName); source.setName(name); source.setIsTesting(isTesting); source.setParent(parent); EnrolmentSubjectResource actual = unit.convert(source); assertEquals(expected, actual); }
@Test public void testConvertWithNoRelations() throws Exception { String abbrName = "abbr name"; String name = "name"; Integer isTesting = 1; EnrolmentSubjectResource expected = new EnrolmentSubjectResource(); expected.setAbbrName(abbrName); expected.setName(name); expected.setIsTesting(isTesting); EnrolmentSubject source = new EnrolmentSubject(); source.setAbbrName(abbrName); source.setName(name); source.setIsTesting(isTesting); EnrolmentSubjectResource actual = unit.convert(source); assertEquals(expected, actual); }