MarkScaleExchangeResourceConverter extends AbstractConverter<MarkScaleExchangeResource, MarkScaleExchange> { @Override public MarkScaleExchange convert(final MarkScaleExchangeResource source, final MarkScaleExchange target) { if (source.getMarkScaleId() != null) { MarkScale markScale = new MarkScale(); markScale.setId(source.getMarkScaleId()); target.setMarkScale(markScale); } if (source.getMarkScaleValueId() != null) { MarkScaleValue markScaleValue = new MarkScaleValue(); markScaleValue.setId(source.getMarkScaleValueId()); target.setMarkScaleValue(markScaleValue); } if (source.getMarkScaleExchangeId() != null) { MarkScale markScaleExchange = new MarkScale(); markScaleExchange.setId(source.getMarkScaleExchangeId()); target.setMarkScaleExchange(markScaleExchange); } if (source.getMarkScaleExchangeValueId() != null) { MarkScaleValue markScaleExchangeValue = new MarkScaleValue(); markScaleExchangeValue.setId(source.getMarkScaleExchangeValueId()); target.setMarkScaleExchangeValue(markScaleExchangeValue); } target.setMarkMin(source.getMarkMin()); target.setMarkMax(source.getMarkMax()); target.setMarkExchange(source.getMarkExchange()); return target; }  @Override MarkScaleExchange convert(final MarkScaleExchangeResource source, final MarkScaleExchange target); @Override MarkScaleExchange convert(final MarkScaleExchangeResource source);  }
@Test public void testConvert() throws Exception { Double markMin = 0.0; Double markMax = 10.0; Double markExchange = 5.0; Long markscaleId = 1L; MarkScale markscale = new MarkScale(); markscale.setId(markscaleId); Long markscaleValueId = 1L; MarkScaleValue markscaleValue = new MarkScaleValue(); markscaleValue.setId(markscaleValueId); Long markscaleExchangeId = 2L; MarkScale markscaleExchange = new MarkScale(); markscaleExchange.setId(markscaleExchangeId); Long markscaleExchangeValueId = 2L; MarkScaleValue markscaleExchangeValue = new MarkScaleValue(); markscaleExchangeValue.setId(markscaleExchangeValueId); MarkScaleExchangeResource source = new MarkScaleExchangeResource(); source.setMarkMin(markMin); source.setMarkMax(markMax); source.setMarkExchange(markExchange); source.setMarkScaleId(markscaleId); source.setMarkScaleValueId(markscaleValueId); source.setMarkScaleExchangeId(markscaleExchangeId); source.setMarkScaleExchangeValueId(markscaleExchangeValueId); MarkScaleExchange expected = new MarkScaleExchange(); expected.setMarkMin(markMin); expected.setMarkMax(markMax); expected.setMarkExchange(markExchange); expected.setMarkScale(markscale); expected.setMarkScaleValue(markscaleValue); expected.setMarkScaleExchange(markscaleExchange); expected.setMarkScaleExchangeValue(markscaleExchangeValue); MarkScaleExchange actual = unit.convert(source); assertEquals(expected, actual); }
@Test public void testConvertWithNoRelations() throws Exception { Double markMin = 0.0; Double markMax = 10.0; Double markExchange = 5.0; MarkScaleExchangeResource source = new MarkScaleExchangeResource(); source.setMarkMin(markMin); source.setMarkMax(markMax); source.setMarkExchange(markExchange); MarkScaleExchange expected = new MarkScaleExchange(); expected.setMarkMin(markMin); expected.setMarkMax(markMax); expected.setMarkExchange(markExchange); MarkScaleExchange actual = unit.convert(source); assertEquals(expected, actual); }