use of org.apache.kafka.test.MockProcessorSupplier in project apache-kafka-on-k8s by banzaicloud.
the class InternalTopologyBuilderTest method testAddStateStore.
@SuppressWarnings("deprecation")
@Test
public void testAddStateStore() {
final StateStoreSupplier supplier = new MockStateStoreSupplier("store-1", false);
builder.addStateStore(supplier);
builder.setApplicationId("X");
builder.addSource(null, "source-1", null, null, null, "topic-1");
builder.addProcessor("processor-1", new MockProcessorSupplier(), "source-1");
assertEquals(0, builder.build(null).stateStores().size());
builder.connectProcessorAndStateStores("processor-1", "store-1");
final List<StateStore> suppliers = builder.build(null).stateStores();
assertEquals(1, suppliers.size());
assertEquals(supplier.name(), suppliers.get(0).name());
}
use of org.apache.kafka.test.MockProcessorSupplier in project apache-kafka-on-k8s by banzaicloud.
the class InternalTopologyBuilderTest method shouldAssociateStateStoreNameWhenStateStoreSupplierIsExternal.
@Test
public void shouldAssociateStateStoreNameWhenStateStoreSupplierIsExternal() throws Exception {
builder.addSource(null, "source", null, null, null, "topic");
builder.addProcessor("processor", new MockProcessorSupplier(), "source");
builder.addStateStore(new MockStateStoreSupplier("store", false), "processor");
final Map<String, List<String>> stateStoreNameToSourceTopic = builder.stateStoreNameToSourceTopics();
assertEquals(1, stateStoreNameToSourceTopic.size());
assertEquals(Collections.singletonList("topic"), stateStoreNameToSourceTopic.get("store"));
}
use of org.apache.kafka.test.MockProcessorSupplier in project apache-kafka-on-k8s by banzaicloud.
the class InternalTopologyBuilderTest method shouldAddInternalTopicConfigForNonWindowStores.
@SuppressWarnings("unchecked")
@Test
public void shouldAddInternalTopicConfigForNonWindowStores() throws Exception {
builder.setApplicationId("appId");
builder.addSource(null, "source", null, null, null, "topic");
builder.addProcessor("processor", new MockProcessorSupplier(), "source");
builder.addStateStore(new MockStateStoreSupplier("store", true), "processor");
final Map<Integer, InternalTopologyBuilder.TopicsInfo> topicGroups = builder.topicGroups();
final InternalTopologyBuilder.TopicsInfo topicsInfo = topicGroups.values().iterator().next();
final InternalTopicConfig topicConfig = topicsInfo.stateChangelogTopics.get("appId-store-changelog");
final Map<String, String> properties = topicConfig.getProperties(Collections.<String, String>emptyMap(), 10000);
assertEquals(1, properties.size());
assertEquals(TopicConfig.CLEANUP_POLICY_COMPACT, properties.get(TopicConfig.CLEANUP_POLICY_CONFIG));
assertEquals("appId-store-changelog", topicConfig.name());
assertTrue(topicConfig instanceof UnwindowedChangelogTopicConfig);
}
use of org.apache.kafka.test.MockProcessorSupplier in project apache-kafka-on-k8s by banzaicloud.
the class InternalTopologyBuilderTest method shouldAssociateStateStoreNameWhenStateStoreSupplierIsInternal.
@Test
public void shouldAssociateStateStoreNameWhenStateStoreSupplierIsInternal() throws Exception {
builder.addSource(null, "source", null, null, null, "topic");
builder.addProcessor("processor", new MockProcessorSupplier(), "source");
builder.addStateStore(new MockStateStoreSupplier("store", false), "processor");
final Map<String, List<String>> stateStoreNameToSourceTopic = builder.stateStoreNameToSourceTopics();
assertEquals(1, stateStoreNameToSourceTopic.size());
assertEquals(Collections.singletonList("topic"), stateStoreNameToSourceTopic.get("store"));
}
use of org.apache.kafka.test.MockProcessorSupplier in project apache-kafka-on-k8s by banzaicloud.
the class InternalTopologyBuilderTest method shouldConnectRegexMatchedTopicsToStateStore.
@Test
public void shouldConnectRegexMatchedTopicsToStateStore() throws Exception {
builder.addSource(null, "ingest", null, null, null, Pattern.compile("topic-\\d+"));
builder.addProcessor("my-processor", new MockProcessorSupplier(), "ingest");
builder.addStateStore(new MockStateStoreSupplier("testStateStore", false), "my-processor");
final InternalTopologyBuilder.SubscriptionUpdates subscriptionUpdates = new InternalTopologyBuilder.SubscriptionUpdates();
final Field updatedTopicsField = subscriptionUpdates.getClass().getDeclaredField("updatedTopicSubscriptions");
updatedTopicsField.setAccessible(true);
final Set<String> updatedTopics = (Set<String>) updatedTopicsField.get(subscriptionUpdates);
updatedTopics.add("topic-2");
updatedTopics.add("topic-3");
updatedTopics.add("topic-A");
builder.updateSubscriptions(subscriptionUpdates, "test-thread");
builder.setApplicationId("test-app");
final Map<String, List<String>> stateStoreAndTopics = builder.stateStoreNameToSourceTopics();
final List<String> topics = stateStoreAndTopics.get("testStateStore");
assertTrue("Expected to contain two topics", topics.size() == 2);
assertTrue(topics.contains("topic-2"));
assertTrue(topics.contains("topic-3"));
assertFalse(topics.contains("topic-A"));
}
Aggregations