SpecOfferWaveParametersExtractor extends AbstractParametersExtractor<SpecOfferWave> { @Override protected Map<String, Object> getParameters(final SpecOfferWave entity, final Map<String, Object> parameters) { addParameter(entity.getSpecOffer(), specOfferDao, "specOffer", parameters); addParameter(entity.getWaveType(), waveTypeDao, "waveType", parameters); addParameter(entity.getLicCount(), "licCount", parameters); addParameter(entity.getStateCount(), "stateCount", parameters); addParameter(entity.getBenefitCount(), "benefitCount", parameters); addParameter(entity.getTargetCount(), "targetCount", parameters); addParameter(entity.getBeginDate(), "beginDate", parameters); addParameter(entity.getEndDate(), "endDate", parameters); return parameters; }    }
@Test public void testGetParameters() throws Exception { Long specOfferId = 1L; SpecOffer specOffer = new SpecOffer(); specOffer.setId(specOfferId); Long waveTypeId = 2L; WaveType waveType = new WaveType(); waveType.setId(waveTypeId); Integer licCount = 1; Integer stateCount = 2; Integer benefitCount = 3; Integer targetCount = 4; Date beginDate = new Date(); Date endDate = new Date(); SpecOfferWave entity = new SpecOfferWave(); entity.setSpecOffer(specOffer); entity.setWaveType(waveType); entity.setLicCount(licCount); entity.setStateCount(stateCount); entity.setBenefitCount(benefitCount); entity.setTargetCount(targetCount); entity.setBeginDate(beginDate); entity.setEndDate(endDate); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("specOffer", specOffer); expected.put("waveType", waveType); expected.put("licCount", licCount); expected.put("stateCount", stateCount); expected.put("benefitCount", benefitCount); expected.put("targetCount", targetCount); expected.put("status", RowStatus.ACTIVE); expected.put("userGroups", groups); expected.put("beginDate", beginDate); expected.put("endDate",endDate); when(specOfferDao.getEntityById(anyLong())).thenReturn(specOffer); when(waveTypeDao.getEntityById(anyLong())).thenReturn(waveType); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersAndDisabledDefaults() throws Exception { unit.setActive(false); unit.setSecurity(false); Long specOfferId = 1L; SpecOffer specOffer = new SpecOffer(); specOffer.setId(specOfferId); Long waveTypeId = 2L; WaveType waveType = new WaveType(); waveType.setId(waveTypeId); Integer licCount = 1; Integer stateCount = 2; Integer benefitCount = 3; Integer targetCount = 4; Date beginDate = new Date(); Date endDate = new Date(); SpecOfferWave entity = new SpecOfferWave(); entity.setSpecOffer(specOffer); entity.setWaveType(waveType); entity.setLicCount(licCount); entity.setStateCount(stateCount); entity.setBenefitCount(benefitCount); entity.setTargetCount(targetCount); entity.setBeginDate(beginDate); entity.setEndDate(endDate); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("specOffer", specOffer); expected.put("waveType", waveType); expected.put("licCount", licCount); expected.put("stateCount", stateCount); expected.put("benefitCount", benefitCount); expected.put("targetCount", targetCount); expected.put("beginDate", beginDate); expected.put("endDate",endDate); when(specOfferDao.getEntityById(anyLong())).thenReturn(specOffer); when(waveTypeDao.getEntityById(anyLong())).thenReturn(waveType); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithDefaultEntity() throws Exception { SpecOfferWave entity = new SpecOfferWave(); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("status", RowStatus.ACTIVE); expected.put("userGroups", groups); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithDefaultEntityAndDisabledSecurity() throws Exception { unit.setSecurity(false); SpecOfferWave entity = new SpecOfferWave(); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("status", RowStatus.ACTIVE); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithDefaultEntityAndDisabledStatus() throws Exception { unit.setActive(false); SpecOfferWave entity = new SpecOfferWave(); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("userGroups", groups); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithDefaultEntityAndDisabledDefaults() throws Exception { unit.setActive(false); unit.setSecurity(false); SpecOfferWave entity = new SpecOfferWave(); Map<String, Object> expected = new HashMap<String, Object>(); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }