### Question:
LinkedHashTreeMap extends AbstractMap<K, V> implements Serializable { @Override public V put(K key, V value) { if (key == null) { throw new NullPointerException("key == null"); } Node<K, V> created = find(key, true); V result = created.value; created.value = value; return result; } LinkedHashTreeMap(); @SuppressWarnings({ "unchecked", "rawtypes" // Unsafe! if comparator is null, this assumes K is comparable. })  LinkedHashTreeMap(Comparator<? super K> comparator); @Override int size(); @Override V get(Object key); @Override boolean containsKey(Object key); @Override V put(K key, V value); @Override void clear(); @Override V remove(Object key); @Override Set<Entry<K, V>> entrySet(); @Override Set<K> keySet();  }### Answer:
@Test public void putNullKeyFails() { LinkedHashTreeMap<String, String> map = new LinkedHashTreeMap<>(); try { map.put(null, "android"); fail(); } catch (NullPointerException expected) { } }
@Test public void putNonComparableKeyFails() { LinkedHashTreeMap<Object, String> map = new LinkedHashTreeMap<>(); try { map.put(new Object(), "android"); fail(); } catch (ClassCastException expected) { } }
@Test public void ContainsNonComparableKeyReturnsFalse() { LinkedHashTreeMap<Object, String> map = new LinkedHashTreeMap<>(); map.put("a", "android"); assertThat(map).doesNotContainKey(new Object()); }
@Test public void containsNullKeyIsAlwaysFalse() { LinkedHashTreeMap<String, String> map = new LinkedHashTreeMap<>(); map.put("a", "android"); assertThat(map).doesNotContainKey(null); }
@Test public void equalsAndHashCode() throws Exception { LinkedHashTreeMap<String, Integer> map1 = new LinkedHashTreeMap<>(); map1.put("A", 1); map1.put("B", 2); map1.put("C", 3); map1.put("D", 4); LinkedHashTreeMap<String, Integer> map2 = new LinkedHashTreeMap<>(); map2.put("C", 3); map2.put("B", 2); map2.put("D", 4); map2.put("A", 1); assertThat(map2).isEqualTo(map1); assertThat(map2.hashCode()).isEqualTo(map1.hashCode()); }