Search in sources :

Example 51 with MockProcessorSupplier

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

the class TopologyBuilderTest method testAddStateStore.

@Test
public void testAddStateStore() {
    final TopologyBuilder builder = new TopologyBuilder();
    StateStoreSupplier supplier = new MockStateStoreSupplier("store-1", false);
    builder.addStateStore(supplier);
    builder.setApplicationId("X");
    builder.addSource("source-1", "topic-1");
    builder.addProcessor("processor-1", new MockProcessorSupplier(), "source-1");
    assertEquals(0, builder.build(null).stateStores().size());
    builder.connectProcessorAndStateStores("processor-1", "store-1");
    List<StateStore> suppliers = builder.build(null).stateStores();
    assertEquals(1, suppliers.size());
    assertEquals(supplier.name(), suppliers.get(0).name());
}
Also used : MockProcessorSupplier(org.apache.kafka.test.MockProcessorSupplier) MockStateStoreSupplier(org.apache.kafka.test.MockStateStoreSupplier) MockStateStoreSupplier(org.apache.kafka.test.MockStateStoreSupplier) Test(org.junit.Test)

Example 52 with MockProcessorSupplier

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

the class TopologyBuilderTest method shouldAddInternalTopicConfigWithCompactForNonWindowStores.

@SuppressWarnings("unchecked")
@Test
public void shouldAddInternalTopicConfigWithCompactForNonWindowStores() throws Exception {
    final TopologyBuilder builder = new TopologyBuilder();
    builder.setApplicationId("appId");
    builder.addSource("source", "topic");
    builder.addProcessor("processor", new MockProcessorSupplier(), "source");
    builder.addStateStore(new MockStateStoreSupplier("name", true), "processor");
    final Map<Integer, TopicsInfo> topicGroups = builder.topicGroups();
    final TopicsInfo topicsInfo = topicGroups.values().iterator().next();
    final InternalTopicConfig topicConfig = topicsInfo.stateChangelogTopics.get("appId-name-changelog");
    final Properties properties = topicConfig.toProperties(0);
    assertEquals("appId-name-changelog", topicConfig.name());
    assertEquals("compact", properties.getProperty(InternalTopicManager.CLEANUP_POLICY_PROP));
    assertEquals(1, properties.size());
}
Also used : MockProcessorSupplier(org.apache.kafka.test.MockProcessorSupplier) MockStateStoreSupplier(org.apache.kafka.test.MockStateStoreSupplier) InternalTopicConfig(org.apache.kafka.streams.processor.internals.InternalTopicConfig) TopicsInfo(org.apache.kafka.streams.processor.TopologyBuilder.TopicsInfo) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

MockProcessorSupplier (org.apache.kafka.test.MockProcessorSupplier)52 Test (org.junit.Test)51 KStreamTestDriver (org.apache.kafka.test.KStreamTestDriver)26 KStreamBuilder (org.apache.kafka.streams.kstream.KStreamBuilder)25 HashMap (java.util.HashMap)15 Metrics (org.apache.kafka.common.metrics.Metrics)14 TaskId (org.apache.kafka.streams.processor.TaskId)13 UUID (java.util.UUID)12 PartitionAssignor (org.apache.kafka.clients.consumer.internals.PartitionAssignor)12 SubscriptionInfo (org.apache.kafka.streams.processor.internals.assignment.SubscriptionInfo)11 HashSet (java.util.HashSet)9 AssignmentInfo (org.apache.kafka.streams.processor.internals.assignment.AssignmentInfo)8 MockInternalTopicManager (org.apache.kafka.test.MockInternalTopicManager)8 MockStateStoreSupplier (org.apache.kafka.test.MockStateStoreSupplier)8 Properties (java.util.Properties)7 StreamsConfig (org.apache.kafka.streams.StreamsConfig)6 TopicPartition (org.apache.kafka.common.TopicPartition)4 KeyValueMapper (org.apache.kafka.streams.kstream.KeyValueMapper)4 Predicate (org.apache.kafka.streams.kstream.Predicate)4 TopicsInfo (org.apache.kafka.streams.processor.TopologyBuilder.TopicsInfo)4