Search in sources :

Example 1 with KeyValueStoreBuilder

use of org.apache.kafka.streams.state.internals.KeyValueStoreBuilder in project apache-kafka-on-k8s by banzaicloud.

the class TopologyTest method addGlobalStoreToTopologyAndExpectedDescription.

private void addGlobalStoreToTopologyAndExpectedDescription(final String globalStoreName, final String sourceName, final String globalTopicName, final String processorName, final int id) {
    final KeyValueStoreBuilder globalStoreBuilder = EasyMock.createNiceMock(KeyValueStoreBuilder.class);
    EasyMock.expect(globalStoreBuilder.name()).andReturn(globalStoreName).anyTimes();
    EasyMock.replay(globalStoreBuilder);
    topology.addGlobalStore(globalStoreBuilder, sourceName, null, null, null, globalTopicName, processorName, new MockProcessorSupplier());
    final TopologyDescription.GlobalStore expectedGlobalStore = new InternalTopologyBuilder.GlobalStore(sourceName, processorName, globalStoreName, globalTopicName, id);
    expectedDescription.addGlobalStore(expectedGlobalStore);
}
Also used : MockProcessorSupplier(org.apache.kafka.test.MockProcessorSupplier) KeyValueStoreBuilder(org.apache.kafka.streams.state.internals.KeyValueStoreBuilder)

Example 2 with KeyValueStoreBuilder

use of org.apache.kafka.streams.state.internals.KeyValueStoreBuilder in project apache-kafka-on-k8s by banzaicloud.

the class TopologyTestDriverTest method shouldReturnAllStores.

@Test
public void shouldReturnAllStores() {
    final Topology topology = setupSourceSinkTopology();
    topology.addStateStore(new KeyValueStoreBuilder<>(Stores.inMemoryKeyValueStore("store"), Serdes.ByteArray(), Serdes.ByteArray(), new SystemTime()).withLoggingDisabled());
    topology.addGlobalStore(new KeyValueStoreBuilder<>(Stores.inMemoryKeyValueStore("globalStore"), Serdes.ByteArray(), Serdes.ByteArray(), new SystemTime()).withLoggingDisabled(), "sourceProcessorName", Serdes.ByteArray().deserializer(), Serdes.ByteArray().deserializer(), "globalTopicName", "globalProcessorName", new ProcessorSupplier() {

        @Override
        public Processor get() {
            return null;
        }
    });
    testDriver = new TopologyTestDriver(topology, config);
    final Set<String> expectedStoreNames = new HashSet<>();
    expectedStoreNames.add("store");
    expectedStoreNames.add("globalStore");
    assertThat(testDriver.getAllStateStores().keySet(), equalTo(expectedStoreNames));
}
Also used : Processor(org.apache.kafka.streams.processor.Processor) KeyValueStoreBuilder(org.apache.kafka.streams.state.internals.KeyValueStoreBuilder) ProcessorSupplier(org.apache.kafka.streams.processor.ProcessorSupplier) SystemTime(org.apache.kafka.common.utils.SystemTime) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

KeyValueStoreBuilder (org.apache.kafka.streams.state.internals.KeyValueStoreBuilder)2 HashSet (java.util.HashSet)1 SystemTime (org.apache.kafka.common.utils.SystemTime)1 Processor (org.apache.kafka.streams.processor.Processor)1 ProcessorSupplier (org.apache.kafka.streams.processor.ProcessorSupplier)1 MockProcessorSupplier (org.apache.kafka.test.MockProcessorSupplier)1 Test (org.junit.Test)1