MarkScaleResourceConverter extends AbstractConverter<MarkScaleResource, MarkScale> { @Override public MarkScale convert(final MarkScaleResource source, final MarkScale target) { if (source.getMarkScaleTypeId() != null) { MarkScaleType markScaleType = new MarkScaleType(); markScaleType.setId(source.getMarkScaleTypeId()); target.setMarkScaleType(markScaleType); } target.setAbbrName(source.getAbbrName()); target.setName(source.getName()); target.setMarkMin(source.getMarkMin()); target.setMarkMax(source.getMarkMax()); return target; }  @Override MarkScale convert(final MarkScaleResource source, final MarkScale target); @Override MarkScale convert(final MarkScaleResource source);  }
@Test public void testConvert() throws Exception { String abbrName = "abbrName"; String name = "name"; Double markMin = 0.0; Double markMax = 10.0; Long markscaleTypeId = 1L; MarkScaleType markscaleType = new MarkScaleType(); markscaleType.setId(markscaleTypeId); MarkScaleResource source = new MarkScaleResource(); source.setAbbrName(abbrName); source.setName(name); source.setMarkMin(markMin); source.setMarkMax(markMax); source.setMarkScaleTypeId(markscaleTypeId); MarkScale expected = new MarkScale(); expected.setAbbrName(abbrName); expected.setName(name); expected.setMarkMin(markMin); expected.setMarkMax(markMax); expected.setMarkScaleType(markscaleType); MarkScale actual = unit.convert(source); assertEquals(expected, actual); }
@Test public void testConvertWithNoRelations() throws Exception { String abbrName = "abbrName"; String name = "name"; Double markMin = 0.0; Double markMax = 10.0; MarkScaleResource source = new MarkScaleResource(); source.setAbbrName(abbrName); source.setName(name); source.setMarkMin(markMin); source.setMarkMax(markMax); MarkScale expected = new MarkScale(); expected.setAbbrName(abbrName); expected.setName(name); expected.setMarkMin(markMin); expected.setMarkMax(markMax); MarkScale actual = unit.convert(source); assertEquals(expected, actual); }