### Question:
NoRandomAccessMap implements Recyclable, Iterable<NoRandomAccessMap.Entry<K, V>> { public void add(K key, @Nullable V value) throws NullPointerException { if (key == null) { throw new NullPointerException("This map doesn't support null keys"); } keys.add(key); values.add(value); }  void add(K key, @Nullable V value); int size(); boolean isEmpty(); @Override void resetState(); @Override java.util.Iterator<NoRandomAccessMap.Entry<K, V>> iterator(); void copyFrom(NoRandomAccessMap<K, V> other);  }### Answer:
@Test void testOneEntry() { map.add("foo", "bar"); int numElements = 0; for (NoRandomAccessMap.Entry entry : map) { numElements++; assertThat(entry.getKey()).isEqualTo("foo"); assertThat(entry.getValue()).isEqualTo("bar"); } assertThat(numElements).isEqualTo(1); }
@Test void testNullValue() { map.add("foo", null); int numElements = 0; for (NoRandomAccessMap.Entry entry : map) { numElements++; assertThat(entry.getKey()).isEqualTo("foo"); assertThat(entry.getValue()).isNull(); } assertThat(numElements).isEqualTo(1); }
@Test void testTwoEntries() { map.add(String.valueOf(0), "value"); map.add(String.valueOf(1), "value"); int index = 0; int numElements = 0; for (NoRandomAccessMap.Entry entry : map) { numElements++; assertThat(entry.getKey()).isEqualTo(String.valueOf(index++)); assertThat(entry.getValue()).isEqualTo("value"); } assertThat(numElements).isEqualTo(2); }
@Test void testTwoIterations() { map.add(String.valueOf(0), "value"); map.add(String.valueOf(1), "value"); int numElements = 0; for (NoRandomAccessMap.Entry entry : map) { numElements++; break; } for (NoRandomAccessMap.Entry entry : map) { numElements++; } assertThat(numElements).isEqualTo(3); }