OrderTypeResourceConverter extends AbstractConverter<OrderTypeResource, OrderType> { @Override public OrderType convert(final OrderTypeResource source, final OrderType target) { target.setAbbrName(source.getAbbrName()); target.setName(source.getName()); if (source.getParentId() != null) { OrderType parent = new OrderType(); parent.setId(source.getParentId()); target.setParent(parent); } return target; }  @Override OrderType convert(final OrderTypeResource source, final OrderType target); @Override OrderType convert(final OrderTypeResource source);  }
@Test public void testConvert() throws Exception { String abbrName = "abbrName"; String name = "name"; Long parentId = 2L; OrderType parent = new OrderType(); parent.setId(parentId); OrderType expected = new OrderType(); expected.setAbbrName(abbrName); expected.setName(name); expected.setParent(parent); OrderTypeResource source = new OrderTypeResource(); source.setAbbrName(abbrName); source.setName(name); source.setParentId(parentId); OrderType actual = unit.convert(source); assertEquals(expected, actual); }
@Test public void testConvertWithNoRelations() throws Exception { String abbrName = "abbrName"; String name = "name"; OrderType expected = new OrderType(); expected.setAbbrName(abbrName); expected.setName(name); OrderTypeResource source = new OrderTypeResource(); source.setAbbrName(abbrName); source.setName(name); OrderType actual = unit.convert(source); assertEquals(expected, actual); }