From 2cd85c0714158aee833ea3d0adc4a9e142c22a82 Mon Sep 17 00:00:00 2001 From: Soby Chacko Date: Fri, 18 Oct 2024 15:36:31 -0400 Subject: [PATCH] Optimize imports based on new checkstyle rules --- .../example/Sample05Application1Tests.java | 4 +- .../example/Sample05Application2Tests.java | 4 +- .../kafka/core/KafkaTemplate.java | 5 +-- .../core/MicrometerConsumerListener.java | 3 +- .../core/MicrometerProducerListener.java | 3 +- .../ReactiveKafkaConsumerTemplate.java | 5 +-- .../ReactiveKafkaProducerTemplate.java | 15 +++---- .../KafkaMessageListenerContainer.java | 5 +-- .../KafkaStreamsMicrometerListener.java | 7 ++- .../support/DefaultKafkaHeaderMapper.java | 17 ++++---- .../kafka/support/JacksonMimeTypeModule.java | 4 +- .../kafka/support/JacksonUtils.java | 4 +- .../ByteArrayJsonMessageConverter.java | 6 +-- .../converter/BytesJsonMessageConverter.java | 5 +-- .../converter/JsonMessageConverter.java | 7 ++- .../MappingJacksonParameterizedConverter.java | 5 +-- .../converter/ProjectingMessageConverter.java | 5 +-- .../converter/StringJsonMessageConverter.java | 6 +-- .../DefaultJackson2JavaTypeMapper.java | 5 +-- .../mapping/Jackson2JavaTypeMapper.java | 3 +- .../KafkaRecordReceiverContext.java | 3 +- .../micrometer/KafkaRecordSenderContext.java | 3 +- .../support/micrometer/MicrometerHolder.java | 10 ++--- .../support/serializer/JsonDeserializer.java | 11 +++-- .../kafka/support/serializer/JsonSerde.java | 7 ++- .../support/serializer/JsonSerializer.java | 9 ++-- .../support/serializer/JsonTypeResolver.java | 3 +- .../KafkaListenerEndpointRegistryTests.java | 8 ++-- .../config/KafkaStreamsCustomizerTests.java | 9 ++-- ...dMessagingMessageListenerAdapterTests.java | 4 +- ...derFactoryBeanInMemoryStateStoreTests.java | 4 +- .../StreamsBuilderFactoryBeanTests.java | 8 ++-- .../StreamsBuilderFactoryLateConfigTests.java | 8 ++-- .../DefaultKafkaConsumerFactoryTests.java | 8 ++-- .../DefaultKafkaProducerFactoryTests.java | 28 ++++++------ .../kafka/core/KafkaAdminBadContextTests.java | 4 +- .../kafka/core/KafkaAdminTests.java | 12 +++--- .../kafka/core/KafkaTemplateTests.java | 36 ++++++++-------- .../core/KafkaTemplateTransactionTests.java | 36 ++++++++-------- .../kafka/core/RoutingKafkaTemplateTests.java | 16 +++---- .../core/TransactionSynchronizationTests.java | 12 +++--- ...KafkaProducerTemplateIntegrationTests.java | 25 ++++++----- ...erTemplateTransactionIntegrationTests.java | 27 ++++++------ .../kafka/listener/ABSwitchClusterTests.java | 10 ++--- .../listener/AsyncAckAfterHandleTests.java | 4 +- .../listener/CommitOnAssignmentTests.java | 22 +++++----- .../listener/ConsumerSeekAwareTests.java | 8 ++-- .../listener/ErrorHandlingCoverageTests.java | 4 +- .../listener/ErrorHandlingUtilsTest.java | 18 ++++---- .../listener/ExceptionClassifierTests.java | 4 +- .../listener/FailedBatchProcessorTests.java | 22 +++++----- .../listener/FailedRecordProcessorTests.java | 4 +- .../listener/FailedRecordTrackerTests.java | 8 ++-- .../listener/ListenerErrorHandlerTests.java | 10 ++--- .../kafka/listener/ListenerUtilsTests.java | 6 +-- .../listener/LoggingErrorHandlerTests.java | 22 +++++----- .../kafka/listener/ManualNackBatchTests.java | 16 +++---- .../listener/ManualNackBatchTxTests.java | 20 ++++----- .../kafka/listener/ManualNackRecordTests.java | 16 +++---- .../kafka/listener/MissingGroupIdTests.java | 4 +- .../kafka/listener/MissingTopicsTests.java | 6 +-- .../kafka/listener/MockConsumerTests.java | 4 +- .../listener/SubBatchPerPartitionTests.java | 22 +++++----- .../kafka/listener/TestOOMError.java | 14 +++--- .../BatchAdapterConversionErrorsTests.java | 8 ++-- .../BatchListenerWithRecordAdapterTests.java | 6 +-- ...hMessagingMessageListenerAdapterTests.java | 6 +-- .../ConvertingMessageListenerTests.java | 17 ++++---- .../adapter/FilteringAdapterTests.java | 14 +++--- ...ckoffAwareMessageListenerAdapterTests.java | 22 +++++----- .../MessagingMessageListenerAdapterTests.java | 10 ++--- .../kafka/streams/Configurer1Tests.java | 4 +- .../kafka/streams/Configurer2Tests.java | 4 +- .../streams/HeaderEnricherProcessorTests.java | 4 +- .../streams/KafkaStreamsBranchTests.java | 4 +- .../KafkaStreamsJsonSerializationTests.java | 7 ++- .../kafka/streams/KafkaStreamsTests.java | 7 ++- ...gDeserializationExceptionHandlerTests.java | 4 +- .../messaging/MessagingProcessorTests.java | 4 +- .../DefaultKafkaHeaderMapperTests.java | 6 +-- ...ExponentialBackOffWithMaxRetriesTests.java | 6 +-- .../support/KafkaStreamBrancherTests.java | 12 +++--- .../kafka/support/LogIfLevelEnabledTests.java | 12 +++--- .../support/LoggingProducerListenerTests.java | 10 ++--- .../support/SimpleKafkaHeaderMapperTests.java | 8 ++-- .../support/TopicPartitionOffsetTests.java | 4 +- .../converter/BatchMessageConverterTests.java | 6 +-- .../MessagingMessageConverterTests.java | 4 +- .../ProjectingMessageConverterTests.java | 11 +++-- .../micrometer/MicrometerHolderTests.java | 23 +++++----- .../ObservationIntegrationTests.java | 19 ++++---- .../support/micrometer/ObservationTests.java | 43 +++++++++---------- .../DelegatingByTopicSerializationTests.java | 4 +- .../DelegatingSerializationTests.java | 12 +++--- .../support/serializer/JsonSerdeTests.java | 4 +- .../serializer/JsonSerializationTests.java | 27 ++++++------ .../serializer/RetryingDeserializerTests.java | 10 ++--- .../SerializationIntegrationTests.java | 6 +-- .../serializer/SerializationUtilsTests.java | 14 +++--- .../StringOrBytesSerializerTests.java | 4 +- .../ToStringSerializationTests.java | 4 +- src/checkstyle/checkstyle.xml | 4 +- 102 files changed, 498 insertions(+), 529 deletions(-) diff --git a/samples/sample-05/src/test/java/com/example/Sample05Application1Tests.java b/samples/sample-05/src/test/java/com/example/Sample05Application1Tests.java index e5cc650ff3..17aa75a9f1 100644 --- a/samples/sample-05/src/test/java/com/example/Sample05Application1Tests.java +++ b/samples/sample-05/src/test/java/com/example/Sample05Application1Tests.java @@ -16,8 +16,6 @@ package com.example; -import static org.awaitility.Awaitility.await; - import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -28,6 +26,8 @@ import org.springframework.kafka.core.KafkaTemplate; import org.springframework.test.annotation.DirtiesContext; +import static org.awaitility.Awaitility.await; + /** * This test is going to fail from IDE since there is no exposed {@code spring.embedded.kafka.brokers} system property. * Use Maven to run tests which enables global embedded Kafka broker via properties provided to Surefire plugin. diff --git a/samples/sample-05/src/test/java/com/example/Sample05Application2Tests.java b/samples/sample-05/src/test/java/com/example/Sample05Application2Tests.java index b49c673aa1..1c8f77dd77 100644 --- a/samples/sample-05/src/test/java/com/example/Sample05Application2Tests.java +++ b/samples/sample-05/src/test/java/com/example/Sample05Application2Tests.java @@ -16,8 +16,6 @@ package com.example; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - import java.util.concurrent.TimeUnit; import org.apache.kafka.common.errors.TimeoutException; @@ -29,6 +27,8 @@ import org.springframework.kafka.core.KafkaTemplate; import org.springframework.test.annotation.DirtiesContext; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; + /** * This test is going to fail from IDE since there is no exposed {@code spring.embedded.kafka.brokers} system property. * This test demonstrates that global embedded Kafka broker config for {@code auto.create.topics.enable=false} diff --git a/spring-kafka/src/main/java/org/springframework/kafka/core/KafkaTemplate.java b/spring-kafka/src/main/java/org/springframework/kafka/core/KafkaTemplate.java index d037c20e0a..b25cf0fab7 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/core/KafkaTemplate.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/core/KafkaTemplate.java @@ -33,6 +33,8 @@ import java.util.concurrent.locks.ReentrantLock; import java.util.function.Function; +import io.micrometer.observation.Observation; +import io.micrometer.observation.ObservationRegistry; import org.apache.commons.logging.LogFactory; import org.apache.kafka.clients.admin.AdminClientConfig; import org.apache.kafka.clients.consumer.Consumer; @@ -82,9 +84,6 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; -import io.micrometer.observation.Observation; -import io.micrometer.observation.ObservationRegistry; - /** * A template for executing high-level operations. When used with a * {@link DefaultKafkaProducerFactory}, the template is thread-safe. The producer factory diff --git a/spring-kafka/src/main/java/org/springframework/kafka/core/MicrometerConsumerListener.java b/spring-kafka/src/main/java/org/springframework/kafka/core/MicrometerConsumerListener.java index bfbf4ea874..27b8a3c629 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/core/MicrometerConsumerListener.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/core/MicrometerConsumerListener.java @@ -22,12 +22,11 @@ import java.util.List; import java.util.Map; -import org.apache.kafka.clients.consumer.Consumer; - import io.micrometer.core.instrument.ImmutableTag; import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.Tag; import io.micrometer.core.instrument.binder.kafka.KafkaClientMetrics; +import org.apache.kafka.clients.consumer.Consumer; /** * A consumer factory listener that manages {@link KafkaClientMetrics}. diff --git a/spring-kafka/src/main/java/org/springframework/kafka/core/MicrometerProducerListener.java b/spring-kafka/src/main/java/org/springframework/kafka/core/MicrometerProducerListener.java index 9a45845753..07584d69a4 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/core/MicrometerProducerListener.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/core/MicrometerProducerListener.java @@ -22,12 +22,11 @@ import java.util.List; import java.util.Map; -import org.apache.kafka.clients.producer.Producer; - import io.micrometer.core.instrument.ImmutableTag; import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.Tag; import io.micrometer.core.instrument.binder.kafka.KafkaClientMetrics; +import org.apache.kafka.clients.producer.Producer; /** * A producer factory listener that manages {@link KafkaClientMetrics}. diff --git a/spring-kafka/src/main/java/org/springframework/kafka/core/reactive/ReactiveKafkaConsumerTemplate.java b/spring-kafka/src/main/java/org/springframework/kafka/core/reactive/ReactiveKafkaConsumerTemplate.java index 0dc15d7b60..17c2a956df 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/core/reactive/ReactiveKafkaConsumerTemplate.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/core/reactive/ReactiveKafkaConsumerTemplate.java @@ -30,9 +30,6 @@ import org.apache.kafka.common.MetricName; import org.apache.kafka.common.PartitionInfo; import org.apache.kafka.common.TopicPartition; - -import org.springframework.util.Assert; - import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.kafka.receiver.KafkaReceiver; @@ -42,6 +39,8 @@ import reactor.util.function.Tuple2; import reactor.util.function.Tuples; +import org.springframework.util.Assert; + /** * Reactive kafka consumer operations implementation. * diff --git a/spring-kafka/src/main/java/org/springframework/kafka/core/reactive/ReactiveKafkaProducerTemplate.java b/spring-kafka/src/main/java/org/springframework/kafka/core/reactive/ReactiveKafkaProducerTemplate.java index e2e9af4771..e4217f94bb 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/core/reactive/ReactiveKafkaProducerTemplate.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/core/reactive/ReactiveKafkaProducerTemplate.java @@ -26,14 +26,6 @@ import org.apache.kafka.common.MetricName; import org.apache.kafka.common.PartitionInfo; import org.reactivestreams.Publisher; - -import org.springframework.beans.factory.DisposableBean; -import org.springframework.kafka.support.KafkaHeaders; -import org.springframework.kafka.support.converter.MessagingMessageConverter; -import org.springframework.kafka.support.converter.RecordMessageConverter; -import org.springframework.messaging.Message; -import org.springframework.util.Assert; - import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.kafka.sender.KafkaSender; @@ -44,6 +36,13 @@ import reactor.util.function.Tuple2; import reactor.util.function.Tuples; +import org.springframework.beans.factory.DisposableBean; +import org.springframework.kafka.support.KafkaHeaders; +import org.springframework.kafka.support.converter.MessagingMessageConverter; +import org.springframework.kafka.support.converter.RecordMessageConverter; +import org.springframework.messaging.Message; +import org.springframework.util.Assert; + /** * Reactive kafka producer operations implementation. * diff --git a/spring-kafka/src/main/java/org/springframework/kafka/listener/KafkaMessageListenerContainer.java b/spring-kafka/src/main/java/org/springframework/kafka/listener/KafkaMessageListenerContainer.java index e71abdd5bb..74bad22bf0 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/listener/KafkaMessageListenerContainer.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/listener/KafkaMessageListenerContainer.java @@ -47,6 +47,8 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; +import io.micrometer.observation.Observation; +import io.micrometer.observation.ObservationRegistry; import org.apache.kafka.clients.admin.AdminClientConfig; import org.apache.kafka.clients.consumer.CommitFailedException; import org.apache.kafka.clients.consumer.Consumer; @@ -132,9 +134,6 @@ import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; -import io.micrometer.observation.Observation; -import io.micrometer.observation.ObservationRegistry; - /** * Single-threaded Message listener container using the Java {@link Consumer} supporting diff --git a/spring-kafka/src/main/java/org/springframework/kafka/streams/KafkaStreamsMicrometerListener.java b/spring-kafka/src/main/java/org/springframework/kafka/streams/KafkaStreamsMicrometerListener.java index e1814c13d1..26e2e323d8 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/streams/KafkaStreamsMicrometerListener.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/streams/KafkaStreamsMicrometerListener.java @@ -22,14 +22,13 @@ import java.util.List; import java.util.Map; -import org.apache.kafka.streams.KafkaStreams; - -import org.springframework.kafka.config.StreamsBuilderFactoryBean; - import io.micrometer.core.instrument.ImmutableTag; import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.Tag; import io.micrometer.core.instrument.binder.kafka.KafkaStreamsMetrics; +import org.apache.kafka.streams.KafkaStreams; + +import org.springframework.kafka.config.StreamsBuilderFactoryBean; /** * Creates a {@link KafkaStreamsMetrics} for the {@link KafkaStreams}. diff --git a/spring-kafka/src/main/java/org/springframework/kafka/support/DefaultKafkaHeaderMapper.java b/spring-kafka/src/main/java/org/springframework/kafka/support/DefaultKafkaHeaderMapper.java index c2bfcd3922..6f1342c1cf 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/support/DefaultKafkaHeaderMapper.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/support/DefaultKafkaHeaderMapper.java @@ -27,15 +27,6 @@ import java.util.Map; import java.util.Set; -import org.apache.kafka.common.header.Header; -import org.apache.kafka.common.header.Headers; -import org.apache.kafka.common.header.internals.RecordHeader; - -import org.springframework.messaging.MessageHeaders; -import org.springframework.util.Assert; -import org.springframework.util.ClassUtils; -import org.springframework.util.MimeType; - import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.DeserializationContext; @@ -45,6 +36,14 @@ import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.node.TextNode; import com.fasterxml.jackson.databind.type.TypeFactory; +import org.apache.kafka.common.header.Header; +import org.apache.kafka.common.header.Headers; +import org.apache.kafka.common.header.internals.RecordHeader; + +import org.springframework.messaging.MessageHeaders; +import org.springframework.util.Assert; +import org.springframework.util.ClassUtils; +import org.springframework.util.MimeType; /** * Default header mapper for Apache Kafka. diff --git a/spring-kafka/src/main/java/org/springframework/kafka/support/JacksonMimeTypeModule.java b/spring-kafka/src/main/java/org/springframework/kafka/support/JacksonMimeTypeModule.java index c353c20fdb..f2b4fb3fb7 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/support/JacksonMimeTypeModule.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/support/JacksonMimeTypeModule.java @@ -18,13 +18,13 @@ import java.io.IOException; -import org.springframework.util.MimeType; - import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.module.SimpleModule; +import org.springframework.util.MimeType; + /** * A {@link SimpleModule} extension for {@link MimeType} serialization. * diff --git a/spring-kafka/src/main/java/org/springframework/kafka/support/JacksonUtils.java b/spring-kafka/src/main/java/org/springframework/kafka/support/JacksonUtils.java index 3121409286..09473e104f 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/support/JacksonUtils.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/support/JacksonUtils.java @@ -16,13 +16,13 @@ package org.springframework.kafka.support; -import org.springframework.util.ClassUtils; - import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.json.JsonMapper; +import org.springframework.util.ClassUtils; + /** * The utilities for Jackson {@link ObjectMapper} instances. * diff --git a/spring-kafka/src/main/java/org/springframework/kafka/support/converter/ByteArrayJsonMessageConverter.java b/spring-kafka/src/main/java/org/springframework/kafka/support/converter/ByteArrayJsonMessageConverter.java index b359ae3f95..4686d09b80 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/support/converter/ByteArrayJsonMessageConverter.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/support/converter/ByteArrayJsonMessageConverter.java @@ -16,12 +16,12 @@ package org.springframework.kafka.support.converter; -import org.springframework.kafka.support.KafkaNull; -import org.springframework.messaging.Message; - import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.kafka.support.KafkaNull; +import org.springframework.messaging.Message; + /** * JSON Message converter - {@code byte[]} on output, String, Bytes, or byte[] on input. * Used in conjunction with Kafka diff --git a/spring-kafka/src/main/java/org/springframework/kafka/support/converter/BytesJsonMessageConverter.java b/spring-kafka/src/main/java/org/springframework/kafka/support/converter/BytesJsonMessageConverter.java index 65e3ca86df..b089e63b2a 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/support/converter/BytesJsonMessageConverter.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/support/converter/BytesJsonMessageConverter.java @@ -16,14 +16,13 @@ package org.springframework.kafka.support.converter; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.kafka.common.utils.Bytes; import org.springframework.kafka.support.KafkaNull; import org.springframework.messaging.Message; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - /** * JSON Message converter - {@code Bytes} on output, String, Bytes, or byte[] on input. * Used in conjunction with Kafka diff --git a/spring-kafka/src/main/java/org/springframework/kafka/support/converter/JsonMessageConverter.java b/spring-kafka/src/main/java/org/springframework/kafka/support/converter/JsonMessageConverter.java index a32872c18c..4a944e3562 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/support/converter/JsonMessageConverter.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/support/converter/JsonMessageConverter.java @@ -19,6 +19,9 @@ import java.io.IOException; import java.lang.reflect.Type; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.type.TypeFactory; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.common.header.Headers; import org.apache.kafka.common.header.internals.RecordHeaders; @@ -32,10 +35,6 @@ import org.springframework.messaging.Message; import org.springframework.util.Assert; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.type.TypeFactory; - /** * Base class for JSON message converters; on the consumer side, it can * handle {@code byte[]}, {@link Bytes} and {@link String} record values. diff --git a/spring-kafka/src/main/java/org/springframework/kafka/support/converter/MappingJacksonParameterizedConverter.java b/spring-kafka/src/main/java/org/springframework/kafka/support/converter/MappingJacksonParameterizedConverter.java index cb534678ee..f162af4e93 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/support/converter/MappingJacksonParameterizedConverter.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/support/converter/MappingJacksonParameterizedConverter.java @@ -19,6 +19,8 @@ import java.io.IOException; import java.lang.reflect.Type; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.type.TypeFactory; import org.apache.kafka.common.header.Headers; import org.apache.kafka.common.utils.Bytes; @@ -32,9 +34,6 @@ import org.springframework.util.Assert; import org.springframework.util.MimeType; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.type.TypeFactory; - /** * Subclass of {@link MappingJackson2MessageConverter} that can handle parameterized * (generic) types. diff --git a/spring-kafka/src/main/java/org/springframework/kafka/support/converter/ProjectingMessageConverter.java b/spring-kafka/src/main/java/org/springframework/kafka/support/converter/ProjectingMessageConverter.java index 6a78d3bc03..70c3cf563f 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/support/converter/ProjectingMessageConverter.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/support/converter/ProjectingMessageConverter.java @@ -21,6 +21,8 @@ import java.lang.reflect.Type; import java.nio.charset.StandardCharsets; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.common.utils.Bytes; @@ -34,9 +36,6 @@ import org.springframework.messaging.Message; import org.springframework.util.Assert; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider; - /** * A {@link MessageConverter} implementation that uses a Spring Data * {@link ProjectionFactory} to bind incoming messages to projection interfaces. diff --git a/spring-kafka/src/main/java/org/springframework/kafka/support/converter/StringJsonMessageConverter.java b/spring-kafka/src/main/java/org/springframework/kafka/support/converter/StringJsonMessageConverter.java index 869b8d2762..7b4392f050 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/support/converter/StringJsonMessageConverter.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/support/converter/StringJsonMessageConverter.java @@ -16,12 +16,12 @@ package org.springframework.kafka.support.converter; -import org.springframework.kafka.support.KafkaNull; -import org.springframework.messaging.Message; - import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.kafka.support.KafkaNull; +import org.springframework.messaging.Message; + /** * JSON Message converter - String on output, String, Bytes, or byte[] on input. Used in * conjunction with Kafka diff --git a/spring-kafka/src/main/java/org/springframework/kafka/support/mapping/DefaultJackson2JavaTypeMapper.java b/spring-kafka/src/main/java/org/springframework/kafka/support/mapping/DefaultJackson2JavaTypeMapper.java index 42e3519f15..f55e67e1bd 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/support/mapping/DefaultJackson2JavaTypeMapper.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/support/mapping/DefaultJackson2JavaTypeMapper.java @@ -20,6 +20,8 @@ import java.util.List; import java.util.Set; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.type.TypeFactory; import org.apache.kafka.common.header.Headers; import org.springframework.messaging.converter.MessageConversionException; @@ -27,9 +29,6 @@ import org.springframework.util.ClassUtils; import org.springframework.util.PatternMatchUtils; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.type.TypeFactory; - /** * Jackson 2 type mapper. * diff --git a/spring-kafka/src/main/java/org/springframework/kafka/support/mapping/Jackson2JavaTypeMapper.java b/spring-kafka/src/main/java/org/springframework/kafka/support/mapping/Jackson2JavaTypeMapper.java index 3f45504a88..06fc6c033d 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/support/mapping/Jackson2JavaTypeMapper.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/support/mapping/Jackson2JavaTypeMapper.java @@ -16,9 +16,8 @@ package org.springframework.kafka.support.mapping; -import org.apache.kafka.common.header.Headers; - import com.fasterxml.jackson.databind.JavaType; +import org.apache.kafka.common.header.Headers; /** * Strategy for setting metadata on messages such that one can create the class that needs diff --git a/spring-kafka/src/main/java/org/springframework/kafka/support/micrometer/KafkaRecordReceiverContext.java b/spring-kafka/src/main/java/org/springframework/kafka/support/micrometer/KafkaRecordReceiverContext.java index b3de789176..5903b48ad2 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/support/micrometer/KafkaRecordReceiverContext.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/support/micrometer/KafkaRecordReceiverContext.java @@ -19,11 +19,10 @@ import java.nio.charset.StandardCharsets; import java.util.function.Supplier; +import io.micrometer.observation.transport.ReceiverContext; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.common.header.Header; -import io.micrometer.observation.transport.ReceiverContext; - /** * {@link ReceiverContext} for {@link ConsumerRecord}s. * diff --git a/spring-kafka/src/main/java/org/springframework/kafka/support/micrometer/KafkaRecordSenderContext.java b/spring-kafka/src/main/java/org/springframework/kafka/support/micrometer/KafkaRecordSenderContext.java index ea6005b883..36de90ff40 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/support/micrometer/KafkaRecordSenderContext.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/support/micrometer/KafkaRecordSenderContext.java @@ -19,9 +19,8 @@ import java.nio.charset.StandardCharsets; import java.util.function.Supplier; -import org.apache.kafka.clients.producer.ProducerRecord; - import io.micrometer.observation.transport.SenderContext; +import org.apache.kafka.clients.producer.ProducerRecord; /** * {@link SenderContext} for {@link ProducerRecord}s. diff --git a/spring-kafka/src/main/java/org/springframework/kafka/support/micrometer/MicrometerHolder.java b/spring-kafka/src/main/java/org/springframework/kafka/support/micrometer/MicrometerHolder.java index 782745925b..3315d45c33 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/support/micrometer/MicrometerHolder.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/support/micrometer/MicrometerHolder.java @@ -20,16 +20,16 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.function.Function; -import org.springframework.beans.factory.NoUniqueBeanDefinitionException; -import org.springframework.context.ApplicationContext; -import org.springframework.lang.Nullable; -import org.springframework.util.Assert; - import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.Timer; import io.micrometer.core.instrument.Timer.Builder; import io.micrometer.core.instrument.Timer.Sample; +import org.springframework.beans.factory.NoUniqueBeanDefinitionException; +import org.springframework.context.ApplicationContext; +import org.springframework.lang.Nullable; +import org.springframework.util.Assert; + /** * A wrapper for micrometer timers when available on the class path. * diff --git a/spring-kafka/src/main/java/org/springframework/kafka/support/serializer/JsonDeserializer.java b/spring-kafka/src/main/java/org/springframework/kafka/support/serializer/JsonDeserializer.java index 14b4a218bb..27853ef722 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/support/serializer/JsonDeserializer.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/support/serializer/JsonDeserializer.java @@ -27,6 +27,11 @@ import java.util.Set; import java.util.function.BiFunction; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectReader; +import com.fasterxml.jackson.databind.type.TypeFactory; import org.apache.kafka.common.errors.SerializationException; import org.apache.kafka.common.header.Headers; import org.apache.kafka.common.serialization.Deserializer; @@ -42,12 +47,6 @@ import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectReader; -import com.fasterxml.jackson.databind.type.TypeFactory; - /** * Generic {@link org.apache.kafka.common.serialization.Deserializer Deserializer} for * receiving JSON from Kafka and return Java objects. diff --git a/spring-kafka/src/main/java/org/springframework/kafka/support/serializer/JsonSerde.java b/spring-kafka/src/main/java/org/springframework/kafka/support/serializer/JsonSerde.java index 8cdfbb114e..0ec37b06fa 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/support/serializer/JsonSerde.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/support/serializer/JsonSerde.java @@ -18,6 +18,9 @@ import java.util.Map; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.kafka.common.serialization.Serde; import org.springframework.core.ResolvableType; @@ -26,10 +29,6 @@ import org.springframework.lang.Nullable; import org.springframework.util.Assert; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; - /** * A {@link org.apache.kafka.common.serialization.Serde} that provides serialization and * deserialization in JSON format. diff --git a/spring-kafka/src/main/java/org/springframework/kafka/support/serializer/JsonSerializer.java b/spring-kafka/src/main/java/org/springframework/kafka/support/serializer/JsonSerializer.java index 41bc98c76e..b3fb4ea4a8 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/support/serializer/JsonSerializer.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/support/serializer/JsonSerializer.java @@ -20,6 +20,10 @@ import java.util.HashMap; import java.util.Map; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectWriter; import org.apache.kafka.common.errors.SerializationException; import org.apache.kafka.common.header.Headers; import org.apache.kafka.common.serialization.Serializer; @@ -33,11 +37,6 @@ import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectWriter; - /** * Generic {@link org.apache.kafka.common.serialization.Serializer Serializer} for sending * Java objects to Kafka as JSON. diff --git a/spring-kafka/src/main/java/org/springframework/kafka/support/serializer/JsonTypeResolver.java b/spring-kafka/src/main/java/org/springframework/kafka/support/serializer/JsonTypeResolver.java index fa3d486017..3b9f053419 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/support/serializer/JsonTypeResolver.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/support/serializer/JsonTypeResolver.java @@ -16,9 +16,8 @@ package org.springframework.kafka.support.serializer; -import org.apache.kafka.common.header.Headers; - import com.fasterxml.jackson.databind.JavaType; +import org.apache.kafka.common.header.Headers; /** * Determine the {@link JavaType} from the topic/data/headers. diff --git a/spring-kafka/src/test/java/org/springframework/kafka/config/KafkaListenerEndpointRegistryTests.java b/spring-kafka/src/test/java/org/springframework/kafka/config/KafkaListenerEndpointRegistryTests.java index 3d395aae6a..9281b35be0 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/config/KafkaListenerEndpointRegistryTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/config/KafkaListenerEndpointRegistryTests.java @@ -16,16 +16,16 @@ package org.springframework.kafka.config; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.mock; - import org.junit.jupiter.api.Test; import org.springframework.context.support.GenericApplicationContext; import org.springframework.kafka.listener.ConcurrentMessageListenerContainer; import org.springframework.kafka.listener.MessageListenerContainer; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; + /** * @author Gary Russell * @author Artem Bilan diff --git a/spring-kafka/src/test/java/org/springframework/kafka/config/KafkaStreamsCustomizerTests.java b/spring-kafka/src/test/java/org/springframework/kafka/config/KafkaStreamsCustomizerTests.java index d3b02aea2c..837898c793 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/config/KafkaStreamsCustomizerTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/config/KafkaStreamsCustomizerTests.java @@ -16,14 +16,15 @@ package org.springframework.kafka.config; -import static org.assertj.core.api.Assertions.assertThat; - import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Properties; import java.util.concurrent.atomic.AtomicBoolean; +import io.micrometer.core.instrument.ImmutableTag; +import io.micrometer.core.instrument.MeterRegistry; +import io.micrometer.core.instrument.simple.SimpleMeterRegistry; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.common.serialization.Serdes; import org.apache.kafka.streams.KafkaStreams; @@ -51,9 +52,7 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -import io.micrometer.core.instrument.ImmutableTag; -import io.micrometer.core.instrument.MeterRegistry; -import io.micrometer.core.instrument.simple.SimpleMeterRegistry; +import static org.assertj.core.api.Assertions.assertThat; /** * @author Nurettin Yilmaz diff --git a/spring-kafka/src/test/java/org/springframework/kafka/config/RecordMessagingMessageListenerAdapterTests.java b/spring-kafka/src/test/java/org/springframework/kafka/config/RecordMessagingMessageListenerAdapterTests.java index 0ba7308bdd..144a00f7c0 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/config/RecordMessagingMessageListenerAdapterTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/config/RecordMessagingMessageListenerAdapterTests.java @@ -16,8 +16,6 @@ package org.springframework.kafka.config; -import static org.assertj.core.api.Assertions.assertThat; - import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; @@ -35,6 +33,8 @@ import org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory; import org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Gary Russell * @since 2.5 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/config/StreamsBuilderFactoryBeanInMemoryStateStoreTests.java b/spring-kafka/src/test/java/org/springframework/kafka/config/StreamsBuilderFactoryBeanInMemoryStateStoreTests.java index 4d9bd19200..0a3309ba33 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/config/StreamsBuilderFactoryBeanInMemoryStateStoreTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/config/StreamsBuilderFactoryBeanInMemoryStateStoreTests.java @@ -16,8 +16,6 @@ package org.springframework.kafka.config; -import static org.assertj.core.api.Assertions.assertThat; - import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -43,6 +41,8 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Cédric Schaller */ diff --git a/spring-kafka/src/test/java/org/springframework/kafka/config/StreamsBuilderFactoryBeanTests.java b/spring-kafka/src/test/java/org/springframework/kafka/config/StreamsBuilderFactoryBeanTests.java index 9da17583e5..d63d19701c 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/config/StreamsBuilderFactoryBeanTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/config/StreamsBuilderFactoryBeanTests.java @@ -16,10 +16,6 @@ package org.springframework.kafka.config; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; - import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -50,6 +46,10 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; + /** * @author Pawel Szymczyk * @author Artem Bilan diff --git a/spring-kafka/src/test/java/org/springframework/kafka/config/StreamsBuilderFactoryLateConfigTests.java b/spring-kafka/src/test/java/org/springframework/kafka/config/StreamsBuilderFactoryLateConfigTests.java index 9abc3f3321..280ebfacb2 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/config/StreamsBuilderFactoryLateConfigTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/config/StreamsBuilderFactoryLateConfigTests.java @@ -16,10 +16,6 @@ package org.springframework.kafka.config; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.assertj.core.api.Assertions.assertThatIllegalStateException; - import java.util.Properties; import java.util.regex.Pattern; @@ -39,6 +35,10 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; + /** * @author Soby Chacko * @author Artem Bilan diff --git a/spring-kafka/src/test/java/org/springframework/kafka/core/DefaultKafkaConsumerFactoryTests.java b/spring-kafka/src/test/java/org/springframework/kafka/core/DefaultKafkaConsumerFactoryTests.java index ae12c8e6aa..c89b2388d8 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/core/DefaultKafkaConsumerFactoryTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/core/DefaultKafkaConsumerFactoryTests.java @@ -16,10 +16,6 @@ package org.springframework.kafka.core; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - import java.util.AbstractMap; import java.util.ArrayList; import java.util.Collections; @@ -56,6 +52,10 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + /** * @author Gary Russell * @author Chris Gilbert diff --git a/spring-kafka/src/test/java/org/springframework/kafka/core/DefaultKafkaProducerFactoryTests.java b/spring-kafka/src/test/java/org/springframework/kafka/core/DefaultKafkaProducerFactoryTests.java index 7a53519a41..bbe492a40b 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/core/DefaultKafkaProducerFactoryTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/core/DefaultKafkaProducerFactoryTests.java @@ -16,20 +16,6 @@ package org.springframework.kafka.core; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatCode; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.ArgumentMatchers.isNull; -import static org.mockito.BDDMockito.given; -import static org.mockito.BDDMockito.willAnswer; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - import java.time.Duration; import java.util.ArrayList; import java.util.Collections; @@ -61,6 +47,20 @@ import org.springframework.transaction.CannotCreateTransactionException; import org.springframework.transaction.support.TransactionTemplate; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.isNull; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.willAnswer; +import static org.mockito.Mockito.inOrder; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + /** * @author Gary Russell * @since 1.3.5 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/core/KafkaAdminBadContextTests.java b/spring-kafka/src/test/java/org/springframework/kafka/core/KafkaAdminBadContextTests.java index bdf18ceb87..1da6656df6 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/core/KafkaAdminBadContextTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/core/KafkaAdminBadContextTests.java @@ -16,8 +16,6 @@ package org.springframework.kafka.core; -import static org.assertj.core.api.Assertions.assertThatIllegalStateException; - import java.util.HashMap; import java.util.Map; @@ -31,6 +29,8 @@ import org.springframework.kafka.test.EmbeddedKafkaBroker; import org.springframework.kafka.test.EmbeddedKafkaZKBroker; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; + /** * @author Gary Russell * @since 1.3 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/core/KafkaAdminTests.java b/spring-kafka/src/test/java/org/springframework/kafka/core/KafkaAdminTests.java index cb8a3885de..5263dbc2ca 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/core/KafkaAdminTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/core/KafkaAdminTests.java @@ -16,12 +16,6 @@ package org.springframework.kafka.core; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatIllegalStateException; -import static org.awaitility.Awaitility.await; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.mock; - import java.lang.reflect.Method; import java.util.Arrays; import java.util.Collections; @@ -64,6 +58,12 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.util.ReflectionUtils; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; +import static org.awaitility.Awaitility.await; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; + /** * @author Gary Russell * @since 1.3 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/core/KafkaTemplateTests.java b/spring-kafka/src/test/java/org/springframework/kafka/core/KafkaTemplateTests.java index 98ab9c3c01..d1507c6c41 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/core/KafkaTemplateTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/core/KafkaTemplateTests.java @@ -16,24 +16,6 @@ package org.springframework.kafka.core; -import static org.assertj.core.api.Assertions.allOf; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; -import static org.mockito.BDDMockito.willAnswer; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; -import static org.springframework.kafka.test.assertj.KafkaConditions.key; -import static org.springframework.kafka.test.assertj.KafkaConditions.keyValue; -import static org.springframework.kafka.test.assertj.KafkaConditions.partition; -import static org.springframework.kafka.test.assertj.KafkaConditions.timestamp; -import static org.springframework.kafka.test.assertj.KafkaConditions.value; - import java.time.Duration; import java.util.ArrayList; import java.util.Collections; @@ -97,6 +79,24 @@ import org.springframework.messaging.Message; import org.springframework.messaging.support.MessageBuilder; +import static org.assertj.core.api.Assertions.allOf; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.willAnswer; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.inOrder; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoInteractions; +import static org.springframework.kafka.test.assertj.KafkaConditions.key; +import static org.springframework.kafka.test.assertj.KafkaConditions.keyValue; +import static org.springframework.kafka.test.assertj.KafkaConditions.partition; +import static org.springframework.kafka.test.assertj.KafkaConditions.timestamp; +import static org.springframework.kafka.test.assertj.KafkaConditions.value; + /** * @author Gary Russell * @author Artem Bilan diff --git a/spring-kafka/src/test/java/org/springframework/kafka/core/KafkaTemplateTransactionTests.java b/spring-kafka/src/test/java/org/springframework/kafka/core/KafkaTemplateTransactionTests.java index 7155145826..965d41976f 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/core/KafkaTemplateTransactionTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/core/KafkaTemplateTransactionTests.java @@ -16,24 +16,6 @@ package org.springframework.kafka.core; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.assertj.core.api.Assertions.assertThatIllegalStateException; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.ArgumentMatchers.isNull; -import static org.mockito.BDDMockito.given; -import static org.mockito.BDDMockito.willThrow; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.springframework.kafka.test.assertj.KafkaConditions.key; -import static org.springframework.kafka.test.assertj.KafkaConditions.value; - import java.time.Duration; import java.util.Collections; import java.util.Iterator; @@ -84,6 +66,24 @@ import org.springframework.transaction.support.DefaultTransactionStatus; import org.springframework.transaction.support.TransactionTemplate; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.isNull; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.willThrow; +import static org.mockito.Mockito.inOrder; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.springframework.kafka.test.assertj.KafkaConditions.key; +import static org.springframework.kafka.test.assertj.KafkaConditions.value; + /** * @author Gary Russell * @author Nakul Mishra diff --git a/spring-kafka/src/test/java/org/springframework/kafka/core/RoutingKafkaTemplateTests.java b/spring-kafka/src/test/java/org/springframework/kafka/core/RoutingKafkaTemplateTests.java index 608ae2fe68..4d31f5f305 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/core/RoutingKafkaTemplateTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/core/RoutingKafkaTemplateTests.java @@ -16,14 +16,6 @@ package org.springframework.kafka.core; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - import java.util.LinkedHashMap; import java.util.Map; import java.util.concurrent.CompletableFuture; @@ -34,6 +26,14 @@ import org.springframework.kafka.test.utils.KafkaTestUtils; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + /** * @author Gary Russell * @author Nathan Xu diff --git a/spring-kafka/src/test/java/org/springframework/kafka/core/TransactionSynchronizationTests.java b/spring-kafka/src/test/java/org/springframework/kafka/core/TransactionSynchronizationTests.java index 2b0eaea06d..38e79f1769 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/core/TransactionSynchronizationTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/core/TransactionSynchronizationTests.java @@ -16,12 +16,6 @@ package org.springframework.kafka.core; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - import org.apache.kafka.clients.producer.Producer; import org.junit.jupiter.api.Test; @@ -34,6 +28,12 @@ import org.springframework.transaction.support.TransactionSynchronizationManager; import org.springframework.transaction.support.TransactionTemplate; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + /** * @author Gary Russell * @since 2.9.7 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/core/reactive/ReactiveKafkaProducerTemplateIntegrationTests.java b/spring-kafka/src/test/java/org/springframework/kafka/core/reactive/ReactiveKafkaProducerTemplateIntegrationTests.java index bd9f1e9896..8dbe8d3a24 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/core/reactive/ReactiveKafkaProducerTemplateIntegrationTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/core/reactive/ReactiveKafkaProducerTemplateIntegrationTests.java @@ -16,9 +16,6 @@ package org.springframework.kafka.core.reactive; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; - import java.time.Duration; import java.time.Instant; import java.util.AbstractMap.SimpleImmutableEntry; @@ -44,6 +41,16 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.reactivestreams.Subscription; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import reactor.kafka.receiver.ReceiverOptions; +import reactor.kafka.receiver.ReceiverRecord; +import reactor.kafka.sender.KafkaSender; +import reactor.kafka.sender.SenderOptions; +import reactor.kafka.sender.SenderRecord; +import reactor.kafka.sender.SenderResult; +import reactor.test.StepVerifier; +import reactor.util.function.Tuple2; import org.springframework.kafka.support.DefaultKafkaHeaderMapper; import org.springframework.kafka.support.KafkaHeaderMapper; @@ -56,16 +63,8 @@ import org.springframework.messaging.MessageHeaders; import org.springframework.messaging.support.MessageBuilder; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.kafka.receiver.ReceiverOptions; -import reactor.kafka.receiver.ReceiverRecord; -import reactor.kafka.sender.KafkaSender; -import reactor.kafka.sender.SenderOptions; -import reactor.kafka.sender.SenderRecord; -import reactor.kafka.sender.SenderResult; -import reactor.test.StepVerifier; -import reactor.util.function.Tuple2; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; /** * @author Mark Norkin diff --git a/spring-kafka/src/test/java/org/springframework/kafka/core/reactive/ReactiveKafkaProducerTemplateTransactionIntegrationTests.java b/spring-kafka/src/test/java/org/springframework/kafka/core/reactive/ReactiveKafkaProducerTemplateTransactionIntegrationTests.java index 5d82eb01a1..39e209183d 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/core/reactive/ReactiveKafkaProducerTemplateTransactionIntegrationTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/core/reactive/ReactiveKafkaProducerTemplateTransactionIntegrationTests.java @@ -16,9 +16,6 @@ package org.springframework.kafka.core.reactive; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; - import java.time.Duration; import java.time.Instant; import java.util.ArrayList; @@ -40,17 +37,6 @@ import org.junit.jupiter.api.TestInfo; import org.reactivestreams.Publisher; import org.reactivestreams.Subscription; - -import org.springframework.core.log.LogAccessor; -import org.springframework.kafka.support.KafkaUtils; -import org.springframework.kafka.support.converter.MessagingMessageConverter; -import org.springframework.kafka.test.condition.EmbeddedKafkaCondition; -import org.springframework.kafka.test.condition.LogLevels; -import org.springframework.kafka.test.condition.LogLevelsCondition; -import org.springframework.kafka.test.context.EmbeddedKafka; -import org.springframework.kafka.test.utils.JUnitUtils; -import org.springframework.kafka.test.utils.KafkaTestUtils; - import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.core.scheduler.Schedulers; @@ -63,6 +49,19 @@ import reactor.kafka.sender.internals.DefaultKafkaSender; import reactor.test.StepVerifier; +import org.springframework.core.log.LogAccessor; +import org.springframework.kafka.support.KafkaUtils; +import org.springframework.kafka.support.converter.MessagingMessageConverter; +import org.springframework.kafka.test.condition.EmbeddedKafkaCondition; +import org.springframework.kafka.test.condition.LogLevels; +import org.springframework.kafka.test.condition.LogLevelsCondition; +import org.springframework.kafka.test.context.EmbeddedKafka; +import org.springframework.kafka.test.utils.JUnitUtils; +import org.springframework.kafka.test.utils.KafkaTestUtils; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; + /** * @author Mark Norkin * @author Gary Russell diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/ABSwitchClusterTests.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/ABSwitchClusterTests.java index 2f6f58b701..a71d4d491a 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/ABSwitchClusterTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/ABSwitchClusterTests.java @@ -16,11 +16,6 @@ package org.springframework.kafka.listener; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.willAnswer; -import static org.mockito.Mockito.mock; - import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -44,6 +39,11 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.willAnswer; +import static org.mockito.Mockito.mock; + /** * @author Gary Russell * @since 2.6 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/AsyncAckAfterHandleTests.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/AsyncAckAfterHandleTests.java index ab436e457e..80dc2e7cc2 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/AsyncAckAfterHandleTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/AsyncAckAfterHandleTests.java @@ -16,8 +16,6 @@ package org.springframework.kafka.listener; -import static org.assertj.core.api.Assertions.assertThat; - import java.util.Map; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -47,6 +45,8 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Gary Russell * @since 3.0 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/CommitOnAssignmentTests.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/CommitOnAssignmentTests.java index 7de877420a..a71abbb73e 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/CommitOnAssignmentTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/CommitOnAssignmentTests.java @@ -16,17 +16,6 @@ package org.springframework.kafka.listener; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyMap; -import static org.mockito.BDDMockito.given; -import static org.mockito.BDDMockito.willAnswer; -import static org.mockito.BDDMockito.willReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.withSettings; - import java.time.Duration; import java.util.Collection; import java.util.Collections; @@ -61,6 +50,17 @@ import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyMap; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.willAnswer; +import static org.mockito.BDDMockito.willReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.withSettings; + /** * @author Gary Russell * @since 2.3.6 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/ConsumerSeekAwareTests.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/ConsumerSeekAwareTests.java index 1442578917..8ed20e9187 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/ConsumerSeekAwareTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/ConsumerSeekAwareTests.java @@ -16,10 +16,6 @@ package org.springframework.kafka.listener; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - import java.util.Collections; import java.util.LinkedHashMap; import java.util.LinkedList; @@ -34,6 +30,10 @@ import org.springframework.kafka.listener.ConsumerSeekAware.ConsumerSeekCallback; import org.springframework.kafka.test.utils.KafkaTestUtils; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + /** * @author Gary Russell * @since 2.6 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/ErrorHandlingCoverageTests.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/ErrorHandlingCoverageTests.java index b0a916bbb0..63970a2d13 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/ErrorHandlingCoverageTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/ErrorHandlingCoverageTests.java @@ -16,12 +16,12 @@ package org.springframework.kafka.listener; -import static org.assertj.core.api.Assertions.assertThat; - import java.util.Map; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Gary Russell * @since 2.9.3 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/ErrorHandlingUtilsTest.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/ErrorHandlingUtilsTest.java index c0e576b1c4..2213512682 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/ErrorHandlingUtilsTest.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/ErrorHandlingUtilsTest.java @@ -16,15 +16,6 @@ package org.springframework.kafka.listener; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.mockito.BDDMockito.willReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -45,6 +36,15 @@ import org.springframework.util.backoff.BackOff; import org.springframework.util.backoff.FixedBackOff; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.BDDMockito.willReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.reset; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoInteractions; + /** * @author Antonio Tomac * @since 3.0.9 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/ExceptionClassifierTests.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/ExceptionClassifierTests.java index 0ef5688e50..3d194eff8e 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/ExceptionClassifierTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/ExceptionClassifierTests.java @@ -16,10 +16,10 @@ package org.springframework.kafka.listener; -import static org.assertj.core.api.Assertions.assertThat; - import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Gary Russell * @since 2.8.4 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/FailedBatchProcessorTests.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/FailedBatchProcessorTests.java index c4da76a1cd..09a85336f7 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/FailedBatchProcessorTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/FailedBatchProcessorTests.java @@ -16,17 +16,6 @@ package org.springframework.kafka.listener; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.assertj.core.api.Assertions.assertThatIllegalStateException; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyMap; -import static org.mockito.BDDMockito.willReturn; -import static org.mockito.BDDMockito.willThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; - import java.util.List; import java.util.Map; import java.util.function.BiConsumer; @@ -47,6 +36,17 @@ import org.springframework.util.backoff.BackOff; import org.springframework.util.backoff.FixedBackOff; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyMap; +import static org.mockito.BDDMockito.willReturn; +import static org.mockito.BDDMockito.willThrow; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; + /** * @author Gary Russell * @author Francois Rosiere diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/FailedRecordProcessorTests.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/FailedRecordProcessorTests.java index 8d72fa9d8d..8c0ed338cc 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/FailedRecordProcessorTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/FailedRecordProcessorTests.java @@ -16,8 +16,6 @@ package org.springframework.kafka.listener; -import static org.assertj.core.api.Assertions.assertThat; - import java.util.Collections; import java.util.List; @@ -27,6 +25,8 @@ import org.springframework.kafka.support.TopicPartitionOffset; import org.springframework.util.backoff.FixedBackOff; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Gary Russell * @since 2.3.6 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/FailedRecordTrackerTests.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/FailedRecordTrackerTests.java index c50db09044..de02ab623f 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/FailedRecordTrackerTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/FailedRecordTrackerTests.java @@ -16,10 +16,6 @@ package org.springframework.kafka.listener; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.mock; - import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -38,6 +34,10 @@ import org.springframework.util.backoff.BackOffExecution; import org.springframework.util.backoff.FixedBackOff; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; + /** * @author Gary Russell * @since 2.2.5 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/ListenerErrorHandlerTests.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/ListenerErrorHandlerTests.java index 53e2e66a82..fc97f1c06e 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/ListenerErrorHandlerTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/ListenerErrorHandlerTests.java @@ -16,11 +16,6 @@ package org.springframework.kafka.listener; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.willThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - import java.lang.reflect.Method; import java.util.Collections; import java.util.List; @@ -34,6 +29,11 @@ import org.springframework.kafka.listener.adapter.RecordMessagingMessageListenerAdapter; import org.springframework.kafka.support.Acknowledgment; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.willThrow; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + /** * @author Gary Russell * @since 2.9 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/ListenerUtilsTests.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/ListenerUtilsTests.java index ae31c9d5b1..278a4a069c 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/ListenerUtilsTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/ListenerUtilsTests.java @@ -16,13 +16,13 @@ package org.springframework.kafka.listener; +import org.apache.kafka.clients.consumer.OffsetAndMetadata; +import org.junit.jupiter.api.Test; + import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; -import org.apache.kafka.clients.consumer.OffsetAndMetadata; -import org.junit.jupiter.api.Test; - /** * @author Gary Russell * @author Francois Rosiere diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/LoggingErrorHandlerTests.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/LoggingErrorHandlerTests.java index 56ca58828d..8678fe0596 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/LoggingErrorHandlerTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/LoggingErrorHandlerTests.java @@ -16,17 +16,6 @@ package org.springframework.kafka.listener; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.ArgumentMatchers.anyMap; -import static org.mockito.BDDMockito.given; -import static org.mockito.BDDMockito.willAnswer; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; - import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; @@ -60,6 +49,17 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.ArgumentMatchers.anyMap; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.willAnswer; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; + /** * @author Gary Russell * @since 2.9 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/ManualNackBatchTests.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/ManualNackBatchTests.java index 725d154d4a..fb162270d0 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/ManualNackBatchTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/ManualNackBatchTests.java @@ -16,14 +16,6 @@ package org.springframework.kafka.listener; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyMap; -import static org.mockito.BDDMockito.given; -import static org.mockito.BDDMockito.willAnswer; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; - import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; @@ -64,6 +56,14 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyMap; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.willAnswer; +import static org.mockito.Mockito.inOrder; +import static org.mockito.Mockito.mock; + /** * @author Gary Russell * @since 2.3 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/ManualNackBatchTxTests.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/ManualNackBatchTxTests.java index e87854623a..08dcb85425 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/ManualNackBatchTxTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/ManualNackBatchTxTests.java @@ -16,16 +16,6 @@ package org.springframework.kafka.listener; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyMap; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.ArgumentMatchers.isNull; -import static org.mockito.BDDMockito.given; -import static org.mockito.BDDMockito.willAnswer; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; - import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; @@ -70,6 +60,16 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyMap; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.isNull; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.willAnswer; +import static org.mockito.Mockito.inOrder; +import static org.mockito.Mockito.mock; + /** * @author Gary Russell * @since 2.3 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/ManualNackRecordTests.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/ManualNackRecordTests.java index a5427e6d95..72bd8cf0ff 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/ManualNackRecordTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/ManualNackRecordTests.java @@ -16,14 +16,6 @@ package org.springframework.kafka.listener; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyMap; -import static org.mockito.BDDMockito.given; -import static org.mockito.BDDMockito.willAnswer; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; - import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; @@ -65,6 +57,14 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyMap; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.willAnswer; +import static org.mockito.Mockito.inOrder; +import static org.mockito.Mockito.mock; + /** * @author Gary Russell * @since 2.3 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/MissingGroupIdTests.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/MissingGroupIdTests.java index 4914fac6c4..ef14136a5f 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/MissingGroupIdTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/MissingGroupIdTests.java @@ -16,8 +16,6 @@ package org.springframework.kafka.listener; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - import java.util.Collections; import org.apache.kafka.clients.consumer.ConsumerConfig; @@ -39,6 +37,8 @@ import org.springframework.kafka.test.condition.EmbeddedKafkaCondition; import org.springframework.kafka.test.context.EmbeddedKafka; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; + /** * @author Gary Russell * @since 2.1.5 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/MissingTopicsTests.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/MissingTopicsTests.java index 264cf30a82..9c56e5bd43 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/MissingTopicsTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/MissingTopicsTests.java @@ -16,9 +16,6 @@ package org.springframework.kafka.listener; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; - import java.util.Map; import org.junit.jupiter.api.BeforeAll; @@ -30,6 +27,9 @@ import org.springframework.kafka.test.context.EmbeddedKafka; import org.springframework.kafka.test.utils.KafkaTestUtils; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; + /** * @author Gary Russell * @since 2.2 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/MockConsumerTests.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/MockConsumerTests.java index ae5c79a465..1116140543 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/MockConsumerTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/MockConsumerTests.java @@ -16,8 +16,6 @@ package org.springframework.kafka.listener; -import static org.assertj.core.api.Assertions.assertThat; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -47,6 +45,8 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Gary Russell * @since 3.0.7 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/SubBatchPerPartitionTests.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/SubBatchPerPartitionTests.java index fc0a781ff6..2a76cd784a 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/SubBatchPerPartitionTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/SubBatchPerPartitionTests.java @@ -16,17 +16,6 @@ package org.springframework.kafka.listener; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyMap; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.BDDMockito.given; -import static org.mockito.BDDMockito.willAnswer; -import static org.mockito.Mockito.atLeastOnce; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; - import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; @@ -67,6 +56,17 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.transaction.PlatformTransactionManager; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyMap; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.willAnswer; +import static org.mockito.Mockito.atLeastOnce; +import static org.mockito.Mockito.inOrder; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; + /** * @author Gary Russell * @since 2.3.2 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/TestOOMError.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/TestOOMError.java index 29f0bafc94..80c5bf5900 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/TestOOMError.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/TestOOMError.java @@ -16,13 +16,6 @@ package org.springframework.kafka.listener; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.ArgumentMatchers.isNull; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.mock; - import java.time.Duration; import java.util.Arrays; import java.util.HashMap; @@ -42,6 +35,13 @@ import org.springframework.kafka.listener.ContainerProperties.AckMode; import org.springframework.kafka.support.TopicPartitionOffset; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.isNull; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; + /** * @author Gary Russell * @since 2.1.11 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/BatchAdapterConversionErrorsTests.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/BatchAdapterConversionErrorsTests.java index 4ac12d81cd..9c8bd46df9 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/BatchAdapterConversionErrorsTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/BatchAdapterConversionErrorsTests.java @@ -16,10 +16,6 @@ package org.springframework.kafka.listener.adapter; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.mockito.Mockito.mock; - import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -47,6 +43,10 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.mockito.Mockito.mock; + /** * @author Gary Russell * @since 2.8 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/BatchListenerWithRecordAdapterTests.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/BatchListenerWithRecordAdapterTests.java index 0276612d89..ccfe86dadd 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/BatchListenerWithRecordAdapterTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/BatchListenerWithRecordAdapterTests.java @@ -16,9 +16,6 @@ package org.springframework.kafka.listener.adapter; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; - import java.util.ArrayList; import java.util.List; @@ -36,6 +33,9 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; + /** * @author Gary Russell * @since 2.2.5 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/BatchMessagingMessageListenerAdapterTests.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/BatchMessagingMessageListenerAdapterTests.java index d19d1bca26..9f37abb010 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/BatchMessagingMessageListenerAdapterTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/BatchMessagingMessageListenerAdapterTests.java @@ -16,9 +16,6 @@ package org.springframework.kafka.listener.adapter; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; - import java.util.Collections; import java.util.List; @@ -39,6 +36,9 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; + /** * @author Gary Russell * @since 2.2.5 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/ConvertingMessageListenerTests.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/ConvertingMessageListenerTests.java index 380248e63f..a9b146465e 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/ConvertingMessageListenerTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/ConvertingMessageListenerTests.java @@ -16,13 +16,8 @@ package org.springframework.kafka.listener.adapter; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.kafka.clients.consumer.Consumer; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.common.header.internals.RecordHeader; @@ -38,8 +33,12 @@ import org.springframework.messaging.converter.MessageConversionException; import org.springframework.messaging.converter.MessageConverter; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; /** * @author Adrian Chlebosz diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/FilteringAdapterTests.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/FilteringAdapterTests.java index 2b04bc3b80..ecc1b87c35 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/FilteringAdapterTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/FilteringAdapterTests.java @@ -16,13 +16,6 @@ package org.springframework.kafka.listener.adapter; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.willAnswer; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; - import java.util.ArrayList; import java.util.List; import java.util.concurrent.CountDownLatch; @@ -34,6 +27,13 @@ import org.springframework.kafka.listener.BatchAcknowledgingMessageListener; import org.springframework.kafka.support.Acknowledgment; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.willAnswer; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; + /** * @author Gary Russell * @since 2.0 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/KafkaBackoffAwareMessageListenerAdapterTests.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/KafkaBackoffAwareMessageListenerAdapterTests.java index d411dababa..54edaa029a 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/KafkaBackoffAwareMessageListenerAdapterTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/KafkaBackoffAwareMessageListenerAdapterTests.java @@ -16,17 +16,6 @@ package org.springframework.kafka.listener.adapter; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.ArgumentMatchers.isNull; -import static org.mockito.BDDMockito.given; -import static org.mockito.BDDMockito.then; -import static org.mockito.BDDMockito.willThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; - import java.math.BigInteger; import java.time.Clock; import java.time.Instant; @@ -50,6 +39,17 @@ import org.springframework.kafka.retrytopic.RetryTopicHeaders; import org.springframework.kafka.support.Acknowledgment; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.isNull; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; +import static org.mockito.BDDMockito.willThrow; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; + /** * @author Tomaz Fernandes diff --git a/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/MessagingMessageListenerAdapterTests.java b/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/MessagingMessageListenerAdapterTests.java index a20468b7b1..a5476be864 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/MessagingMessageListenerAdapterTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/listener/adapter/MessagingMessageListenerAdapterTests.java @@ -16,11 +16,6 @@ package org.springframework.kafka.listener.adapter; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.mockito.BDDMockito.willReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - import java.lang.reflect.Method; import org.apache.kafka.clients.consumer.ConsumerRecord; @@ -33,6 +28,11 @@ import org.springframework.kafka.support.converter.RecordMessageConverter; import org.springframework.messaging.support.GenericMessage; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.mockito.BDDMockito.willReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + /** * @author Gary Russell * @since 1.1.2 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/streams/Configurer1Tests.java b/spring-kafka/src/test/java/org/springframework/kafka/streams/Configurer1Tests.java index a473fed795..178fa200de 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/streams/Configurer1Tests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/streams/Configurer1Tests.java @@ -16,8 +16,6 @@ package org.springframework.kafka.streams; -import static org.assertj.core.api.Assertions.assertThat; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -44,6 +42,8 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Gary Russell * @since 2.7 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/streams/Configurer2Tests.java b/spring-kafka/src/test/java/org/springframework/kafka/streams/Configurer2Tests.java index b1e7ffe71a..c4ad73e662 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/streams/Configurer2Tests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/streams/Configurer2Tests.java @@ -16,8 +16,6 @@ package org.springframework.kafka.streams; -import static org.assertj.core.api.Assertions.assertThat; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -44,6 +42,8 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Gary Russell * @since 2.7 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/streams/HeaderEnricherProcessorTests.java b/spring-kafka/src/test/java/org/springframework/kafka/streams/HeaderEnricherProcessorTests.java index 7f5c2f92cc..944b139d28 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/streams/HeaderEnricherProcessorTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/streams/HeaderEnricherProcessorTests.java @@ -16,8 +16,6 @@ package org.springframework.kafka.streams; -import static org.assertj.core.api.Assertions.assertThat; - import java.util.HashMap; import java.util.Map; import java.util.Properties; @@ -38,6 +36,8 @@ import org.springframework.expression.common.LiteralExpression; import org.springframework.expression.spel.standard.SpelExpressionParser; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Gary Russell * @since 2.3 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/streams/KafkaStreamsBranchTests.java b/spring-kafka/src/test/java/org/springframework/kafka/streams/KafkaStreamsBranchTests.java index c145d29cd7..4c77f0030a 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/streams/KafkaStreamsBranchTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/streams/KafkaStreamsBranchTests.java @@ -16,8 +16,6 @@ package org.springframework.kafka.streams; -import static org.assertj.core.api.Assertions.assertThat; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -54,6 +52,8 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Elliot Kennedy * @author Artem Bilan diff --git a/spring-kafka/src/test/java/org/springframework/kafka/streams/KafkaStreamsJsonSerializationTests.java b/spring-kafka/src/test/java/org/springframework/kafka/streams/KafkaStreamsJsonSerializationTests.java index 46112bfed4..d1a4c0ec7d 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/streams/KafkaStreamsJsonSerializationTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/streams/KafkaStreamsJsonSerializationTests.java @@ -16,12 +16,12 @@ package org.springframework.kafka.streams; -import static org.assertj.core.api.Assertions.assertThat; - import java.util.HashMap; import java.util.Map; import java.util.UUID; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.kafka.clients.consumer.Consumer; import org.apache.kafka.clients.consumer.ConsumerConfig; import org.apache.kafka.clients.consumer.ConsumerRecord; @@ -57,8 +57,7 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import static org.assertj.core.api.Assertions.assertThat; /** * @author Elliot Kennedy diff --git a/spring-kafka/src/test/java/org/springframework/kafka/streams/KafkaStreamsTests.java b/spring-kafka/src/test/java/org/springframework/kafka/streams/KafkaStreamsTests.java index d28d506cfc..eef22fc69f 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/streams/KafkaStreamsTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/streams/KafkaStreamsTests.java @@ -16,9 +16,6 @@ package org.springframework.kafka.streams; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; - import java.time.Duration; import java.util.HashMap; import java.util.Map; @@ -28,6 +25,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; +import kafka.server.BrokerServer; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.common.serialization.Serdes; import org.apache.kafka.streams.KafkaStreams; @@ -75,7 +73,8 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -import kafka.server.BrokerServer; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; /** * @author Artem Bilan diff --git a/spring-kafka/src/test/java/org/springframework/kafka/streams/RecoveringDeserializationExceptionHandlerTests.java b/spring-kafka/src/test/java/org/springframework/kafka/streams/RecoveringDeserializationExceptionHandlerTests.java index bb4098c95f..a81d11d8ec 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/streams/RecoveringDeserializationExceptionHandlerTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/streams/RecoveringDeserializationExceptionHandlerTests.java @@ -16,8 +16,6 @@ package org.springframework.kafka.streams; -import static org.assertj.core.api.Assertions.assertThat; - import java.util.HashMap; import java.util.Map; import java.util.concurrent.CompletableFuture; @@ -67,6 +65,8 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Gary Russell * @since 2.3 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/streams/messaging/MessagingProcessorTests.java b/spring-kafka/src/test/java/org/springframework/kafka/streams/messaging/MessagingProcessorTests.java index 0ef2fffeb4..dcf5d1a41c 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/streams/messaging/MessagingProcessorTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/streams/messaging/MessagingProcessorTests.java @@ -16,8 +16,6 @@ package org.springframework.kafka.streams.messaging; -import static org.assertj.core.api.Assertions.assertThat; - import java.util.Collections; import java.util.Properties; @@ -41,6 +39,8 @@ import org.springframework.kafka.support.converter.MessagingMessageConverter; import org.springframework.messaging.support.MessageBuilder; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Gary Russell * @since 2.3 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/support/DefaultKafkaHeaderMapperTests.java b/spring-kafka/src/test/java/org/springframework/kafka/support/DefaultKafkaHeaderMapperTests.java index afa7525d04..8e498d57e3 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/support/DefaultKafkaHeaderMapperTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/support/DefaultKafkaHeaderMapperTests.java @@ -16,9 +16,6 @@ package org.springframework.kafka.support; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.entry; - import java.net.URI; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; @@ -47,6 +44,9 @@ import org.springframework.util.MimeType; import org.springframework.util.MimeTypeUtils; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.entry; + /** * @author Gary Russell * @author Artem Bilan diff --git a/spring-kafka/src/test/java/org/springframework/kafka/support/ExponentialBackOffWithMaxRetriesTests.java b/spring-kafka/src/test/java/org/springframework/kafka/support/ExponentialBackOffWithMaxRetriesTests.java index 8c6949a75b..d2b2e40a62 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/support/ExponentialBackOffWithMaxRetriesTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/support/ExponentialBackOffWithMaxRetriesTests.java @@ -16,9 +16,6 @@ package org.springframework.kafka.support; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatIllegalStateException; - import java.util.ArrayList; import java.util.List; import java.util.stream.IntStream; @@ -27,6 +24,9 @@ import org.springframework.util.backoff.BackOffExecution; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; + /** * @author Gary Russell * @since 2.7.3 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/support/KafkaStreamBrancherTests.java b/spring-kafka/src/test/java/org/springframework/kafka/support/KafkaStreamBrancherTests.java index 1717d273ce..94265418e4 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/support/KafkaStreamBrancherTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/support/KafkaStreamBrancherTests.java @@ -16,18 +16,18 @@ package org.springframework.kafka.support; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.mock; - import java.util.concurrent.atomic.AtomicInteger; import org.apache.kafka.streams.kstream.KStream; import org.apache.kafka.streams.kstream.Predicate; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; + /** * @author Ivan Ponomarev * @author Artem Bilan diff --git a/spring-kafka/src/test/java/org/springframework/kafka/support/LogIfLevelEnabledTests.java b/spring-kafka/src/test/java/org/springframework/kafka/support/LogIfLevelEnabledTests.java index 597f199678..9a09d1c20c 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/support/LogIfLevelEnabledTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/support/LogIfLevelEnabledTests.java @@ -16,18 +16,18 @@ package org.springframework.kafka.support; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.withSettings; - import java.util.function.Supplier; import org.junit.jupiter.api.Test; import org.springframework.core.log.LogAccessor; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.withSettings; + /** * @author Gary Russell * @since 2.2.1 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/support/LoggingProducerListenerTests.java b/spring-kafka/src/test/java/org/springframework/kafka/support/LoggingProducerListenerTests.java index 83220be1d2..e0047236f5 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/support/LoggingProducerListenerTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/support/LoggingProducerListenerTests.java @@ -16,11 +16,6 @@ package org.springframework.kafka.support; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.willAnswer; -import static org.mockito.Mockito.spy; - import java.util.concurrent.atomic.AtomicReference; import java.util.function.Supplier; @@ -31,6 +26,11 @@ import org.springframework.core.log.LogAccessor; import org.springframework.kafka.test.utils.KafkaTestUtils; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.willAnswer; +import static org.mockito.Mockito.spy; + /** * @author Gary Russell * @since 2.5.16 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/support/SimpleKafkaHeaderMapperTests.java b/spring-kafka/src/test/java/org/springframework/kafka/support/SimpleKafkaHeaderMapperTests.java index 77caa3d81a..cbc15e572f 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/support/SimpleKafkaHeaderMapperTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/support/SimpleKafkaHeaderMapperTests.java @@ -16,10 +16,6 @@ package org.springframework.kafka.support; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatIllegalStateException; -import static org.assertj.core.api.Assertions.entry; - import java.nio.ByteBuffer; import java.util.HashMap; import java.util.Map; @@ -32,6 +28,10 @@ import org.springframework.messaging.MessageHeaders; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; +import static org.assertj.core.api.Assertions.entry; + /** * @author Gary Russell * @since 2.2.5 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/support/TopicPartitionOffsetTests.java b/spring-kafka/src/test/java/org/springframework/kafka/support/TopicPartitionOffsetTests.java index 1ad0d983b5..2b227d191e 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/support/TopicPartitionOffsetTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/support/TopicPartitionOffsetTests.java @@ -16,8 +16,6 @@ package org.springframework.kafka.support; -import static org.assertj.core.api.Assertions.assertThat; - import java.util.Objects; import org.apache.kafka.common.TopicPartition; @@ -25,6 +23,8 @@ import org.springframework.kafka.support.TopicPartitionOffset.SeekPosition; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Gary Russell * @since 2.3.13 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/support/converter/BatchMessageConverterTests.java b/spring-kafka/src/test/java/org/springframework/kafka/support/converter/BatchMessageConverterTests.java index 1e7921194a..2942739e4c 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/support/converter/BatchMessageConverterTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/support/converter/BatchMessageConverterTests.java @@ -16,9 +16,6 @@ package org.springframework.kafka.support.converter; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -42,6 +39,9 @@ import org.springframework.messaging.Message; import org.springframework.messaging.MessageHeaders; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; + /** * @author Biju Kunjummen * @author Artem Bilan diff --git a/spring-kafka/src/test/java/org/springframework/kafka/support/converter/MessagingMessageConverterTests.java b/spring-kafka/src/test/java/org/springframework/kafka/support/converter/MessagingMessageConverterTests.java index 2386881e18..ccc9976ff0 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/support/converter/MessagingMessageConverterTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/support/converter/MessagingMessageConverterTests.java @@ -16,8 +16,6 @@ package org.springframework.kafka.support.converter; -import static org.assertj.core.api.Assertions.assertThat; - import java.util.Arrays; import java.util.Collection; import java.util.Map; @@ -40,6 +38,8 @@ import org.springframework.messaging.support.GenericMessage; import org.springframework.util.MimeType; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Gary Russell * @author Artem Bilan diff --git a/spring-kafka/src/test/java/org/springframework/kafka/support/converter/ProjectingMessageConverterTests.java b/spring-kafka/src/test/java/org/springframework/kafka/support/converter/ProjectingMessageConverterTests.java index dd17646d99..be4152841b 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/support/converter/ProjectingMessageConverterTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/support/converter/ProjectingMessageConverterTests.java @@ -16,15 +16,11 @@ package org.springframework.kafka.support.converter; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import static org.mockito.Mockito.doReturn; - import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; +import com.jayway.jsonpath.DocumentContext; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.common.utils.Bytes; import org.junit.jupiter.api.Test; @@ -37,7 +33,10 @@ import org.springframework.kafka.support.KafkaNull; import org.springframework.messaging.support.MessageBuilder; -import com.jayway.jsonpath.DocumentContext; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.mockito.Mockito.doReturn; /** * @author Oliver Gierke diff --git a/spring-kafka/src/test/java/org/springframework/kafka/support/micrometer/MicrometerHolderTests.java b/spring-kafka/src/test/java/org/springframework/kafka/support/micrometer/MicrometerHolderTests.java index 4ee64bcf00..f13332db75 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/support/micrometer/MicrometerHolderTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/support/micrometer/MicrometerHolderTests.java @@ -16,18 +16,12 @@ package org.springframework.kafka.support.micrometer; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatIllegalStateException; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; - import java.util.Collections; import java.util.Map; +import io.micrometer.core.instrument.MeterRegistry; +import io.micrometer.core.instrument.Timer; +import io.micrometer.core.instrument.simple.SimpleMeterRegistry; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.ObjectProvider; @@ -37,9 +31,14 @@ import org.springframework.context.annotation.Primary; import org.springframework.test.util.ReflectionTestUtils; -import io.micrometer.core.instrument.MeterRegistry; -import io.micrometer.core.instrument.Timer; -import io.micrometer.core.instrument.simple.SimpleMeterRegistry; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * @author Vasyl Sarzhynskyi diff --git a/spring-kafka/src/test/java/org/springframework/kafka/support/micrometer/ObservationIntegrationTests.java b/spring-kafka/src/test/java/org/springframework/kafka/support/micrometer/ObservationIntegrationTests.java index ce3935b38a..aeb143f256 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/support/micrometer/ObservationIntegrationTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/support/micrometer/ObservationIntegrationTests.java @@ -16,14 +16,20 @@ package org.springframework.kafka.support.micrometer; -import static org.assertj.core.api.Assertions.assertThat; - import java.util.List; import java.util.Map; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; +import io.micrometer.common.KeyValues; +import io.micrometer.core.tck.MeterRegistryAssert; +import io.micrometer.observation.ObservationRegistry; +import io.micrometer.tracing.Span.Kind; +import io.micrometer.tracing.exporter.FinishedSpan; +import io.micrometer.tracing.test.SampleTestRunner; +import io.micrometer.tracing.test.simple.SpanAssert; +import io.micrometer.tracing.test.simple.SpansAssert; import org.apache.kafka.clients.admin.AdminClientConfig; import org.apache.kafka.clients.consumer.ConsumerRecord; @@ -43,14 +49,7 @@ import org.springframework.kafka.test.EmbeddedKafkaZKBroker; import org.springframework.kafka.test.utils.KafkaTestUtils; -import io.micrometer.common.KeyValues; -import io.micrometer.core.tck.MeterRegistryAssert; -import io.micrometer.observation.ObservationRegistry; -import io.micrometer.tracing.Span.Kind; -import io.micrometer.tracing.exporter.FinishedSpan; -import io.micrometer.tracing.test.SampleTestRunner; -import io.micrometer.tracing.test.simple.SpanAssert; -import io.micrometer.tracing.test.simple.SpansAssert; +import static org.assertj.core.api.Assertions.assertThat; /** * @author Artem Bilan diff --git a/spring-kafka/src/test/java/org/springframework/kafka/support/micrometer/ObservationTests.java b/spring-kafka/src/test/java/org/springframework/kafka/support/micrometer/ObservationTests.java index d93c606919..4b325ba385 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/support/micrometer/ObservationTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/support/micrometer/ObservationTests.java @@ -16,11 +16,6 @@ package org.springframework.kafka.support.micrometer; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.awaitility.Awaitility.await; -import static org.mockito.Mockito.mock; - import java.util.Arrays; import java.util.Deque; import java.util.List; @@ -31,6 +26,23 @@ import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicReference; +import io.micrometer.common.KeyValues; +import io.micrometer.core.instrument.MeterRegistry; +import io.micrometer.core.instrument.observation.DefaultMeterObservationHandler; +import io.micrometer.core.instrument.simple.SimpleMeterRegistry; +import io.micrometer.core.tck.MeterRegistryAssert; +import io.micrometer.observation.ObservationHandler; +import io.micrometer.observation.ObservationRegistry; +import io.micrometer.observation.tck.TestObservationRegistry; +import io.micrometer.tracing.Span; +import io.micrometer.tracing.TraceContext; +import io.micrometer.tracing.Tracer; +import io.micrometer.tracing.handler.DefaultTracingObservationHandler; +import io.micrometer.tracing.handler.PropagatingReceiverTracingObservationHandler; +import io.micrometer.tracing.handler.PropagatingSenderTracingObservationHandler; +import io.micrometer.tracing.propagation.Propagator; +import io.micrometer.tracing.test.simple.SimpleSpan; +import io.micrometer.tracing.test.simple.SimpleTracer; import org.apache.kafka.clients.admin.AdminClientConfig; import org.apache.kafka.clients.consumer.ConsumerConfig; import org.apache.kafka.clients.consumer.ConsumerRecord; @@ -66,23 +78,10 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.util.StringUtils; -import io.micrometer.common.KeyValues; -import io.micrometer.core.instrument.MeterRegistry; -import io.micrometer.core.instrument.observation.DefaultMeterObservationHandler; -import io.micrometer.core.instrument.simple.SimpleMeterRegistry; -import io.micrometer.core.tck.MeterRegistryAssert; -import io.micrometer.observation.ObservationHandler; -import io.micrometer.observation.ObservationRegistry; -import io.micrometer.observation.tck.TestObservationRegistry; -import io.micrometer.tracing.Span; -import io.micrometer.tracing.TraceContext; -import io.micrometer.tracing.Tracer; -import io.micrometer.tracing.handler.DefaultTracingObservationHandler; -import io.micrometer.tracing.handler.PropagatingReceiverTracingObservationHandler; -import io.micrometer.tracing.handler.PropagatingSenderTracingObservationHandler; -import io.micrometer.tracing.propagation.Propagator; -import io.micrometer.tracing.test.simple.SimpleSpan; -import io.micrometer.tracing.test.simple.SimpleTracer; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.awaitility.Awaitility.await; +import static org.mockito.Mockito.mock; /** * @author Gary Russell diff --git a/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/DelegatingByTopicSerializationTests.java b/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/DelegatingByTopicSerializationTests.java index 9a79f6cc48..a6cc5d38b7 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/DelegatingByTopicSerializationTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/DelegatingByTopicSerializationTests.java @@ -16,8 +16,6 @@ package org.springframework.kafka.support.serializer; -import static org.assertj.core.api.Assertions.assertThat; - import java.util.HashMap; import java.util.Map; @@ -31,6 +29,8 @@ import org.apache.kafka.common.serialization.StringSerializer; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Gary Russell * @since 2.8 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/DelegatingSerializationTests.java b/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/DelegatingSerializationTests.java index 6f47ba4805..83b54fed27 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/DelegatingSerializationTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/DelegatingSerializationTests.java @@ -16,12 +16,6 @@ package org.springframework.kafka.support.serializer; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -44,6 +38,12 @@ import org.springframework.kafka.support.DefaultKafkaHeaderMapper; import org.springframework.messaging.MessageHeaders; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + /** * @author Gary Russell * @author Artem Bilan diff --git a/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/JsonSerdeTests.java b/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/JsonSerdeTests.java index de6012babb..fd71051059 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/JsonSerdeTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/JsonSerdeTests.java @@ -16,13 +16,13 @@ package org.springframework.kafka.support.serializer; -import static org.assertj.core.api.Assertions.assertThat; - import org.junit.jupiter.api.Test; import org.springframework.kafka.support.mapping.AbstractJavaTypeMapper; import org.springframework.kafka.test.utils.KafkaTestUtils; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Gary Russell * @since 2.3 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/JsonSerializationTests.java b/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/JsonSerializationTests.java index ff04ce17af..71de9c1aad 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/JsonSerializationTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/JsonSerializationTests.java @@ -16,11 +16,6 @@ package org.springframework.kafka.support.serializer; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import static org.assertj.core.api.Assertions.assertThatIllegalStateException; - import java.io.IOException; import java.util.Arrays; import java.util.Collections; @@ -30,6 +25,15 @@ import java.util.Objects; import java.util.Set; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.type.TypeFactory; import org.apache.kafka.common.errors.SerializationException; import org.apache.kafka.common.header.Headers; import org.apache.kafka.common.header.internals.RecordHeaders; @@ -45,15 +49,10 @@ import org.springframework.kafka.support.serializer.testentities.DummyEntity; import org.springframework.kafka.test.utils.KafkaTestUtils; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.type.TypeFactory; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; /** * @author Igor Stepanov diff --git a/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/RetryingDeserializerTests.java b/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/RetryingDeserializerTests.java index 64f501cc6a..d1dba50495 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/RetryingDeserializerTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/RetryingDeserializerTests.java @@ -16,11 +16,6 @@ package org.springframework.kafka.support.serializer; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - import java.util.concurrent.atomic.AtomicInteger; import org.apache.kafka.common.header.internals.RecordHeaders; @@ -31,6 +26,11 @@ import org.springframework.retry.RetryContext; import org.springframework.retry.support.RetryTemplate; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + /** * @author Gary Russell * @author Wang Zhiyang diff --git a/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/SerializationIntegrationTests.java b/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/SerializationIntegrationTests.java index 5b71aed27c..30e2e451b3 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/SerializationIntegrationTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/SerializationIntegrationTests.java @@ -16,9 +16,6 @@ package org.springframework.kafka.support.serializer; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; - import java.util.Map; import java.util.regex.Pattern; @@ -35,6 +32,9 @@ import org.springframework.kafka.test.context.EmbeddedKafka; import org.springframework.kafka.test.utils.KafkaTestUtils; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; + /** * @author Gary Russell * @since 2.8.1 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/SerializationUtilsTests.java b/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/SerializationUtilsTests.java index ead2dbc401..5acefe432b 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/SerializationUtilsTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/SerializationUtilsTests.java @@ -16,13 +16,6 @@ package org.springframework.kafka.support.serializer; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.BDDMockito.given; -import static org.mockito.BDDMockito.willAnswer; -import static org.mockito.BDDMockito.willReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; - import java.util.List; import java.util.function.Supplier; @@ -35,6 +28,13 @@ import org.springframework.core.log.LogAccessor; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.willAnswer; +import static org.mockito.BDDMockito.willReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; + /** * @author Gary Russell * @since 2.9.11 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/StringOrBytesSerializerTests.java b/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/StringOrBytesSerializerTests.java index 4ba81b738d..fc087ae0dd 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/StringOrBytesSerializerTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/StringOrBytesSerializerTests.java @@ -16,8 +16,6 @@ package org.springframework.kafka.support.serializer; -import static org.assertj.core.api.Assertions.assertThat; - import java.util.Collections; import java.util.Map; @@ -26,6 +24,8 @@ import org.springframework.kafka.test.utils.KafkaTestUtils; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Gary Russell * @since 2.3 diff --git a/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/ToStringSerializationTests.java b/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/ToStringSerializationTests.java index c81610b9aa..6a71894155 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/ToStringSerializationTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/support/serializer/ToStringSerializationTests.java @@ -16,8 +16,6 @@ package org.springframework.kafka.support.serializer; -import static org.assertj.core.api.Assertions.assertThat; - import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.HashMap; @@ -31,6 +29,8 @@ import org.springframework.kafka.support.serializer.testentities.DummyEntity; import org.springframework.lang.Nullable; +import static org.assertj.core.api.Assertions.assertThat; + /** * * @author Alexei Klenin diff --git a/src/checkstyle/checkstyle.xml b/src/checkstyle/checkstyle.xml index 313da7c27c..0764835c9a 100644 --- a/src/checkstyle/checkstyle.xml +++ b/src/checkstyle/checkstyle.xml @@ -97,10 +97,10 @@ - + - +