MarkScaleValueConverter extends AbstractConverter<MarkScaleValue, MarkScaleValueResource> { @Override public MarkScaleValueResource convert(final MarkScaleValue source, final MarkScaleValueResource target) { if (source.getMarkScale() != null) { target.setMarkScaleId(source.getMarkScale().getId()); } target.setStrValue(source.getStrValue()); target.setId(source.getId()); return target; }  @Override MarkScaleValueResource convert(final MarkScaleValue source, final MarkScaleValueResource target); @Override MarkScaleValueResource convert(final MarkScaleValue source);  }
@Test public void testConvert() throws Exception { Long id = 1L; String strValue = "strValue"; Long markscaleId = 1L; MarkScale markscale = new MarkScale(); markscale.setId(markscaleId); MarkScaleValueResource expected = new MarkScaleValueResource(); expected.setId(id); expected.setStrValue(strValue); expected.setMarkScaleId(markscaleId); MarkScaleValue source = new MarkScaleValue(); source.setId(id); source.setStrValue(strValue); source.setMarkScale(markscale); MarkScaleValueResource actual = unit.convert(source); assertEquals(expected, actual); }
@Test public void testConvertWithNoRelations() throws Exception { Long id = 1L; String strValue = "strValue"; MarkScaleValueResource expected = new MarkScaleValueResource(); expected.setId(id); expected.setStrValue(strValue); MarkScaleValue source = new MarkScaleValue(); source.setId(id); source.setStrValue(strValue); MarkScaleValueResource actual = unit.convert(source); assertEquals(expected, actual); }