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