EnrolmentSubjectResourceConverter extends AbstractConverter<EnrolmentSubjectResource, EnrolmentSubject> { @Override public EnrolmentSubject convert(final EnrolmentSubjectResource source, final EnrolmentSubject target) { target.setAbbrName(source.getAbbrName()); target.setName(source.getName()); target.setIsTesting(source.getIsTesting()); if (source.getParentId() != null) { EnrolmentSubject parent = new EnrolmentSubject(); parent.setId(source.getParentId()); target.setParent(parent); } return target; }  @Override EnrolmentSubject convert(final EnrolmentSubjectResource source, final EnrolmentSubject target); @Override EnrolmentSubject convert(final EnrolmentSubjectResource 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 source = new EnrolmentSubjectResource(); source.setAbbrName(abbrName); source.setName(name); source.setIsTesting(isTesting); source.setParentId(parentId); EnrolmentSubject expected = new EnrolmentSubject(); expected.setAbbrName(abbrName); expected.setName(name); expected.setIsTesting(isTesting); expected.setParent(parent); EnrolmentSubject actual = unit.convert(source); assertEquals(expected, actual); }
@Test public void testConvertWithNoRelations() throws Exception { String abbrName = "abbr name"; String name = "name"; Integer isTesting = 1; EnrolmentSubjectResource source = new EnrolmentSubjectResource(); source.setAbbrName(abbrName); source.setName(name); source.setIsTesting(isTesting); EnrolmentSubject expected = new EnrolmentSubject(); expected.setAbbrName(abbrName); expected.setName(name); expected.setIsTesting(isTesting); EnrolmentSubject actual = unit.convert(source); assertEquals(expected, actual); }