SpecOfferWaveConverter extends AbstractConverter<SpecOfferWave, SpecOfferWaveResource> { @Override public SpecOfferWaveResource convert(final SpecOfferWave source, final SpecOfferWaveResource target) { target.setId(source.getId()); 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.getSpecOffer() != null) { target.setSpecOfferId(source.getSpecOffer().getId()); } if (source.getWaveType() != null) { target.setWaveTypeId(source.getWaveType().getId()); } return target; }  @Override SpecOfferWaveResource convert(final SpecOfferWave source, final SpecOfferWaveResource target); @Override SpecOfferWaveResource convert(final SpecOfferWave 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 begDate = new Date(); Date endDate = new Date(); SpecOfferWaveResource expected = new SpecOfferWaveResource(); expected.setLicCount(licCount); expected.setStateCount(stateCount); expected.setBenefitCount(benefitCount); expected.setTargetCount(targetCount); expected.setSpecOfferId(specOfferId); expected.setWaveTypeId(waveTypeId); expected.setBeginDate(begDate); expected.setEndDate(endDate); SpecOfferWave source = new SpecOfferWave(); source.setLicCount(licCount); source.setStateCount(stateCount); source.setBenefitCount(benefitCount); source.setTargetCount(targetCount); source.setSpecOffer(specOffer); source.setWaveType(waveType); source.setBeginDate(begDate); source.setEndDate(endDate); SpecOfferWaveResource actual = unit.convert(source); assertEquals(expected, actual); }
@Test public void testConvertWithEmptyFields() throws Exception { SpecOfferWaveResource expected = new SpecOfferWaveResource(); SpecOfferWave source = new SpecOfferWave(); SpecOfferWaveResource actual = unit.convert(source); assertEquals(expected, actual); }