use of org.apache.kafka.streams.kstream.internals.TimeWindow in project kafka by apache.
the class TimeWindowsTest method shouldComputeWindowsForHoppingWindows.
@Test
public void shouldComputeWindowsForHoppingWindows() {
TimeWindows windows = TimeWindows.of(12L).advanceBy(5L);
Map<Long, TimeWindow> matched = windows.windowsFor(21L);
assertEquals(12L / 5L + 1, matched.size());
assertEquals(new TimeWindow(10L, 22L), matched.get(10L));
assertEquals(new TimeWindow(15L, 27L), matched.get(15L));
assertEquals(new TimeWindow(20L, 32L), matched.get(20L));
}
use of org.apache.kafka.streams.kstream.internals.TimeWindow in project kafka by apache.
the class CachingWindowStoreTest method shouldForwardDirtyItemsWhenFlushCalled.
@Test
public void shouldForwardDirtyItemsWhenFlushCalled() throws Exception {
final Windowed<String> windowedKey = new Windowed<>("1", new TimeWindow(DEFAULT_TIMESTAMP, DEFAULT_TIMESTAMP + WINDOW_SIZE));
cachingStore.put("1", "a");
cachingStore.flush();
assertEquals("a", cacheListener.forwarded.get(windowedKey).newValue);
assertNull(cacheListener.forwarded.get(windowedKey).oldValue);
}
use of org.apache.kafka.streams.kstream.internals.TimeWindow in project kafka by apache.
the class CachingWindowStoreTest method shouldForwardOldValuesWhenEnabled.
@Test
public void shouldForwardOldValuesWhenEnabled() throws Exception {
final Windowed<String> windowedKey = new Windowed<>("1", new TimeWindow(DEFAULT_TIMESTAMP, DEFAULT_TIMESTAMP + WINDOW_SIZE));
cachingStore.put("1", "a");
cachingStore.flush();
cachingStore.put("1", "b");
cachingStore.flush();
assertEquals("b", cacheListener.forwarded.get(windowedKey).newValue);
assertEquals("a", cacheListener.forwarded.get(windowedKey).oldValue);
}
use of org.apache.kafka.streams.kstream.internals.TimeWindow in project kafka by apache.
the class TimeWindowsTest method shouldComputeWindowsForBarelyOverlappingHoppingWindows.
@Test
public void shouldComputeWindowsForBarelyOverlappingHoppingWindows() {
TimeWindows windows = TimeWindows.of(6L).advanceBy(5L);
Map<Long, TimeWindow> matched = windows.windowsFor(7L);
assertEquals(1, matched.size());
assertEquals(new TimeWindow(5L, 11L), matched.get(5L));
}
use of org.apache.kafka.streams.kstream.internals.TimeWindow in project kafka by apache.
the class TimeWindowsTest method shouldComputeWindowsForTumblingWindows.
@Test
public void shouldComputeWindowsForTumblingWindows() {
TimeWindows windows = TimeWindows.of(12L);
Map<Long, TimeWindow> matched = windows.windowsFor(21L);
assertEquals(1, matched.size());
assertEquals(new TimeWindow(12L, 24L), matched.get(12L));
}
Aggregations