use of org.apache.kafka.test.ProcessorTopologyTestDriver in project apache-kafka-on-k8s by banzaicloud.
the class ProcessorTopologyTest method shouldDriveGlobalStore.
@SuppressWarnings("unchecked")
@Test
public void shouldDriveGlobalStore() {
final String storeName = "my-store";
final StateStoreSupplier storeSupplier = Stores.create(storeName).withStringKeys().withStringValues().inMemory().disableLogging().build();
final String global = "global";
final String topic = "topic";
final TopologyBuilder topologyBuilder = this.builder.addGlobalStore(storeSupplier, global, STRING_DESERIALIZER, STRING_DESERIALIZER, topic, "processor", define(new StatefulProcessor(storeName)));
driver = new ProcessorTopologyTestDriver(config, topologyBuilder.internalTopologyBuilder);
final KeyValueStore<String, String> globalStore = (KeyValueStore<String, String>) topologyBuilder.globalStateStores().get(storeName);
driver.process(topic, "key1", "value1", STRING_SERIALIZER, STRING_SERIALIZER);
driver.process(topic, "key2", "value2", STRING_SERIALIZER, STRING_SERIALIZER);
assertEquals("value1", globalStore.get("key1"));
assertEquals("value2", globalStore.get("key2"));
}
use of org.apache.kafka.test.ProcessorTopologyTestDriver in project apache-kafka-on-k8s by banzaicloud.
the class ProcessorTopologyTest method shouldConsiderModifiedTimeStamps.
@Test
public void shouldConsiderModifiedTimeStamps() {
final int partition = 10;
driver = new ProcessorTopologyTestDriver(config, createTimestampTopology(partition).internalTopologyBuilder);
driver.process(INPUT_TOPIC_1, "key1", "value1", STRING_SERIALIZER, STRING_SERIALIZER, 10L);
driver.process(INPUT_TOPIC_1, "key2", "value2", STRING_SERIALIZER, STRING_SERIALIZER, 20L);
driver.process(INPUT_TOPIC_1, "key3", "value3", STRING_SERIALIZER, STRING_SERIALIZER, 30L);
assertNextOutputRecord(OUTPUT_TOPIC_1, "key1", "value1", partition, 20L);
assertNextOutputRecord(OUTPUT_TOPIC_1, "key2", "value2", partition, 30L);
assertNextOutputRecord(OUTPUT_TOPIC_1, "key3", "value3", partition, 40L);
}
Aggregations