MarkScaleParametersExtractor extends AbstractParametersExtractor<MarkScale> { @Override public Map<String, Object> getParameters(final MarkScale entity, final Map<String, Object> parameters) { addParameter(entity.getMarkScaleType(), markScaleTypeDao, "markScaleType", parameters); addParameter(entity.getAbbrName(), "abbrName", parameters); addParameter(entity.getName(), "name", parameters); addParameter(entity.getMarkMin(), "markMin", parameters); addParameter(entity.getMarkMax(), "markMax", parameters); return parameters; }  @Override Map<String, Object> getParameters(final MarkScale entity, final Map<String, Object> parameters);  }
@Test public void testGetParameters() throws Exception { String abbrName = "abbrName"; String name = "name"; Double markMin = 0.0; Double markMax = 10.0;; MarkScaleType markscaleType = new MarkScaleType(); markscaleType.setId(1L); MarkScale entity = new MarkScale(); entity.setAbbrName(abbrName); entity.setName(name); entity.setMarkMin(markMin); entity.setMarkMax(markMax); entity.setMarkScaleType(markscaleType); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("abbrName", abbrName); expected.put("name", name); expected.put("markMin", markMin); expected.put("markMax", markMax); expected.put("markScaleType", markscaleType); expected.put("status", RowStatus.ACTIVE); expected.put("userGroups", groups); when(markScaleTypeDao.getEntityById(anyLong())).thenReturn(markscaleType); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithDisabledDefaults() throws Exception { unit.setActive(false); unit.setSecurity(false); String abbrName = "abbrName"; String name = "name"; Double markMin = 0.0; Double markMax = 10.0;; MarkScaleType markscaleType = new MarkScaleType(); markscaleType.setId(1L); MarkScale entity = new MarkScale(); entity.setAbbrName(abbrName); entity.setName(name); entity.setMarkMin(markMin); entity.setMarkMax(markMax); entity.setMarkScaleType(markscaleType); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("abbrName", abbrName); expected.put("name", name); expected.put("markMin", markMin); expected.put("markMax", markMax); expected.put("markScaleType", markscaleType); when(markScaleTypeDao.getEntityById(anyLong())).thenReturn(markscaleType); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithDefaultEntity() throws Exception { MarkScale entity = new MarkScale(); 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); MarkScale entity = new MarkScale(); 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); MarkScale entity = new MarkScale(); 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); MarkScale entity = new MarkScale(); Map<String, Object> expected = new HashMap<String, Object>(); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }