ResettableSingletonTraverser implements Traverser<T>, Consumer<T> { @Override public void accept(@Nullable T item) { assert this.item == null : "accept() called, but previous item still present. Previous: " + this.item + ", new: " + item; this.item = item; }  @Override T next(); @Override void accept(@Nullable T item);  }
@Test(expected = AssertionError.class) public void when_itemNotConsumed_thenAcceptFails() { trav.accept(1); trav.accept(2); }