Search in sources :

Example 11 with MockTimestampExtractor

use of org.apache.kafka.test.MockTimestampExtractor in project apache-kafka-on-k8s by banzaicloud.

the class InternalStreamsBuilderTest method ktableShouldUseProvidedTimestampExtractor.

@Test
public void ktableShouldUseProvidedTimestampExtractor() throws Exception {
    final ConsumedInternal<String, String> consumed = new ConsumedInternal<>(Consumed.<String, String>with(new MockTimestampExtractor()));
    builder.table("topic", consumed, materialized);
    final ProcessorTopology processorTopology = builder.internalTopologyBuilder.build(null);
    assertThat(processorTopology.source("topic").getTimestampExtractor(), instanceOf(MockTimestampExtractor.class));
}
Also used : ProcessorTopology(org.apache.kafka.streams.processor.internals.ProcessorTopology) MockTimestampExtractor(org.apache.kafka.test.MockTimestampExtractor) Test(org.junit.Test)

Example 12 with MockTimestampExtractor

use of org.apache.kafka.test.MockTimestampExtractor in project apache-kafka-on-k8s by banzaicloud.

the class InternalTopologyBuilderTest method shouldAddTimestampExtractorWithPatternPerSource.

@SuppressWarnings("unchecked")
@Test
public void shouldAddTimestampExtractorWithPatternPerSource() throws Exception {
    final Pattern pattern = Pattern.compile("t.*");
    builder.addSource(null, "source", new MockTimestampExtractor(), null, null, pattern);
    final ProcessorTopology processorTopology = builder.build(null);
    assertThat(processorTopology.source(pattern.pattern()).getTimestampExtractor(), instanceOf(MockTimestampExtractor.class));
}
Also used : Pattern(java.util.regex.Pattern) MockTimestampExtractor(org.apache.kafka.test.MockTimestampExtractor) Test(org.junit.Test)

Example 13 with MockTimestampExtractor

use of org.apache.kafka.test.MockTimestampExtractor in project apache-kafka-on-k8s by banzaicloud.

the class TopologyBuilderTest method shouldAddTimestampExtractorPerSource.

@Test
public void shouldAddTimestampExtractorPerSource() {
    final TopologyBuilder builder = new TopologyBuilder();
    builder.addSource(new MockTimestampExtractor(), "source", "topic");
    final ProcessorTopology processorTopology = builder.build(null);
    assertThat(processorTopology.source("topic").getTimestampExtractor(), instanceOf(MockTimestampExtractor.class));
}
Also used : ProcessorTopology(org.apache.kafka.streams.processor.internals.ProcessorTopology) MockTimestampExtractor(org.apache.kafka.test.MockTimestampExtractor) Test(org.junit.Test)

Example 14 with MockTimestampExtractor

use of org.apache.kafka.test.MockTimestampExtractor in project apache-kafka-on-k8s by banzaicloud.

the class TopologyBuilderTest method shouldAddTimestampExtractorWithPatternPerSource.

@Test
public void shouldAddTimestampExtractorWithPatternPerSource() {
    final TopologyBuilder builder = new TopologyBuilder();
    final Pattern pattern = Pattern.compile("t.*");
    builder.addSource(new MockTimestampExtractor(), "source", pattern);
    final ProcessorTopology processorTopology = builder.build(null);
    assertThat(processorTopology.source(pattern.pattern()).getTimestampExtractor(), instanceOf(MockTimestampExtractor.class));
}
Also used : Pattern(java.util.regex.Pattern) ProcessorTopology(org.apache.kafka.streams.processor.internals.ProcessorTopology) MockTimestampExtractor(org.apache.kafka.test.MockTimestampExtractor) Test(org.junit.Test)

Example 15 with MockTimestampExtractor

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

the class InternalStreamsBuilderTest method shouldUseProvidedTimestampExtractor.

@Test
public void shouldUseProvidedTimestampExtractor() {
    final ConsumedInternal<String, String> consumed = new ConsumedInternal<>(Consumed.with(new MockTimestampExtractor()));
    builder.stream(Collections.singleton("topic"), consumed);
    builder.buildAndOptimizeTopology();
    final ProcessorTopology processorTopology = builder.internalTopologyBuilder.rewriteTopology(new StreamsConfig(StreamsTestUtils.getStreamsConfig(APP_ID))).buildTopology();
    assertThat(processorTopology.source("topic").getTimestampExtractor(), instanceOf(MockTimestampExtractor.class));
}
Also used : ProcessorTopology(org.apache.kafka.streams.processor.internals.ProcessorTopology) MockTimestampExtractor(org.apache.kafka.test.MockTimestampExtractor) StreamsConfig(org.apache.kafka.streams.StreamsConfig) Test(org.junit.Test)

Aggregations

MockTimestampExtractor (org.apache.kafka.test.MockTimestampExtractor)17 Test (org.junit.Test)17 ProcessorTopology (org.apache.kafka.streams.processor.internals.ProcessorTopology)13 Pattern (java.util.regex.Pattern)5 StreamsConfig (org.apache.kafka.streams.StreamsConfig)4 SourceNode (org.apache.kafka.streams.processor.internals.SourceNode)1