AdminUnitTypeParametersExtractor extends AbstractParametersExtractor<AdminUnitType> { @Override protected Map<String, Object> getParameters(final AdminUnitType entity, final Map<String, Object> parameters) { addParameter(entity.getAbbrName(), "abbrName", parameters); addParameter(entity.getName(), "name", parameters); return parameters; }    }
@Test public void testGetParameters() throws Exception { String name = "AdminUnitN"; String abbrName = "AN"; AdminUnitType entity = new AdminUnitType(); entity.setName(name); entity.setAbbrName(abbrName); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("name", name); expected.put("abbrName", abbrName); expected.put("status", RowStatus.ACTIVE); 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 = "AdminUnitN"; String abbrName = "AN"; AdminUnitType entity = new AdminUnitType(); entity.setName(name); entity.setAbbrName(abbrName); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("name", name); expected.put("abbrName", abbrName); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithoutDefaultParameters() throws Exception { unit.setActive(false); unit.setSecurity(false); String name = "AdminUnitN"; String abbrName = "AN"; AdminUnitType entity = new AdminUnitType(); entity.setName(name); entity.setAbbrName(abbrName); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("name", name); expected.put("abbrName", abbrName); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithoutStatus() throws Exception { unit.setActive(false); String name = "AdminUnitN"; String abbrName = "AN"; AdminUnitType entity = new AdminUnitType(); entity.setName(name); entity.setAbbrName(abbrName); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("name", name); expected.put("abbrName", abbrName); expected.put("userGroups", groups); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithoutSecurity() throws Exception { unit.setSecurity(false); String name = "AdminUnitN"; String abbrName = "AN"; AdminUnitType entity = new AdminUnitType(); entity.setName(name); entity.setAbbrName(abbrName); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("name", name); expected.put("abbrName", abbrName); expected.put("status", RowStatus.ACTIVE); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithDefaultEntity() throws Exception { AdminUnitType entity = new AdminUnitType(); 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); }