UserGroupViewParametersExtractor extends AbstractParametersExtractor<List<Long>> { @Override protected Map<String, Object> getParameters(final List<Long> entity, final Map<String, Object> parameters) { addParameter(entity, "groupIds", parameters); return parameters; }    }
@Test public void testGetParameters() throws Exception { Long groupId1 = 1L; List<Long> entity = Arrays.asList(groupId1); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("groupIds", entity); expected.put("status", RowStatus.ACTIVE); expected.put("userGroups", groups); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithDisabledSecurity() throws Exception { unit.setSecurity(false); Long groupId1 = 1L; List<Long> entity = Arrays.asList(groupId1); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("groupIds", entity); expected.put("status", RowStatus.ACTIVE); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithDisabledStatus() throws Exception { unit.setActive(false); Long groupId1 = 1L; List<Long> entity = Arrays.asList(groupId1); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("groupIds", entity); 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); Long groupId1 = 1L; List<Long> entity = Arrays.asList(groupId1); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("groupIds", entity); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithDefaultEntity() throws Exception { List<Long> entity = Collections.emptyList(); 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 testGetParametersWithNullEntity() throws Exception { List<Long> entity = null; 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 testGetParametersWithDefaultEntityAndDisabledDefaults() throws Exception { unit.setActive(false); unit.setSecurity(false); List<Long> entity = Collections.emptyList(); Map<String, Object> expected = new HashMap<String, Object>(); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }