### Question:
MetadataMap implements MultivaluedMap<K, V> { public void putSingle(K key, V value) { List<V> data = new ArrayList<>(); data.add(value); this.put(key, data); } MetadataMap();  MetadataMap(int size);  MetadataMap(Map<K, List<V>> store);  MetadataMap(Map<K, List<V>> store, boolean copy);  MetadataMap(boolean readOnly, boolean caseInsensitive);  MetadataMap(Map<K, List<V>> store, boolean readOnly, boolean caseInsensitive);  MetadataMap(Map<K, List<V>> store, boolean copyStore,
                       boolean readOnly, boolean caseInsensitive); void add(K key, V value); V getFirst(K key); void putSingle(K key, V value); void clear(); boolean containsKey(Object key); boolean containsValue(Object value); Set<Entry<K, List<V>>> entrySet(); List<V> get(Object key); boolean isEmpty(); Set<K> keySet(); List<V> put(K key, List<V> value); void putAll(Map<? extends K, ? extends List<V>> map); List<V> remove(Object key); int size(); Collection<List<V>> values(); @Override int hashCode(); @Override boolean equals(Object o); String toString(); @SafeVarargs final void addAll(K key, V... newValues); void addAll(K key, List<V> newValues); void addFirst(K key, V value); boolean equalsIgnoreValueOrder(MultivaluedMap<K, V> map);  }### Answer:
@Test public void testPutSingle() { MetadataMap<String, Object> m = new MetadataMap<>(); List<Object> value1 = new ArrayList<>(); value1.add("bar"); value1.add("foo"); m.put("baz", value1); m.putSingle("baz", "clazz"); List<Object> value2 = m.get("baz"); assertEquals("Only a single value should be in the list", 1, value2.size()); assertEquals("Value is wrong", "clazz", value2.get(0)); assertNull(m.get("baZ")); }
@Test(expected = UnsupportedOperationException.class) public void testReadOnlyPutSingle() { Map<String, List<String>> values = new HashMap<>(); MultivaluedMap<String, String> map = new MetadataMap<>(values, false, true, true); map.putSingle("baz", "baz"); }