NonBlockingHashMultimap implements Multimap<K, V> { @Override public int size() { return totalSize; } private  NonBlockingHashMultimap(NonBlockingHashMap<K, Set<V>> map); static NonBlockingHashMultimap<K, V> create(); @Override Map<K, Collection<V>> asMap(); @Override void clear(); @SuppressWarnings("unchecked") @Override boolean containsEntry(Object key, Object value); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override Collection<Entry<K, V>> entries(); @Override Set<V> get(K key); @Override boolean isEmpty(); @Override Multiset<K> keys(); @Override Set<K> keySet(); @Override boolean put(K key, V value); @Override boolean putAll(K key, Iterable<? extends V> values); @Override boolean putAll(Multimap<? extends K, ? extends V> multimap); @Override boolean remove(Object key, Object value); @Override Collection<V> removeAll(Object key); @Override Collection<V> replaceValues(K key, Iterable<? extends V> values); @Override int size(); @Override Collection<V> values(); @Override int hashCode(); @SuppressWarnings("unchecked") @Override boolean equals(Object obj); @Override String toString();  }
@Test public void testSize() { int count = TestData.getScaleCount(); String[] keys = new String[count]; for (int i = 0; i < count; i++) { keys[i] = TestData.getString(); } int totalSize = 0; for (int i = 0; i < count * TestData.getScaleCount(); i++) { String key = keys[(TestData.getScaleCount() * i) % count]; Object value = null; while (value == null || map.containsEntry(key, value)) { value = TestData.getObject(); } map.put(key, value); totalSize++; } Assert.assertEquals(totalSize, map.size()); }