@Test public void testGetEntityFromList() { EntityBody body = helper.getEntityFromList(createEntityList(true), "field1", "2"); assertEquals("Should match", "2", body.get("field1")); assertEquals("Should match", "2", body.get("field2")); assertEquals("Should match", "2", body.get("id")); body = helper.getEntityFromList(null, "field1", "2"); assertNull("Should be null", body); body = helper.getEntityFromList(createEntityList(true), null, "2"); assertNull("Should be null", body); body = helper.getEntityFromList(createEntityList(true), "field1", null); assertNull("Should be null", body); body = helper.getEntityFromList(null, null, null); assertNull("Should be null", body); body = helper.getEntityFromList(createEntityList(true), "", ""); assertNull("Should be null", body); }
public EntityBody getEntityFromList(List<EntityBody> list, String field, String value) { if (list == null || field == null || value == null) { return null; } for (EntityBody e : list) { if (value.equals(e.get(field))) { return e; } } return null; }
OptionalFieldAppenderHelper { public EntityBody getEntityFromList(List<EntityBody> list, String field, String value) { if (list == null || field == null || value == null) { return null; } for (EntityBody e : list) { if (value.equals(e.get(field))) { return e; } } return null; } }
OptionalFieldAppenderHelper { public EntityBody getEntityFromList(List<EntityBody> list, String field, String value) { if (list == null || field == null || value == null) { return null; } for (EntityBody e : list) { if (value.equals(e.get(field))) { return e; } } return null; }  }
OptionalFieldAppenderHelper { public EntityBody getEntityFromList(List<EntityBody> list, String field, String value) { if (list == null || field == null || value == null) { return null; } for (EntityBody e : list) { if (value.equals(e.get(field))) { return e; } } return null; }  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 EntityBody getEntityFromList(List<EntityBody> list, String field, String value) { if (list == null || field == null || value == null) { return null; } for (EntityBody e : list) { if (value.equals(e.get(field))) { return e; } } return null; }  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);  }