use of org.apache.flink.streaming.api.windowing.assigners.EventTimeSessionWindows in project flink by apache.
the class EventTimeSessionWindowsTest method testTimeUnits.
@Test
public void testTimeUnits() {
// sanity check with one other time unit
final int sessionGap = 5000;
WindowAssigner.WindowAssignerContext mockContext = mock(WindowAssigner.WindowAssignerContext.class);
EventTimeSessionWindows assigner = EventTimeSessionWindows.withGap(Time.seconds(sessionGap / 1000));
assertThat(assigner.assignWindows("String", 0L, mockContext), contains(timeWindow(0, 0 + sessionGap)));
assertThat(assigner.assignWindows("String", 4999L, mockContext), contains(timeWindow(4999, 4999 + sessionGap)));
assertThat(assigner.assignWindows("String", 5000L, mockContext), contains(timeWindow(5000, 5000 + sessionGap)));
}
use of org.apache.flink.streaming.api.windowing.assigners.EventTimeSessionWindows in project flink by apache.
the class EventTimeSessionWindowsTest method testMergeConsecutiveWindows.
@Test
public void testMergeConsecutiveWindows() {
MergingWindowAssigner.MergeCallback callback = mock(MergingWindowAssigner.MergeCallback.class);
EventTimeSessionWindows assigner = EventTimeSessionWindows.withGap(Time.milliseconds(5000));
assigner.mergeWindows(Lists.newArrayList(new TimeWindow(0, 1), new TimeWindow(1, 2), new TimeWindow(2, 3), new TimeWindow(4, 5), new TimeWindow(5, 6)), callback);
verify(callback, times(1)).merge((Collection<TimeWindow>) argThat(containsInAnyOrder(new TimeWindow(0, 1), new TimeWindow(1, 2), new TimeWindow(2, 3))), eq(new TimeWindow(0, 3)));
verify(callback, times(1)).merge((Collection<TimeWindow>) argThat(containsInAnyOrder(new TimeWindow(4, 5), new TimeWindow(5, 6))), eq(new TimeWindow(4, 6)));
verify(callback, times(2)).merge(anyCollection(), Matchers.anyObject());
}
use of org.apache.flink.streaming.api.windowing.assigners.EventTimeSessionWindows in project flink by apache.
the class EventTimeSessionWindowsTest method testProperties.
@Test
public void testProperties() {
EventTimeSessionWindows assigner = EventTimeSessionWindows.withGap(Time.seconds(5));
assertTrue(assigner.isEventTime());
assertEquals(new TimeWindow.Serializer(), assigner.getWindowSerializer(new ExecutionConfig()));
assertThat(assigner.getDefaultTrigger(mock(StreamExecutionEnvironment.class)), instanceOf(EventTimeTrigger.class));
}
use of org.apache.flink.streaming.api.windowing.assigners.EventTimeSessionWindows in project flink by apache.
the class EventTimeSessionWindowsTest method testMergeCoveringWindow.
@Test
public void testMergeCoveringWindow() {
MergingWindowAssigner.MergeCallback callback = mock(MergingWindowAssigner.MergeCallback.class);
EventTimeSessionWindows assigner = EventTimeSessionWindows.withGap(Time.milliseconds(5000));
assigner.mergeWindows(Lists.newArrayList(new TimeWindow(1, 1), new TimeWindow(0, 2), new TimeWindow(4, 7), new TimeWindow(5, 6)), callback);
verify(callback, times(1)).merge((Collection<TimeWindow>) argThat(containsInAnyOrder(new TimeWindow(1, 1), new TimeWindow(0, 2))), eq(new TimeWindow(0, 2)));
verify(callback, times(1)).merge((Collection<TimeWindow>) argThat(containsInAnyOrder(new TimeWindow(5, 6), new TimeWindow(4, 7))), eq(new TimeWindow(4, 7)));
verify(callback, times(2)).merge(anyCollection(), Matchers.anyObject());
}
Aggregations