Search in sources :

Example 16 with MockTimestampExtractor

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

the class InternalStreamsBuilderTest method ktableShouldUseProvidedTimestampExtractor.

@Test
public void ktableShouldUseProvidedTimestampExtractor() {
    final ConsumedInternal<String, String> consumed = new ConsumedInternal<>(Consumed.with(new MockTimestampExtractor()));
    builder.table("topic", consumed, materialized);
    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)

Example 17 with MockTimestampExtractor

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

the class InternalTopologyBuilderTest method shouldAddTimestampExtractorWithPatternPerSource.

@Test
public void shouldAddTimestampExtractorWithPatternPerSource() {
    final Pattern pattern = Pattern.compile("t.*");
    builder.addSource(null, "source", new MockTimestampExtractor(), null, null, pattern);
    final ProcessorTopology processorTopology = builder.rewriteTopology(new StreamsConfig(StreamsTestUtils.getStreamsConfig())).buildTopology();
    assertThat(processorTopology.source(pattern.pattern()).getTimestampExtractor(), instanceOf(MockTimestampExtractor.class));
}
Also used : Pattern(java.util.regex.Pattern) 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