EnrolmentTypeParametersExtractor extends AbstractParametersExtractor<EnrolmentType> { @Override public Map<String, Object> getParameters(final EnrolmentType entity, final Map<String, Object> parameters) { addParameter(entity.getParent(), enrolmentTypeDao, "parent", parameters); addParameter(entity.getName(), "name", parameters); addParameter(entity.getAbbrName(), "abbrName", parameters); return parameters; }  @Override Map<String, Object> getParameters(final EnrolmentType entity, final Map<String, Object> parameters);  }
@Test public void testGetParameters() throws Exception { Long parentId = 1L; EnrolmentType parent = new EnrolmentType(); parent.setId(parentId); String name = "AddressN"; String abbrname = "fsdfds"; EnrolmentType entity = new EnrolmentType(); entity.setName(name); entity.setAbbrName(abbrname); entity.setParent(parent); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("parent", parent); expected.put("name", name); expected.put("abbrName", abbrname); expected.put("status", RowStatus.ACTIVE); expected.put("userGroups", groups); when(enrolmentTypeDao.getEntityById(anyLong())).thenReturn(parent); Map<String, Object> actual = unit.getParameters(entity); verify(enrolmentTypeDao).getEntityById(parentId); assertEquals(expected, actual); }
@Test public void testGetParametersWithDisabledDefaults() throws Exception { unit.setActive(false); unit.setSecurity(false); String name = "AddressN"; String abbrname = "fsdfds"; EnrolmentType entity = new EnrolmentType(); 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 testGetParametersWithNoRelations() throws Exception { EnrolmentType entity = new EnrolmentType(); 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 testGetParametersWithNoRelationsAndDisabledSecurity() throws Exception { unit.setSecurity(false); EnrolmentType entity = new EnrolmentType(); 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 testGetParametersWithNoRelationsAndDisabledStatus() throws Exception { unit.setActive(false); EnrolmentType entity = new EnrolmentType(); 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 testGetParametersWithNoRelationsAndDisabledDefaults() throws Exception { unit.setActive(false); unit.setSecurity(false); EnrolmentType entity = new EnrolmentType(); Map<String, Object> expected = new HashMap<String, Object>(); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }