PartialOrderedSet extends HashSet<E> { @Override public void clear() { super.clear(); this.order.clear(); } PartialOrderedSet(final PartialOrderedSet<E> original);  PartialOrderedSet(); void addABeforeB(final E a, final E b); void requireABeforeB(final E a, final E b); boolean allowsABeforeB(final E a, final E b); Map<E, Set<E>> getOrder(); boolean isADirectlyBeforeB(final E a, final E b); Set<E> getTransitiveClosure(final E e); Set<E> getTransitiveClosure(final Set<E> subSet); boolean isReflexive(); List<E> getTotalOrder(); void merge(final PartialOrderedSet<? extends E> set); void addAll(final PartialOrderedSet<? extends E> set); @Override String toString(); List<E> getLinearization(); @Override Iterator<E> iterator(); @Override void clear(); @Override boolean removeAll(final Collection<?> c); @Override boolean retainAll(final Collection<?> c); @Override boolean removeIf(final Predicate<? super E> filter); @Override boolean remove(final Object e); @Override int hashCode(); @SuppressWarnings("rawtypes") @Override boolean equals(final Object obj);  }
@Test public void testClear() { this.set.clear(); assertTrue("Even after clear the set wasn't empty.", this.set.isEmpty()); assertTrue("Empty set should allow a before a, but doesn't.", !this.set.allowsABeforeB(A, A)); assertTrue("Empty set should allow a before b, but doesn't.", this.set.allowsABeforeB(A, B)); assertTrue("Empty set should allow a before c, but doesn't.", this.set.allowsABeforeB(A, C)); assertTrue("Empty set should allow a before d, but doesn't.", this.set.allowsABeforeB(A, D)); assertTrue("Empty set should allow b before a, but doesn't.", this.set.allowsABeforeB(B, A)); assertTrue("Empty set should allow b before b, but doesn't.", !this.set.allowsABeforeB(B, B)); assertTrue("Empty set should allow b before c, but doesn't.", this.set.allowsABeforeB(B, C)); assertTrue("Empty set should allow b before d, but doesn't.", this.set.allowsABeforeB(B, D)); assertTrue("Empty set should allow c before a, but doesn't.", this.set.allowsABeforeB(C, A)); assertTrue("Empty set should allow c before b, but doesn't.", this.set.allowsABeforeB(C, B)); assertTrue("Empty set should allow c before c, but doesn't.", !this.set.allowsABeforeB(C, C)); assertTrue("Empty set should allow c before d, but doesn't.", this.set.allowsABeforeB(C, D)); assertTrue("Empty set should allow d before a, but doesn't.", this.set.allowsABeforeB(D, A)); assertTrue("Empty set should allow d before b, but doesn't.", this.set.allowsABeforeB(D, B)); assertTrue("Empty set should allow d before c, but doesn't.", this.set.allowsABeforeB(D, C)); assertTrue("Empty set should allow d before d, but doesn't.", !this.set.allowsABeforeB(D, D)); }