ObservableSet { public boolean add(T val) { boolean changed = delegate.add(val); if (changed) { for (CollectionChangeListener<? super T> listener : listeners) { listener.onItemAdded(val); } } return changed; } ObservableSet();  ObservableSet(Set<T> delegate); void addListener(CollectionChangeListener<? super T> listener); void removeListener(CollectionChangeListener<? super T> listener); boolean add(T val); boolean remove(T val); boolean contains(T val);  }
@Test public void testAdd() { boolean result1 = set.add("val1"); assertTrue(result1); assertEquals(listener.getCalls(), ImmutableList.of(new Call(NotificationType.ADDED, "val1"))); listener.clear(); boolean result2 = set.add("val1"); assertFalse(result2); assertEquals(listener.getCalls(), ImmutableList.of()); }