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