MarkScaleExchangeConverter extends AbstractConverter<MarkScaleExchange, MarkScaleExchangeResource> { @Override public MarkScaleExchangeResource convert(final MarkScaleExchange source, final MarkScaleExchangeResource target) { if (source.getMarkScale() != null) { target.setMarkScaleId(source.getMarkScale().getId()); } if (source.getMarkScaleValue() != null) { target.setMarkScaleValueId(source.getMarkScaleValue().getId()); } if (source.getMarkScaleExchange() != null) { target.setMarkScaleExchangeId(source.getMarkScaleExchange().getId()); } if (source.getMarkScaleExchangeValue() != null) { target.setMarkScaleExchangeValueId(source.getMarkScaleExchangeValue().getId()); } target.setMarkMin(source.getMarkMin()); target.setMarkMax(source.getMarkMax()); target.setMarkExchange(source.getMarkExchange()); target.setId(source.getId()); return target; }  @Override MarkScaleExchangeResource convert(final MarkScaleExchange source, final MarkScaleExchangeResource target); @Override MarkScaleExchangeResource convert(final MarkScaleExchange source);  }
@Test public void testConvertWithNoRelations() throws Exception { Long id = 1L; Double markMin = 0.0; Double markMax = 10.0; Double markExchange = 5.0; MarkScaleExchangeResource expected = new MarkScaleExchangeResource(); expected.setId(id); expected.setMarkMin(markMin); expected.setMarkMax(markMax); expected.setMarkExchange(markExchange); MarkScaleExchange source = new MarkScaleExchange(); source.setId(id); source.setMarkMin(markMin); source.setMarkMax(markMax); source.setMarkExchange(markExchange); MarkScaleExchangeResource actual = unit.convert(source); assertEquals(expected, actual); }
@Test public void testConvert() throws Exception { Long id = 1L; 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 expected = new MarkScaleExchangeResource(); expected.setId(id); expected.setMarkMin(markMin); expected.setMarkMax(markMax); expected.setMarkExchange(markExchange); expected.setMarkScaleId(markscaleId); expected.setMarkScaleValueId(markscaleValueId); expected.setMarkScaleExchangeId(markscaleExchangeId); expected.setMarkScaleExchangeValueId(markscaleExchangeValueId); MarkScaleExchange source = new MarkScaleExchange(); source.setId(id); source.setMarkMin(markMin); source.setMarkMax(markMax); source.setMarkExchange(markExchange); source.setMarkScale(markscale); source.setMarkScaleValue(markscaleValue); source.setMarkScaleExchange(markscaleExchange); source.setMarkScaleExchangeValue(markscaleExchangeValue); MarkScaleExchangeResource actual = unit.convert(source); assertEquals(expected, actual); }