use of org.apache.flink.streaming.runtime.streamrecord.StreamRecord in project flink by apache.
the class ProcessingTimeTriggerTest method testMergingWindows.
@Test
public void testMergingWindows() throws Exception {
TriggerTestHarness<Object, TimeWindow> testHarness = new TriggerTestHarness<>(ProcessingTimeTrigger.create(), new TimeWindow.Serializer());
assertTrue(ProcessingTimeTrigger.create().canMerge());
assertEquals(TriggerResult.CONTINUE, testHarness.processElement(new StreamRecord<Object>(1), new TimeWindow(0, 2)));
assertEquals(TriggerResult.CONTINUE, testHarness.processElement(new StreamRecord<Object>(1), new TimeWindow(2, 4)));
assertEquals(0, testHarness.numStateEntries());
assertEquals(0, testHarness.numEventTimeTimers());
assertEquals(2, testHarness.numProcessingTimeTimers());
assertEquals(1, testHarness.numProcessingTimeTimers(new TimeWindow(0, 2)));
assertEquals(1, testHarness.numProcessingTimeTimers(new TimeWindow(2, 4)));
testHarness.mergeWindows(new TimeWindow(0, 4), Lists.newArrayList(new TimeWindow(0, 2), new TimeWindow(2, 4)));
assertEquals(0, testHarness.numStateEntries());
assertEquals(0, testHarness.numEventTimeTimers());
assertEquals(1, testHarness.numProcessingTimeTimers());
assertEquals(0, testHarness.numProcessingTimeTimers(new TimeWindow(0, 2)));
assertEquals(0, testHarness.numProcessingTimeTimers(new TimeWindow(2, 4)));
assertEquals(1, testHarness.numProcessingTimeTimers(new TimeWindow(0, 4)));
assertEquals(TriggerResult.FIRE, testHarness.advanceProcessingTime(4, new TimeWindow(0, 4)));
assertEquals(0, testHarness.numStateEntries());
assertEquals(0, testHarness.numProcessingTimeTimers());
assertEquals(0, testHarness.numEventTimeTimers());
}
Aggregations