TrackingMultimap extends AbstractMap<K, Set<V>> { @Override public Set<V> put(K key, Set<V> value) { Set<V> stored = newHashSetNullSafe(data.get(key)); if(stored == null) { data.put(key, new ValueSetWrapper(key)); } for (V element : MoreObjects.firstNonNull(stored, Collections.<V> emptySet())) { delete(key, element); } for (V element : value) { insert(key, element); } return stored; } protected  TrackingMultimap(Map<K, Set<V>> delegate,
            @Nullable Comparator<K> comparator); boolean containsDataType(DataType type); long count(); boolean delete(K key, V value); double distinctiveness(); @Override Set<Entry<K, Set<V>>> entrySet(); @SuppressWarnings("unchecked") @Override boolean equals(Object obj); @Override Set<V> get(Object key); @Override int hashCode(); boolean hasValue(V value); boolean insert(K key, V value); K max(); Set<V> merge(K key, Set<V> values); K min(); double percentKeyDataType(DataType type); double proportion(K element); @Override Set<V> put(K key, Set<V> value); @SuppressWarnings("unchecked") @Override Set<V> remove(Object key); double spread(); @Override String toString(); double uniqueness(); VariableType variableType();  }
@Test public void testSize() { int count = Random.getScaleCount(); for (int i = 0; i < count; i++) { boolean added = false; while (!added) { added = map.put(Random.getString(), randomValueSet()) == null; } } Assert.assertEquals(map.size(), count); }
@Test public void testIsEmpty() { Assert.assertTrue(map.isEmpty()); for (int i = 0; i < Random.getScaleCount(); i++) { map.put(Random.getString(), randomValueSet()); } Assert.assertFalse(map.isEmpty()); }
@Test public void testContainsKey() { String key = Random.getString(); Assert.assertFalse(map.containsKey(key)); map.put(key, randomValueSet()); Assert.assertTrue(map.containsKey(key)); }
@Test public void testContainsValue() { Set<Integer> value = randomValueSet(); Assert.assertFalse(map.containsValue(value)); map.put(Random.getString(), value); Assert.assertTrue(map.containsValue(value)); }
@Test public void testPut() { String key = Random.getString(); Set<Integer> value1 = randomValueSet(); Set<Integer> value2 = randomValueSet(); Assert.assertNull(map.get(key)); Assert.assertNull(map.put(key, value1)); Assert.assertEquals(map.put(key, value2), value1); }
@Test public void testClear() { int count = Random.getScaleCount(); for (int i = 0; i < count; i++) { map.put(Random.getString(), randomValueSet()); } Assert.assertFalse(map.isEmpty()); map.clear(); Assert.assertTrue(map.isEmpty()); }
@Test public void testKeySet() { Set<String> keys = new HashSet<String>(); for (int i = 0; i < Random.getScaleCount(); i++) { String key = Random.getSimpleString(); keys.add(key); map.put(key, randomValueSet()); } for (String key : map.keySet()) { Assert.assertTrue(keys.contains(key)); } Assert.assertTrue(keys.size() == map.keySet().size()); }
@Test public void testValues() { List<Set<Integer>> values = new ArrayList<Set<Integer>>(); for (int i = 0; i < Random.getScaleCount(); i++) { Set<Integer> value = randomValueSet(); values.add(value); map.put(Random.getString(), value); } for (Set<Integer> value : map.values()) { Assert.assertTrue(values.contains(value)); } Assert.assertTrue(values.size() == map.values().size()); }