Search in sources :

Example 11 with StateStoreProviderStub

use of org.apache.kafka.test.StateStoreProviderStub in project apache-kafka-on-k8s by banzaicloud.

the class QueryableStoreProviderTest method before.

@Before
public void before() {
    final StateStoreProviderStub theStoreProvider = new StateStoreProviderStub(false);
    theStoreProvider.addStore(keyValueStore, new NoOpReadOnlyStore<>());
    theStoreProvider.addStore(windowStore, new NoOpWindowStore());
    globalStateStores = new HashMap<>();
    storeProvider = new QueryableStoreProvider(Collections.<StateStoreProvider>singletonList(theStoreProvider), new GlobalStateStoreProvider(globalStateStores));
}
Also used : NoOpWindowStore(org.apache.kafka.streams.state.NoOpWindowStore) StateStoreProviderStub(org.apache.kafka.test.StateStoreProviderStub) Before(org.junit.Before)

Example 12 with StateStoreProviderStub

use of org.apache.kafka.test.StateStoreProviderStub in project apache-kafka-on-k8s by banzaicloud.

the class CompositeReadOnlyWindowStoreTest method before.

@Before
public void before() {
    stubProviderOne = new StateStoreProviderStub(false);
    stubProviderTwo = new StateStoreProviderStub(false);
    underlyingWindowStore = new ReadOnlyWindowStoreStub<>(WINDOW_SIZE);
    stubProviderOne.addStore(storeName, underlyingWindowStore);
    otherUnderlyingStore = new ReadOnlyWindowStoreStub<>(WINDOW_SIZE);
    stubProviderOne.addStore("other-window-store", otherUnderlyingStore);
    windowStore = new CompositeReadOnlyWindowStore<>(new WrappingStoreProvider(Arrays.<StateStoreProvider>asList(stubProviderOne, stubProviderTwo)), QueryableStoreTypes.<String, String>windowStore(), storeName);
}
Also used : StateStoreProviderStub(org.apache.kafka.test.StateStoreProviderStub) Before(org.junit.Before)

Example 13 with StateStoreProviderStub

use of org.apache.kafka.test.StateStoreProviderStub in project apache-kafka-on-k8s by banzaicloud.

the class CompositeReadOnlyWindowStoreTest method emptyIteratorPeekNextKeyShouldThrowNoSuchElementException.

@Test
public void emptyIteratorPeekNextKeyShouldThrowNoSuchElementException() {
    final CompositeReadOnlyWindowStore<Object, Object> store = new CompositeReadOnlyWindowStore<>(new StateStoreProviderStub(false), QueryableStoreTypes.windowStore(), "foo");
    final WindowStoreIterator<Object> windowStoreIterator = store.fetch("key", 1, 10);
    windowStoreIteratorException.expect(NoSuchElementException.class);
    windowStoreIterator.peekNextKey();
}
Also used : StateStoreProviderStub(org.apache.kafka.test.StateStoreProviderStub) Test(org.junit.Test)

Example 14 with StateStoreProviderStub

use of org.apache.kafka.test.StateStoreProviderStub in project apache-kafka-on-k8s by banzaicloud.

the class CompositeReadOnlyWindowStoreTest method shouldThrowInvalidStateStoreExceptionOnRebalance.

@Test(expected = InvalidStateStoreException.class)
public void shouldThrowInvalidStateStoreExceptionOnRebalance() {
    final CompositeReadOnlyWindowStore<Object, Object> store = new CompositeReadOnlyWindowStore<>(new StateStoreProviderStub(true), QueryableStoreTypes.windowStore(), "foo");
    store.fetch("key", 1, 10);
}
Also used : StateStoreProviderStub(org.apache.kafka.test.StateStoreProviderStub) Test(org.junit.Test)

Example 15 with StateStoreProviderStub

use of org.apache.kafka.test.StateStoreProviderStub in project apache-kafka-on-k8s by banzaicloud.

the class CompositeReadOnlyWindowStoreTest method emptyIteratorNextShouldThrowNoSuchElementException.

@Test
public void emptyIteratorNextShouldThrowNoSuchElementException() {
    final CompositeReadOnlyWindowStore<Object, Object> store = new CompositeReadOnlyWindowStore<>(new StateStoreProviderStub(false), QueryableStoreTypes.windowStore(), "foo");
    final WindowStoreIterator<Object> windowStoreIterator = store.fetch("key", 1, 10);
    windowStoreIteratorException.expect(NoSuchElementException.class);
    windowStoreIterator.next();
}
Also used : StateStoreProviderStub(org.apache.kafka.test.StateStoreProviderStub) Test(org.junit.Test)

Aggregations

StateStoreProviderStub (org.apache.kafka.test.StateStoreProviderStub)17 Test (org.junit.Test)9 Before (org.junit.Before)8 NoOpWindowStore (org.apache.kafka.streams.state.NoOpWindowStore)4 ReadOnlySessionStore (org.apache.kafka.streams.state.ReadOnlySessionStore)1