MarkScaleExchangeParametersExtractor extends AbstractParametersExtractor<MarkScaleExchange> { @Override public Map<String, Object> getParameters(final MarkScaleExchange entity, final Map<String, Object> parameters) { addParameter(entity.getMarkScale(), markScaleDao, "markScale", parameters); addParameter(entity.getMarkScaleValue(), markScaleValueDao, "markScaleValue", parameters); addParameter(entity.getMarkScaleExchange(), markScaleDao, "markScaleExchange", parameters); addParameter(entity.getMarkScaleExchangeValue(), markScaleValueDao, "markScaleExchangeValue", parameters); addParameter(entity.getMarkMin(), "markMin", parameters); addParameter(entity.getMarkMax(), "markMax", parameters); addParameter(entity.getMarkExchange(), "markExchange", parameters); return parameters; }  @Override Map<String, Object> getParameters(final MarkScaleExchange entity, final Map<String, Object> parameters);  }
@Test public void testGetParameters() throws Exception { Double markMin = 0.0; Double markMax = 10.0; Double markExchange = 5.0; Long markScaleId = 1L; Long markScaleValueId = 1L; Long markScaleExchangeId = 2L; Long markScaleExchangeValueId = 2L; MarkScale markScale = new MarkScale(); markScale.setId(markScaleId); MarkScaleValue markScaleValue = new MarkScaleValue(); markScaleValue.setId(markScaleValueId); MarkScale markScaleExchange = new MarkScale(); markScaleExchange.setId(markScaleExchangeId); MarkScaleValue markScaleExchangeValue = new MarkScaleValue(); markScaleExchangeValue.setId(markScaleExchangeValueId); MarkScaleExchange entity = new MarkScaleExchange(); entity.setMarkMin(markMin); entity.setMarkMax(markMax); entity.setMarkExchange(markExchange); entity.setMarkScale(markScale); entity.setMarkScaleValue(markScaleValue); entity.setMarkScaleExchange(markScaleExchange); entity.setMarkScaleExchangeValue(markScaleExchangeValue); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("markMin", markMin); expected.put("markMax", markMax); expected.put("markExchange", markExchange); expected.put("markScale", markScale); expected.put("markScaleValue", markScaleValue); expected.put("markScaleExchange", markScaleExchange); expected.put("markScaleExchangeValue", markScaleExchangeValue); expected.put("status", RowStatus.ACTIVE); expected.put("userGroups", groups); when(markScaleDao.getEntityById(markScaleId)).thenReturn(markScale); when(markScaleDao.getEntityById(markScaleExchangeId)).thenReturn(markScaleExchange); when(markScaleValueDao.getEntityById(markScaleValueId)).thenReturn(markScaleValue); when(markScaleValueDao.getEntityById(markScaleExchangeValueId)).thenReturn(markScaleExchangeValue); Map<String, Object> actual = unit.getParameters(entity); verify(markScaleDao).getEntityById(markScaleId); verify(markScaleDao).getEntityById(markScaleExchangeId); verify(markScaleValueDao).getEntityById(markScaleValueId); verify(markScaleValueDao).getEntityById(markScaleExchangeValueId); assertEquals(expected, actual); }
@Test public void testGetParametersWithDisabledDefaults() throws Exception { unit.setActive(false); unit.setSecurity(false); Double markMin = 0.0; Double markMax = 10.0; Double markExchange = 5.0; MarkScale markScale = new MarkScale(); markScale.setId(1L); MarkScaleValue markScaleValue = new MarkScaleValue(); markScaleValue.setId(1L); MarkScale markScaleExchange = new MarkScale(); markScaleExchange.setId(2L); MarkScaleValue markScaleExchangeValue = new MarkScaleValue(); markScaleExchangeValue.setId(2L); MarkScaleExchange entity = new MarkScaleExchange(); entity.setMarkMin(markMin); entity.setMarkMax(markMax); entity.setMarkExchange(markExchange); entity.setMarkScale(markScale); entity.setMarkScaleValue(markScaleValue); entity.setMarkScaleExchange(markScaleExchange); entity.setMarkScaleExchangeValue(markScaleExchangeValue); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("markMin", markMin); expected.put("markMax", markMax); expected.put("markExchange", markExchange); expected.put("markScale", markScale); expected.put("markScaleValue", markScaleValue); expected.put("markScaleExchange", markScaleExchange); expected.put("markScaleExchangeValue", markScaleExchangeValue); when(markScaleDao.getEntityById(1l)).thenReturn(markScale); when(markScaleDao.getEntityById(2l)).thenReturn(markScaleExchange); when(markScaleValueDao.getEntityById(1l)).thenReturn(markScaleValue); when(markScaleValueDao.getEntityById(2l)).thenReturn(markScaleExchangeValue); Map<String, Object> actual = unit.getParameters(entity); verify(markScaleDao).getEntityById(1L); verify(markScaleDao).getEntityById(2L); verify(markScaleValueDao).getEntityById(1L); verify(markScaleValueDao).getEntityById(2L); assertEquals(expected, actual); }
@Test public void testGetParametersWithDefaultEntity() throws Exception { MarkScaleExchange entity = new MarkScaleExchange(); 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); MarkScaleExchange entity = new MarkScaleExchange(); 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); MarkScaleExchange entity = new MarkScaleExchange(); 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); MarkScaleExchange entity = new MarkScaleExchange(); Map<String, Object> expected = new HashMap<String, Object>(); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }