Search in sources :

Example 1 with ReadOnlySessionStoreStub

use of org.apache.kafka.test.ReadOnlySessionStoreStub in project kafka by apache.

the class CompositeReadOnlySessionStoreTest method shouldFindValueForKeyWhenMultiStores.

@Test
public void shouldFindValueForKeyWhenMultiStores() throws Exception {
    final ReadOnlySessionStoreStub<String, Long> secondUnderlying = new ReadOnlySessionStoreStub<>();
    stubProviderTwo.addStore(storeName, secondUnderlying);
    final Windowed<String> keyOne = new Windowed<>("key-one", new SessionWindow(0, 0));
    final Windowed<String> keyTwo = new Windowed<>("key-two", new SessionWindow(0, 0));
    underlyingSessionStore.put(keyOne, 0L);
    secondUnderlying.put(keyTwo, 10L);
    final List<KeyValue<Windowed<String>, Long>> keyOneResults = toList(sessionStore.fetch("key-one"));
    final List<KeyValue<Windowed<String>, Long>> keyTwoResults = toList(sessionStore.fetch("key-two"));
    assertEquals(Collections.singletonList(KeyValue.pair(keyOne, 0L)), keyOneResults);
    assertEquals(Collections.singletonList(KeyValue.pair(keyTwo, 10L)), keyTwoResults);
}
Also used : Windowed(org.apache.kafka.streams.kstream.Windowed) KeyValue(org.apache.kafka.streams.KeyValue) ReadOnlySessionStoreStub(org.apache.kafka.test.ReadOnlySessionStoreStub) SessionWindow(org.apache.kafka.streams.kstream.internals.SessionWindow) Test(org.junit.Test)

Aggregations

KeyValue (org.apache.kafka.streams.KeyValue)1 Windowed (org.apache.kafka.streams.kstream.Windowed)1 SessionWindow (org.apache.kafka.streams.kstream.internals.SessionWindow)1 ReadOnlySessionStoreStub (org.apache.kafka.test.ReadOnlySessionStoreStub)1 Test (org.junit.Test)1