From 58a735b88559c0f2ae14f2b90681cca43d095673 Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Tue, 18 Jun 2024 10:03:25 +0800 Subject: [PATCH] apply to `streams:examples` and `streams-scala` --- build.gradle | 4 +--- .../examples/pageview/JsonTimestampExtractor.java | 3 ++- .../examples/pageview/PageViewTypedDemo.java | 9 +++++---- .../examples/pageview/PageViewUntypedDemo.java | 11 ++++++----- .../examples/wordcount/WordCountProcessorDemo.java | 13 +++++++------ .../examples/docs/DeveloperGuideTesting.java | 1 + .../examples/wordcount/WordCountDemoTest.java | 3 ++- .../examples/wordcount/WordCountProcessorTest.java | 1 + .../wordcount/WordCountTransformerTest.java | 1 + 9 files changed, 26 insertions(+), 20 deletions(-) diff --git a/build.gradle b/build.gradle index f0e1e8ec08540..1b407bfdaf2cc 100644 --- a/build.gradle +++ b/build.gradle @@ -204,9 +204,7 @@ def determineCommitId() { def excludedSpotlessModules = [':clients', ':connect:runtime', ':core', - ':streams', - ':streams:examples', - ':streams:streams-scala'] + ':streams'] apply from: file('wrapper.gradle') diff --git a/streams/examples/src/main/java/org/apache/kafka/streams/examples/pageview/JsonTimestampExtractor.java b/streams/examples/src/main/java/org/apache/kafka/streams/examples/pageview/JsonTimestampExtractor.java index d760183a8a522..6522aadf62331 100644 --- a/streams/examples/src/main/java/org/apache/kafka/streams/examples/pageview/JsonTimestampExtractor.java +++ b/streams/examples/src/main/java/org/apache/kafka/streams/examples/pageview/JsonTimestampExtractor.java @@ -16,10 +16,11 @@ */ package org.apache.kafka.streams.examples.pageview; -import com.fasterxml.jackson.databind.JsonNode; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.streams.processor.TimestampExtractor; +import com.fasterxml.jackson.databind.JsonNode; + /** * A timestamp extractor implementation that tries to extract event time from * the "timestamp" field in the Json formatted message. diff --git a/streams/examples/src/main/java/org/apache/kafka/streams/examples/pageview/PageViewTypedDemo.java b/streams/examples/src/main/java/org/apache/kafka/streams/examples/pageview/PageViewTypedDemo.java index 367c6e5597d60..efa550222f859 100644 --- a/streams/examples/src/main/java/org/apache/kafka/streams/examples/pageview/PageViewTypedDemo.java +++ b/streams/examples/src/main/java/org/apache/kafka/streams/examples/pageview/PageViewTypedDemo.java @@ -16,9 +16,6 @@ */ package org.apache.kafka.streams.examples.pageview; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.kafka.clients.consumer.ConsumerConfig; import org.apache.kafka.common.errors.SerializationException; import org.apache.kafka.common.serialization.Deserializer; @@ -30,12 +27,16 @@ import org.apache.kafka.streams.StreamsBuilder; import org.apache.kafka.streams.StreamsConfig; import org.apache.kafka.streams.kstream.Consumed; -import org.apache.kafka.streams.kstream.Produced; import org.apache.kafka.streams.kstream.Grouped; import org.apache.kafka.streams.kstream.KStream; import org.apache.kafka.streams.kstream.KTable; +import org.apache.kafka.streams.kstream.Produced; import org.apache.kafka.streams.kstream.TimeWindows; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.databind.ObjectMapper; + import java.io.IOException; import java.time.Duration; import java.util.Map; diff --git a/streams/examples/src/main/java/org/apache/kafka/streams/examples/pageview/PageViewUntypedDemo.java b/streams/examples/src/main/java/org/apache/kafka/streams/examples/pageview/PageViewUntypedDemo.java index 70b70d5714ffd..155dc1b46b337 100644 --- a/streams/examples/src/main/java/org/apache/kafka/streams/examples/pageview/PageViewUntypedDemo.java +++ b/streams/examples/src/main/java/org/apache/kafka/streams/examples/pageview/PageViewUntypedDemo.java @@ -16,10 +16,6 @@ */ package org.apache.kafka.streams.examples.pageview; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.JsonNodeFactory; -import com.fasterxml.jackson.databind.node.ObjectNode; -import java.time.Duration; import org.apache.kafka.clients.consumer.ConsumerConfig; import org.apache.kafka.common.serialization.Deserializer; import org.apache.kafka.common.serialization.Serde; @@ -27,17 +23,22 @@ import org.apache.kafka.common.serialization.Serializer; import org.apache.kafka.connect.json.JsonDeserializer; import org.apache.kafka.connect.json.JsonSerializer; -import org.apache.kafka.streams.kstream.Consumed; import org.apache.kafka.streams.KafkaStreams; import org.apache.kafka.streams.KeyValue; import org.apache.kafka.streams.StreamsBuilder; import org.apache.kafka.streams.StreamsConfig; +import org.apache.kafka.streams.kstream.Consumed; import org.apache.kafka.streams.kstream.Grouped; import org.apache.kafka.streams.kstream.KStream; import org.apache.kafka.streams.kstream.KTable; import org.apache.kafka.streams.kstream.Produced; import org.apache.kafka.streams.kstream.TimeWindows; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; + +import java.time.Duration; import java.util.Properties; /** diff --git a/streams/examples/src/main/java/org/apache/kafka/streams/examples/wordcount/WordCountProcessorDemo.java b/streams/examples/src/main/java/org/apache/kafka/streams/examples/wordcount/WordCountProcessorDemo.java index 594c7d4f20d83..a48babc0d766e 100644 --- a/streams/examples/src/main/java/org/apache/kafka/streams/examples/wordcount/WordCountProcessorDemo.java +++ b/streams/examples/src/main/java/org/apache/kafka/streams/examples/wordcount/WordCountProcessorDemo.java @@ -16,12 +16,6 @@ */ package org.apache.kafka.streams.examples.wordcount; -import java.io.FileInputStream; -import java.io.IOException; -import java.time.Duration; -import java.util.Locale; -import java.util.Properties; -import java.util.concurrent.CountDownLatch; import org.apache.kafka.clients.consumer.ConsumerConfig; import org.apache.kafka.common.serialization.Serdes; import org.apache.kafka.streams.KafkaStreams; @@ -36,6 +30,13 @@ import org.apache.kafka.streams.state.KeyValueStore; import org.apache.kafka.streams.state.Stores; +import java.io.FileInputStream; +import java.io.IOException; +import java.time.Duration; +import java.util.Locale; +import java.util.Properties; +import java.util.concurrent.CountDownLatch; + /** * Demonstrates, using the low-level Processor APIs, how to implement the WordCount program * that computes a simple word occurrence histogram from an input text. diff --git a/streams/examples/src/test/java/org/apache/kafka/streams/examples/docs/DeveloperGuideTesting.java b/streams/examples/src/test/java/org/apache/kafka/streams/examples/docs/DeveloperGuideTesting.java index 140ccc73a63bd..d0b9864c9f5dd 100644 --- a/streams/examples/src/test/java/org/apache/kafka/streams/examples/docs/DeveloperGuideTesting.java +++ b/streams/examples/src/test/java/org/apache/kafka/streams/examples/docs/DeveloperGuideTesting.java @@ -32,6 +32,7 @@ import org.apache.kafka.streams.state.KeyValueIterator; import org.apache.kafka.streams.state.KeyValueStore; import org.apache.kafka.streams.state.Stores; + import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/streams/examples/src/test/java/org/apache/kafka/streams/examples/wordcount/WordCountDemoTest.java b/streams/examples/src/test/java/org/apache/kafka/streams/examples/wordcount/WordCountDemoTest.java index 1136889cac963..6ce41cb714739 100644 --- a/streams/examples/src/test/java/org/apache/kafka/streams/examples/wordcount/WordCountDemoTest.java +++ b/streams/examples/src/test/java/org/apache/kafka/streams/examples/wordcount/WordCountDemoTest.java @@ -22,10 +22,11 @@ import org.apache.kafka.common.serialization.StringSerializer; import org.apache.kafka.streams.KeyValue; import org.apache.kafka.streams.StreamsBuilder; -import org.apache.kafka.streams.TopologyTestDriver; import org.apache.kafka.streams.TestInputTopic; import org.apache.kafka.streams.TestOutputTopic; +import org.apache.kafka.streams.TopologyTestDriver; import org.apache.kafka.test.TestUtils; + import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/streams/examples/src/test/java/org/apache/kafka/streams/examples/wordcount/WordCountProcessorTest.java b/streams/examples/src/test/java/org/apache/kafka/streams/examples/wordcount/WordCountProcessorTest.java index 1343a2974f2ea..50df2f1e4fc69 100644 --- a/streams/examples/src/test/java/org/apache/kafka/streams/examples/wordcount/WordCountProcessorTest.java +++ b/streams/examples/src/test/java/org/apache/kafka/streams/examples/wordcount/WordCountProcessorTest.java @@ -22,6 +22,7 @@ import org.apache.kafka.streams.processor.api.Record; import org.apache.kafka.streams.state.KeyValueStore; import org.apache.kafka.streams.state.Stores; + import org.junit.jupiter.api.Test; import java.util.Arrays; diff --git a/streams/examples/src/test/java/org/apache/kafka/streams/examples/wordcount/WordCountTransformerTest.java b/streams/examples/src/test/java/org/apache/kafka/streams/examples/wordcount/WordCountTransformerTest.java index 27d32ee9332d8..28fc324c07c85 100644 --- a/streams/examples/src/test/java/org/apache/kafka/streams/examples/wordcount/WordCountTransformerTest.java +++ b/streams/examples/src/test/java/org/apache/kafka/streams/examples/wordcount/WordCountTransformerTest.java @@ -25,6 +25,7 @@ import org.apache.kafka.streams.processor.api.Processor; import org.apache.kafka.streams.processor.api.Record; import org.apache.kafka.streams.state.StoreBuilder; + import org.junit.jupiter.api.Test; import java.time.Duration;