use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project apache-kafka-on-k8s by banzaicloud.
the class StreamsBuilderTest method shouldAllowJoinMaterializedSourceKTable.
@Test
public void shouldAllowJoinMaterializedSourceKTable() {
final KTable<Bytes, String> table = builder.table("table-topic");
builder.<Bytes, String>stream("stream-topic").join(table, MockValueJoiner.TOSTRING_JOINER);
driver.setUp(builder, TestUtils.tempDirectory());
ProcessorTopology topology = builder.internalTopologyBuilder.build();
assertThat(topology.stateStores().size(), equalTo(1));
assertThat(topology.processorConnectedStateStores("KTABLE-SOURCE-0000000002"), equalTo(Collections.singleton(topology.stateStores().get(0).name())));
assertThat(topology.processorConnectedStateStores("KSTREAM-JOIN-0000000004"), equalTo(Collections.singleton(topology.stateStores().get(0).name())));
}
use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project apache-kafka-on-k8s by banzaicloud.
the class StreamsBuilderTest method shouldAllowJoinUnmaterializedFilteredKTable.
@Test
public void shouldAllowJoinUnmaterializedFilteredKTable() {
final KTable<Bytes, String> filteredKTable = builder.<Bytes, String>table("table-topic").filter(MockPredicate.<Bytes, String>allGoodPredicate());
builder.<Bytes, String>stream("stream-topic").join(filteredKTable, MockValueJoiner.TOSTRING_JOINER);
driver.setUp(builder, TestUtils.tempDirectory());
ProcessorTopology topology = builder.internalTopologyBuilder.build();
assertThat(topology.stateStores().size(), equalTo(1));
assertThat(topology.processorConnectedStateStores("KSTREAM-JOIN-0000000005"), equalTo(Collections.singleton(topology.stateStores().get(0).name())));
assertThat(topology.processorConnectedStateStores("KTABLE-FILTER-0000000003").isEmpty(), is(true));
}
use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project apache-kafka-on-k8s by banzaicloud.
the class KStreamImplTest method shouldUseRecordMetadataTimestampExtractorWithThrough.
@Test
public void shouldUseRecordMetadataTimestampExtractorWithThrough() {
final StreamsBuilder builder = new StreamsBuilder();
final Consumed<String, String> consumed = Consumed.with(stringSerde, stringSerde);
KStream<String, String> stream1 = builder.stream(Arrays.asList("topic-1", "topic-2"), consumed);
KStream<String, String> stream2 = builder.stream(Arrays.asList("topic-3", "topic-4"), consumed);
stream1.to("topic-5");
stream2.through("topic-6");
ProcessorTopology processorTopology = StreamsBuilderTest.internalTopologyBuilder(builder).setApplicationId("X").build(null);
assertThat(processorTopology.source("topic-6").getTimestampExtractor(), instanceOf(FailOnInvalidTimestamp.class));
assertEquals(processorTopology.source("topic-4").getTimestampExtractor(), null);
assertEquals(processorTopology.source("topic-3").getTimestampExtractor(), null);
assertEquals(processorTopology.source("topic-2").getTimestampExtractor(), null);
assertEquals(processorTopology.source("topic-1").getTimestampExtractor(), null);
}
use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project apache-kafka-on-k8s by banzaicloud.
the class KStreamBuilderTest method doBuildGlobalTopologyWithAllGlobalTables.
private void doBuildGlobalTopologyWithAllGlobalTables() {
final ProcessorTopology topology = builder.buildGlobalStateTopology();
final List<StateStore> stateStores = topology.globalStateStores();
final Set<String> sourceTopics = topology.sourceTopics();
assertEquals(Utils.mkSet("table", "table2"), sourceTopics);
assertEquals(2, stateStores.size());
}
use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project apache-kafka-on-k8s by banzaicloud.
the class KStreamBuilderTest method shouldAddTimestampExtractorToTablePerSource.
@Test
public void shouldAddTimestampExtractorToTablePerSource() {
builder.table("topic", "store");
final ProcessorTopology processorTopology = builder.build(null);
assertNull(processorTopology.source("topic").getTimestampExtractor());
}
Aggregations