### Question:
SmallMap extends AbstractMap<K, V> { @Override public V remove(Object key) { if (entries != null) { return entries.remove(key); } if (firstKey != null && firstKey.equals(key)) { V oldV = firstValue; firstKey = null; firstValue = null; return oldV; } return null; } 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 testRemove() throws Exception { SmallMap<Integer, String> map = new SmallMap<>(); assertEquals(map.size(), 0); assertEquals(map.remove(2), null); assertEquals(map.remove(1), null); map.put(1, "one"); assertEquals(map.size(), 1); assertEquals(map.remove(2), null); assertEquals(map.remove(1), "one"); assertEquals(map.size(), 0); map.put(1, "one"); map.put(2, "two"); assertEquals(map.size(), 2); assertEquals(map.remove(1), "one"); assertEquals(map.size(), 1); }