TimePeriodParametersExtractor extends AbstractParametersExtractor<TimePeriod> { @Override public Map<String, Object> getParameters(final TimePeriod entity, final Map<String, Object> parameters) { addParameter(entity.getBegDate(), "begDate", parameters); addParameter(entity.getEndDate(), "endDate", parameters); addParameter(entity.getName(), "name", parameters); addParameter(entity.getNumValue(), "numValue", parameters); addParameter(entity.getParent(), timePeriodDao, "parent", parameters); addParameter(entity.getTimePeriodType(), timePeriodTypeDao, "timePeriodType", parameters); return parameters; }  @Override Map<String, Object> getParameters(final TimePeriod entity, final Map<String, Object> parameters);  }
@Test public void testGetParameters() throws Exception { String name = "Extract Me All"; TimePeriod entity = new TimePeriod(); entity.setName(name); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("name", name); expected.put("status", RowStatus.ACTIVE); expected.put("userGroups", groups); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithDisabledSecurity() throws Exception { unit.setSecurity(false); String name = "Extract Me All"; TimePeriod entity = new TimePeriod(); entity.setName(name); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("name", name); expected.put("status", RowStatus.ACTIVE); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithDisabledStatus() throws Exception { unit.setActive(false); String name = "Extract Me All"; TimePeriod entity = new TimePeriod(); entity.setName(name); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("name", name); expected.put("userGroups", groups); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithDisabledDefaults() throws Exception { unit.setActive(false); unit.setSecurity(false); String name = "Extract Me All"; TimePeriod entity = new TimePeriod(); entity.setName(name); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("name", name); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithDefaultEntity() throws Exception { TimePeriod entity = new TimePeriod(); 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 testGetParametersWithDefaultEntityAndDisabledDefaults() throws Exception { unit.setActive(false); unit.setSecurity(false); TimePeriod entity = new TimePeriod(); Map<String, Object> expected = new HashMap<String, Object>(); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }