MegabyteCountRolloverCondition implements RolloverCondition { @Override public boolean isRolloverReady(PacketBuffer packetBuffer) { notNull(packetBuffer, "packetBuffer must be non-null"); return packetBuffer.getByteCount() >= getByteCountThreshold(); } MegabyteCountRolloverCondition(long megabyteCountThreshold); long getMegabyteCountThreshold(); void setMegabyteCountThreshold(long megabyteCountThreshold); @Override boolean isRolloverReady(PacketBuffer packetBuffer); @Override void accept(Visitor visitor); @Override String toString(); static final long MIN_VALUE; static final long MAX_VALUE; }
@Test public void testCurrentLessThanThreshold() { when(packetBuffer.getByteCount()).thenReturn(getThresholdAsBytes() - 1); assertThat(condition.isRolloverReady(packetBuffer), is(false)); }
@Test public void testCurrentEqualToThreshold() { when(packetBuffer.getByteCount()).thenReturn(getThresholdAsBytes()); assertThat(condition.isRolloverReady(packetBuffer), is(true)); }
@Test public void testCurrentGreaterThanThreshold() { when(packetBuffer.getByteCount()).thenReturn(getThresholdAsBytes() + 1); assertThat(condition.isRolloverReady(packetBuffer), is(true)); }