use of org.apache.flink.streaming.api.windowing.assigners.ProcessingTimeSessionWindows in project flink by apache.
the class ProcessingTimeSessionWindowsTest method testProperties.
@Test
public void testProperties() {
ProcessingTimeSessionWindows assigner = ProcessingTimeSessionWindows.withGap(Time.seconds(5));
assertFalse(assigner.isEventTime());
assertEquals(new TimeWindow.Serializer(), assigner.getWindowSerializer(new ExecutionConfig()));
assertThat(assigner.getDefaultTrigger(mock(StreamExecutionEnvironment.class)), instanceOf(ProcessingTimeTrigger.class));
}
use of org.apache.flink.streaming.api.windowing.assigners.ProcessingTimeSessionWindows in project flink by apache.
the class ProcessingTimeSessionWindowsTest method testWindowAssignment.
@Test
public void testWindowAssignment() {
WindowAssigner.WindowAssignerContext mockContext = mock(WindowAssigner.WindowAssignerContext.class);
ProcessingTimeSessionWindows assigner = ProcessingTimeSessionWindows.withGap(Time.milliseconds(5000));
when(mockContext.getCurrentProcessingTime()).thenReturn(0L);
assertThat(assigner.assignWindows("String", Long.MIN_VALUE, mockContext), contains(timeWindow(0, 5000)));
when(mockContext.getCurrentProcessingTime()).thenReturn(4999L);
assertThat(assigner.assignWindows("String", Long.MIN_VALUE, mockContext), contains(timeWindow(4999, 9999)));
when(mockContext.getCurrentProcessingTime()).thenReturn(5000L);
assertThat(assigner.assignWindows("String", Long.MIN_VALUE, mockContext), contains(timeWindow(5000, 10000)));
}
use of org.apache.flink.streaming.api.windowing.assigners.ProcessingTimeSessionWindows in project flink by apache.
the class ProcessingTimeSessionWindowsTest method testTimeUnits.
@Test
public void testTimeUnits() {
// sanity check with one other time unit
WindowAssigner.WindowAssignerContext mockContext = mock(WindowAssigner.WindowAssignerContext.class);
ProcessingTimeSessionWindows assigner = ProcessingTimeSessionWindows.withGap(Time.seconds(5));
when(mockContext.getCurrentProcessingTime()).thenReturn(0L);
assertThat(assigner.assignWindows("String", Long.MIN_VALUE, mockContext), contains(timeWindow(0, 5000)));
when(mockContext.getCurrentProcessingTime()).thenReturn(4999L);
assertThat(assigner.assignWindows("String", Long.MIN_VALUE, mockContext), contains(timeWindow(4999, 9999)));
when(mockContext.getCurrentProcessingTime()).thenReturn(5000L);
assertThat(assigner.assignWindows("String", Long.MIN_VALUE, mockContext), contains(timeWindow(5000, 10000)));
}
use of org.apache.flink.streaming.api.windowing.assigners.ProcessingTimeSessionWindows in project flink by apache.
the class ProcessingTimeSessionWindowsTest method testMergeSinglePointWindow.
@Test
public void testMergeSinglePointWindow() {
MergingWindowAssigner.MergeCallback callback = mock(MergingWindowAssigner.MergeCallback.class);
ProcessingTimeSessionWindows assigner = ProcessingTimeSessionWindows.withGap(Time.milliseconds(5000));
assigner.mergeWindows(Lists.newArrayList(new TimeWindow(0, 0)), callback);
verify(callback, never()).merge(anyCollection(), Matchers.anyObject());
}
use of org.apache.flink.streaming.api.windowing.assigners.ProcessingTimeSessionWindows in project flink by apache.
the class ProcessingTimeSessionWindowsTest method testMergeConsecutiveWindows.
@Test
public void testMergeConsecutiveWindows() {
MergingWindowAssigner.MergeCallback callback = mock(MergingWindowAssigner.MergeCallback.class);
ProcessingTimeSessionWindows assigner = ProcessingTimeSessionWindows.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());
}
Aggregations