@Test public void testGetIdList() { List<String> list = helper.getIdList(createEntityList(true), "id"); assertEquals("Should match", 4, list.size()); assertTrue("Should contain", list.contains("1")); assertTrue("Should contain", list.contains("2")); assertTrue("Should contain", list.contains("3")); assertTrue("Should contain", list.contains("4")); assertFalse("Should not contain", list.contains("5")); list = helper.getIdList(null, "id"); assertEquals("Should match", 0, list.size()); list = helper.getIdList(null, null); assertEquals("Should match", 0, list.size()); list = helper.getIdList(createEntityList(true), ""); assertEquals("Should match", 0, list.size()); }
public List<String> getIdList(List<EntityBody> list, String field) { List<String> ids = new ArrayList<String>(); if (list == null || field == null) { return ids; } for (EntityBody e : list) { if (e.get(field) != null) { ids.add((String) e.get(field)); } } return ids; }
OptionalFieldAppenderHelper { public List<String> getIdList(List<EntityBody> list, String field) { List<String> ids = new ArrayList<String>(); if (list == null || field == null) { return ids; } for (EntityBody e : list) { if (e.get(field) != null) { ids.add((String) e.get(field)); } } return ids; } }
OptionalFieldAppenderHelper { public List<String> getIdList(List<EntityBody> list, String field) { List<String> ids = new ArrayList<String>(); if (list == null || field == null) { return ids; } for (EntityBody e : list) { if (e.get(field) != null) { ids.add((String) e.get(field)); } } return ids; }  }
OptionalFieldAppenderHelper { public List<String> getIdList(List<EntityBody> list, String field) { List<String> ids = new ArrayList<String>(); if (list == null || field == null) { return ids; } for (EntityBody e : list) { if (e.get(field) != null) { ids.add((String) e.get(field)); } } return ids; }  List<EntityBody> queryEntities(String resourceName, String key, List<String> values); List<EntityBody> queryEntities(String resourceName, NeutralQuery query); EntityBody getEntityFromList(List<EntityBody> list, String field, String value); List<EntityBody> getEntitySubList(List<EntityBody> list, String field, String value); List<String> getIdList(List<EntityBody> list, String field); Set<String> getSectionIds(List<EntityBody> entities); }
OptionalFieldAppenderHelper { public List<String> getIdList(List<EntityBody> list, String field) { List<String> ids = new ArrayList<String>(); if (list == null || field == null) { return ids; } for (EntityBody e : list) { if (e.get(field) != null) { ids.add((String) e.get(field)); } } return ids; }  List<EntityBody> queryEntities(String resourceName, String key, List<String> values); List<EntityBody> queryEntities(String resourceName, NeutralQuery query); EntityBody getEntityFromList(List<EntityBody> list, String field, String value); List<EntityBody> getEntitySubList(List<EntityBody> list, String field, String value); List<String> getIdList(List<EntityBody> list, String field); Set<String> getSectionIds(List<EntityBody> entities);  }