OrFinallyTrigger extends Trigger { @Override public Instant getWatermarkThatGuaranteesFiring(BoundedWindow window) { Instant actualDeadline = subTriggers.get(ACTUAL).getWatermarkThatGuaranteesFiring(window); Instant untilDeadline = subTriggers.get(UNTIL).getWatermarkThatGuaranteesFiring(window); return actualDeadline.isBefore(untilDeadline) ? actualDeadline : untilDeadline; } @VisibleForTesting  OrFinallyTrigger(Trigger actual, Trigger.OnceTrigger until); Trigger getMainTrigger(); OnceTrigger getUntilTrigger(); @Override Instant getWatermarkThatGuaranteesFiring(BoundedWindow window); @Override boolean mayFinish(); @Override String toString();  }
@Test public void testFireDeadline() throws Exception { BoundedWindow window = new IntervalWindow(new Instant(0), new Instant(10)); assertEquals( new Instant(9), Repeatedly.forever(AfterWatermark.pastEndOfWindow()) .getWatermarkThatGuaranteesFiring(window)); assertEquals( new Instant(9), Repeatedly.forever(AfterWatermark.pastEndOfWindow()) .orFinally(AfterPane.elementCountAtLeast(1)) .getWatermarkThatGuaranteesFiring(window)); assertEquals( new Instant(9), Repeatedly.forever(AfterPane.elementCountAtLeast(1)) .orFinally(AfterWatermark.pastEndOfWindow()) .getWatermarkThatGuaranteesFiring(window)); assertEquals( new Instant(9), AfterPane.elementCountAtLeast(100) .orFinally(AfterWatermark.pastEndOfWindow()) .getWatermarkThatGuaranteesFiring(window)); assertEquals( BoundedWindow.TIMESTAMP_MAX_VALUE, Repeatedly.forever(AfterPane.elementCountAtLeast(1)) .orFinally(AfterPane.elementCountAtLeast(10)) .getWatermarkThatGuaranteesFiring(window)); }