### Question:
ManyToManyMap { public void add(L left, R right) { if (left == null) throw new NullPointerException("left must not be null."); if (right == null) throw new NullPointerException("right must not be null."); Set<R> rights = lToRMappings.get(left); if (rights == null) rights = new HashSet<R>(); rights.add(right); lToRMappings.put(left, rights); Set<L> lefts = rToLMappings.get(right); if (lefts == null) lefts = new HashSet<L>(); lefts.add(left); rToLMappings.put(right, lefts); } ManyToManyMap();  ManyToManyMap(int initialCapacity);  ManyToManyMap(int initialCapacity, float loadFactor); void add(L left, R right); boolean remove(L left, R right); Set<R> removeAllMappingsForLeft(L left); Set<L> removeAllMappingsForRight(R right); Set<R> getRight(L left); Set<L> getLeft(R right); int size(); int numberOfmappingsForLeft(L left); int numberOfmappingsForRight(R right); boolean containsLeft(L left); boolean containsRight(R right); boolean isEmpty(); void clear(); Iterator<L> leftIterator(); Iterator<R> rightIterator(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void testAdd() { ManyToManyMap<String, String> map = new ManyToManyMap<String, String>(); map.add("A.1", "A"); map.add("A.2", "A"); map.add("A.1", "AB"); map.add("A.2", "AB"); map.add("B.1", "B"); map.add("B.2", "B"); map.add("B.1", "AB"); map.add("B.2", "AB"); map.add("C.1", "C"); assertEquals(9, map.size()); Set<String> manys = map.getRight("A.1"); assertEquals(2, manys.size()); assertTrue(manys.contains("A")); assertTrue(manys.contains("AB")); manys = map.getLeft("A"); assertEquals(2, manys.size()); assertTrue(manys.contains("A.1")); assertTrue(manys.contains("A.2")); manys = map.getLeft("AB"); assertEquals(4, manys.size()); assertTrue(manys.contains("A.1")); assertTrue(manys.contains("A.2")); assertTrue(manys.contains("B.1")); assertTrue(manys.contains("B.2")); manys = map.getLeft("C"); assertEquals(1, manys.size()); assertTrue(manys.contains("C.1")); }