SpecOfferBenefitResourceConverter extends AbstractConverter<SpecOfferBenefitResource, SpecOfferBenefit> { @Override public SpecOfferBenefit convert(final SpecOfferBenefitResource source, final SpecOfferBenefit target) { if (source.getBenefitId() != null) { Benefit benefit = new Benefit(); benefit.setId(source.getBenefitId()); target.setBenefit(benefit); } if (source.getSpecOfferId() != null) { SpecOffer specOffer = new SpecOffer(); specOffer.setId(source.getSpecOfferId()); target.setSpecOffer(specOffer); } return target; }  @Override SpecOfferBenefit convert(final SpecOfferBenefitResource source, final SpecOfferBenefit target); @Override SpecOfferBenefit convert(final SpecOfferBenefitResource source);  }
@Test public void testConvert() throws Exception { Long specOfferId = 2L; Long benefitId = 1L; SpecOfferBenefitResource source = new SpecOfferBenefitResource(); source.setBenefitId(benefitId); source.setSpecOfferId(specOfferId); Benefit benefit = new Benefit(); benefit.setId(benefitId); SpecOffer specOffer = new SpecOffer(); specOffer.setId(specOfferId); SpecOfferBenefit expected = new SpecOfferBenefit(); expected.setBenefit(benefit); expected.setSpecOffer(specOffer); SpecOfferBenefit actual = unit.convert(source); assertEquals(expected, actual); }
@Test public void testConvertWithNoRelations() throws Exception { SpecOfferBenefitResource source = new SpecOfferBenefitResource(); SpecOfferBenefit expected = new SpecOfferBenefit(); SpecOfferBenefit actual = unit.convert(source); assertEquals(expected, actual); }