From f473529655275612f774c398e884146f574b8c7a Mon Sep 17 00:00:00 2001 From: mischwarz Date: Fri, 8 Dec 2023 15:18:31 +0100 Subject: [PATCH 1/3] #140 supress Uni and Message --- .../scanner/AsyncApiAnnotationScanner.java | 19 +++++++++++++++---- ...yncApiAnnotationScannerUnFilteredTest.java | 4 ++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/quarkus-asyncapi-scanner/deployment/src/main/java/io/quarkiverse/asyncapi/annotation/scanner/AsyncApiAnnotationScanner.java b/quarkus-asyncapi-scanner/deployment/src/main/java/io/quarkiverse/asyncapi/annotation/scanner/AsyncApiAnnotationScanner.java index af58320..bd909fa 100644 --- a/quarkus-asyncapi-scanner/deployment/src/main/java/io/quarkiverse/asyncapi/annotation/scanner/AsyncApiAnnotationScanner.java +++ b/quarkus-asyncapi-scanner/deployment/src/main/java/io/quarkiverse/asyncapi/annotation/scanner/AsyncApiAnnotationScanner.java @@ -58,6 +58,8 @@ import io.quarkiverse.asyncapi.annotation.scanner.config.Channel; import io.quarkiverse.asyncapi.annotation.scanner.kafka.binding.KafkaResolver; +import io.smallrye.mutiny.Multi; +import io.smallrye.mutiny.Uni; /** * @since 09.02.2023 @@ -273,10 +275,19 @@ public ChannelData(AnnotationInstance aAnnotationInstance, ResolveType aType) { } } - final Type resolveType(Type aFirstParameterType) { - return aFirstParameterType.kind().equals(PARAMETERIZED_TYPE) - ? aFirstParameterType.asParameterizedType() - : aFirstParameterType; + final Type resolveType(Type aType) { + Type bType = aType; + if (DotName.createSimple(Uni.class).equals(aType.name()) + || DotName.createSimple(Multi.class).equals(aType.name())) { + bType = aType.asParameterizedType().arguments().get(0); + } + if (DotName.createSimple("org.eclipse.microprofile.reactive.messaging.Message").equals(bType.name())) { + bType = bType.asParameterizedType().arguments().get(0); + } + Type type = bType.kind().equals(PARAMETERIZED_TYPE) + ? bType.asParameterizedType() + : bType; + return type; } } diff --git a/quarkus-asyncapi-scanner/quarkus-asyncapi-scanner-tests/quarkus-asyncapi-scanner-tests-simple/src/test/java/io/quarkiverse/asyncapi/annotation/scanner/AsyncApiAnnotationScannerUnFilteredTest.java b/quarkus-asyncapi-scanner/quarkus-asyncapi-scanner-tests/quarkus-asyncapi-scanner-tests-simple/src/test/java/io/quarkiverse/asyncapi/annotation/scanner/AsyncApiAnnotationScannerUnFilteredTest.java index 94e4dfb..8bbec39 100644 --- a/quarkus-asyncapi-scanner/quarkus-asyncapi-scanner-tests/quarkus-asyncapi-scanner-tests-simple/src/test/java/io/quarkiverse/asyncapi/annotation/scanner/AsyncApiAnnotationScannerUnFilteredTest.java +++ b/quarkus-asyncapi-scanner/quarkus-asyncapi-scanner-tests/quarkus-asyncapi-scanner-tests-simple/src/test/java/io/quarkiverse/asyncapi/annotation/scanner/AsyncApiAnnotationScannerUnFilteredTest.java @@ -45,6 +45,10 @@ void shouldScanEmitterAnnotations() throws Exception { assertThat(oneOfOpenApiNodeOneOf.get(0).get("type").asText()).isEqualTo("string"); assertThat(oneOfOpenApiNodeOneOf.get(1).get("type").asText()).isEqualTo("integer"); + //Uni> + assertThat(asyncAPI.at("/channels/outgoing-channel-part/publish/message/payload/$ref").asText()) + .isEqualTo("#/components/schemas/Part"); + //JsonGetter assertThat(asyncAPI.at("/channels/channel-x/publish/message/payload/properties/i18n/description").asText()) .isNotEmpty(); From f6804f40f257fe61e2f871e5357ffc40714d9193 Mon Sep 17 00:00:00 2001 From: mischwarz Date: Tue, 12 Dec 2023 14:24:08 +0100 Subject: [PATCH 2/3] #140 fix failing test: missing signature change outgoing-channel-part with Uni> --- .../asyncapi/annotation/scanner/DummyController.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/quarkus-asyncapi-scanner/quarkus-asyncapi-scanner-tests/quarkus-asyncapi-scanner-tests-simple/src/main/java/io/quarkiverse/asyncapi/annotation/scanner/DummyController.java b/quarkus-asyncapi-scanner/quarkus-asyncapi-scanner-tests/quarkus-asyncapi-scanner-tests-simple/src/main/java/io/quarkiverse/asyncapi/annotation/scanner/DummyController.java index f50c445..56beb1b 100644 --- a/quarkus-asyncapi-scanner/quarkus-asyncapi-scanner-tests/quarkus-asyncapi-scanner-tests-simple/src/main/java/io/quarkiverse/asyncapi/annotation/scanner/DummyController.java +++ b/quarkus-asyncapi-scanner/quarkus-asyncapi-scanner-tests/quarkus-asyncapi-scanner-tests-simple/src/main/java/io/quarkiverse/asyncapi/annotation/scanner/DummyController.java @@ -5,14 +5,12 @@ import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; -import org.eclipse.microprofile.reactive.messaging.Channel; -import org.eclipse.microprofile.reactive.messaging.Emitter; -import org.eclipse.microprofile.reactive.messaging.Incoming; -import org.eclipse.microprofile.reactive.messaging.Outgoing; +import org.eclipse.microprofile.reactive.messaging.*; import org.reactivestreams.Publisher; import io.quarkiverse.asyncapi.annotation.Schema; import io.smallrye.mutiny.Multi; +import io.smallrye.mutiny.Uni; import io.smallrye.reactive.messaging.annotations.Broadcast; /** @@ -61,7 +59,7 @@ public String sendMessageString() { } @Outgoing("outgoing-channel-part") - public GecMessage sendMessageTyped() { + public Uni> sendMessageTyped() { //Do nothing return null; } From ac318a9d1a7716f49913ea1439b77dce0c7c9657 Mon Sep 17 00:00:00 2001 From: mischwarz Date: Tue, 12 Dec 2023 15:10:26 +0100 Subject: [PATCH 3/3] #140 extra test channel for Uni and revert DummyController:sendMessageTyped --- .../asyncapi/annotation/scanner/DummyController.java | 8 +++++++- .../src/main/resources/application.properties | 4 ++++ .../scanner/AsyncApiAnnotationScannerUnFilteredTest.java | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/quarkus-asyncapi-scanner/quarkus-asyncapi-scanner-tests/quarkus-asyncapi-scanner-tests-simple/src/main/java/io/quarkiverse/asyncapi/annotation/scanner/DummyController.java b/quarkus-asyncapi-scanner/quarkus-asyncapi-scanner-tests/quarkus-asyncapi-scanner-tests-simple/src/main/java/io/quarkiverse/asyncapi/annotation/scanner/DummyController.java index 56beb1b..776204e 100644 --- a/quarkus-asyncapi-scanner/quarkus-asyncapi-scanner-tests/quarkus-asyncapi-scanner-tests-simple/src/main/java/io/quarkiverse/asyncapi/annotation/scanner/DummyController.java +++ b/quarkus-asyncapi-scanner/quarkus-asyncapi-scanner-tests/quarkus-asyncapi-scanner-tests-simple/src/main/java/io/quarkiverse/asyncapi/annotation/scanner/DummyController.java @@ -59,7 +59,13 @@ public String sendMessageString() { } @Outgoing("outgoing-channel-part") - public Uni> sendMessageTyped() { + public GecMessage sendMessageTyped() { + //Do nothing + return null; + } + + @Outgoing("outgoing-channel-reactive-part") + public Uni> sendReactiveMessageTyped() { //Do nothing return null; } diff --git a/quarkus-asyncapi-scanner/quarkus-asyncapi-scanner-tests/quarkus-asyncapi-scanner-tests-simple/src/main/resources/application.properties b/quarkus-asyncapi-scanner/quarkus-asyncapi-scanner-tests/quarkus-asyncapi-scanner-tests-simple/src/main/resources/application.properties index 9c9517a..a8e8ca3 100644 --- a/quarkus-asyncapi-scanner/quarkus-asyncapi-scanner-tests/quarkus-asyncapi-scanner-tests-simple/src/main/resources/application.properties +++ b/quarkus-asyncapi-scanner/quarkus-asyncapi-scanner-tests/quarkus-asyncapi-scanner-tests-simple/src/main/resources/application.properties @@ -36,6 +36,10 @@ mp.messaging.outgoing.outgoing-channel-part.connector=smallrye-kafka mp.messaging.outgoing.outgoing-channel-part.topic=outgoing-channel-part-topic mp.messaging.outgoing.outgoing-channel-part.value.serializer=org.apache.kafka.common.serialization.StringSerializer +mp.messaging.outgoing.outgoing-channel-reactive-part.connector=smallrye-kafka +mp.messaging.outgoing.outgoing-channel-reactive-part.topic=outgoing-channel-reactive-part-topic +mp.messaging.outgoing.outgoing-channel-reactive-part.value.serializer=org.apache.kafka.common.serialization.StringSerializer + mp.messaging.incoming.prices.connector=smallrye-kafka # Set root path to / (all resources - inclusive html pages are) diff --git a/quarkus-asyncapi-scanner/quarkus-asyncapi-scanner-tests/quarkus-asyncapi-scanner-tests-simple/src/test/java/io/quarkiverse/asyncapi/annotation/scanner/AsyncApiAnnotationScannerUnFilteredTest.java b/quarkus-asyncapi-scanner/quarkus-asyncapi-scanner-tests/quarkus-asyncapi-scanner-tests-simple/src/test/java/io/quarkiverse/asyncapi/annotation/scanner/AsyncApiAnnotationScannerUnFilteredTest.java index 8bbec39..5952ae8 100644 --- a/quarkus-asyncapi-scanner/quarkus-asyncapi-scanner-tests/quarkus-asyncapi-scanner-tests-simple/src/test/java/io/quarkiverse/asyncapi/annotation/scanner/AsyncApiAnnotationScannerUnFilteredTest.java +++ b/quarkus-asyncapi-scanner/quarkus-asyncapi-scanner-tests/quarkus-asyncapi-scanner-tests-simple/src/test/java/io/quarkiverse/asyncapi/annotation/scanner/AsyncApiAnnotationScannerUnFilteredTest.java @@ -46,7 +46,7 @@ void shouldScanEmitterAnnotations() throws Exception { assertThat(oneOfOpenApiNodeOneOf.get(1).get("type").asText()).isEqualTo("integer"); //Uni> - assertThat(asyncAPI.at("/channels/outgoing-channel-part/publish/message/payload/$ref").asText()) + assertThat(asyncAPI.at("/channels/outgoing-channel-reactive-part/publish/message/payload/$ref").asText()) .isEqualTo("#/components/schemas/Part"); //JsonGetter