LazyMap implements Map<K, V> { @Override public final Set<Entry<K, V>> entrySet() { return delegate.entrySet(); }  @Override final int size(); @Override final boolean isEmpty(); @Override final boolean containsKey(Object key); @Override final boolean containsValue(Object value); @Override final V get(Object key); @Override final V put(K key, V value); @Override final V remove(Object key); @Override final void putAll(Map<? extends K, ? extends V> m); @Override final void clear(); @Override final Set<K> keySet(); @Override final Collection<V> values(); @Override final Set<Entry<K, V>> entrySet(); @Override final int hashCode(); @Override final boolean equals(Object obj); static LazyMap<K, V> newHashMap();  }
@Test public void requireThatSingletonEntryImplementsEquals() { Map.Entry<String, String> map = newSingletonMap("foo", "bar").entrySet().iterator().next(); assertNotEquals(map, null); assertNotEquals(map, new Object()); assertEquals(map, map); assertNotEquals(map, newSingletonMap("baz", "cox").entrySet().iterator().next()); assertNotEquals(map, newSingletonMap("foo", "cox").entrySet().iterator().next()); assertEquals(map, newSingletonMap("foo", "bar").entrySet().iterator().next()); }
@Test public void requireThatSingletonEntrySetIteratorNextThrowsIfInvokedMoreThanOnce() { LazyMap<String, String> map = newSingletonMap("foo", "bar"); Iterator<Map.Entry<String, String>> it = map.entrySet().iterator(); it.next(); try { it.next(); fail(); } catch (NoSuchElementException e) { } try { it.next(); fail(); } catch (NoSuchElementException e) { } }