From ef385bbe32a59b65b6112b61dd8d91f991f9a98b Mon Sep 17 00:00:00 2001 From: Carlos Tasada Date: Mon, 5 Jun 2023 16:12:33 +0200 Subject: [PATCH] feat: Remove usage of Guava The Guava library is really convenient, but over time, most of its features became part of the vanilla Java. This PR removes the usage of Guava, replacing it by Java equivalents. --- build.gradle | 2 - springwolf-core/build.gradle | 2 - .../springwolf/asyncapi/MessageHelper.java | 3 +- .../AbstractClassLevelListenerScanner.java | 3 +- .../AbstractMethodLevelListenerScanner.java | 3 +- .../asyncapi/types/ConsumerData.java | 6 +- .../asyncapi/types/ProducerData.java | 6 +- .../AsyncHeadersForCloudEventsBuilder.java | 19 +++--- .../DefaultAsyncApiSerializerServiceTest.java | 9 ++- .../asyncapi/DefaultAsyncApiServiceTest.java | 13 ++--- .../asyncapi/DefaultChannelsServiceTest.java | 9 ++- .../asyncapi/MessageHelperTest.java | 22 ++++--- .../beans/DefaultBeanMethodsScannerTest.java | 3 +- .../scanners/channels/ChannelMergerTest.java | 29 +++++----- .../TestMethodLevelListenerScanner.java | 7 +-- .../TestMethodLevelListenerScannerTest.java | 10 ++-- .../ConsumerOperationDataScannerTest.java | 44 +++++++------- .../ProducerOperationDataScannerTest.java | 44 +++++++------- .../AsyncListenerAnnotationScannerTest.java | 10 ++-- .../AsyncPublisherAnnotationScannerTest.java | 10 ++-- .../springwolf-amqp-example/build.gradle | 1 - .../build.gradle | 1 - .../springwolf-kafka-example/build.gradle | 1 - .../springwolf-amqp-plugin/build.gradle | 1 - .../MethodLevelRabbitListenerScanner.java | 7 +-- .../asyncapi/types/AmqpConsumerData.java | 8 +-- .../asyncapi/types/AmqpProducerData.java | 8 +-- .../MethodLevelRabbitListenerScannerTest.java | 42 +++++++------- .../producer/SpringwolfAmqpProducerTest.java | 15 +++-- .../build.gradle | 1 - .../CloudStreamFunctionChannelsScanner.java | 18 +++--- .../FunctionalChannelBeanData.java | 9 ++- ...loudStreamFunctionChannelsScannerTest.java | 58 +++++++++---------- .../springwolf-kafka-plugin/README.md | 2 +- .../springwolf-kafka-plugin/build.gradle | 1 - .../annotation/KafkaListenerUtil.java | 7 +-- .../asyncapi/types/KafkaConsumerData.java | 9 +-- .../asyncapi/types/KafkaProducerData.java | 9 +-- .../AsyncHeadersForSpringKafkaBuilder.java | 4 +- .../ClassLevelKafkaListenerScannerTest.java | 45 +++++++------- .../MethodLevelKafkaListenerScannerTest.java | 34 +++++------ 41 files changed, 243 insertions(+), 292 deletions(-) diff --git a/build.gradle b/build.gradle index b2664f27b..7d0d6e858 100644 --- a/build.gradle +++ b/build.gradle @@ -28,8 +28,6 @@ ext { commonsIoVersion = '2.12.0' - guavaVersion = '32.0.0-jre' - javaMoneyMonetaVersion = '1.4.2' jsonAssertVersion = '1.5.1' diff --git a/springwolf-core/build.gradle b/springwolf-core/build.gradle index 6033799e4..0b0eb5da1 100644 --- a/springwolf-core/build.gradle +++ b/springwolf-core/build.gradle @@ -38,8 +38,6 @@ dependencies { implementation "org.springframework:spring-messaging" implementation "org.springframework.boot:spring-boot-autoconfigure" - implementation "com.google.guava:guava:${guavaVersion}" - compileOnly "org.projectlombok:lombok:${lombokVersion}" annotationProcessor "org.projectlombok:lombok:${lombokVersion}" annotationProcessor "org.springframework.boot:spring-boot-configuration-processor" diff --git a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/MessageHelper.java b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/MessageHelper.java index 56b203002..f5530b1a7 100644 --- a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/MessageHelper.java +++ b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/MessageHelper.java @@ -1,6 +1,5 @@ package io.github.stavshamir.springwolf.asyncapi; -import com.google.common.collect.ImmutableMap; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.Message; import lombok.extern.slf4j.Slf4j; @@ -28,7 +27,7 @@ public static Object toMessageObjectOrComposition(Set messages) { case 0 -> throw new IllegalArgumentException("messages must not be empty"); case 1 -> messages.toArray()[0]; default -> - ImmutableMap.of(ONE_OF, new ArrayList<>(messages.stream().collect(Collectors.toCollection(messageSupplier)))); + Map.of(ONE_OF, new ArrayList<>(messages.stream().collect(Collectors.toCollection(messageSupplier)))); }; } diff --git a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/AbstractClassLevelListenerScanner.java b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/AbstractClassLevelListenerScanner.java index 4de44f081..75ddd2999 100644 --- a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/AbstractClassLevelListenerScanner.java +++ b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/AbstractClassLevelListenerScanner.java @@ -5,7 +5,6 @@ import com.asyncapi.v2.binding.operation.OperationBinding; import com.asyncapi.v2._0_0.model.channel.ChannelItem; import com.asyncapi.v2._0_0.model.channel.operation.Operation; -import com.google.common.collect.Maps; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.ChannelMerger; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.ChannelsScanner; import io.github.stavshamir.springwolf.asyncapi.scanners.classes.ComponentClassScanner; @@ -126,7 +125,7 @@ private Optional> mapClassToChannel(Class comp } ChannelItem channelItem = buildChannel(component.getSimpleName(), annotatedMethods, channelBinding, operationBinding); - return Optional.of(Maps.immutableEntry(channelName, channelItem)); + return Optional.of(Map.entry(channelName, channelItem)); } private Set getAnnotatedMethods(Class component) { diff --git a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/AbstractMethodLevelListenerScanner.java b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/AbstractMethodLevelListenerScanner.java index 91ca690ab..c6b8d0d88 100644 --- a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/AbstractMethodLevelListenerScanner.java +++ b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/AbstractMethodLevelListenerScanner.java @@ -5,7 +5,6 @@ import com.asyncapi.v2.binding.operation.OperationBinding; import com.asyncapi.v2._0_0.model.channel.ChannelItem; import com.asyncapi.v2._0_0.model.channel.operation.Operation; -import com.google.common.collect.Maps; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.ChannelsScanner; import io.github.stavshamir.springwolf.asyncapi.scanners.classes.ComponentClassScanner; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.Message; @@ -104,7 +103,7 @@ private Map.Entry mapMethodToChannel(Method method) { String operationId = channelName + "_publish_" + method.getName(); ChannelItem channel = buildChannel(channelBinding, payload, operationBinding, messageBinding, operationId); - return Maps.immutableEntry(channelName, channel); + return Map.entry(channelName, channel); } private ChannelItem buildChannel(Map channelBinding, diff --git a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/ConsumerData.java b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/ConsumerData.java index 0d4c76008..f125ca2ea 100644 --- a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/ConsumerData.java +++ b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/ConsumerData.java @@ -36,7 +36,7 @@ public class ConsumerData implements OperationData { *
* For example: * - * ImmutableMap.of("kafka", new KafkaChannelBinding()) + * Map.of("kafka", new KafkaChannelBinding()) * */ protected Map channelBinding; @@ -57,7 +57,7 @@ public class ConsumerData implements OperationData { *
* For example: * - * ImmutableMap.of("kafka", new KafkaOperationBinding()) + * Map.of("kafka", new KafkaOperationBinding()) * */ protected Map operationBinding; @@ -67,7 +67,7 @@ public class ConsumerData implements OperationData { *
* For example: * - * ImmutableMap.of("kafka", new KafkaMessageBinding()) + * Map.of("kafka", new KafkaMessageBinding()) * */ protected Map messageBinding; diff --git a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/ProducerData.java b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/ProducerData.java index cde1f17fc..c220b14df 100644 --- a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/ProducerData.java +++ b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/ProducerData.java @@ -36,7 +36,7 @@ public class ProducerData implements OperationData { *
* For example: * - * ImmutableMap.of("kafka", new KafkaChannelBinding()) + * Map.of("kafka", new KafkaChannelBinding()) * */ protected Map channelBinding; @@ -57,7 +57,7 @@ public class ProducerData implements OperationData { *
* For example: * - * ImmutableMap.of("kafka", new KafkaOperationBinding()) + * Map.of("kafka", new KafkaOperationBinding()) * */ protected Map operationBinding; @@ -67,7 +67,7 @@ public class ProducerData implements OperationData { *
* For example: * - * ImmutableMap.of("kafka", new KafkaMessageBinding()) + * Map.of("kafka", new KafkaMessageBinding()) * */ protected Map messageBinding; diff --git a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/channel/operation/message/header/AsyncHeadersForCloudEventsBuilder.java b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/channel/operation/message/header/AsyncHeadersForCloudEventsBuilder.java index 731e184ac..f60d04e90 100644 --- a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/channel/operation/message/header/AsyncHeadersForCloudEventsBuilder.java +++ b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/channel/operation/message/header/AsyncHeadersForCloudEventsBuilder.java @@ -5,9 +5,6 @@ import java.util.List; -import static com.google.common.collect.ImmutableList.of; -import static java.util.stream.Collectors.toList; - public class AsyncHeadersForCloudEventsBuilder { private final AsyncHeaders headers; @@ -25,11 +22,11 @@ public AsyncHeadersForCloudEventsBuilder(String newSchemaName, AsyncHeaders base } public AsyncHeadersForCloudEventsBuilder withContentTypeHeader(MediaType contentType) { - return withContentTypeHeader(contentType, of(contentType)); + return withContentTypeHeader(contentType, List.of(contentType)); } public AsyncHeadersForCloudEventsBuilder withContentTypeHeader(MediaType exampleContentType, List contentTypeValues) { - List contentTypeStringValues = contentTypeValues.stream().map(MimeType::toString).collect(toList()); + List contentTypeStringValues = contentTypeValues.stream().map(MimeType::toString).toList(); return withHeader( "content-type", contentTypeStringValues, @@ -39,7 +36,7 @@ public AsyncHeadersForCloudEventsBuilder withContentTypeHeader(MediaType example } public AsyncHeadersForCloudEventsBuilder withSpecVersionHeader(String specVersion) { - return withSpecVersionHeader(specVersion, of(specVersion)); + return withSpecVersionHeader(specVersion, List.of(specVersion)); } public AsyncHeadersForCloudEventsBuilder withSpecVersionHeader(String specVersion, List specValues) { @@ -52,7 +49,7 @@ public AsyncHeadersForCloudEventsBuilder withSpecVersionHeader(String specVersio } public AsyncHeadersForCloudEventsBuilder withIdHeader(String idExample) { - return withIdHeader(idExample, of(idExample)); + return withIdHeader(idExample, List.of(idExample)); } public AsyncHeadersForCloudEventsBuilder withIdHeader(String idExample, List idValues) { @@ -65,7 +62,7 @@ public AsyncHeadersForCloudEventsBuilder withIdHeader(String idExample, List timeValues) { @@ -78,7 +75,7 @@ public AsyncHeadersForCloudEventsBuilder withTimeHeader(String timeExample, List } public AsyncHeadersForCloudEventsBuilder withTypeHeader(String typeExample) { - return withTypeHeader(typeExample, of(typeExample)); + return withTypeHeader(typeExample, List.of(typeExample)); } public AsyncHeadersForCloudEventsBuilder withTypeHeader(String typeExample, List typeValues) { @@ -91,7 +88,7 @@ public AsyncHeadersForCloudEventsBuilder withTypeHeader(String typeExample, List } public AsyncHeadersForCloudEventsBuilder withSourceHeader(String sourceExample) { - return withSourceHeader(sourceExample, of(sourceExample)); + return withSourceHeader(sourceExample, List.of(sourceExample)); } public AsyncHeadersForCloudEventsBuilder withSourceHeader(String sourceExample, List sourceValues) { @@ -104,7 +101,7 @@ public AsyncHeadersForCloudEventsBuilder withSourceHeader(String sourceExample, } public AsyncHeadersForCloudEventsBuilder withSubjectHeader(String subjectExample) { - return withSubjectHeader(subjectExample, of(subjectExample)); + return withSubjectHeader(subjectExample, List.of(subjectExample)); } public AsyncHeadersForCloudEventsBuilder withSubjectHeader(String subjectExample, List subjectValues) { diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiSerializerServiceTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiSerializerServiceTest.java index 00a24a14e..4d1749931 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiSerializerServiceTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiSerializerServiceTest.java @@ -10,7 +10,6 @@ import com.asyncapi.v2.binding.operation.OperationBinding; import com.asyncapi.v2.binding.operation.kafka.KafkaOperationBinding; import com.asyncapi.v2.schema.Type; -import com.google.common.collect.ImmutableMap; import io.github.stavshamir.springwolf.asyncapi.types.AsyncAPI; import io.github.stavshamir.springwolf.asyncapi.types.Components; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.Message; @@ -72,7 +71,7 @@ private AsyncAPI getAsyncAPITestObject() { .name("io.github.stavshamir.springwolf.ExamplePayload") .title("Example Payload") .payload(PayloadReference.fromModelName("ExamplePayload")) - .bindings(ImmutableMap.of("kafka", new KafkaMessageBinding(new StringSchema(), null, null, null, "binding-version-1"))) + .bindings(Map.of("kafka", new KafkaMessageBinding(new StringSchema(), null, null, null, "binding-version-1"))) .build(); com.asyncapi.v2.schema.Schema groupId = new com.asyncapi.v2.schema.Schema(); @@ -84,7 +83,7 @@ private AsyncAPI getAsyncAPITestObject() { .description("Auto-generated description") .operationId("new-user_listenerMethod_subscribe") .message(message) - .bindings(ImmutableMap.of("kafka", operationBinding)) + .bindings(Map.of("kafka", operationBinding)) .build(); ChannelItem newUserChannel = ChannelItem.builder() @@ -97,8 +96,8 @@ private AsyncAPI getAsyncAPITestObject() { AsyncAPI asyncapi = AsyncAPI.builder() .info(info) .defaultContentType("application/json") - .servers(ImmutableMap.of("production", productionServer)) - .channels(ImmutableMap.of("new-user", newUserChannel)) + .servers(Map.of("production", productionServer)) + .channels(Map.of("new-user", newUserChannel)) .components(Components.builder().schemas(schemas).build()) .build(); diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiServiceTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiServiceTest.java index 1e5aeffba..2953d1ac4 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiServiceTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiServiceTest.java @@ -5,7 +5,6 @@ import com.asyncapi.v2._0_0.model.channel.ChannelItem; import com.asyncapi.v2._0_0.model.info.Info; import com.asyncapi.v2._0_0.model.server.Server; -import com.google.common.collect.ImmutableMap; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.ConsumerOperationDataScanner; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.ProducerOperationDataScanner; import io.github.stavshamir.springwolf.asyncapi.types.ConsumerData; @@ -53,16 +52,16 @@ public AsyncApiDocket docket() { .channelName("producer-topic") .description("producer-topic-description") .payloadType(String.class) - .operationBinding(ImmutableMap.of("kafka", new KafkaOperationBinding())) - .messageBinding(ImmutableMap.of("kafka", new KafkaMessageBinding())) + .operationBinding(Map.of("kafka", new KafkaOperationBinding())) + .messageBinding(Map.of("kafka", new KafkaMessageBinding())) .build(); ConsumerData kafkaConsumerData = ConsumerData.builder() .channelName("consumer-topic") .description("consumer-topic-description") .payloadType(String.class) - .operationBinding(ImmutableMap.of("kafka", new KafkaOperationBinding())) - .messageBinding(ImmutableMap.of("kafka", new KafkaMessageBinding())) + .operationBinding(Map.of("kafka", new KafkaOperationBinding())) + .messageBinding(Map.of("kafka", new KafkaMessageBinding())) .build(); return AsyncApiDocket.builder() @@ -111,7 +110,7 @@ void getAsyncAPI_producers_should_be_correct() { final Message message = (Message) channel.getSubscribe().getMessage(); // Message description is not supported yet assertThat(message.getDescription()).isNull(); - assertThat(message.getBindings()).isEqualTo(ImmutableMap.of("kafka", new KafkaMessageBinding())); + assertThat(message.getBindings()).isEqualTo(Map.of("kafka", new KafkaMessageBinding())); } @Test @@ -127,7 +126,7 @@ void getAsyncAPI_consumers_should_be_correct() { final Message message = (Message) channel.getPublish().getMessage(); // Message description is not supported yet assertThat(message.getDescription()).isNull(); - assertThat(message.getBindings()).isEqualTo(ImmutableMap.of("kafka", new KafkaMessageBinding())); + assertThat(message.getBindings()).isEqualTo(Map.of("kafka", new KafkaMessageBinding())); } } diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultChannelsServiceTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultChannelsServiceTest.java index 7a7ffd90e..0934c1dc9 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultChannelsServiceTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultChannelsServiceTest.java @@ -2,7 +2,6 @@ import com.asyncapi.v2._0_0.model.channel.ChannelItem; import com.asyncapi.v2._0_0.model.channel.operation.Operation; -import com.google.common.collect.ImmutableMap; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.ChannelsScanner; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -48,7 +47,7 @@ void getChannels() { static class FooChannelScanner implements ChannelsScanner { @Override public Map scan() { - return ImmutableMap.of("foo", new ChannelItem()); + return Map.of("foo", new ChannelItem()); } } @@ -56,7 +55,7 @@ public Map scan() { static class BarChannelScanner implements ChannelsScanner { @Override public Map scan() { - return ImmutableMap.of("bar", new ChannelItem()); + return Map.of("bar", new ChannelItem()); } } @@ -73,7 +72,7 @@ static class ProduceChannelScanner implements ChannelsScanner { @Override public Map scan() { - return ImmutableMap.of(topicName, ChannelItem.builder().publish(publishOperation).build()); + return Map.of(topicName, ChannelItem.builder().publish(publishOperation).build()); } } @@ -83,7 +82,7 @@ static class SubscribeChannelScanner implements ChannelsScanner { @Override public Map scan() { - return ImmutableMap.of(topicName, ChannelItem.builder().subscribe(subscribeOperation).build()); + return Map.of(topicName, ChannelItem.builder().subscribe(subscribeOperation).build()); } } } diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/MessageHelperTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/MessageHelperTest.java index 193ea3c6f..712ff69d8 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/MessageHelperTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/MessageHelperTest.java @@ -1,12 +1,10 @@ package io.github.stavshamir.springwolf.asyncapi; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.Message; import org.junit.jupiter.api.Test; import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.Set; @@ -29,7 +27,7 @@ void toMessageObjectOrComposition_oneMessage() { .name("foo") .build(); - Object asObject = toMessageObjectOrComposition(ImmutableSet.of(message)); + Object asObject = toMessageObjectOrComposition(Set.of(message)); assertThat(asObject) .isInstanceOf(Message.class) @@ -47,11 +45,11 @@ void toMessageObjectOrComposition_multipleMessages() { .name("bar") .build(); - Object asObject = toMessageObjectOrComposition(ImmutableSet.of(message1, message2)); + Object asObject = toMessageObjectOrComposition(Set.of(message1, message2)); assertThat(asObject) .isInstanceOf(Map.class) - .isEqualTo(ImmutableMap.of("oneOf", ImmutableList.of(message2, message1))); + .isEqualTo(Map.of("oneOf", List.of(message2, message1))); } @Test @@ -71,12 +69,12 @@ void toMessageObjectOrComposition_multipleMessages_remove_duplicates() { .description("This is message 3, but in essence the same payload type as message 2") .build(); - Object asObject = toMessageObjectOrComposition(ImmutableSet.of(message1, message2, message3)); + Object asObject = toMessageObjectOrComposition(Set.of(message1, message2, message3)); // Message3 is not included as it is identical in terms of payload type (Message#name) to message 2 assertThat(asObject) .isInstanceOf(Map.class) - .isEqualTo(ImmutableMap.of("oneOf", ImmutableList.of(message2, message1))); + .isEqualTo(Map.of("oneOf", List.of(message2, message1))); } @Test @@ -91,7 +89,7 @@ void toMessageObjectOrComposition_multipleMessages_should_not_break_deep_equals( .description("This is actual message 2") .build(); - Object actualObject = toMessageObjectOrComposition(ImmutableSet.of(actualMessage1, actualMessage2)); + Object actualObject = toMessageObjectOrComposition(Set.of(actualMessage1, actualMessage2)); Message expectedMessage1 = Message.builder() .name("foo") @@ -103,7 +101,7 @@ void toMessageObjectOrComposition_multipleMessages_should_not_break_deep_equals( .description("This is expected message 2") .build(); - Object expectedObject = toMessageObjectOrComposition(ImmutableSet.of(expectedMessage1, expectedMessage2)); + Object expectedObject = toMessageObjectOrComposition(Set.of(expectedMessage1, expectedMessage2)); assertThat(actualObject).isNotEqualTo(expectedObject); } @@ -123,7 +121,7 @@ void messageObjectToSet_Message() { Message message = Message.builder() .name("foo") .build(); - Object asObject = toMessageObjectOrComposition(ImmutableSet.of(message)); + Object asObject = toMessageObjectOrComposition(Set.of(message)); Set messages = messageObjectToSet(asObject); @@ -141,7 +139,7 @@ void messageObjectToSet_SetOfMessage() { .name("bar") .build(); - Object asObject = toMessageObjectOrComposition(ImmutableSet.of(message1, message2)); + Object asObject = toMessageObjectOrComposition(Set.of(message1, message2)); Set messages = messageObjectToSet(asObject); diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/beans/DefaultBeanMethodsScannerTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/beans/DefaultBeanMethodsScannerTest.java index 66cfc8d1b..7a765b0ce 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/beans/DefaultBeanMethodsScannerTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/beans/DefaultBeanMethodsScannerTest.java @@ -1,6 +1,5 @@ package io.github.stavshamir.springwolf.asyncapi.scanners.beans; -import com.google.common.collect.ImmutableSet; import io.github.stavshamir.springwolf.asyncapi.scanners.classes.ConfigurationClassScanner; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -31,7 +30,7 @@ class DefaultBeanMethodsScannerTest { @Test void name() { when(configurationClassScanner.scan()) - .thenReturn(ImmutableSet.of(ConfigurationClass.class)); + .thenReturn(Set.of(ConfigurationClass.class)); Set beanMethods = beanMethodsScanner.getBeanMethods().stream() .map(Method::getName) diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/ChannelMergerTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/ChannelMergerTest.java index 8a64bcca8..3c0ba48ef 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/ChannelMergerTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/ChannelMergerTest.java @@ -3,14 +3,13 @@ import com.asyncapi.v2._0_0.model.channel.ChannelItem; import com.asyncapi.v2._0_0.model.channel.operation.Operation; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; import io.github.stavshamir.springwolf.asyncapi.MessageHelper; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.Message; import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Map; +import java.util.Set; import static org.assertj.core.api.Assertions.assertThat; @@ -28,8 +27,8 @@ void shouldNotMergeDifferentChannelNames() { // when Map mergedChannels = ChannelMerger.merge(Arrays.asList( - Maps.immutableEntry(channelName1, publisherChannel), - Maps.immutableEntry(channelName2, subscriberChannel))); + Map.entry(channelName1, publisherChannel), + Map.entry(channelName2, subscriberChannel))); // then assertThat(mergedChannels).hasSize(2) @@ -54,8 +53,8 @@ void shouldMergePublisherAndSubscriberIntoOneChannel() { // when Map mergedChannels = ChannelMerger.merge(Arrays.asList( - Maps.immutableEntry(channelName, publisherChannel), - Maps.immutableEntry(channelName, subscriberChannel))); + Map.entry(channelName, publisherChannel), + Map.entry(channelName, subscriberChannel))); // then assertThat(mergedChannels).hasSize(1) @@ -76,8 +75,8 @@ void shouldUseFirstOperationFound() { // when Map mergedChannels = ChannelMerger.merge(Arrays.asList( - Maps.immutableEntry(channelName, publisherChannel1), - Maps.immutableEntry(channelName, publisherChannel2))); + Map.entry(channelName, publisherChannel1), + Map.entry(channelName, publisherChannel2))); // then assertThat(mergedChannels).hasSize(1) @@ -103,13 +102,13 @@ void shouldMergeDifferentMessageForSameOperation() { // when Map mergedChannels = ChannelMerger.merge(Arrays.asList( - Maps.immutableEntry(channelName, publisherChannel1), - Maps.immutableEntry(channelName, publisherChannel2), - Maps.immutableEntry(channelName, publisherChannel3))); + Map.entry(channelName, publisherChannel1), + Map.entry(channelName, publisherChannel2), + Map.entry(channelName, publisherChannel3))); // then expectedMessage only includes message1 and message2. // Message3 is not included as it is identical in terms of payload type (Message#name) to message 2 - Object expectedMessages = MessageHelper.toMessageObjectOrComposition(Sets.newHashSet(message1, message2)); + Object expectedMessages = MessageHelper.toMessageObjectOrComposition(Set.of(message1, message2)); assertThat(mergedChannels).hasSize(1) .hasEntrySatisfying(channelName, it -> { assertThat(it.getPublish()).isEqualTo(Operation.builder().operationId("publisher1").message(expectedMessages).build()); @@ -129,11 +128,11 @@ void shouldUseOtherMessageIfFirstMessageIsMissing() { // when Map mergedChannels = ChannelMerger.merge(Arrays.asList( - Maps.immutableEntry(channelName, publisherChannel1), - Maps.immutableEntry(channelName, publisherChannel2))); + Map.entry(channelName, publisherChannel1), + Map.entry(channelName, publisherChannel2))); // then expectedMessage message2 - Object expectedMessages = MessageHelper.toMessageObjectOrComposition(Sets.newHashSet(message2)); + Object expectedMessages = MessageHelper.toMessageObjectOrComposition(Set.of(message2)); assertThat(mergedChannels).hasSize(1) .hasEntrySatisfying(channelName, it -> { assertThat(it.getPublish()).isEqualTo(Operation.builder().operationId("publisher1").message(expectedMessages).build()); diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/TestMethodLevelListenerScanner.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/TestMethodLevelListenerScanner.java index 710eefdaf..5c9d2bb95 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/TestMethodLevelListenerScanner.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/TestMethodLevelListenerScanner.java @@ -3,7 +3,6 @@ import com.asyncapi.v2.binding.channel.ChannelBinding; import com.asyncapi.v2.binding.message.MessageBinding; import com.asyncapi.v2.binding.operation.OperationBinding; -import com.google.common.collect.ImmutableMap; import lombok.EqualsAndHashCode; import java.lang.reflect.Method; @@ -23,17 +22,17 @@ protected String getChannelName(TestMethodLevelListenerScannerTest.TestChannelLi @Override protected Map buildChannelBinding(TestMethodLevelListenerScannerTest.TestChannelListener annotation) { - return ImmutableMap.of("test-channel-binding", new TestChannelBinding()); + return Map.of("test-channel-binding", new TestChannelBinding()); } @Override protected Map buildOperationBinding(TestMethodLevelListenerScannerTest.TestChannelListener annotation) { - return ImmutableMap.of("test-operation-binding", new TestOperationBinding()); + return Map.of("test-operation-binding", new TestOperationBinding()); } @Override protected Map buildMessageBinding(TestMethodLevelListenerScannerTest.TestChannelListener annotation) { - return ImmutableMap.of("test-message-binding", new TestMessageBinding()); + return Map.of("test-message-binding", new TestMessageBinding()); } @Override diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/TestMethodLevelListenerScannerTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/TestMethodLevelListenerScannerTest.java index 14d785863..1af88cc2f 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/TestMethodLevelListenerScannerTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/TestMethodLevelListenerScannerTest.java @@ -2,8 +2,6 @@ import com.asyncapi.v2._0_0.model.channel.ChannelItem; import com.asyncapi.v2._0_0.model.channel.operation.Operation; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; import io.github.stavshamir.springwolf.asyncapi.scanners.classes.ComponentClassScanner; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.Message; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.PayloadReference; @@ -72,23 +70,23 @@ void scan_componentHasListenerMethod() { .title(SimpleFoo.class.getSimpleName()) .payload(PayloadReference.fromModelName(SimpleFoo.class.getSimpleName())) .headers(HeaderReference.fromModelName(AsyncHeaders.NOT_DOCUMENTED.getSchemaName())) - .bindings(ImmutableMap.of("test-message-binding", new TestMethodLevelListenerScanner.TestMessageBinding())) + .bindings(Map.of("test-message-binding", new TestMethodLevelListenerScanner.TestMessageBinding())) .build(); Operation operation = Operation.builder() .description("Auto-generated description") .operationId("test-channel_publish_methodWithAnnotation") - .bindings(ImmutableMap.of("test-operation-binding", new TestMethodLevelListenerScanner.TestOperationBinding())) + .bindings(Map.of("test-operation-binding", new TestMethodLevelListenerScanner.TestOperationBinding())) .message(message) .build(); ChannelItem expectedChannel = ChannelItem.builder() - .bindings(ImmutableMap.of("test-channel-binding", new TestMethodLevelListenerScanner.TestChannelBinding())) + .bindings(Map.of("test-channel-binding", new TestMethodLevelListenerScanner.TestChannelBinding())) .publish(operation) .build(); assertThat(actualChannels) - .containsExactly(Maps.immutableEntry("test-channel", expectedChannel)); + .containsExactly(Map.entry("test-channel", expectedChannel)); } private static class ClassWithoutListenerAnnotation { diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/ConsumerOperationDataScannerTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/ConsumerOperationDataScannerTest.java index ce5046ff8..b5f0fa298 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/ConsumerOperationDataScannerTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/ConsumerOperationDataScannerTest.java @@ -6,9 +6,6 @@ import com.asyncapi.v2._0_0.model.channel.ChannelItem; import com.asyncapi.v2._0_0.model.channel.operation.Operation; import com.asyncapi.v2._0_0.model.info.Info; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import io.github.stavshamir.springwolf.asyncapi.types.ConsumerData; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.Message; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.PayloadReference; @@ -25,6 +22,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.Collection; +import java.util.List; import java.util.Map; import java.util.Set; @@ -50,13 +48,13 @@ void allFieldsConsumerData() { ConsumerData consumerData = ConsumerData.builder() .channelName(channelName) .description(description) - .channelBinding(ImmutableMap.of("kafka", new KafkaChannelBinding())) - .operationBinding(ImmutableMap.of("kafka", new KafkaOperationBinding())) - .messageBinding(ImmutableMap.of("kafka", new KafkaMessageBinding())) + .channelBinding(Map.of("kafka", new KafkaChannelBinding())) + .operationBinding(Map.of("kafka", new KafkaOperationBinding())) + .messageBinding(Map.of("kafka", new KafkaMessageBinding())) .payloadType(ExamplePayloadDto.class) .build(); - mockConsumers(ImmutableList.of(consumerData)); + mockConsumers(List.of(consumerData)); // When scanning for consumers Map consumerChannels = scanner.scan(); @@ -68,7 +66,7 @@ void allFieldsConsumerData() { Operation operation = Operation.builder() .description(description) .operationId("example-consumer-topic-foo1_publish") - .bindings(ImmutableMap.of("kafka", new KafkaOperationBinding())) + .bindings(Map.of("kafka", new KafkaOperationBinding())) .message(Message.builder() .name(ExamplePayloadDto.class.getName()) // Message description is not supported yet @@ -76,12 +74,12 @@ void allFieldsConsumerData() { .title(ExamplePayloadDto.class.getSimpleName()) .payload(PayloadReference.fromModelName(ExamplePayloadDto.class.getSimpleName())) .headers(HeaderReference.fromModelName(AsyncHeaders.NOT_DOCUMENTED.getSchemaName())) - .bindings(ImmutableMap.of("kafka", new KafkaMessageBinding())) + .bindings(Map.of("kafka", new KafkaMessageBinding())) .build()) .build(); ChannelItem expectedChannel = ChannelItem.builder() - .bindings(ImmutableMap.of("kafka", new KafkaChannelBinding())) + .bindings(Map.of("kafka", new KafkaChannelBinding())) .publish(operation) .build(); @@ -97,7 +95,7 @@ void missingFieldConsumerData() { .channelName(channelName) .build(); - mockConsumers(ImmutableList.of(consumerData)); + mockConsumers(List.of(consumerData)); // When scanning for consumers Map consumerChannels = scanner.scan(); @@ -116,23 +114,23 @@ void multipleConsumersForSameTopic() { ConsumerData consumerData1 = ConsumerData.builder() .channelName(channelName) .description(description1) - .channelBinding(ImmutableMap.of("kafka", new KafkaChannelBinding())) - .operationBinding(ImmutableMap.of("kafka", new KafkaOperationBinding())) - .messageBinding(ImmutableMap.of("kafka", new KafkaMessageBinding())) + .channelBinding(Map.of("kafka", new KafkaChannelBinding())) + .operationBinding(Map.of("kafka", new KafkaOperationBinding())) + .messageBinding(Map.of("kafka", new KafkaMessageBinding())) .payloadType(ExamplePayloadDto.class) .build(); ConsumerData consumerData2 = ConsumerData.builder() .channelName(channelName) .description(description2) - .channelBinding(ImmutableMap.of("kafka", new KafkaChannelBinding())) - .operationBinding(ImmutableMap.of("kafka", new KafkaOperationBinding())) - .messageBinding(ImmutableMap.of("kafka", new KafkaMessageBinding())) + .channelBinding(Map.of("kafka", new KafkaChannelBinding())) + .operationBinding(Map.of("kafka", new KafkaOperationBinding())) + .messageBinding(Map.of("kafka", new KafkaMessageBinding())) .payloadType(AnotherExamplePayloadDto.class) .headers(AsyncHeaders.NOT_USED) .build(); - mockConsumers(ImmutableList.of(consumerData1, consumerData2)); + mockConsumers(List.of(consumerData1, consumerData2)); // When scanning for consumers Map consumerChannels = scanner.scan(); @@ -142,7 +140,7 @@ void multipleConsumersForSameTopic() { .hasSize(1) .containsKey(channelName); - Set messages = ImmutableSet.of( + Set messages = Set.of( Message.builder() .name(ExamplePayloadDto.class.getName()) // Message description is not supported yet @@ -150,7 +148,7 @@ void multipleConsumersForSameTopic() { .title(ExamplePayloadDto.class.getSimpleName()) .payload(PayloadReference.fromModelName(ExamplePayloadDto.class.getSimpleName())) .headers(HeaderReference.fromModelName(AsyncHeaders.NOT_DOCUMENTED.getSchemaName())) - .bindings(ImmutableMap.of("kafka", new KafkaMessageBinding())) + .bindings(Map.of("kafka", new KafkaMessageBinding())) .build(), Message.builder() .name(AnotherExamplePayloadDto.class.getName()) @@ -159,19 +157,19 @@ void multipleConsumersForSameTopic() { .title(AnotherExamplePayloadDto.class.getSimpleName()) .payload(PayloadReference.fromModelName(AnotherExamplePayloadDto.class.getSimpleName())) .headers(HeaderReference.fromModelName(AsyncHeaders.NOT_USED.getSchemaName())) - .bindings(ImmutableMap.of("kafka", new KafkaMessageBinding())) + .bindings(Map.of("kafka", new KafkaMessageBinding())) .build() ); Operation operation = Operation.builder() .description(description1) .operationId("example-consumer-topic_publish") - .bindings(ImmutableMap.of("kafka", new KafkaOperationBinding())) + .bindings(Map.of("kafka", new KafkaOperationBinding())) .message(toMessageObjectOrComposition(messages)) .build(); ChannelItem expectedChannel = ChannelItem.builder() - .bindings(ImmutableMap.of("kafka", new KafkaChannelBinding())) + .bindings(Map.of("kafka", new KafkaChannelBinding())) .publish(operation) .build(); diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/ProducerOperationDataScannerTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/ProducerOperationDataScannerTest.java index 6bf2c3b19..5371824ba 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/ProducerOperationDataScannerTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/ProducerOperationDataScannerTest.java @@ -6,9 +6,6 @@ import com.asyncapi.v2._0_0.model.channel.ChannelItem; import com.asyncapi.v2._0_0.model.channel.operation.Operation; import com.asyncapi.v2._0_0.model.info.Info; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import io.github.stavshamir.springwolf.asyncapi.types.ProducerData; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.Message; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.PayloadReference; @@ -25,6 +22,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.Collection; +import java.util.List; import java.util.Map; import java.util.Set; @@ -50,13 +48,13 @@ void allFieldsProducerData() { ProducerData producerData = ProducerData.builder() .channelName(channelName) .description(description) - .channelBinding(ImmutableMap.of("kafka", new KafkaChannelBinding())) - .operationBinding(ImmutableMap.of("kafka", new KafkaOperationBinding())) - .messageBinding(ImmutableMap.of("kafka", new KafkaMessageBinding())) + .channelBinding(Map.of("kafka", new KafkaChannelBinding())) + .operationBinding(Map.of("kafka", new KafkaOperationBinding())) + .messageBinding(Map.of("kafka", new KafkaMessageBinding())) .payloadType(ExamplePayloadDto.class) .build(); - mockProducers(ImmutableList.of(producerData)); + mockProducers(List.of(producerData)); // When scanning for producers Map producerChannels = scanner.scan(); @@ -68,7 +66,7 @@ void allFieldsProducerData() { Operation operation = Operation.builder() .description(description) .operationId("example-producer-topic-foo1_subscribe") - .bindings(ImmutableMap.of("kafka", new KafkaOperationBinding())) + .bindings(Map.of("kafka", new KafkaOperationBinding())) .message(Message.builder() .name(ExamplePayloadDto.class.getName()) // Message description is not supported yet @@ -76,12 +74,12 @@ void allFieldsProducerData() { .title(ExamplePayloadDto.class.getSimpleName()) .payload(PayloadReference.fromModelName(ExamplePayloadDto.class.getSimpleName())) .headers(HeaderReference.fromModelName(AsyncHeaders.NOT_DOCUMENTED.getSchemaName())) - .bindings(ImmutableMap.of("kafka", new KafkaMessageBinding())) + .bindings(Map.of("kafka", new KafkaMessageBinding())) .build()) .build(); ChannelItem expectedChannel = ChannelItem.builder() - .bindings(ImmutableMap.of("kafka", new KafkaChannelBinding())) + .bindings(Map.of("kafka", new KafkaChannelBinding())) .subscribe(operation) .build(); @@ -97,7 +95,7 @@ void missingFieldProducerData() { .channelName(channelName) .build(); - mockProducers(ImmutableList.of(producerData)); + mockProducers(List.of(producerData)); // When scanning for producers Map producerChannels = scanner.scan(); @@ -116,23 +114,23 @@ void multipleProducersForSameTopic() { ProducerData producerData1 = ProducerData.builder() .channelName(channelName) .description(description1) - .channelBinding(ImmutableMap.of("kafka", new KafkaChannelBinding())) - .operationBinding(ImmutableMap.of("kafka", new KafkaOperationBinding())) - .messageBinding(ImmutableMap.of("kafka", new KafkaMessageBinding())) + .channelBinding(Map.of("kafka", new KafkaChannelBinding())) + .operationBinding(Map.of("kafka", new KafkaOperationBinding())) + .messageBinding(Map.of("kafka", new KafkaMessageBinding())) .payloadType(ExamplePayloadDto.class) .build(); ProducerData producerData2 = ProducerData.builder() .channelName(channelName) .description(description2) - .channelBinding(ImmutableMap.of("kafka", new KafkaChannelBinding())) - .operationBinding(ImmutableMap.of("kafka", new KafkaOperationBinding())) - .messageBinding(ImmutableMap.of("kafka", new KafkaMessageBinding())) + .channelBinding(Map.of("kafka", new KafkaChannelBinding())) + .operationBinding(Map.of("kafka", new KafkaOperationBinding())) + .messageBinding(Map.of("kafka", new KafkaMessageBinding())) .payloadType(AnotherExamplePayloadDto.class) .headers(AsyncHeaders.NOT_USED) .build(); - mockProducers(ImmutableList.of(producerData1, producerData2)); + mockProducers(List.of(producerData1, producerData2)); // When scanning for producers Map producerChannels = scanner.scan(); @@ -142,7 +140,7 @@ void multipleProducersForSameTopic() { .hasSize(1) .containsKey(channelName); - Set messages = ImmutableSet.of( + Set messages = Set.of( Message.builder() .name(ExamplePayloadDto.class.getName()) // Message description is not supported yet @@ -150,7 +148,7 @@ void multipleProducersForSameTopic() { .title(ExamplePayloadDto.class.getSimpleName()) .payload(PayloadReference.fromModelName(ExamplePayloadDto.class.getSimpleName())) .headers(HeaderReference.fromModelName(AsyncHeaders.NOT_DOCUMENTED.getSchemaName())) - .bindings(ImmutableMap.of("kafka", new KafkaMessageBinding())) + .bindings(Map.of("kafka", new KafkaMessageBinding())) .build(), Message.builder() .name(AnotherExamplePayloadDto.class.getName()) @@ -159,19 +157,19 @@ void multipleProducersForSameTopic() { .title(AnotherExamplePayloadDto.class.getSimpleName()) .payload(PayloadReference.fromModelName(AnotherExamplePayloadDto.class.getSimpleName())) .headers(HeaderReference.fromModelName(AsyncHeaders.NOT_USED.getSchemaName())) - .bindings(ImmutableMap.of("kafka", new KafkaMessageBinding())) + .bindings(Map.of("kafka", new KafkaMessageBinding())) .build() ); Operation operation = Operation.builder() .description(description1) .operationId("example-producer-topic_subscribe") - .bindings(ImmutableMap.of("kafka", new KafkaOperationBinding())) + .bindings(Map.of("kafka", new KafkaOperationBinding())) .message(toMessageObjectOrComposition(messages)) .build(); ChannelItem expectedChannel = ChannelItem.builder() - .bindings(ImmutableMap.of("kafka", new KafkaChannelBinding())) + .bindings(Map.of("kafka", new KafkaChannelBinding())) .subscribe(operation) .build(); diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncListenerAnnotationScannerTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncListenerAnnotationScannerTest.java index 068869fd1..0ca155bde 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncListenerAnnotationScannerTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncListenerAnnotationScannerTest.java @@ -2,8 +2,6 @@ import com.asyncapi.v2._0_0.model.channel.ChannelItem; import com.asyncapi.v2._0_0.model.channel.operation.Operation; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; import io.github.stavshamir.springwolf.asyncapi.scanners.classes.ComponentClassScanner; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.Message; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.PayloadReference; @@ -86,7 +84,7 @@ void scan_componentHasListenerMethod() { .build(); assertThat(actualChannels) - .containsExactly(Maps.immutableEntry("test-channel", expectedChannel)); + .containsExactly(Map.entry("test-channel", expectedChannel)); } @Test @@ -111,7 +109,7 @@ void scan_componentHasListenerMethodWithAllAttributes() { Operation operation = Operation.builder() .description("description") .operationId("test-channel_publish") - .bindings(ImmutableMap.of(TestOperationBindingProcessor.TYPE, TestOperationBindingProcessor.BINDING)) + .bindings(Map.of(TestOperationBindingProcessor.TYPE, TestOperationBindingProcessor.BINDING)) .message(message) .build(); @@ -121,7 +119,7 @@ void scan_componentHasListenerMethodWithAllAttributes() { .build(); assertThat(actualChannels) - .containsExactly(Maps.immutableEntry("test-channel", expectedChannel)); + .containsExactly(Map.entry("test-channel", expectedChannel)); } @Test @@ -168,7 +166,7 @@ void scan_componentHasMultipleListenerAnnotations() { assertThat(actualChannels) .containsExactlyEntriesOf( - ImmutableMap.of( + Map.of( "test-channel-1", expectedChannel1, "test-channel-2", expectedChannel2)); } diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncPublisherAnnotationScannerTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncPublisherAnnotationScannerTest.java index 6147c798d..7c69e8860 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncPublisherAnnotationScannerTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncPublisherAnnotationScannerTest.java @@ -2,8 +2,6 @@ import com.asyncapi.v2._0_0.model.channel.ChannelItem; import com.asyncapi.v2._0_0.model.channel.operation.Operation; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; import io.github.stavshamir.springwolf.asyncapi.scanners.classes.ComponentClassScanner; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.Message; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.PayloadReference; @@ -86,7 +84,7 @@ void scan_componentHasPublisherMethod() { .build(); assertThat(actualChannels) - .containsExactly(Maps.immutableEntry("test-channel", expectedChannel)); + .containsExactly(Map.entry("test-channel", expectedChannel)); } @Test @@ -111,7 +109,7 @@ void scan_componentHasPublisherMethodWithAllAttributes() { Operation operation = Operation.builder() .description("description") .operationId("test-channel_subscribe") - .bindings(ImmutableMap.of(TestOperationBindingProcessor.TYPE, TestOperationBindingProcessor.BINDING)) + .bindings(Map.of(TestOperationBindingProcessor.TYPE, TestOperationBindingProcessor.BINDING)) .message(message) .build(); @@ -121,7 +119,7 @@ void scan_componentHasPublisherMethodWithAllAttributes() { .build(); assertThat(actualChannels) - .containsExactly(Maps.immutableEntry("test-channel", expectedChannel)); + .containsExactly(Map.entry("test-channel", expectedChannel)); } @Test @@ -169,7 +167,7 @@ void scan_componentHasMultiplePublisherAnnotations() { assertThat(actualChannels) .containsExactlyEntriesOf( - ImmutableMap.of( + Map.of( "test-channel-1", expectedChannel1, "test-channel-2", expectedChannel2)); } diff --git a/springwolf-examples/springwolf-amqp-example/build.gradle b/springwolf-examples/springwolf-amqp-example/build.gradle index f3949d683..946f22b89 100644 --- a/springwolf-examples/springwolf-amqp-example/build.gradle +++ b/springwolf-examples/springwolf-amqp-example/build.gradle @@ -20,7 +20,6 @@ dependencies { implementation "org.springframework.boot:spring-boot-starter-web" implementation "org.springframework.amqp:spring-rabbit" - implementation "com.google.guava:guava:${guavaVersion}" implementation "org.slf4j:slf4j-api" implementation "io.swagger.core.v3:swagger-core-jakarta:${swaggerCoreVersion}" diff --git a/springwolf-examples/springwolf-cloud-stream-example/build.gradle b/springwolf-examples/springwolf-cloud-stream-example/build.gradle index 536542e3b..d96edf6f7 100644 --- a/springwolf-examples/springwolf-cloud-stream-example/build.gradle +++ b/springwolf-examples/springwolf-cloud-stream-example/build.gradle @@ -31,7 +31,6 @@ dependencies { implementation "org.springframework.boot:spring-boot-starter-web" implementation "org.springframework.cloud:spring-cloud-stream" implementation "org.springframework.cloud:spring-cloud-stream-binder-kafka-streams" - implementation "com.google.guava:guava:${guavaVersion}" implementation "org.slf4j:slf4j-api" implementation "io.swagger.core.v3:swagger-core-jakarta:${swaggerCoreVersion}" diff --git a/springwolf-examples/springwolf-kafka-example/build.gradle b/springwolf-examples/springwolf-kafka-example/build.gradle index 15d2cb92c..87a030707 100644 --- a/springwolf-examples/springwolf-kafka-example/build.gradle +++ b/springwolf-examples/springwolf-kafka-example/build.gradle @@ -23,7 +23,6 @@ dependencies { implementation "org.springframework.boot:spring-boot-starter-web" implementation "org.springframework.kafka:spring-kafka" implementation "org.springframework.boot:spring-boot-starter-security" - implementation "com.google.guava:guava:${guavaVersion}" implementation "org.slf4j:slf4j-api" implementation "org.javamoney:moneta:${javaMoneyMonetaVersion}" implementation "io.swagger.core.v3:swagger-core-jakarta:${swaggerCoreVersion}" diff --git a/springwolf-plugins/springwolf-amqp-plugin/build.gradle b/springwolf-plugins/springwolf-amqp-plugin/build.gradle index 254792155..066207350 100644 --- a/springwolf-plugins/springwolf-amqp-plugin/build.gradle +++ b/springwolf-plugins/springwolf-amqp-plugin/build.gradle @@ -20,7 +20,6 @@ dependencies { implementation "org.springframework:spring-web" implementation "org.springframework.amqp:spring-rabbit" - implementation "com.google.guava:guava:${guavaVersion}" implementation "org.slf4j:slf4j-api" compileOnly "org.projectlombok:lombok:${lombokVersion}" diff --git a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelRabbitListenerScanner.java b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelRabbitListenerScanner.java index ac525cf63..2d657e2c8 100644 --- a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelRabbitListenerScanner.java +++ b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelRabbitListenerScanner.java @@ -6,7 +6,6 @@ import com.asyncapi.v2.binding.channel.amqp.AMQPChannelBinding; import com.asyncapi.v2.binding.message.amqp.AMQPMessageBinding; import com.asyncapi.v2.binding.operation.amqp.AMQPOperationBinding; -import com.google.common.collect.ImmutableMap; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.ChannelPriority; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.ChannelsScanner; import lombok.extern.slf4j.Slf4j; @@ -89,7 +88,7 @@ private String getChannelNameFromBindings(RabbitListener annotation) { .is("routingKey") .exchange(exchangeProperties) .build(); - return ImmutableMap.of("amqp", channelBinding); + return Map.of("amqp", channelBinding); } private String getExchangeName(RabbitListener annotation) { @@ -110,13 +109,13 @@ private String getExchangeName(RabbitListener annotation) { @Override protected Map buildOperationBinding(RabbitListener annotation) { - return ImmutableMap.of("amqp", AMQPOperationBinding.builder().cc(getRoutingKeys(annotation)).build()); + return Map.of("amqp", AMQPOperationBinding.builder().cc(getRoutingKeys(annotation)).build()); } @Override protected Map buildMessageBinding(RabbitListener annotation) { // currently the feature to define amqp message binding is not implemented. - return ImmutableMap.of("amqp", new AMQPMessageBinding()); + return Map.of("amqp", new AMQPMessageBinding()); } private List getRoutingKeys(RabbitListener annotation) { diff --git a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/AmqpConsumerData.java b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/AmqpConsumerData.java index f4b3533b3..6ba25da36 100644 --- a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/AmqpConsumerData.java +++ b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/AmqpConsumerData.java @@ -3,11 +3,11 @@ import com.asyncapi.v2.binding.channel.amqp.AMQPChannelBinding; import com.asyncapi.v2.binding.message.amqp.AMQPMessageBinding; import com.asyncapi.v2.binding.operation.amqp.AMQPOperationBinding; -import com.google.common.collect.ImmutableMap; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.header.AsyncHeaders; import lombok.Builder; import java.util.Collections; +import java.util.Map; public class AmqpConsumerData extends ConsumerData { @@ -18,16 +18,16 @@ public AmqpConsumerData(String queueName, String exchangeName, String routingKey AMQPChannelBinding.ExchangeProperties exchangeProperties = new AMQPChannelBinding.ExchangeProperties(); exchangeProperties.setName(exchangeName); - this.channelBinding = ImmutableMap.of("amqp", AMQPChannelBinding.builder() + this.channelBinding = Map.of("amqp", AMQPChannelBinding.builder() .is("routingKey") .exchange(exchangeProperties) .build()); - this.operationBinding = ImmutableMap.of("amqp", AMQPOperationBinding.builder() + this.operationBinding = Map.of("amqp", AMQPOperationBinding.builder() .cc(Collections.singletonList(routingKey)) .build()); - this.messageBinding = ImmutableMap.of("amqp", AMQPMessageBinding.builder() + this.messageBinding = Map.of("amqp", AMQPMessageBinding.builder() .build()); this.payloadType = payloadType; diff --git a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/AmqpProducerData.java b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/AmqpProducerData.java index df6891581..d9a185036 100644 --- a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/AmqpProducerData.java +++ b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/AmqpProducerData.java @@ -3,11 +3,11 @@ import com.asyncapi.v2.binding.channel.amqp.AMQPChannelBinding; import com.asyncapi.v2.binding.message.amqp.AMQPMessageBinding; import com.asyncapi.v2.binding.operation.amqp.AMQPOperationBinding; -import com.google.common.collect.ImmutableMap; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.header.AsyncHeaders; import lombok.Builder; import java.util.Collections; +import java.util.Map; public class AmqpProducerData extends ProducerData { @@ -18,16 +18,16 @@ public AmqpProducerData(String queueName, String exchangeName, String routingKey AMQPChannelBinding.ExchangeProperties exchangeProperties = new AMQPChannelBinding.ExchangeProperties(); exchangeProperties.setName(exchangeName); - this.channelBinding = ImmutableMap.of("amqp", AMQPChannelBinding.builder() + this.channelBinding = Map.of("amqp", AMQPChannelBinding.builder() .is("routingKey") .exchange(exchangeProperties) .build()); - this.operationBinding = ImmutableMap.of("amqp", AMQPOperationBinding.builder() + this.operationBinding = Map.of("amqp", AMQPOperationBinding.builder() .cc(Collections.singletonList(routingKey)) .build()); - this.messageBinding = ImmutableMap.of("amqp", AMQPMessageBinding.builder() + this.messageBinding = Map.of("amqp", AMQPMessageBinding.builder() .build()); this.payloadType = payloadType; diff --git a/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelRabbitListenerScannerTest.java b/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelRabbitListenerScannerTest.java index 0818b3088..14b32c7fe 100644 --- a/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelRabbitListenerScannerTest.java +++ b/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelRabbitListenerScannerTest.java @@ -6,8 +6,6 @@ import com.asyncapi.v2.binding.operation.amqp.AMQPOperationBinding; import com.asyncapi.v2._0_0.model.channel.ChannelItem; import com.asyncapi.v2._0_0.model.channel.operation.Operation; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; import io.github.stavshamir.springwolf.asyncapi.scanners.classes.ComponentClassScanner; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.Message; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.PayloadReference; @@ -100,25 +98,25 @@ void scan_componentHasRabbitListenerMethods_hardCodedTopic() { .title(SimpleFoo.class.getSimpleName()) .payload(PayloadReference.fromModelName(SimpleFoo.class.getSimpleName())) .headers(HeaderReference.fromModelName(AsyncHeaders.NOT_DOCUMENTED.getSchemaName())) - .bindings(ImmutableMap.of("amqp", new AMQPMessageBinding())) + .bindings(Map.of("amqp", new AMQPMessageBinding())) .build(); Operation operation = Operation.builder() .description("Auto-generated description") .operationId("test-queue_publish_methodWithAnnotation") - .bindings(ImmutableMap.of("amqp", AMQPOperationBinding.builder() + .bindings(Map.of("amqp", AMQPOperationBinding.builder() .cc(Collections.singletonList(QUEUE)) .build())) .message(message) .build(); ChannelItem expectedChannelItem = ChannelItem.builder() - .bindings(ImmutableMap.of("amqp", channelBinding)) + .bindings(Map.of("amqp", channelBinding)) .publish(operation) .build(); assertThat(actualChannelItems) - .containsExactly(Maps.immutableEntry(QUEUE, expectedChannelItem)); + .containsExactly(Map.entry(QUEUE, expectedChannelItem)); } @Test @@ -142,25 +140,25 @@ void scan_componentHasRabbitListenerMethods_embeddedValueTopic() { .title(SimpleFoo.class.getSimpleName()) .payload(PayloadReference.fromModelName(SimpleFoo.class.getSimpleName())) .headers(HeaderReference.fromModelName(AsyncHeaders.NOT_DOCUMENTED.getSchemaName())) - .bindings(ImmutableMap.of("amqp", new AMQPMessageBinding())) + .bindings(Map.of("amqp", new AMQPMessageBinding())) .build(); Operation operation = Operation.builder() .description("Auto-generated description") .operationId("test-queue_publish_methodWithAnnotation1") - .bindings(ImmutableMap.of("amqp", AMQPOperationBinding.builder() + .bindings(Map.of("amqp", AMQPOperationBinding.builder() .cc(Collections.singletonList(QUEUE)) .build())) .message(message) .build(); ChannelItem expectedChannelItem = ChannelItem.builder() - .bindings(ImmutableMap.of("amqp", channelBinding)) + .bindings(Map.of("amqp", channelBinding)) .publish(operation) .build(); assertThat(actualChannelItems) - .containsExactly(Maps.immutableEntry(QUEUE, expectedChannelItem)); + .containsExactly(Map.entry(QUEUE, expectedChannelItem)); } @Test @@ -181,25 +179,25 @@ void scan_componentHasRabbitListenerMethods_bindingsAnnotation() { .title(SimpleFoo.class.getSimpleName()) .payload(PayloadReference.fromModelName(SimpleFoo.class.getSimpleName())) .headers(HeaderReference.fromModelName(AsyncHeaders.NOT_DOCUMENTED.getSchemaName())) - .bindings(ImmutableMap.of("amqp", new AMQPMessageBinding())) + .bindings(Map.of("amqp", new AMQPMessageBinding())) .build(); Operation operation = Operation.builder() .description("Auto-generated description") .operationId("test-queue_publish_methodWithAnnotation1") - .bindings(ImmutableMap.of("amqp", AMQPOperationBinding.builder() + .bindings(Map.of("amqp", AMQPOperationBinding.builder() .cc(Collections.singletonList("key")) .build())) .message(message) .build(); ChannelItem expectedChannelItem = ChannelItem.builder() - .bindings(ImmutableMap.of("amqp", channelBinding)) + .bindings(Map.of("amqp", channelBinding)) .publish(operation) .build(); assertThat(actualChannelItems) - .containsExactly(Maps.immutableEntry(QUEUE, expectedChannelItem)); + .containsExactly(Map.entry(QUEUE, expectedChannelItem)); } @Test @@ -220,25 +218,25 @@ void scan_componentHasRabbitListenerMethods_bindingBean() { .title(SimpleFoo.class.getSimpleName()) .payload(PayloadReference.fromModelName(SimpleFoo.class.getSimpleName())) .headers(HeaderReference.fromModelName(AsyncHeaders.NOT_DOCUMENTED.getSchemaName())) - .bindings(ImmutableMap.of("amqp", new AMQPMessageBinding())) + .bindings(Map.of("amqp", new AMQPMessageBinding())) .build(); Operation operation = Operation.builder() .description("Auto-generated description") .operationId("binding-bean-queue_publish_methodWithAnnotation1") - .bindings(ImmutableMap.of("amqp", AMQPOperationBinding.builder() + .bindings(Map.of("amqp", AMQPOperationBinding.builder() .cc(Collections.singletonList("binding-bean-key")) .build())) .message(message) .build(); ChannelItem expectedChannelItem = ChannelItem.builder() - .bindings(ImmutableMap.of("amqp", channelBinding)) + .bindings(Map.of("amqp", channelBinding)) .publish(operation) .build(); assertThat(actualChannelItems) - .containsExactly(Maps.immutableEntry("binding-bean-queue", expectedChannelItem)); + .containsExactly(Map.entry("binding-bean-queue", expectedChannelItem)); } @Test @@ -276,25 +274,25 @@ void scan_componentHasRabbitListenerMethods_multipleParamsWithPayloadAnnotation( .title(SimpleFoo.class.getSimpleName()) .payload(PayloadReference.fromModelName(SimpleFoo.class.getSimpleName())) .headers(HeaderReference.fromModelName(AsyncHeaders.NOT_DOCUMENTED.getSchemaName())) - .bindings(ImmutableMap.of("amqp", new AMQPMessageBinding())) + .bindings(Map.of("amqp", new AMQPMessageBinding())) .build(); Operation operation = Operation.builder() .description("Auto-generated description") .operationId("test-queue_publish_methodWithAnnotation") - .bindings(ImmutableMap.of("amqp", AMQPOperationBinding.builder() + .bindings(Map.of("amqp", AMQPOperationBinding.builder() .cc(Collections.singletonList(QUEUE)) .build())) .message(message) .build(); ChannelItem expectedChannelItem = ChannelItem.builder() - .bindings(ImmutableMap.of("amqp", channelBinding)) + .bindings(Map.of("amqp", channelBinding)) .publish(operation) .build(); assertThat(actualChannelItems) - .containsExactly(Maps.immutableEntry(QUEUE, expectedChannelItem)); + .containsExactly(Map.entry(QUEUE, expectedChannelItem)); } private static class ClassWithoutRabbitListenerAnnotations { diff --git a/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/stavshamir/springwolf/producer/SpringwolfAmqpProducerTest.java b/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/stavshamir/springwolf/producer/SpringwolfAmqpProducerTest.java index 3d69e0e69..10811f3f8 100644 --- a/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/stavshamir/springwolf/producer/SpringwolfAmqpProducerTest.java +++ b/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/stavshamir/springwolf/producer/SpringwolfAmqpProducerTest.java @@ -4,7 +4,6 @@ import com.asyncapi.v2.binding.operation.amqp.AMQPOperationBinding; import com.asyncapi.v2._0_0.model.channel.ChannelItem; import com.asyncapi.v2._0_0.model.channel.operation.Operation; -import com.google.common.collect.ImmutableMap; import io.github.stavshamir.springwolf.asyncapi.ChannelsService; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -34,7 +33,7 @@ void setUp() { @Test void send_defaultExchangeAndChannelNameAsRoutingKey() { - when(channelsService.getChannels()).thenReturn(ImmutableMap.of("channel-name", new ChannelItem())); + when(channelsService.getChannels()).thenReturn(Map.of("channel-name", new ChannelItem())); Map payload = new HashMap<>(); springwolfAmqpProducer.send("channel-name", payload); @@ -47,14 +46,14 @@ void send_exchangeAndNoRoutingKey() { AMQPChannelBinding.ExchangeProperties properties = new AMQPChannelBinding.ExchangeProperties(); properties.setName("exchange-name"); ChannelItem channelItem = ChannelItem.builder() - .bindings(ImmutableMap.of("amqp", AMQPChannelBinding.builder() + .bindings(Map.of("amqp", AMQPChannelBinding.builder() .exchange(properties) .build())) .publish(Operation.builder() - .bindings(ImmutableMap.of("amqp", new AMQPOperationBinding())) + .bindings(Map.of("amqp", new AMQPOperationBinding())) .build()) .build(); - Map channels = ImmutableMap.of("channel-name", channelItem); + Map channels = Map.of("channel-name", channelItem); when(channelsService.getChannels()).thenReturn(channels); Map payload = new HashMap<>(); @@ -68,16 +67,16 @@ void send_exchangeAndRoutingKeyFromBindings() { AMQPChannelBinding.ExchangeProperties properties = new AMQPChannelBinding.ExchangeProperties(); properties.setName("exchange-name"); ChannelItem channelItem = ChannelItem.builder() - .bindings(ImmutableMap.of("amqp", AMQPChannelBinding.builder() + .bindings(Map.of("amqp", AMQPChannelBinding.builder() .exchange(properties) .build())) .publish(Operation.builder() - .bindings(ImmutableMap.of("amqp", AMQPOperationBinding.builder() + .bindings(Map.of("amqp", AMQPOperationBinding.builder() .cc(Collections.singletonList("routing-key")) .build())) .build()) .build(); - Map channels = ImmutableMap.of("channel-name", channelItem); + Map channels = Map.of("channel-name", channelItem); when(channelsService.getChannels()).thenReturn(channels); Map payload = new HashMap<>(); diff --git a/springwolf-plugins/springwolf-cloud-stream-plugin/build.gradle b/springwolf-plugins/springwolf-cloud-stream-plugin/build.gradle index fd5496d02..ebc9056b5 100644 --- a/springwolf-plugins/springwolf-cloud-stream-plugin/build.gradle +++ b/springwolf-plugins/springwolf-cloud-stream-plugin/build.gradle @@ -27,7 +27,6 @@ dependencies { implementation "org.springframework.cloud:spring-cloud-stream" - implementation "com.google.guava:guava:${guavaVersion}" implementation "org.slf4j:slf4j-api" compileOnly "org.projectlombok:lombok:${lombokVersion}" diff --git a/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/cloudstream/CloudStreamFunctionChannelsScanner.java b/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/cloudstream/CloudStreamFunctionChannelsScanner.java index 86760c11c..fc8dd613a 100644 --- a/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/cloudstream/CloudStreamFunctionChannelsScanner.java +++ b/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/cloudstream/CloudStreamFunctionChannelsScanner.java @@ -6,8 +6,6 @@ import com.asyncapi.v2.binding.channel.ChannelBinding; import com.asyncapi.v2.binding.message.MessageBinding; import com.asyncapi.v2.binding.operation.OperationBinding; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; import io.github.stavshamir.springwolf.asyncapi.scanners.beans.DefaultBeanMethodsScanner; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.ChannelsScanner; import io.github.stavshamir.springwolf.asyncapi.types.channel.bindings.EmptyChannelBinding; @@ -68,7 +66,7 @@ private Map.Entry toChannelEntry(FunctionalChannelBeanData String operationId = buildOperationId(beanData, channelName); ChannelItem channelItem = buildChannel(beanData, operationId); - return Maps.immutableEntry(channelName, channelItem); + return Map.entry(channelName, channelItem); } private ChannelItem buildChannel(FunctionalChannelBeanData beanData, String operationId) { @@ -90,25 +88,25 @@ private ChannelItem buildChannel(FunctionalChannelBeanData beanData, String oper .bindings(buildOperationBinding()) .build(); - ImmutableMap channelBinding = buildChannelBinding(); + Map channelBinding = buildChannelBinding(); return beanData.getBeanType() == FunctionalChannelBeanData.BeanType.CONSUMER ? ChannelItem.builder().bindings(channelBinding).publish(operation).build() : ChannelItem.builder().bindings(channelBinding).subscribe(operation).build(); } - private ImmutableMap buildMessageBinding() { + private Map buildMessageBinding() { String protocolName = getProtocolName(); - return ImmutableMap.of(protocolName, new EmptyMessageBinding()); + return Map.of(protocolName, new EmptyMessageBinding()); } - private ImmutableMap buildOperationBinding() { + private Map buildOperationBinding() { String protocolName = getProtocolName(); - return ImmutableMap.of(protocolName, new EmptyOperationBinding()); + return Map.of(protocolName, new EmptyOperationBinding()); } - private ImmutableMap buildChannelBinding() { + private Map buildChannelBinding() { String protocolName = getProtocolName(); - return ImmutableMap.of(protocolName, new EmptyChannelBinding()); + return Map.of(protocolName, new EmptyChannelBinding()); } private String getProtocolName() { diff --git a/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/cloudstream/FunctionalChannelBeanData.java b/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/cloudstream/FunctionalChannelBeanData.java index 186094389..6bb1e58a3 100644 --- a/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/cloudstream/FunctionalChannelBeanData.java +++ b/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/cloudstream/FunctionalChannelBeanData.java @@ -1,6 +1,5 @@ package io.github.stavshamir.springwolf.asyncapi.scanners.channels.cloudstream; -import com.google.common.collect.ImmutableSet; import lombok.Data; import java.lang.reflect.Method; @@ -29,12 +28,12 @@ static Set fromMethodBean(Method methodBean) { if (Consumer.class.isAssignableFrom(returnType)) { Class payloadType = getReturnTypeGenerics(methodBean).get(0); - return ImmutableSet.of(ofConsumer(methodBean.getName(), payloadType)); + return Set.of(ofConsumer(methodBean.getName(), payloadType)); } if (Supplier.class.isAssignableFrom(returnType)) { Class payloadType = getReturnTypeGenerics(methodBean).get(0); - return ImmutableSet.of(ofSupplier(methodBean.getName(), payloadType)); + return Set.of(ofSupplier(methodBean.getName(), payloadType)); } if (Function.class.isAssignableFrom(returnType)) { @@ -52,13 +51,13 @@ private static FunctionalChannelBeanData ofSupplier(String name, Class payloa return new FunctionalChannelBeanData(name, payloadType, BeanType.SUPPLIER, name + "-out-0"); } - private static ImmutableSet fromFunctionBean(Method methodBean) { + private static Set fromFunctionBean(Method methodBean) { String name = methodBean.getName(); Class inputType = getReturnTypeGenerics(methodBean).get(0); Class outputType = getReturnTypeGenerics(methodBean).get(1); - return ImmutableSet.of( + return Set.of( ofConsumer(name, inputType), ofSupplier(name, outputType) ); diff --git a/springwolf-plugins/springwolf-cloud-stream-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/cloudstream/CloudStreamFunctionChannelsScannerTest.java b/springwolf-plugins/springwolf-cloud-stream-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/cloudstream/CloudStreamFunctionChannelsScannerTest.java index 6c7d9af49..5e56bdfac 100644 --- a/springwolf-plugins/springwolf-cloud-stream-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/cloudstream/CloudStreamFunctionChannelsScannerTest.java +++ b/springwolf-plugins/springwolf-cloud-stream-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/cloudstream/CloudStreamFunctionChannelsScannerTest.java @@ -4,8 +4,6 @@ import com.asyncapi.v2._0_0.model.channel.operation.Operation; import com.asyncapi.v2._0_0.model.info.Info; import com.asyncapi.v2._0_0.model.server.Server; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; import io.github.stavshamir.springwolf.asyncapi.scanners.beans.DefaultBeanMethodsScanner; import io.github.stavshamir.springwolf.asyncapi.scanners.classes.ConfigurationClassScanner; import io.github.stavshamir.springwolf.asyncapi.types.channel.bindings.EmptyChannelBinding; @@ -70,7 +68,7 @@ void testConsumerBinding() { BindingProperties testConsumerInBinding = new BindingProperties(); String topicName = "test-consumer-input-topic"; testConsumerInBinding.setDestination(topicName); - when(bindingServiceProperties.getBindings()).thenReturn(ImmutableMap.of( + when(bindingServiceProperties.getBindings()).thenReturn(Map.of( "testConsumer-in-0", testConsumerInBinding )); @@ -83,23 +81,23 @@ void testConsumerBinding() { .title(String.class.getSimpleName()) .payload(PayloadReference.fromModelName(String.class.getSimpleName())) .headers(HeaderReference.fromModelName(AsyncHeaders.NOT_DOCUMENTED.getSchemaName())) - .bindings(ImmutableMap.of("kafka", new EmptyMessageBinding())) + .bindings(Map.of("kafka", new EmptyMessageBinding())) .build(); Operation operation = Operation.builder() - .bindings(ImmutableMap.of("kafka", new EmptyOperationBinding())) + .bindings(Map.of("kafka", new EmptyOperationBinding())) .description("Auto-generated description") .operationId("test-consumer-input-topic_publish_testConsumer") .message(message) .build(); ChannelItem expectedChannel = ChannelItem.builder() - .bindings(ImmutableMap.of("kafka", new EmptyChannelBinding())) + .bindings(Map.of("kafka", new EmptyChannelBinding())) .publish(operation) .build(); assertThat(channels) - .containsExactly(Maps.immutableEntry(topicName, expectedChannel)); + .containsExactly(Map.entry(topicName, expectedChannel)); } @@ -109,7 +107,7 @@ void testSupplierBinding() { BindingProperties testSupplierOutBinding = new BindingProperties(); String topicName = "test-supplier-output-topic"; testSupplierOutBinding.setDestination(topicName); - when(bindingServiceProperties.getBindings()).thenReturn(ImmutableMap.of( + when(bindingServiceProperties.getBindings()).thenReturn(Map.of( "testSupplier-out-0", testSupplierOutBinding )); @@ -122,23 +120,23 @@ void testSupplierBinding() { .title(String.class.getSimpleName()) .payload(PayloadReference.fromModelName(String.class.getSimpleName())) .headers(HeaderReference.fromModelName(AsyncHeaders.NOT_DOCUMENTED.getSchemaName())) - .bindings(ImmutableMap.of("kafka", new EmptyMessageBinding())) + .bindings(Map.of("kafka", new EmptyMessageBinding())) .build(); Operation operation = Operation.builder() - .bindings(ImmutableMap.of("kafka", new EmptyOperationBinding())) + .bindings(Map.of("kafka", new EmptyOperationBinding())) .description("Auto-generated description") .operationId("test-supplier-output-topic_subscribe_testSupplier") .message(message) .build(); ChannelItem expectedChannel = ChannelItem.builder() - .bindings(ImmutableMap.of("kafka", new EmptyChannelBinding())) + .bindings(Map.of("kafka", new EmptyChannelBinding())) .subscribe(operation) .build(); assertThat(channels) - .containsExactly(Maps.immutableEntry(topicName, expectedChannel)); + .containsExactly(Map.entry(topicName, expectedChannel)); } @Test @@ -153,7 +151,7 @@ void testFunctionBinding() { BindingProperties testFunctionOutBinding = new BindingProperties(); testFunctionOutBinding.setDestination(outputTopicName) ; - when(bindingServiceProperties.getBindings()).thenReturn(ImmutableMap.of( + when(bindingServiceProperties.getBindings()).thenReturn(Map.of( "testFunction-in-0", testFunctionInBinding, "testFunction-out-0", testFunctionOutBinding )); @@ -167,18 +165,18 @@ void testFunctionBinding() { .title(Integer.class.getSimpleName()) .payload(PayloadReference.fromModelName(Integer.class.getSimpleName())) .headers(HeaderReference.fromModelName(AsyncHeaders.NOT_DOCUMENTED.getSchemaName())) - .bindings(ImmutableMap.of("kafka", new EmptyMessageBinding())) + .bindings(Map.of("kafka", new EmptyMessageBinding())) .build(); Operation subscribeOperation = Operation.builder() - .bindings(ImmutableMap.of("kafka", new EmptyOperationBinding())) + .bindings(Map.of("kafka", new EmptyOperationBinding())) .description("Auto-generated description") .operationId("test-out-topic_subscribe_testFunction") .message(subscribeMessage) .build(); ChannelItem subscribeChannel = ChannelItem.builder() - .bindings(ImmutableMap.of("kafka", new EmptyChannelBinding())) + .bindings(Map.of("kafka", new EmptyChannelBinding())) .subscribe(subscribeOperation) .build(); @@ -188,24 +186,24 @@ void testFunctionBinding() { .title(String.class.getSimpleName()) .payload(PayloadReference.fromModelName(String.class.getSimpleName())) .headers(HeaderReference.fromModelName(AsyncHeaders.NOT_DOCUMENTED.getSchemaName())) - .bindings(ImmutableMap.of("kafka", new EmptyMessageBinding())) + .bindings(Map.of("kafka", new EmptyMessageBinding())) .build(); Operation publishOperation = Operation.builder() - .bindings(ImmutableMap.of("kafka", new EmptyOperationBinding())) + .bindings(Map.of("kafka", new EmptyOperationBinding())) .description("Auto-generated description") .operationId("test-in-topic_publish_testFunction") .message(publishMessage) .build(); ChannelItem publishChannel = ChannelItem.builder() - .bindings(ImmutableMap.of("kafka", new EmptyChannelBinding())) + .bindings(Map.of("kafka", new EmptyChannelBinding())) .publish(publishOperation) .build(); assertThat(channels).contains( - Maps.immutableEntry(inputTopicName, publishChannel), - Maps.immutableEntry(outputTopicName, subscribeChannel) + Map.entry(inputTopicName, publishChannel), + Map.entry(outputTopicName, subscribeChannel) ); } @@ -221,7 +219,7 @@ void testKStreamFunctionBinding() { BindingProperties testFunctionOutBinding = new BindingProperties(); testFunctionOutBinding.setDestination(outputTopicName) ; - when(bindingServiceProperties.getBindings()).thenReturn(ImmutableMap.of( + when(bindingServiceProperties.getBindings()).thenReturn(Map.of( "kStreamTestFunction-in-0", testFunctionInBinding, "kStreamTestFunction-out-0", testFunctionOutBinding )); @@ -235,18 +233,18 @@ void testKStreamFunctionBinding() { .title(Integer.class.getSimpleName()) .payload(PayloadReference.fromModelName(Integer.class.getSimpleName())) .headers(HeaderReference.fromModelName(AsyncHeaders.NOT_DOCUMENTED.getSchemaName())) - .bindings(ImmutableMap.of("kafka", new EmptyMessageBinding())) + .bindings(Map.of("kafka", new EmptyMessageBinding())) .build(); Operation subscribeOperation = Operation.builder() - .bindings(ImmutableMap.of("kafka", new EmptyOperationBinding())) + .bindings(Map.of("kafka", new EmptyOperationBinding())) .description("Auto-generated description") .operationId("test-out-topic_subscribe_kStreamTestFunction") .message(subscribeMessage) .build(); ChannelItem subscribeChannel = ChannelItem.builder() - .bindings(ImmutableMap.of("kafka", new EmptyChannelBinding())) + .bindings(Map.of("kafka", new EmptyChannelBinding())) .subscribe(subscribeOperation) .build(); @@ -256,24 +254,24 @@ void testKStreamFunctionBinding() { .title(String.class.getSimpleName()) .payload(PayloadReference.fromModelName(String.class.getSimpleName())) .headers(HeaderReference.fromModelName(AsyncHeaders.NOT_DOCUMENTED.getSchemaName())) - .bindings(ImmutableMap.of("kafka", new EmptyMessageBinding())) + .bindings(Map.of("kafka", new EmptyMessageBinding())) .build(); Operation publishOperation = Operation.builder() - .bindings(ImmutableMap.of("kafka", new EmptyOperationBinding())) + .bindings(Map.of("kafka", new EmptyOperationBinding())) .description("Auto-generated description") .operationId("test-in-topic_publish_kStreamTestFunction") .message(publishMessage) .build(); ChannelItem publishChannel = ChannelItem.builder() - .bindings(ImmutableMap.of("kafka", new EmptyChannelBinding())) + .bindings(Map.of("kafka", new EmptyChannelBinding())) .publish(publishOperation) .build(); assertThat(channels).contains( - Maps.immutableEntry(inputTopicName, publishChannel), - Maps.immutableEntry(outputTopicName, subscribeChannel) + Map.entry(inputTopicName, publishChannel), + Map.entry(outputTopicName, subscribeChannel) ); } diff --git a/springwolf-plugins/springwolf-kafka-plugin/README.md b/springwolf-plugins/springwolf-kafka-plugin/README.md index fa06d6ec2..7f7a0bff2 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/README.md +++ b/springwolf-plugins/springwolf-kafka-plugin/README.md @@ -55,7 +55,7 @@ public class AsyncApiConfiguration { // you will need to build a ProducerData and register it in the docket (line 65) ProducerData exampleProducerData = ProducerData.builder() .channelName("example-producer-topic") - .binding(ImmutableMap.of("kafka", new KafkaOperationBinding())) + .binding(Map.of("kafka", new KafkaOperationBinding())) .payloadType(ExamplePayloadDto.class) .build(); diff --git a/springwolf-plugins/springwolf-kafka-plugin/build.gradle b/springwolf-plugins/springwolf-kafka-plugin/build.gradle index 34a050efc..5105b99a0 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/build.gradle +++ b/springwolf-plugins/springwolf-kafka-plugin/build.gradle @@ -21,7 +21,6 @@ dependencies { implementation "org.springframework.kafka:spring-kafka" implementation "io.swagger.core.v3:swagger-models:${swaggerCoreVersion}" - implementation "com.google.guava:guava:${guavaVersion}" implementation "org.slf4j:slf4j-api" compileOnly "org.projectlombok:lombok:${lombokVersion}" diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/KafkaListenerUtil.java b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/KafkaListenerUtil.java index 95206edfa..38b085a0e 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/KafkaListenerUtil.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/KafkaListenerUtil.java @@ -8,7 +8,6 @@ import com.asyncapi.v2.binding.operation.kafka.KafkaOperationBinding; import com.asyncapi.v2.schema.Schema; import com.asyncapi.v2.schema.Type; -import com.google.common.collect.ImmutableMap; import lombok.extern.slf4j.Slf4j; import org.springframework.kafka.annotation.KafkaListener; import org.springframework.util.StringValueResolver; @@ -33,7 +32,7 @@ public static String getChannelName(KafkaListener annotation, StringValueResolve } public static Map buildChannelBinding() { - return ImmutableMap.of("kafka", new KafkaChannelBinding()); + return Map.of("kafka", new KafkaChannelBinding()); } public static Map buildOperationBinding(KafkaListener annotation, StringValueResolver resolver) { @@ -42,7 +41,7 @@ public static String getChannelName(KafkaListener annotation, StringValueResolve KafkaOperationBinding binding = new KafkaOperationBinding(); binding.setGroupId(groupIdSchema); - return ImmutableMap.of("kafka", binding); + return Map.of("kafka", binding); } @Nullable @@ -82,6 +81,6 @@ private static Schema createStringSchema(String value) { } public static Map buildMessageBinding() { - return ImmutableMap.of("kafka", new KafkaMessageBinding()); + return Map.of("kafka", new KafkaMessageBinding()); } } diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/KafkaConsumerData.java b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/KafkaConsumerData.java index 6ce63af7f..50985182d 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/KafkaConsumerData.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/KafkaConsumerData.java @@ -3,19 +3,20 @@ import com.asyncapi.v2.binding.channel.kafka.KafkaChannelBinding; import com.asyncapi.v2.binding.message.kafka.KafkaMessageBinding; import com.asyncapi.v2.binding.operation.kafka.KafkaOperationBinding; -import com.google.common.collect.ImmutableMap; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.header.AsyncHeaders; import lombok.Builder; +import java.util.Map; + public class KafkaConsumerData extends ConsumerData { @Builder(builderMethodName = "kafkaConsumerDataBuilder") public KafkaConsumerData(String topicName, Class payloadType, String description, AsyncHeaders headers) { this.channelName = topicName; this.description = description; - this.channelBinding = ImmutableMap.of("kafka", new KafkaChannelBinding()); + this.channelBinding = Map.of("kafka", new KafkaChannelBinding()); this.payloadType = payloadType; this.headers = headers != null ? headers : this.headers; - this.operationBinding = ImmutableMap.of("kafka", new KafkaOperationBinding()); - this.messageBinding = ImmutableMap.of("kafka", new KafkaMessageBinding()); + this.operationBinding = Map.of("kafka", new KafkaOperationBinding()); + this.messageBinding = Map.of("kafka", new KafkaMessageBinding()); } } diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/KafkaProducerData.java b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/KafkaProducerData.java index c397b61f2..b203b8458 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/KafkaProducerData.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/KafkaProducerData.java @@ -3,21 +3,22 @@ import com.asyncapi.v2.binding.channel.kafka.KafkaChannelBinding; import com.asyncapi.v2.binding.message.kafka.KafkaMessageBinding; import com.asyncapi.v2.binding.operation.kafka.KafkaOperationBinding; -import com.google.common.collect.ImmutableMap; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.header.AsyncHeaders; import lombok.Builder; +import java.util.Map; + public class KafkaProducerData extends ProducerData { @Builder(builderMethodName = "kafkaProducerDataBuilder") public KafkaProducerData(String topicName, Class payloadType, String description, AsyncHeaders headers) { this.channelName = topicName; this.description = description; - this.channelBinding = ImmutableMap.of("kafka", new KafkaChannelBinding()); + this.channelBinding = Map.of("kafka", new KafkaChannelBinding()); this.payloadType = payloadType; this.headers = headers != null ? headers : this.headers; - this.operationBinding = ImmutableMap.of("kafka", new KafkaOperationBinding()); - this.messageBinding = ImmutableMap.of("kafka", new KafkaMessageBinding()); + this.operationBinding = Map.of("kafka", new KafkaOperationBinding()); + this.messageBinding = Map.of("kafka", new KafkaMessageBinding()); } } diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/channel/operation/message/header/AsyncHeadersForSpringKafkaBuilder.java b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/channel/operation/message/header/AsyncHeadersForSpringKafkaBuilder.java index 2b0ffb0cc..998cb8785 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/channel/operation/message/header/AsyncHeadersForSpringKafkaBuilder.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/channel/operation/message/header/AsyncHeadersForSpringKafkaBuilder.java @@ -4,8 +4,6 @@ import java.util.List; -import static com.google.common.collect.ImmutableList.of; - public class AsyncHeadersForSpringKafkaBuilder { private final AsyncHeaders headers; @@ -18,7 +16,7 @@ public AsyncHeadersForSpringKafkaBuilder(String schemaName) { } public AsyncHeadersForSpringKafkaBuilder withTypeIdHeader(String exampleTypeId) { - return withTypeIdHeader(exampleTypeId, of(exampleTypeId)); + return withTypeIdHeader(exampleTypeId, List.of(exampleTypeId)); } public AsyncHeadersForSpringKafkaBuilder withTypeIdHeader(String exampleTypeId, List types) { diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/ClassLevelKafkaListenerScannerTest.java b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/ClassLevelKafkaListenerScannerTest.java index 8278bf4b4..942b626ba 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/ClassLevelKafkaListenerScannerTest.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/ClassLevelKafkaListenerScannerTest.java @@ -5,9 +5,6 @@ import com.asyncapi.v2.binding.operation.kafka.KafkaOperationBinding; import com.asyncapi.v2._0_0.model.channel.ChannelItem; import com.asyncapi.v2._0_0.model.channel.operation.Operation; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; import io.github.stavshamir.springwolf.asyncapi.scanners.classes.ComponentClassScanner; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.Message; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.PayloadReference; @@ -63,7 +60,7 @@ private void setClassesToScan(Set> classesToScan) { @Test void scan_componentWithMultipleKafkaListenersAndHandlers() { // Given multiple @KafkaListener annotated classes with method(s) annotated with @KafkaHandler - ImmutableSet> classesToScan = ImmutableSet.of( + Set> classesToScan = Set.of( KafkaListenerClassWithOneKafkaHandler.class, KafkaListenerClassWithMultipleKafkaHandler.class ); @@ -78,7 +75,7 @@ void scan_componentWithMultipleKafkaListenersAndHandlers() { .title(SimpleFoo.class.getSimpleName()) .payload(PayloadReference.fromModelName(SimpleFoo.class.getSimpleName())) .headers(HeaderReference.fromModelName("SpringKafkaDefaultHeaders-" + SimpleFoo.class.getSimpleName())) - .bindings(ImmutableMap.of("kafka", new KafkaMessageBinding())) + .bindings(Map.of("kafka", new KafkaMessageBinding())) .build(); Message barMessage = Message.builder() @@ -86,23 +83,23 @@ void scan_componentWithMultipleKafkaListenersAndHandlers() { .title(SimpleBar.class.getSimpleName()) .payload(PayloadReference.fromModelName(SimpleBar.class.getSimpleName())) .headers(HeaderReference.fromModelName("SpringKafkaDefaultHeaders-" + SimpleBar.class.getSimpleName())) - .bindings(ImmutableMap.of("kafka", new KafkaMessageBinding())) + .bindings(Map.of("kafka", new KafkaMessageBinding())) .build(); Operation operation = Operation.builder() .description("Auto-generated description") .operationId("KafkaListenerClassWithMultipleKafkaHandler_publish") - .bindings(ImmutableMap.of("kafka", new KafkaOperationBinding())) - .message(toMessageObjectOrComposition(ImmutableSet.of(fooMessage, barMessage))) + .bindings(Map.of("kafka", new KafkaOperationBinding())) + .message(toMessageObjectOrComposition(Set.of(fooMessage, barMessage))) .build(); ChannelItem expectedChannel = ChannelItem.builder() - .bindings(ImmutableMap.of("kafka", new KafkaChannelBinding())) + .bindings(Map.of("kafka", new KafkaChannelBinding())) .publish(operation) .build(); assertThat(actualChannels) - .containsExactly(Maps.immutableEntry(TOPIC, expectedChannel)); + .containsExactly(Map.entry(TOPIC, expectedChannel)); } @Test @@ -142,23 +139,23 @@ void scan_componentWithSingleKafkaHandlerMethod() { .title(SimpleFoo.class.getSimpleName()) .payload(PayloadReference.fromModelName(SimpleFoo.class.getSimpleName())) .headers(HeaderReference.fromModelName("SpringKafkaDefaultHeaders-" + SimpleFoo.class.getSimpleName())) - .bindings(ImmutableMap.of("kafka", new KafkaMessageBinding())) + .bindings(Map.of("kafka", new KafkaMessageBinding())) .build(); Operation operation = Operation.builder() .description("Auto-generated description") .operationId("KafkaListenerClassWithOneKafkaHandler_publish") - .bindings(ImmutableMap.of("kafka", new KafkaOperationBinding())) + .bindings(Map.of("kafka", new KafkaOperationBinding())) .message(message) .build(); ChannelItem expectedChannel = ChannelItem.builder() - .bindings(ImmutableMap.of("kafka", new KafkaChannelBinding())) + .bindings(Map.of("kafka", new KafkaChannelBinding())) .publish(operation) .build(); assertThat(actualChannels) - .containsExactly(Maps.immutableEntry(TOPIC, expectedChannel)); + .containsExactly(Map.entry(TOPIC, expectedChannel)); } @Test @@ -175,7 +172,7 @@ void scan_componentWithMultipleKafkaHandlerMethods() { .title(SimpleFoo.class.getSimpleName()) .payload(PayloadReference.fromModelName(SimpleFoo.class.getSimpleName())) .headers(HeaderReference.fromModelName("SpringKafkaDefaultHeaders-" + SimpleFoo.class.getSimpleName())) - .bindings(ImmutableMap.of("kafka", new KafkaMessageBinding())) + .bindings(Map.of("kafka", new KafkaMessageBinding())) .build(); Message barMessage = Message.builder() @@ -183,23 +180,23 @@ void scan_componentWithMultipleKafkaHandlerMethods() { .title(SimpleBar.class.getSimpleName()) .payload(PayloadReference.fromModelName(SimpleBar.class.getSimpleName())) .headers(HeaderReference.fromModelName("SpringKafkaDefaultHeaders-" + SimpleBar.class.getSimpleName())) - .bindings(ImmutableMap.of("kafka", new KafkaMessageBinding())) + .bindings(Map.of("kafka", new KafkaMessageBinding())) .build(); Operation operation = Operation.builder() .description("Auto-generated description") .operationId("KafkaListenerClassWithMultipleKafkaHandler_publish") - .bindings(ImmutableMap.of("kafka", new KafkaOperationBinding())) - .message(toMessageObjectOrComposition(ImmutableSet.of(fooMessage, barMessage))) + .bindings(Map.of("kafka", new KafkaOperationBinding())) + .message(toMessageObjectOrComposition(Set.of(fooMessage, barMessage))) .build(); ChannelItem expectedChannel = ChannelItem.builder() - .bindings(ImmutableMap.of("kafka", new KafkaChannelBinding())) + .bindings(Map.of("kafka", new KafkaChannelBinding())) .publish(operation) .build(); assertThat(actualChannels) - .containsExactly(Maps.immutableEntry(TOPIC, expectedChannel)); + .containsExactly(Map.entry(TOPIC, expectedChannel)); } @Test @@ -217,23 +214,23 @@ void scan_componentWithSingleKafkaHandlerMethod_batchPayload() { .title(SimpleFoo.class.getSimpleName()) .payload(PayloadReference.fromModelName(SimpleFoo.class.getSimpleName())) .headers(HeaderReference.fromModelName("SpringKafkaDefaultHeaders-" + SimpleFoo.class.getSimpleName())) - .bindings(ImmutableMap.of("kafka", new KafkaMessageBinding())) + .bindings(Map.of("kafka", new KafkaMessageBinding())) .build(); Operation operation = Operation.builder() .description("Auto-generated description") .operationId("KafkaListenerClassWithKafkaHandlerWithBatchPayload_publish") - .bindings(ImmutableMap.of("kafka", new KafkaOperationBinding())) + .bindings(Map.of("kafka", new KafkaOperationBinding())) .message(message) .build(); ChannelItem expectedChannel = ChannelItem.builder() - .bindings(ImmutableMap.of("kafka", new KafkaChannelBinding())) + .bindings(Map.of("kafka", new KafkaChannelBinding())) .publish(operation) .build(); assertThat(actualChannels) - .containsExactly(Maps.immutableEntry(TOPIC, expectedChannel)); + .containsExactly(Map.entry(TOPIC, expectedChannel)); } diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelKafkaListenerScannerTest.java b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelKafkaListenerScannerTest.java index 70dcddd5e..f14e93324 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelKafkaListenerScannerTest.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelKafkaListenerScannerTest.java @@ -6,8 +6,6 @@ import com.asyncapi.v2.binding.operation.kafka.KafkaOperationBinding; import com.asyncapi.v2._0_0.model.channel.ChannelItem; import com.asyncapi.v2._0_0.model.channel.operation.Operation; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; import io.github.stavshamir.springwolf.asyncapi.scanners.classes.ComponentClassScanner; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.Message; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.PayloadReference; @@ -81,23 +79,23 @@ void scan_componentHasKafkaListenerMethods_hardCodedTopic() { .title(SimpleFoo.class.getSimpleName()) .payload(PayloadReference.fromModelName(SimpleFoo.class.getSimpleName())) .headers(HeaderReference.fromModelName(AsyncHeaders.NOT_DOCUMENTED.getSchemaName())) - .bindings(ImmutableMap.of("kafka", new KafkaMessageBinding())) + .bindings(Map.of("kafka", new KafkaMessageBinding())) .build(); Operation operation = Operation.builder() .description("Auto-generated description") .operationId("test-topic_publish_methodWithAnnotation") - .bindings(ImmutableMap.of("kafka", new KafkaOperationBinding())) + .bindings(Map.of("kafka", new KafkaOperationBinding())) .message(message) .build(); ChannelItem expectedChannel = ChannelItem.builder() - .bindings(ImmutableMap.of("kafka", new KafkaChannelBinding())) + .bindings(Map.of("kafka", new KafkaChannelBinding())) .publish(operation) .build(); assertThat(actualChannels) - .containsExactly(Maps.immutableEntry(TOPIC, expectedChannel)); + .containsExactly(Map.entry(TOPIC, expectedChannel)); } @Test @@ -114,23 +112,23 @@ void scan_componentHasKafkaListenerMethods_embeddedValueTopic() { .title(SimpleFoo.class.getSimpleName()) .payload(PayloadReference.fromModelName(SimpleFoo.class.getSimpleName())) .headers(HeaderReference.fromModelName(AsyncHeaders.NOT_DOCUMENTED.getSchemaName())) - .bindings(ImmutableMap.of("kafka", new KafkaMessageBinding())) + .bindings(Map.of("kafka", new KafkaMessageBinding())) .build(); Operation operation = Operation.builder() .description("Auto-generated description") .operationId("test-topic_publish_methodWithAnnotation1") - .bindings(ImmutableMap.of("kafka", new KafkaOperationBinding())) + .bindings(Map.of("kafka", new KafkaOperationBinding())) .message(message) .build(); ChannelItem expectedChannel = ChannelItem.builder() - .bindings(ImmutableMap.of("kafka", new KafkaChannelBinding())) + .bindings(Map.of("kafka", new KafkaChannelBinding())) .publish(operation) .build(); assertThat(actualChannels) - .containsExactly(Maps.immutableEntry(TOPIC, expectedChannel)); + .containsExactly(Map.entry(TOPIC, expectedChannel)); } @Test @@ -182,23 +180,23 @@ void scan_componentHasKafkaListenerMethods_multipleParamsWithPayloadAnnotation() .title(SimpleFoo.class.getSimpleName()) .payload(PayloadReference.fromModelName(SimpleFoo.class.getSimpleName())) .headers(HeaderReference.fromModelName(AsyncHeaders.NOT_DOCUMENTED.getSchemaName())) - .bindings(ImmutableMap.of("kafka", new KafkaMessageBinding())) + .bindings(Map.of("kafka", new KafkaMessageBinding())) .build(); Operation operation = Operation.builder() .description("Auto-generated description") .operationId("test-topic_publish_methodWithAnnotation") - .bindings(ImmutableMap.of("kafka", new KafkaOperationBinding())) + .bindings(Map.of("kafka", new KafkaOperationBinding())) .message(message) .build(); ChannelItem expectedChannel = ChannelItem.builder() - .bindings(ImmutableMap.of("kafka", new KafkaChannelBinding())) + .bindings(Map.of("kafka", new KafkaChannelBinding())) .publish(operation) .build(); assertThat(actualChannels) - .containsExactly(Maps.immutableEntry(TOPIC, expectedChannel)); + .containsExactly(Map.entry(TOPIC, expectedChannel)); } @Test @@ -215,23 +213,23 @@ void scan_componentHasKafkaListenerMethods_batchPayload() { .title(SimpleFoo.class.getSimpleName()) .payload(PayloadReference.fromModelName(SimpleFoo.class.getSimpleName())) .headers(HeaderReference.fromModelName(AsyncHeaders.NOT_DOCUMENTED.getSchemaName())) - .bindings(ImmutableMap.of("kafka", new KafkaMessageBinding())) + .bindings(Map.of("kafka", new KafkaMessageBinding())) .build(); Operation operation = Operation.builder() .description("Auto-generated description") .operationId("test-topic_publish_methodWithAnnotation") - .bindings(ImmutableMap.of("kafka", new KafkaOperationBinding())) + .bindings(Map.of("kafka", new KafkaOperationBinding())) .message(message) .build(); ChannelItem expectedChannel = ChannelItem.builder() - .bindings(ImmutableMap.of("kafka", new KafkaChannelBinding())) + .bindings(Map.of("kafka", new KafkaChannelBinding())) .publish(operation) .build(); assertThat(actualChannels) - .containsExactly(Maps.immutableEntry(TOPIC, expectedChannel)); + .containsExactly(Map.entry(TOPIC, expectedChannel)); } private static class ClassWithoutKafkaListenerAnnotations {