AbstractProcessor implements Processor { @SuppressWarnings("unchecked") protected final <E> boolean emitFromTraverser(@Nonnull int[] ordinals, @Nonnull Traverser<E> traverser) { E item; if (pendingItem != null) { item = (E) pendingItem; pendingItem = null; } else { item = traverser.next(); } for (; item != null; item = traverser.next()) { if (!tryEmit(ordinals, item)) { pendingItem = item; return false; } } return true; }  @Override final void init(@Nonnull Outbox outbox, @Nonnull Context context); @Override final void restoreFromSnapshot(@Nonnull Inbox inbox); @Override @SuppressWarnings("checkstyle:magicnumber") void process(int ordinal, @Nonnull Inbox inbox); @Override boolean tryProcessWatermark(@Nonnull Watermark watermark);  }
@Test public void when_emitFromTraverserToAll_then_emittedToAll() { Traverser<Object> trav = Traversers.singleton(MOCK_ITEM); boolean done = p.emitFromTraverser(trav); assertTrue("done", done); validateReceptionAtOrdinals(MOCK_ITEM, ALL_ORDINALS); }
@Test public void when_emitFromTraverserTo1_then_emittedTo1() { Traverser<Object> trav = Traversers.traverseItems(MOCK_ITEM, MOCK_ITEM); boolean done; do { done = p.emitFromTraverser(ORDINAL_1, trav); validateReceptionAtOrdinals(MOCK_ITEM, ORDINAL_1); } while (!done); }
@Test public void when_emitFromTraverserTo1And2_then_emittedTo1And2() { Traverser<Object> trav = Traversers.traverseItems(MOCK_ITEM, MOCK_ITEM); boolean done; do { done = p.emitFromTraverser(ORDINALS_1_2, trav); validateReceptionAtOrdinals(MOCK_ITEM, ORDINALS_1_2); } while (!done); }