SpecOfferTypeParametersExtractor extends AbstractParametersExtractor<SpecOfferType> { @Override public Map<String, Object> getParameters(final SpecOfferType entity, final Map<String, Object> parameters) { addParameter(entity.getAbbrName(), "abbrName", parameters); addParameter(entity.getName(), "name", parameters); addParameter(entity.getTimePeriod(), timePeriodDao, "timePeriod", parameters); return parameters; }  @Override Map<String, Object> getParameters(final SpecOfferType entity, final Map<String, Object> parameters);  }
@Test public void testGetParameters() throws Exception { Long specialTypeId = 2L; TimePeriod timePeriod = new TimePeriod(); timePeriod.setId(specialTypeId); String name = "name"; String abbrName = "abbr name"; SpecOfferType entity = new SpecOfferType(); entity.setTimePeriod(timePeriod); entity.setName(name); entity.setAbbrName(abbrName); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("name", name); expected.put("abbrName", abbrName); expected.put("timePeriod", timePeriod); expected.put("status", RowStatus.ACTIVE); expected.put("userGroups", groups); when(timePeriodDao.getEntityById(anyLong())).thenReturn(timePeriod); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersAndDisabledDefaults() throws Exception { unit.setActive(false); unit.setSecurity(false); Long timePeriodId = 2L; TimePeriod timePeriod = new TimePeriod(); timePeriod.setId(timePeriodId); String name = "name"; String abbrName = "abbr name"; SpecOfferType entity = new SpecOfferType(); entity.setTimePeriod(timePeriod); entity.setName(name); entity.setAbbrName(abbrName); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("name", name); expected.put("abbrName", abbrName); expected.put("timePeriod", timePeriod); when(timePeriodDao.getEntityById(anyLong())).thenReturn(timePeriod); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithDefaultEntity() throws Exception { SpecOfferType entity = new SpecOfferType(); 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); SpecOfferType entity = new SpecOfferType(); 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); SpecOfferType entity = new SpecOfferType(); 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); SpecOfferType entity = new SpecOfferType(); Map<String, Object> expected = new HashMap<String, Object>(); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }