### Question:
Bag extends AbstractCollection<T> implements Serializable { public Map<T, Integer> toMap() { return new HashMap<>(map); } Bag();  Bag(Map<? extends T, ? extends Integer> map); private  Bag(Map<T, Integer> map, int size);  Bag(Iterable<? extends T> iterable); @Deprecated static Bag<T> create(); @Deprecated static Bag<T> create(Iterable<? extends T> iterable); @Deprecated static Bag<T> create(Map<? extends T, ? extends Integer> map); @Override boolean add(T item); @Override Iterator<T> iterator(); @Override int size(); int add(T item, int increment); int removeAll(T item); int set(T item, int count); int count(T item); Set<Entry<T, Integer>> unique(); Set<T> uniqueItems(); Entry<T, Integer> getMax(); Entry<T, Integer> getMin(); Bag<T> createSorted(Order order); Map<T, Integer> toMap(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }### Answer:
@Test public void testToMap() { Map<String, Integer> map = bag1.toMap(); assertEquals(3, map.size()); assertEquals(3, (int)map.get(ELEMENT1)); assertEquals(5, (int)map.get(ELEMENT2)); assertEquals(2, (int)map.get(ELEMENT3)); }