### Question:
TopNSortedMap implements Map<K, V> { @Override public V put(K key, V value) { V oldItem = index.put(key, value); items.add(new KeyValue<>(key, value)); if (size() > this.maxItems) { popLastItem(); } return oldItem; } TopNSortedMap(int size); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override V get(Object key); @Override V put(K key, V value); @Override V remove(Object key); @Override void putAll(Map<? extends K, ? extends V> m); @Override void clear(); @Override Set<K> keySet(); @Override Collection<V> values(); @Override Set<java.util.Map.Entry<K, V>> entrySet(); Map<K, V> toMap();  }### Answer:
@SuppressWarnings("nls") @Test public void testPut() { TopNSortedMap<String, Long> top5 = new TopNSortedMap<>(5); top5.put("10", 10l); Assert.assertEquals(1, top5.size()); Assert.assertEquals((Long) 10L, (Long) top5.get("10")); top5.put("5", 5l); top5.put("20", 20l); top5.put("15", 15l); Assert.assertEquals(4, top5.size()); Assert.assertEquals((Long) 10L, (Long) top5.get("10")); Assert.assertEquals((Long) 20L, (Long) top5.get("20")); top5.put("3", 3l); top5.put("50", 50l); top5.put("65", 65l); top5.put("75", 75l); top5.put("55", 55l); Assert.assertEquals(5, top5.size()); Assert.assertEquals((Long) null, (Long) top5.get("10")); Assert.assertEquals((Long) 20L, (Long) top5.get("20")); Assert.assertEquals((Long) null, (Long) top5.get("5")); Assert.assertEquals((Long) 55L, (Long) top5.get("55")); Assert.assertEquals((Long) 75L, (Long) top5.get("75")); }