SpecOfferWaveResourceConverter extends AbstractConverter<SpecOfferWaveResource, SpecOfferWave> { @Override public SpecOfferWave convert(final SpecOfferWaveResource source, final SpecOfferWave target) { target.setLicCount(source.getLicCount()); target.setStateCount(source.getStateCount()); target.setBenefitCount(source.getBenefitCount()); target.setTargetCount(source.getTargetCount()); target.setBeginDate(source.getBeginDate()); target.setEndDate(source.getEndDate()); if (source.getSpecOfferId() != null) { SpecOffer specOffer = new SpecOffer(); specOffer.setId(source.getSpecOfferId()); target.setSpecOffer(specOffer); } if (source.getWaveTypeId() != null) { WaveType waveType = new WaveType(); waveType.setId(source.getWaveTypeId()); target.setWaveType(waveType); } return target; }  @Override SpecOfferWave convert(final SpecOfferWaveResource source, final SpecOfferWave target); @Override SpecOfferWave convert(final SpecOfferWaveResource source);  }
@Test public void testConvert() throws Exception { Integer licCount = 1; Integer stateCount = 2; Integer benefitCount = 3; Integer targetCount = 4; Long specOfferId = 3L; SpecOffer specOffer = new SpecOffer(); specOffer.setId(specOfferId); Long waveTypeId = 2L; WaveType waveType = new WaveType(); waveType.setId(waveTypeId); Date beginDate = new Date(); Date endDate = new Date(); SpecOfferWaveResource source = new SpecOfferWaveResource(); source.setLicCount(licCount); source.setStateCount(stateCount); source.setBenefitCount(benefitCount); source.setTargetCount(targetCount); source.setSpecOfferId(specOfferId); source.setWaveTypeId(waveTypeId); source.setBeginDate(beginDate); source.setEndDate(endDate); SpecOfferWave expected = new SpecOfferWave(); expected.setLicCount(licCount); expected.setStateCount(stateCount); expected.setBenefitCount(benefitCount); expected.setTargetCount(targetCount); expected.setSpecOffer(specOffer); expected.setWaveType(waveType); expected.setBeginDate(beginDate); expected.setEndDate(endDate); SpecOfferWave actual = unit.convert(source); assertEquals(expected, actual); }
@Test public void testConvertWithEmptyFields() throws Exception { SpecOfferWaveResource source = new SpecOfferWaveResource(); SpecOfferWave expected = new SpecOfferWave(); SpecOfferWave actual = unit.convert(source); assertEquals(expected, actual); }