@Test
public void testTimeSlidingLabelAssignment() {
TimeSliding<Long> windowing = TimeSliding
.of(Duration.ofHours(1), Duration.ofMinutes(20));
UnaryFunction<Long, Long> eventTimeAssigner = e -> e * 1000L;
long[] data = {
3590,
3600,
3610,
3800,
7190,
7200,
7210
};
for (long event : data) {
Iterable<TimeInterval> labels = windowing
.assignWindowsToElement(new Elem<>(
GlobalWindowing.Window.get(), event, eventTimeAssigner.apply(event)));
assertEquals(3, Iterables.size(labels));
for (TimeInterval l : labels) {
long stamp = event * 1000L;
assertTrue(stamp >= l.getStartMillis());
assertTrue(stamp <= l.getEndMillis());
}
}
}