THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Code Block |
---|
package org.apache.kafka.streams.internals; public class MockStoreFactory<K, V> { final String storeName; final Serde<K> keySerde; final Serde<V> valueSerde; final Time time; final Boolean persistent; public MockStoreFactory (final String storeName, final Serde<K> keySerde, final Serde<V> valueSerde, final Time time, final Boolean persistent) { this.storeName = storeName; this.keySerde = keySerde; this.valueSerde = valueSerde; this.time = time; this.persistent = persistent; } public MockKeyValueStoreBuilder createKeyValueStoreBuilder(){ return new MockKeyValueStoreBuilder<K,V>(storeName, keySerde, valueSerde, time, persistent); } } |
I will use the KeyValueStoreBuilder as an example. Window and Session will have a similar structure.
...
Code Block |
---|
package org.apache.kafka.streams.internals; public class MockKeyValueStoreBuilder<K, V> extends AbstractStoreBuilder<K, V, StateStore> { final Boolean persistent; public MockKeyValueStoreBuilder(final String storeName, final Serde<K> keySerde, final Serde<V> valueSerde, final Time time, final Boolean persistent) { super(storeName, keySerde, valueSerde, time); this.persistent = persistent; } @Override public KeyValueStore build() { return new MockKeyValueStore(name, persistent); } } |
Then in the Store, we will build a wrapper around a InMemoryStore, and capture all the get/put calls (excluding Iterators)
...