@Test public void testGetId() { EntityBody entityBody = new EntityBody(createTestMap()); List<String> list1 = entityBody.getValues("key1"); assertNotNull("List should not be null", list1); assertEquals("List should have 1 value", list1.size(), 1); assertEquals("List value should be original id", list1.get(0), "stringValue1"); List<String> list2 = entityBody.getValues("key2"); assertNotNull("List should not be null", list2); assertEquals("List should have 1 value", list2.size(), 1); assertEquals("List value should be original id", list2.get(0), "stringValue2"); List<String> list3 = entityBody.getValues("key3"); assertNotNull("List should not be null", list3); assertEquals("List should have 2 values", list3.size(), 2); assertEquals("List value 1 should be original id", list3.get(0), "stringInList1"); assertEquals("List value 2 should be original id", list3.get(1), "stringInList2"); List<String> list4 = entityBody.getValues("key4"); assertNotNull("List should not be null", list4); assertEquals("List should have 0 values", list4.size(), 0); }
public List<String> getValues(String key) { List<String> valueList = new ArrayList<String>(); Object value = this.get(key); if (value instanceof String) { valueList.add((String) value); } else if (value instanceof List<?>) { for (Object subValues : (List<?>) value) { valueList.add(subValues.toString()); } } return valueList; }
EntityBody extends HashMap<String, Object> { public List<String> getValues(String key) { List<String> valueList = new ArrayList<String>(); Object value = this.get(key); if (value instanceof String) { valueList.add((String) value); } else if (value instanceof List<?>) { for (Object subValues : (List<?>) value) { valueList.add(subValues.toString()); } } return valueList; } }
EntityBody extends HashMap<String, Object> { public List<String> getValues(String key) { List<String> valueList = new ArrayList<String>(); Object value = this.get(key); if (value instanceof String) { valueList.add((String) value); } else if (value instanceof List<?>) { for (Object subValues : (List<?>) value) { valueList.add(subValues.toString()); } } return valueList; } EntityBody();  EntityBody(Map<? extends String, ? extends Object> m); }
EntityBody extends HashMap<String, Object> { public List<String> getValues(String key) { List<String> valueList = new ArrayList<String>(); Object value = this.get(key); if (value instanceof String) { valueList.add((String) value); } else if (value instanceof List<?>) { for (Object subValues : (List<?>) value) { valueList.add(subValues.toString()); } } return valueList; } EntityBody();  EntityBody(Map<? extends String, ? extends Object> m); List<String> getValues(String key); }
EntityBody extends HashMap<String, Object> { public List<String> getValues(String key) { List<String> valueList = new ArrayList<String>(); Object value = this.get(key); if (value instanceof String) { valueList.add((String) value); } else if (value instanceof List<?>) { for (Object subValues : (List<?>) value) { valueList.add(subValues.toString()); } } return valueList; } EntityBody();  EntityBody(Map<? extends String, ? extends Object> m); List<String> getValues(String key);  }