public static AfterProcessingTimeStateMachine pastFirstElementInPane() {
    return new AfterProcessingTimeStateMachine(IDENTITY);
  }
@Test
  public void testAfterProcessingTimeWithMergingWindow() throws Exception {
    SimpleTriggerStateMachineTester<IntervalWindow> tester =
        TriggerStateMachineTester.forTrigger(
            AfterProcessingTimeStateMachine.pastFirstElementInPane()
                .plusDelayOf(Duration.millis(5)),
            Sessions.withGapDuration(Duration.millis(10)));

    tester.advanceProcessingTime(new Instant(10));
    tester.injectElements(1); // in [1, 11), timer for 15
    IntervalWindow firstWindow = new IntervalWindow(new Instant(1), new Instant(11));
    assertFalse(tester.shouldFire(firstWindow));

    tester.advanceProcessingTime(new Instant(12));
    tester.injectElements(3); // in [3, 13), timer for 17
    IntervalWindow secondWindow = new IntervalWindow(new Instant(3), new Instant(13));
    assertFalse(tester.shouldFire(secondWindow));

    tester.mergeWindows();
    IntervalWindow mergedWindow = new IntervalWindow(new Instant(1), new Instant(13));

    tester.advanceProcessingTime(new Instant(16));
    assertTrue(tester.shouldFire(mergedWindow));
  }