SortedTagList implements TagList { @Override public Map<String, String> asMap() { Map<String, String> stringMap = new LinkedHashMap<>(size); for (Tag t : tagSortedMap.values()) { stringMap.put(t.getKey(), t.getValue()); } return stringMap; } private  SortedTagList(Builder builder); @Override Tag getTag(String key); String getValue(String key); @Override boolean containsKey(String key); @Override boolean isEmpty(); @Override int size(); @Override Iterator<Tag> iterator(); @Override Map<String, String> asMap(); static Builder builder(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); static final SortedTagList EMPTY; }
@Test public void testAsMap() throws Exception { Map<String, String> stringMap = testListFromCollection.asMap(); int i = 0; for (String s : stringMap.keySet()) { assertEquals(s, TAG_ARRAY[i].getKey()); i++; } i = 0; for (String s : stringMap.values()) { assertEquals(s, TAG_ARRAY[i].getValue()); i++; } }