OutboxImpl implements OutboxInternal { @Override public final boolean offer(int ordinal, @Nonnull Object item) { if (ordinal == -1) { return offerInternal(allEdges, item); } else { if (ordinal == bucketCount()) { throw new IllegalArgumentException("Illegal edge ordinal: " + ordinal); } singleEdge[0] = ordinal; return offerInternal(singleEdge, item); } } OutboxImpl(OutboundCollector[] outstreams, boolean hasSnapshot, ProgressTracker progTracker,
                      SerializationService serializationService, int batchSize, AtomicLongArray counters); @Override final int bucketCount(); @Override final boolean offer(int ordinal, @Nonnull Object item); @Override final boolean offer(@Nonnull int[] ordinals, @Nonnull Object item); @Override final boolean offer(@Nonnull Object item); @Override final boolean offerToSnapshot(@Nonnull Object key, @Nonnull Object value); @Override boolean hasUnfinishedItem(); @Override void block(); @Override void unblock(); @Override void reset(); @Override long lastForwardedWm();  }
@Test public void when_offer1_then_rateLimited() { do_when_offer_then_rateLimited(e -> outbox.offer(e)); }
@Test public void when_offer2_then_rateLimited() { do_when_offer_then_rateLimited(e -> outbox.offer(0, e)); }
@Test public void when_offer4_then_rateLimited() { do_when_offer_then_rateLimited(e -> outbox.offer(new int[] {0}, e)); }
@Test public void when_queueFullAndOfferReturnedFalse_then_subsequentCallFails() { outbox = new OutboxImpl(new OutboundCollector[] {e -> DONE, e -> NO_PROGRESS}, true, new ProgressTracker(), mockSerializationService(), 128, new AtomicLongArray(3)); assertFalse(outbox.offer(4)); exception.expectMessage("offer() called again"); outbox.offer(4); }
@Test public void when_sameItemOfferedTwice_then_success() { String item = "foo"; assertTrue(outbox.offer(item)); assertTrue(outbox.offer(item)); }
@Test public void when_offer1FailsAndDifferentItemOffered_then_fail() { do_when_offerDifferent_then_fail(e -> outbox.offer(e)); }
@Test public void when_offer2FailsAndDifferentItemOffered_then_fail() { do_when_offerDifferent_then_fail(e -> outbox.offer(0, e)); }
@Test public void when_offer4FailsAndDifferentItemOffered_then_fail() { do_when_offerDifferent_then_fail(e -> outbox.offer(new int[] {0}, e)); }
@Test public void when_offerFailsAndOfferedToDifferentOrdinal_then_fail_1() { do_when_offerToDifferentOrdinal_then_fail(e -> outbox.offer(0, e), e -> outbox.offer(1, e)); }
@Test public void when_offerFailsAndOfferedToDifferentOrdinal_then_fail_3() { do_when_offerToDifferentOrdinal_then_fail(e -> outbox.offer(0, e), e -> outbox.offer(e)); }