@Override
  public Instant getWatermarkThatGuaranteesFiring(BoundedWindow window) {
    // This trigger fires once either the trigger or the until trigger fires.
    Instant actualDeadline = subTriggers.get(ACTUAL).getWatermarkThatGuaranteesFiring(window);
    Instant untilDeadline = subTriggers.get(UNTIL).getWatermarkThatGuaranteesFiring(window);
    return actualDeadline.isBefore(untilDeadline) ? actualDeadline : untilDeadline;
  }
@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));
  }