### Question:
SmallMap extends AbstractMap<K, V> { @Override public V put(K key, V value) { rejectIfNull(key); if (entries != null) { return entries.put(key, value); } if (firstKey == null) { firstKey = key; firstValue = value; return null; } if (firstKey.equals(key)) { V oldValue = firstValue; firstValue = value; return oldValue; } entries = new LinkedHashMap<>(2); entries.put(firstKey, firstValue); firstKey = null; firstValue = null; return entries.put(key, value); } SmallMap(); @Override V get(Object key); @Override V put(K key, V value); @Override void putAll(Map<? extends K, ? extends V> m); @Override V remove(Object key); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override int size(); @Override Set<Entry<K, V>> entrySet();  }### Answer:
@Test(dependsOnMethods = { "testPutAndSize" }) public void testContains() throws Exception { SmallMap<Integer, String> map = new SmallMap<>(); assertDoesNotContain(map, entry(2, "two")); map.put(1, null); assertContains(map, entry(1, (String) null)); assertDoesNotContain(map, entry(2, "two")); map.put(1, "one"); assertContains(map, entry(1, "one")); assertDoesNotContain(map, entry(2, "two")); map.put(2, "two"); assertContains(map, entry(1, "one")); assertContains(map, entry(2, "two")); assertDoesNotContain(map, entry(3, "three")); }
@Test(expectedExceptions = { NullPointerException.class }) public void testPutRejectsNull() throws Exception { new SmallMap<Integer, String>().put(null, null); }