From 660dd73e6fb53f458a188e66ccd5daf50b7e187d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 May 2022 19:13:24 +0000 Subject: [PATCH 01/33] Bump version.smallrye-stork from 1.1.0 to 1.1.2 Bumps `version.smallrye-stork` from 1.1.0 to 1.1.2. Updates `stork-core` from 1.1.0 to 1.1.2 Updates `stork-api` from 1.1.0 to 1.1.2 Updates `stork-service-discovery-static-list` from 1.1.0 to 1.1.2 Updates `stork-microprofile-config` from 1.1.0 to 1.1.2 --- updated-dependencies: - dependency-name: io.smallrye.stork:stork-core dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: io.smallrye.stork:stork-api dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: io.smallrye.stork:stork-service-discovery-static-list dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: io.smallrye.stork:stork-microprofile-config dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3f7f4ad66..4685958d2 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ 2.0.0-RC2 1.4.0 2.0.0-RC1 - 1.1.0 + 1.1.2 0.33.0 2.0.4 3.0.1 From 4276ff1da3a3eaf23bfecfbdc0eeb1cc5dd518a7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Jun 2022 19:15:09 +0000 Subject: [PATCH 02/33] Bump weld-junit5 from 4.0.0.CR1 to 4.0.0.Final Bumps [weld-junit5](https://github.com/weld/weld-junit) from 4.0.0.CR1 to 4.0.0.Final. - [Release notes](https://github.com/weld/weld-junit/releases) - [Commits](https://github.com/weld/weld-junit/compare/4.0.0.CR1...4.0.0.Final) --- updated-dependencies: - dependency-name: org.jboss.weld:weld-junit5 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ef1bd1b9e..db9fea241 100644 --- a/pom.xml +++ b/pom.xml @@ -44,7 +44,7 @@ 3.0.0-RC1 8.0.0.Alpha3 4.0.2 - 4.0.0.CR1 + 4.0.0.Final 2.2.21 2.13.3 4.6.0 From adbe583b06538efd357bb32d85ec11549ab87d5f Mon Sep 17 00:00:00 2001 From: Jan Martiska Date: Wed, 15 Jun 2022 11:06:15 +0200 Subject: [PATCH 03/33] Minor changes to client logging --- .../vertx/typesafe/VertxTypesafeGraphQLClientProxy.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/implementation-vertx/src/main/java/io/smallrye/graphql/client/vertx/typesafe/VertxTypesafeGraphQLClientProxy.java b/client/implementation-vertx/src/main/java/io/smallrye/graphql/client/vertx/typesafe/VertxTypesafeGraphQLClientProxy.java index 1965cf6ba..f4e93087e 100644 --- a/client/implementation-vertx/src/main/java/io/smallrye/graphql/client/vertx/typesafe/VertxTypesafeGraphQLClientProxy.java +++ b/client/implementation-vertx/src/main/java/io/smallrye/graphql/client/vertx/typesafe/VertxTypesafeGraphQLClientProxy.java @@ -146,7 +146,9 @@ Object invoke(MethodInvocation method) { private Object executeSingleResultOperationOverHttpSync(MethodInvocation method, JsonObject request, MultiMap headers) { HttpResponse response = postSync(request.toString(), headers); - log.debugf("response graphql: %s", response); + if (log.isTraceEnabled() && response != null) { + log.tracef("response graphql: %s", response.bodyAsString()); + } return new ResultBuilder(method, response.bodyAsString(), response.statusCode(), response.statusMessage()).read(); } @@ -251,9 +253,8 @@ private JsonObject request(MethodInvocation method) { request.add("query", query); request.add("variables", variables(method)); request.add("operationName", method.getName()); - log.debugf("request graphql: %s", query); JsonObject result = request.build(); - log.debugf("full graphql request: %s", result.toString()); + log.tracef("full graphql request: %s", result.toString()); return result; } From 780adb9e41db3ccf83ff465a4529736266b64666 Mon Sep 17 00:00:00 2001 From: Jacrispy Date: Tue, 21 Jun 2022 14:09:19 -0700 Subject: [PATCH 04/33] Implement "Headers" into vertex to set multiple in one call. --- .../dynamic/VertxDynamicGraphQLClientBuilder.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/client/implementation-vertx/src/main/java/io/smallrye/graphql/client/vertx/dynamic/VertxDynamicGraphQLClientBuilder.java b/client/implementation-vertx/src/main/java/io/smallrye/graphql/client/vertx/dynamic/VertxDynamicGraphQLClientBuilder.java index 97673efb0..418932cda 100644 --- a/client/implementation-vertx/src/main/java/io/smallrye/graphql/client/vertx/dynamic/VertxDynamicGraphQLClientBuilder.java +++ b/client/implementation-vertx/src/main/java/io/smallrye/graphql/client/vertx/dynamic/VertxDynamicGraphQLClientBuilder.java @@ -1,9 +1,6 @@ package io.smallrye.graphql.client.vertx.dynamic; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.EnumSet; -import java.util.List; +import java.util.*; import org.jboss.logging.Logger; @@ -61,6 +58,11 @@ public VertxDynamicGraphQLClientBuilder header(String name, String value) { return this; } + public VertxDynamicGraphQLClientBuilder headers(Map headers) { + headersMap.setAll(headers); + return this; + } + public VertxDynamicGraphQLClientBuilder options(WebClientOptions options) { this.options = options; return this; From a539d81b1fc43e1a32a0d809636cb1af5f73b9b9 Mon Sep 17 00:00:00 2001 From: Jan Martiska Date: Fri, 17 Jun 2022 09:24:02 +0200 Subject: [PATCH 05/33] Support DecimalMin and DecimalMax for constraint directives --- .../io/smallrye/graphql/schema/Classes.java | 8 +++++ .../BeanValidationDirectivesHelper.java | 34 +++++++++++++++++++ .../graphql/schema/model/Scalars.java | 4 +++ 3 files changed, 46 insertions(+) diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/Classes.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/Classes.java index c063ba2bd..192ac3fe7 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/Classes.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/Classes.java @@ -349,7 +349,11 @@ public static boolean isUnwrappedType(Type type) { // Validation public static final DotName JAVAX_VALIDATION_ANNOTATION_EMAIL = DotName.createSimple("javax.validation.constraints.Email"); public static final DotName JAVAX_VALIDATION_ANNOTATION_MAX = DotName.createSimple("javax.validation.constraints.Max"); + public static final DotName JAVAX_VALIDATION_ANNOTATION_DECIMAL_MAX = DotName + .createSimple("javax.validation.constraints.DecimalMax"); public static final DotName JAVAX_VALIDATION_ANNOTATION_MIN = DotName.createSimple("javax.validation.constraints.Min"); + public static final DotName JAVAX_VALIDATION_ANNOTATION_DECIMAL_MIN = DotName + .createSimple("javax.validation.constraints.DecimalMin"); public static final DotName JAVAX_VALIDATION_ANNOTATION_PATTERN = DotName .createSimple("javax.validation.constraints.Pattern"); public static final DotName JAVAX_VALIDATION_ANNOTATION_SIZE = DotName.createSimple("javax.validation.constraints.Size"); @@ -357,7 +361,11 @@ public static boolean isUnwrappedType(Type type) { public static final DotName JAKARTA_VALIDATION_ANNOTATION_EMAIL = DotName .createSimple("jakarta.validation.constraints.Email"); public static final DotName JAKARTA_VALIDATION_ANNOTATION_MAX = DotName.createSimple("jakarta.validation.constraints.Max"); + public static final DotName JAKARTA_VALIDATION_ANNOTATION_DECIMAL_MAX = DotName + .createSimple("jakarta.validation.constraints.DecimalMax"); public static final DotName JAKARTA_VALIDATION_ANNOTATION_MIN = DotName.createSimple("jakarta.validation.constraints.Min"); + public static final DotName JAKARTA_VALIDATION_ANNOTATION_DECIMAL_MIN = DotName + .createSimple("jakarta.validation.constraints.DecimalMin"); public static final DotName JAKARTA_VALIDATION_ANNOTATION_PATTERN = DotName .createSimple("jakarta.validation.constraints.Pattern"); public static final DotName JAKARTA_VALIDATION_ANNOTATION_SIZE = DotName diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/helper/BeanValidationDirectivesHelper.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/helper/BeanValidationDirectivesHelper.java index 8cca20f97..f52b17f26 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/helper/BeanValidationDirectivesHelper.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/helper/BeanValidationDirectivesHelper.java @@ -1,5 +1,6 @@ package io.smallrye.graphql.schema.helper; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; @@ -7,6 +8,7 @@ import org.jboss.jandex.AnnotationValue; import org.jboss.jandex.DotName; +import org.jboss.logging.Logger; import io.smallrye.graphql.schema.Annotations; import io.smallrye.graphql.schema.Classes; @@ -20,6 +22,8 @@ public class BeanValidationDirectivesHelper { public final static DirectiveType CONSTRAINT_DIRECTIVE_TYPE; + private static Logger LOGGER = Logger.getLogger(BeanValidationDirectivesHelper.class); + static { CONSTRAINT_DIRECTIVE_TYPE = new DirectiveType(); CONSTRAINT_DIRECTIVE_TYPE.setName("constraint"); @@ -34,7 +38,9 @@ public class BeanValidationDirectivesHelper { addArgument("maxLength", Scalars.getIntScalar()); addArgument("format", Scalars.getStringScalar()); addArgument("min", Scalars.getBigIntegerScalar()); + addArgument("minFloat", Scalars.getBigDecimalScalar()); addArgument("max", Scalars.getBigIntegerScalar()); + addArgument("maxFloat", Scalars.getBigDecimalScalar()); addArgument("pattern", Scalars.getStringScalar()); } @@ -90,6 +96,34 @@ public List transformBeanValidationConstraintsToDirectives(An directive.setValue("min", getLongValue(annotations, annotationName, "value")); result.add(directive); } + if (annotationName.equals(Classes.JAKARTA_VALIDATION_ANNOTATION_DECIMAL_MAX) + || annotationName.equals(Classes.JAVAX_VALIDATION_ANNOTATION_DECIMAL_MAX)) { + DirectiveInstance directive = new DirectiveInstance(); + directive.setType(CONSTRAINT_DIRECTIVE_TYPE); + String value = getStringValue(annotations, annotationName, "value"); + try { + directive.setValue("maxFloat", new BigDecimal(value).doubleValue()); + result.add(directive); + } catch (NumberFormatException nfe) { + LOGGER.warn( + "Not generating a bean validation directive for " + annotations.getAnnotationValue(annotationName) + + " because the value can't be parsed as a BigDecimal"); + } + } + if (annotationName.equals(Classes.JAKARTA_VALIDATION_ANNOTATION_DECIMAL_MIN) + || annotationName.equals(Classes.JAVAX_VALIDATION_ANNOTATION_DECIMAL_MIN)) { + DirectiveInstance directive = new DirectiveInstance(); + directive.setType(CONSTRAINT_DIRECTIVE_TYPE); + String value = getStringValue(annotations, annotationName, "value"); + try { + directive.setValue("minFloat", new BigDecimal(value).doubleValue()); + result.add(directive); + } catch (NumberFormatException nfe) { + LOGGER.warn( + "Not generating a bean validation directive for " + annotations.getAnnotationValue(annotationName) + + " because the value can't be parsed as a BigDecimal"); + } + } if (annotationName.equals(Classes.JAKARTA_VALIDATION_ANNOTATION_PATTERN) || annotationName.equals(Classes.JAVAX_VALIDATION_ANNOTATION_PATTERN)) { DirectiveInstance directive = new DirectiveInstance(); diff --git a/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/Scalars.java b/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/Scalars.java index c2c99834c..b732df144 100644 --- a/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/Scalars.java +++ b/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/Scalars.java @@ -75,6 +75,10 @@ public static Reference getBigIntegerScalar() { return getScalar(BIGINTEGER); } + public static Reference getBigDecimalScalar() { + return getScalar(BIGDECIMAL); + } + public static Reference getFormattedScalar(String className) { return formattedScalarMap.get(className); } From ba9a11347c2ea5cbbfe75e88cb645ed6f4505b9f Mon Sep 17 00:00:00 2001 From: Jan Martiska Date: Thu, 23 Jun 2022 12:16:41 +0200 Subject: [PATCH 06/33] Don't store ValidationFactory in a static field --- docs/server_configuration.md | 2 +- .../io/smallrye/graphql/cdi/validation/ValidationService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/server_configuration.md b/docs/server_configuration.md index 92184a2b1..b7af9686a 100644 --- a/docs/server_configuration.md +++ b/docs/server_configuration.md @@ -27,7 +27,7 @@ From SmallRye GraphQL | `smallrye.graphql.allowGet` | `false` | Allow HTTP GET Method | | `smallrye.graphql.metrics.enabled` | `false` | Enable metrics | | `smallrye.graphql.tracing.enabled` | `false` | Enable tracing | -| `smallrye.graphql.validation.enabled` | `false` | Enable Bean Validation | +| `smallrye.graphql.validation.enabled` | `true` if Bean Validation is present | Enable Bean Validation. This property is DEPRECATED, setting to `false` won't actually turn off validation. It will be removed in a future release. | | `smallrye.graphql.events.enabled`| `true` if one of metrics, tracing or bean validation is true | Enable eventing | | `smallrye.graphql.logPayload`| `false` | Log the payload in the log file | | `smallrye.graphql.fieldVisibility` | | To control the field visibility on introspection | diff --git a/server/implementation-cdi/src/main/java/io/smallrye/graphql/cdi/validation/ValidationService.java b/server/implementation-cdi/src/main/java/io/smallrye/graphql/cdi/validation/ValidationService.java index 8733215e9..0f5dcc831 100644 --- a/server/implementation-cdi/src/main/java/io/smallrye/graphql/cdi/validation/ValidationService.java +++ b/server/implementation-cdi/src/main/java/io/smallrye/graphql/cdi/validation/ValidationService.java @@ -16,7 +16,7 @@ * Validate input before execution */ public class ValidationService implements EventingService { - private static ValidatorFactory VALIDATOR_FACTORY = null; + private ValidatorFactory VALIDATOR_FACTORY = null; private final LookupService lookupService; public ValidationService() { From 077f8b6a9d90baf34b06473c684fb58b5d82169c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Phillip=20Kr=C3=BCger?= Date: Mon, 27 Jun 2022 17:55:38 +1000 Subject: [PATCH 07/33] Delete power-annotations directory --- power-annotations/annotations/pom.xml | 14 - .../com/github/t1/annotations/MixinFor.java | 46 --- .../com/github/t1/annotations/Stereotype.java | 23 -- power-annotations/common/pom.xml | 21 - .../powerannotations/common/CommonUtils.java | 41 -- .../t1/powerannotations/common/Jandex.java | 218 ---------- .../common/JandexPrinter.java | 42 -- .../t1/powerannotations/common/Logger.java | 5 - .../common/MixinResolver.java | 106 ----- .../common/PowerAnnotations.java | 23 -- .../common/StereotypeResolver.java | 126 ------ .../java/org/jboss/jandex/JandexBackdoor.java | 116 ------ .../org/jboss/jandex/ReflectionUtils.java | 81 ---- power-annotations/maven-plugin/pom.xml | 80 ---- .../t1/powerjandex/PowerJandexMojo.java | 112 ----- power-annotations/pom.xml | 48 --- power-annotations/scanner/pom.xml | 37 -- .../scanner/IndexBuilder.java | 44 -- .../scanner/IndexerConfig.java | 54 --- .../t1/powerannotations/scanner/Scanner.java | 118 ------ .../scanner/IndexerConfigBehavior.java | 54 --- .../test/resources/META-INF/empty.properties | 0 .../META-INF/invalid-exclude.properties | 1 - .../META-INF/multi-exclude.properties | 2 - .../resources/META-INF/one-exclude.properties | 1 - .../test/resources/META-INF/other.properties | 2 - power-annotations/tck/pom.xml | 94 ----- .../tck/AnnotationValueTypeClasses.java | 158 -------- .../tck/CombinedAnnotationClasses.java | 37 -- .../tck/ContainingTypeClasses.java | 81 ---- .../tck/DirectAnnotationClasses.java | 55 --- .../tck/InheritedAnnotationClasses.java | 52 --- .../t1/annotations/tck/MixinClasses.java | 304 -------------- .../annotations/tck/RepeatableAnnotation.java | 26 -- .../tck/RepeatableAnnotationClasses.java | 26 -- .../t1/annotations/tck/SomeAnnotation.java | 15 - .../t1/annotations/tck/StereotypeClasses.java | 186 --------- .../test/AnnotationValueTypeBehavior.java | 222 ---------- .../src/test/java/test/CombinedBehavior.java | 47 --- .../java/test/ContainingTypeBehavior.java | 159 -------- .../java/test/DirectAnnotationsBehavior.java | 206 ---------- .../test/InheritedAnnotationsTestSuite.java | 12 - .../src/test/java/test/InheritedBehavior.java | 95 ----- .../tck/src/test/java/test/MixinBehavior.java | 380 ----------------- .../test/RepeatableAnnotationBehavior.java | 147 ------- .../test/java/test/StereotypeBehavior.java | 382 ------------------ .../TypeToMemberAnnotationsTestSuite.java | 12 - power-annotations/utils/api/pom.xml | 13 - ...mbiguousAnnotationResolutionException.java | 27 -- .../github/t1/annotations/Annotations.java | 63 --- .../t1/annotations/AnnotationsLoader.java | 29 -- power-annotations/utils/jandex/pom.xml | 27 -- .../utils/jandex/AnnotationProxy.java | 114 ------ .../utils/jandex/JandexAnnotationsLoader.java | 178 -------- .../main/resources/META-INF/jandex.properties | 16 - ...om.github.t1.annotations.AnnotationsLoader | 1 - power-annotations/utils/pom.xml | 20 - 57 files changed, 4599 deletions(-) delete mode 100644 power-annotations/annotations/pom.xml delete mode 100644 power-annotations/annotations/src/main/java/com/github/t1/annotations/MixinFor.java delete mode 100644 power-annotations/annotations/src/main/java/com/github/t1/annotations/Stereotype.java delete mode 100644 power-annotations/common/pom.xml delete mode 100644 power-annotations/common/src/main/java/com/github/t1/powerannotations/common/CommonUtils.java delete mode 100644 power-annotations/common/src/main/java/com/github/t1/powerannotations/common/Jandex.java delete mode 100644 power-annotations/common/src/main/java/com/github/t1/powerannotations/common/JandexPrinter.java delete mode 100644 power-annotations/common/src/main/java/com/github/t1/powerannotations/common/Logger.java delete mode 100644 power-annotations/common/src/main/java/com/github/t1/powerannotations/common/MixinResolver.java delete mode 100644 power-annotations/common/src/main/java/com/github/t1/powerannotations/common/PowerAnnotations.java delete mode 100644 power-annotations/common/src/main/java/com/github/t1/powerannotations/common/StereotypeResolver.java delete mode 100644 power-annotations/common/src/main/java/org/jboss/jandex/JandexBackdoor.java delete mode 100644 power-annotations/common/src/main/java/org/jboss/jandex/ReflectionUtils.java delete mode 100644 power-annotations/maven-plugin/pom.xml delete mode 100644 power-annotations/maven-plugin/src/main/java/com/github/t1/powerjandex/PowerJandexMojo.java delete mode 100644 power-annotations/pom.xml delete mode 100644 power-annotations/scanner/pom.xml delete mode 100644 power-annotations/scanner/src/main/java/com/github/t1/powerannotations/scanner/IndexBuilder.java delete mode 100644 power-annotations/scanner/src/main/java/com/github/t1/powerannotations/scanner/IndexerConfig.java delete mode 100644 power-annotations/scanner/src/main/java/com/github/t1/powerannotations/scanner/Scanner.java delete mode 100644 power-annotations/scanner/src/test/java/com/github/t1/powerannotations/scanner/IndexerConfigBehavior.java delete mode 100644 power-annotations/scanner/src/test/resources/META-INF/empty.properties delete mode 100644 power-annotations/scanner/src/test/resources/META-INF/invalid-exclude.properties delete mode 100644 power-annotations/scanner/src/test/resources/META-INF/multi-exclude.properties delete mode 100644 power-annotations/scanner/src/test/resources/META-INF/one-exclude.properties delete mode 100644 power-annotations/scanner/src/test/resources/META-INF/other.properties delete mode 100644 power-annotations/tck/pom.xml delete mode 100644 power-annotations/tck/src/main/java/com/github/t1/annotations/tck/AnnotationValueTypeClasses.java delete mode 100644 power-annotations/tck/src/main/java/com/github/t1/annotations/tck/CombinedAnnotationClasses.java delete mode 100644 power-annotations/tck/src/main/java/com/github/t1/annotations/tck/ContainingTypeClasses.java delete mode 100644 power-annotations/tck/src/main/java/com/github/t1/annotations/tck/DirectAnnotationClasses.java delete mode 100644 power-annotations/tck/src/main/java/com/github/t1/annotations/tck/InheritedAnnotationClasses.java delete mode 100644 power-annotations/tck/src/main/java/com/github/t1/annotations/tck/MixinClasses.java delete mode 100644 power-annotations/tck/src/main/java/com/github/t1/annotations/tck/RepeatableAnnotation.java delete mode 100644 power-annotations/tck/src/main/java/com/github/t1/annotations/tck/RepeatableAnnotationClasses.java delete mode 100644 power-annotations/tck/src/main/java/com/github/t1/annotations/tck/SomeAnnotation.java delete mode 100644 power-annotations/tck/src/main/java/com/github/t1/annotations/tck/StereotypeClasses.java delete mode 100644 power-annotations/tck/src/test/java/test/AnnotationValueTypeBehavior.java delete mode 100644 power-annotations/tck/src/test/java/test/CombinedBehavior.java delete mode 100644 power-annotations/tck/src/test/java/test/ContainingTypeBehavior.java delete mode 100644 power-annotations/tck/src/test/java/test/DirectAnnotationsBehavior.java delete mode 100644 power-annotations/tck/src/test/java/test/InheritedAnnotationsTestSuite.java delete mode 100644 power-annotations/tck/src/test/java/test/InheritedBehavior.java delete mode 100644 power-annotations/tck/src/test/java/test/MixinBehavior.java delete mode 100644 power-annotations/tck/src/test/java/test/RepeatableAnnotationBehavior.java delete mode 100644 power-annotations/tck/src/test/java/test/StereotypeBehavior.java delete mode 100644 power-annotations/tck/src/test/java/test/TypeToMemberAnnotationsTestSuite.java delete mode 100644 power-annotations/utils/api/pom.xml delete mode 100644 power-annotations/utils/api/src/main/java/com/github/t1/annotations/AmbiguousAnnotationResolutionException.java delete mode 100644 power-annotations/utils/api/src/main/java/com/github/t1/annotations/Annotations.java delete mode 100644 power-annotations/utils/api/src/main/java/com/github/t1/annotations/AnnotationsLoader.java delete mode 100644 power-annotations/utils/jandex/pom.xml delete mode 100644 power-annotations/utils/jandex/src/main/java/com/github/t1/powerannotations/utils/jandex/AnnotationProxy.java delete mode 100644 power-annotations/utils/jandex/src/main/java/com/github/t1/powerannotations/utils/jandex/JandexAnnotationsLoader.java delete mode 100644 power-annotations/utils/jandex/src/main/resources/META-INF/jandex.properties delete mode 100644 power-annotations/utils/jandex/src/main/resources/META-INF/services/com.github.t1.annotations.AnnotationsLoader delete mode 100644 power-annotations/utils/pom.xml diff --git a/power-annotations/annotations/pom.xml b/power-annotations/annotations/pom.xml deleted file mode 100644 index 190c734e0..000000000 --- a/power-annotations/annotations/pom.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - 4.0.0 - - - io.smallrye - smallrye-power-annotations-parent - 2.0.0-SNAPSHOT - - - power-annotations - Power Annotations: Annotations - The Annotations resolved by Power Annotations - diff --git a/power-annotations/annotations/src/main/java/com/github/t1/annotations/MixinFor.java b/power-annotations/annotations/src/main/java/com/github/t1/annotations/MixinFor.java deleted file mode 100644 index 24cc3fc05..000000000 --- a/power-annotations/annotations/src/main/java/com/github/t1/annotations/MixinFor.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.github.t1.annotations; - -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -/** - * Add annotations to another class that you can't change; if you can change that class, - * use explicit {@link Stereotype}s instead. Using Mixins is very implicit and difficult to trace back; - * it is often better to actually copy the target class, so you can directly add your annotations, - * instead of working with mixins. You have been warned! - * - * If you have a class that you don't control, e.g.: - * - *
- *     public class ImportedClass {
- *         ...
- *     }
- * 
- * - * And you need it to be annotated as @SomeAnnotation. Then you can write a mixin (the name is arbitrary): - * - *
- *     @MixinFor(ImportedClass.class)
- *     @SomeAnnotation
- *     public class ImportedClassMixin {
- *         ...
- *     }
- * 
- * - * After the Power Annotations have been resolved, the target class looks as if it had another annotation: - * - *
- *     @SomeAnnotation
- *     public class ImportedClass {
- *         ...
- *     }
- * 
- */ -@Retention(RUNTIME) -@Target(TYPE) -public @interface MixinFor { - Class value(); -} diff --git a/power-annotations/annotations/src/main/java/com/github/t1/annotations/Stereotype.java b/power-annotations/annotations/src/main/java/com/github/t1/annotations/Stereotype.java deleted file mode 100644 index 4eeb3daf7..000000000 --- a/power-annotations/annotations/src/main/java/com/github/t1/annotations/Stereotype.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.github.t1.annotations; - -import static java.lang.annotation.ElementType.ANNOTATION_TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -/** - * Marks an annotation to be a meta annotation, i.e. the annotations on the stereotype (i.e. the annotation that is - * annotated as Stereotype) are logically copied to all targets (i.e. the classes/fields/methods that are - * annotated with the stereotype). - * - * Power Annotations doesn't depend on CDI, so it handles all classes named Stereotype the same. - * You can use this class if you don't have another stereotype class on your classpath, - * but in JEE/MP applications you should have javax.enterprise.inject.Stereotype. - */ -@Retention(RUNTIME) -@Target(ANNOTATION_TYPE) -@Documented -public @interface Stereotype { -} diff --git a/power-annotations/common/pom.xml b/power-annotations/common/pom.xml deleted file mode 100644 index fda8ccbbf..000000000 --- a/power-annotations/common/pom.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - 4.0.0 - - - io.smallrye - smallrye-power-annotations-parent - 2.0.0-SNAPSHOT - - - power-annotations-jandex-common - Power Annotations: Jandex Common - Common Jandex specific Power Annotations code used by build plugins and the runtime scanner. - - - - org.jboss - jandex - - - diff --git a/power-annotations/common/src/main/java/com/github/t1/powerannotations/common/CommonUtils.java b/power-annotations/common/src/main/java/com/github/t1/powerannotations/common/CommonUtils.java deleted file mode 100644 index 45e581f4e..000000000 --- a/power-annotations/common/src/main/java/com/github/t1/powerannotations/common/CommonUtils.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.github.t1.powerannotations.common; - -import static java.util.stream.Collectors.joining; - -import java.util.Arrays; -import java.util.stream.Stream; - -import org.jboss.jandex.DotName; - -public class CommonUtils { - private CommonUtils() { - } - - public static DotName toDotName(Class type) { - return toDotName(type.getName()); - } - - public static DotName toDotName(String typeName) { - return DotName.createSimple(typeName); - } - - public static String signature(String methodName, String... argTypeNames) { - return methodName + Stream.of(argTypeNames).collect(joining(", ", "(", ")")); - } - - public static T[] with(T[] original, T newInstance) { - T[] copy = Arrays.copyOf(original, original.length + 1); - copy[original.length] = newInstance; - return copy; - } - - public static void replace(T[] array, T original, T replacement) { - for (int i = 0; i < array.length; i++) { - if (array[i] == original) { - array[i] = replacement; - return; - } - } - throw new RuntimeException("original element " + original + " not in array " + Arrays.toString(array)); - } -} diff --git a/power-annotations/common/src/main/java/com/github/t1/powerannotations/common/Jandex.java b/power-annotations/common/src/main/java/com/github/t1/powerannotations/common/Jandex.java deleted file mode 100644 index 993d39099..000000000 --- a/power-annotations/common/src/main/java/com/github/t1/powerannotations/common/Jandex.java +++ /dev/null @@ -1,218 +0,0 @@ -package com.github.t1.powerannotations.common; - -import static com.github.t1.powerannotations.common.PowerAnnotations.log; -import static java.lang.reflect.Modifier.PUBLIC; -import static java.util.Arrays.asList; -import static java.util.Collections.emptyMap; -import static org.jboss.jandex.AnnotationValue.createNestedAnnotationValue; -import static org.jboss.jandex.JandexBackdoor.annotations; -import static org.jboss.jandex.JandexBackdoor.classes; -import static org.jboss.jandex.Type.Kind.ARRAY; -import static org.jboss.jandex.Type.Kind.CLASS; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.jboss.jandex.AnnotationInstance; -import org.jboss.jandex.AnnotationTarget; -import org.jboss.jandex.AnnotationValue; -import org.jboss.jandex.ClassInfo; -import org.jboss.jandex.DotName; -import org.jboss.jandex.FieldInfo; -import org.jboss.jandex.Index; -import org.jboss.jandex.JandexBackdoor; -import org.jboss.jandex.MethodInfo; -import org.jboss.jandex.Type; - -public class Jandex { - final Index index; - - private final Map> annotations; - private final Map classes; - - public Jandex(Index index) { - this.index = index; - - this.annotations = annotations(index); - this.classes = classes(index); - } - - List getAnnotationInstances(DotName annotationName) { - return index.getAnnotations(annotationName); - } - - Set allAnnotationNames() { - return annotations.keySet(); - } - - ClassInfo getClassInfo(DotName className) { - ClassInfo classInfo = classes.get(className); - return (classInfo == null) ? mock(className) : classInfo; - } - - @SuppressWarnings("deprecation") - private static org.jboss.jandex.ClassInfo mock(DotName name) { - log.info("create mock for " + name); - return org.jboss.jandex.ClassInfo.create( - name, null, (short) PUBLIC, new DotName[0], emptyMap(), true); - } - - boolean isNotTargetable(DotName annotationName, AnnotationTarget annotationTarget) { - return !isTargetable(annotationName, annotationTarget); - } - - private boolean isTargetable(DotName annotationName, AnnotationTarget annotationTarget) { - AnnotationInstance target = getClassInfo(annotationName).classAnnotation(TARGET); - if (target == null) - return true; - List allowedTypes = asList(target.value().asEnumArray()); - switch (annotationTarget.kind()) { - case CLASS: - return allowedTypes.contains("TYPE"); - case FIELD: - return allowedTypes.contains("FIELD"); - case METHOD: - return allowedTypes.contains("METHOD"); - } - throw new UnsupportedOperationException("unexpected annotation kind " + annotationTarget.kind()); - } - - AnnotationInstance copyAnnotationInstance(AnnotationInstance original, AnnotationTarget annotationTarget) { - AnnotationValue[] values = original.values().toArray(new AnnotationValue[0]); - return AnnotationInstance.create(original.name(), annotationTarget, values); - } - - void addOrSkip(ClassInfo targetClass, AnnotationInstance annotation) { - List annotationInstances = get(annotations(targetClass), annotation.name()); - if (isRepeatable(annotation) || isRepeatedAnnotation(annotation) || indexOfType(annotationInstances, annotation) < 0) - add(annotationInstances, annotation); - } - - boolean addOrReplace(ClassInfo targetClass, AnnotationInstance annotation) { - List annotationInstances = get(annotations(targetClass), annotation.name()); - if (isRepeatable(annotation)) { - add(annotationInstances, annotation); - return false; - } else { - boolean replaced = replace(annotationInstances, annotation); - if (!replaced) - add(annotationInstances, annotation); - return replaced; - } - } - - void addOrSkip(FieldInfo targetField, AnnotationInstance annotation) { - List annotationInstances = get(annotations(targetField.declaringClass()), annotation.name()); - if (isRepeatable(annotation) || indexOfType(annotationInstances, annotation) < 0) { - add(annotationInstances, annotation); - JandexBackdoor.add(targetField, annotation); - } - } - - void addOrReplace(FieldInfo targetField, AnnotationInstance copy) { - boolean replaced = addOrReplace(targetField.declaringClass(), copy); - if (replaced) - JandexBackdoor.replace(targetField, copy); - else - JandexBackdoor.add(targetField, copy); - } - - void addOrReplace(MethodInfo targetMethod, AnnotationInstance copy) { - boolean replaced = addOrReplace(targetMethod.declaringClass(), copy); - if (replaced) - JandexBackdoor.replace(copy, targetMethod); - else - JandexBackdoor.add(targetMethod, copy); - } - - void addOrSkip(MethodInfo targetMethod, AnnotationInstance annotation) { - List annotationInstances = get(annotations(targetMethod.declaringClass()), annotation.name()); - if (isRepeatable(annotation) || indexOfType(annotationInstances, annotation) < 0) { - add(annotationInstances, annotation); - JandexBackdoor.add(targetMethod, annotation); - } - } - - private void add(List existingAnnotations, AnnotationInstance newAnnotation) { - if (isRepeatable(newAnnotation)) { - for (int i = 0; i < existingAnnotations.size(); i++) { - AnnotationInstance existingAnnotation = existingAnnotations.get(i); - if (existingAnnotation.name().equals(newAnnotation.name())) { - existingAnnotations.remove(i); - AnnotationValue values = AnnotationValue.createArrayValue("value", new AnnotationValue[] { - createNestedAnnotationValue("", existingAnnotation), - createNestedAnnotationValue("", newAnnotation) - }); - newAnnotation = AnnotationInstance.create( - repeaterTypeName(newAnnotation.name()), - newAnnotation.target(), - new AnnotationValue[] { values }); - break; - } - } - } - existingAnnotations.add(newAnnotation); - } - - private DotName repeaterTypeName(DotName repeatedType) { - ClassInfo repeatedClass = getClassInfo(repeatedType); - AnnotationInstance repeatableAnnotation = repeatedClass.classAnnotation(REPEATABLE); - return repeatableAnnotation.value().asClass().name(); - } - - public boolean isRepeatedAnnotation(AnnotationInstance annotationInstance) { - ClassInfo annotationType = getClassInfo(annotationInstance.name()); - if (annotationType.methods().size() == 1 && annotationType.method("value") != null) { - Type returnType = annotationType.method("value").returnType(); - if (returnType.kind() == ARRAY && returnType.asArrayType().component().kind() == CLASS) { - ClassInfo returnClassInfo = getClassInfo(returnType.asArrayType().component().name()); - return returnClassInfo != null && isRepeatable(returnClassInfo); - } - } - return false; - } - - private boolean isRepeatable(AnnotationInstance annotationInstance) { - ClassInfo annotationType = getClassInfo(annotationInstance.name()); - return annotationType != null && isRepeatable(annotationType); - } - - private boolean isRepeatable(ClassInfo annotationType) { - return annotationType.classAnnotation(REPEATABLE) != null; - } - - private static boolean replace(List instances, AnnotationInstance newInstance) { - // we can't use `instances.replaceAll()`, because Maven plugins can't run with lambdas and fail with IndexOutOfBounds - int index = indexOfType(instances, newInstance); - if (index < 0) - return false; - instances.set(index, newInstance); - return true; - } - - private static List get(Map> map, K name) { - // we can't use `map.computeIfAbsent()`, because Maven plugins can't run with lambdas and fail with IndexOutOfBounds - if (!map.containsKey(name)) - map.put(name, new ArrayList<>()); - return map.get(name); - } - - private static int indexOfType(List instances, AnnotationInstance annotation) { - for (int i = 0; i < instances.size(); i++) - if (instances.get(i).name().equals(annotation.name()) - // AnnotationInstance subclasses don't override equals/hashCode - && instances.get(i).target().toString().equals(annotation.target().toString())) - return i; - return -1; - } - - static boolean isAnnotationType(ClassInfo classInfo) { - return classInfo.interfaceNames().contains(ANNOTATION); - } - - private static final DotName REPEATABLE = DotName.createSimple("java.lang.annotation.Repeatable"); - private static final DotName ANNOTATION = DotName.createSimple("java.lang.annotation.Annotation"); - private static final DotName TARGET = DotName.createSimple("java.lang.annotation.Target"); -} diff --git a/power-annotations/common/src/main/java/com/github/t1/powerannotations/common/JandexPrinter.java b/power-annotations/common/src/main/java/com/github/t1/powerannotations/common/JandexPrinter.java deleted file mode 100644 index e319a3bb6..000000000 --- a/power-annotations/common/src/main/java/com/github/t1/powerannotations/common/JandexPrinter.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.github.t1.powerannotations.common; - -import static com.github.t1.powerannotations.common.PowerAnnotations.log; - -import java.util.function.Consumer; - -import org.jboss.jandex.ClassInfo; -import org.jboss.jandex.Index; -import org.jboss.jandex.IndexView; -import org.jboss.jandex.MethodInfo; - -public class JandexPrinter { - - private final IndexView index; - - public JandexPrinter(IndexView index) { - this.index = index; - } - - public void run() { - log.info("------------------------------------------------------------"); - ((Index) index).printAnnotations(); - log.info("------------------------------------------------------------"); - ((Index) index).printSubclasses(); - log.info("------------------------------------------------------------"); - index.getKnownClasses().forEach(new Consumer() { - @Override - public void accept(ClassInfo classInfo) { - if (!classInfo.name().toString().startsWith("test.")) - return; - log.info(classInfo.name() + ":"); - classInfo.methods().forEach(new Consumer() { - @Override - public void accept(MethodInfo method) { - log.info(" " + method.name() + " [" + method.defaultValue() + "]"); - } - }); - } - }); - log.info("------------------------------------------------------------"); - } -} diff --git a/power-annotations/common/src/main/java/com/github/t1/powerannotations/common/Logger.java b/power-annotations/common/src/main/java/com/github/t1/powerannotations/common/Logger.java deleted file mode 100644 index e9292cac6..000000000 --- a/power-annotations/common/src/main/java/com/github/t1/powerannotations/common/Logger.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.github.t1.powerannotations.common; - -public interface Logger { - void info(String message); -} diff --git a/power-annotations/common/src/main/java/com/github/t1/powerannotations/common/MixinResolver.java b/power-annotations/common/src/main/java/com/github/t1/powerannotations/common/MixinResolver.java deleted file mode 100644 index 6be226205..000000000 --- a/power-annotations/common/src/main/java/com/github/t1/powerannotations/common/MixinResolver.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.github.t1.powerannotations.common; - -import static com.github.t1.powerannotations.common.PowerAnnotations.log; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.jboss.jandex.AnnotationInstance; -import org.jboss.jandex.AnnotationTarget; -import org.jboss.jandex.ClassInfo; -import org.jboss.jandex.DotName; -import org.jboss.jandex.FieldInfo; -import org.jboss.jandex.MethodInfo; -import org.jboss.jandex.Type; - -class MixinResolver implements Runnable { - private final Jandex jandex; - - MixinResolver(Jandex jandex) { - this.jandex = jandex; - } - - @Override - public void run() { - for (AnnotationInstance mixin : jandex.getAnnotationInstances(MIXIN_FOR)) { - ClassInfo mixinTarget = jandex.getClassInfo(mixin.value().asClass().name()); - ClassInfo mixinClass = mixin.target().asClass(); - log.info("mix " + mixinClass + " into " + mixinTarget); - if (Jandex.isAnnotationType(mixinTarget)) - resolveAnnotationMixin(mixinTarget, mixinClass); - else - resolveMixinAnnotations(mixinTarget, mixinClass); - } - } - - private void resolveAnnotationMixin(ClassInfo mixinTarget, ClassInfo mixinClass) { - for (AnnotationInstance annotationInstance : new ArrayList<>(jandex.getAnnotationInstances(mixinTarget.name()))) { - resolveMixinAnnotations(annotationInstance.target(), mixinClass); - } - } - - private void resolveMixinAnnotations(AnnotationTarget mixinTarget, ClassInfo mixinClass) { - Map> annotations = mixinClass.annotations(); - for (DotName annotationName : annotations.keySet()) { - if (MIXIN_FOR.equals(annotationName)) - continue; - for (AnnotationInstance annotationInstance : annotations.get(annotationName)) { - AnnotationTarget annotation = annotationInstance.target(); - log.info("- " + annotationInstance + " -> " + annotation.kind().name().toLowerCase() + " " + annotation); - switch (annotation.kind()) { - case CLASS: - switch (mixinTarget.kind()) { - case CLASS: - resolveClassMixin(annotationInstance, mixinTarget.asClass()); - continue; - case FIELD: - resolveFieldMixin(annotationInstance, mixinTarget.asField()); - continue; - case METHOD: - try { - MethodInfo targetMethod = getTargetMethod(mixinTarget.asMethod().declaringClass(), - mixinTarget.asMethod()); - resolveMethodMixin(annotationInstance, targetMethod); - } catch (Exception e) { - e.printStackTrace(); - } - continue; - default: - throw new RuntimeException( - "can't resolve an annotation mixin for the " + mixinTarget.kind() + ": " + mixinTarget); - } - case FIELD: - resolveFieldMixin(annotationInstance, mixinTarget.asClass().field(annotation.asField().name())); - continue; - case METHOD: - resolveMethodMixin(annotationInstance, getTargetMethod(mixinTarget.asClass(), annotation.asMethod())); - continue; - } - throw new UnsupportedOperationException("don't know how to resolve a " + annotation.kind() + " mixin: " - + annotationInstance); - } - } - } - - private MethodInfo getTargetMethod(ClassInfo classInfo, MethodInfo method) { - return classInfo.method(method.name(), method.parameters().toArray(new Type[0])); - } - - private void resolveClassMixin(AnnotationInstance annotationInstance, ClassInfo mixinTarget) { - AnnotationInstance copy = jandex.copyAnnotationInstance(annotationInstance, mixinTarget); - jandex.addOrReplace(mixinTarget, copy); - } - - private void resolveFieldMixin(AnnotationInstance annotationInstance, FieldInfo targetField) { - AnnotationInstance copy = jandex.copyAnnotationInstance(annotationInstance, targetField); - jandex.addOrReplace(targetField, copy); - } - - private void resolveMethodMixin(AnnotationInstance annotationInstance, MethodInfo targetMethod) { - AnnotationInstance copy = jandex.copyAnnotationInstance(annotationInstance, targetMethod); - jandex.addOrReplace(targetMethod, copy); - } - - private static final DotName MIXIN_FOR = DotName.createSimple("com.github.t1.annotations.MixinFor"); -} diff --git a/power-annotations/common/src/main/java/com/github/t1/powerannotations/common/PowerAnnotations.java b/power-annotations/common/src/main/java/com/github/t1/powerannotations/common/PowerAnnotations.java deleted file mode 100644 index a09b3d9a8..000000000 --- a/power-annotations/common/src/main/java/com/github/t1/powerannotations/common/PowerAnnotations.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.github.t1.powerannotations.common; - -import org.jboss.jandex.Index; - -public class PowerAnnotations { - private final Jandex jandex; - @SuppressWarnings({ "Convert2Lambda", "Anonymous2MethodRef" }) // wouldn't work in a Maven Plugin - public static Logger log = new Logger() { - @Override - public void info(String message) { - System.out.println(message); - } - }; - - public PowerAnnotations(Index index) { - this.jandex = new Jandex(index); - } - - public void resolveAnnotations() { - new MixinResolver(jandex).run(); - new StereotypeResolver(jandex).run(); - } -} diff --git a/power-annotations/common/src/main/java/com/github/t1/powerannotations/common/StereotypeResolver.java b/power-annotations/common/src/main/java/com/github/t1/powerannotations/common/StereotypeResolver.java deleted file mode 100644 index 1c440a9db..000000000 --- a/power-annotations/common/src/main/java/com/github/t1/powerannotations/common/StereotypeResolver.java +++ /dev/null @@ -1,126 +0,0 @@ -package com.github.t1.powerannotations.common; - -import static com.github.t1.powerannotations.common.PowerAnnotations.log; - -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import org.jboss.jandex.AnnotationInstance; -import org.jboss.jandex.AnnotationTarget; -import org.jboss.jandex.ClassInfo; -import org.jboss.jandex.DotName; -import org.jboss.jandex.FieldInfo; -import org.jboss.jandex.MethodInfo; - -class StereotypeResolver implements Runnable { - private static final Map STEREOTYPE_NESTING_LEVELS = new TreeMap<>(); - - private final Jandex jandex; - - StereotypeResolver(Jandex jandex) { - this.jandex = jandex; - } - - @Override - public void run() { - for (DotName stereotypeTypeName : jandex.allAnnotationNames()) { - if (!stereotypeTypeName.withoutPackagePrefix().equals("Stereotype")) - continue; - log.info("stereotype type " + stereotypeTypeName); - for (ClassInfo stereotype : stereotypes(stereotypeTypeName)) { - log.info("stereotype " + stereotype); - for (AnnotationInstance stereotypeTargetAnnotationInstance : new ArrayList<>( - jandex.getAnnotationInstances(stereotype.asClass().name()))) { - AnnotationTarget annotationTarget = stereotypeTargetAnnotationInstance.target(); - log.info("-> " + annotationTarget.kind().name().toLowerCase() + " " + annotationTarget); - Map> annotations = stereotype.annotations(); - for (DotName annotationName : annotations.keySet()) { - if (stereotypeTypeName.equals(annotationName) || RETENTION.equals(annotationName) - || jandex.isNotTargetable(annotationName, annotationTarget)) - continue; - for (AnnotationInstance annotationInstance : annotations.get(annotationName)) { - log.info(" - " + annotationInstance); - switch (annotationTarget.kind()) { - case CLASS: - resolveClassStereotype(annotationInstance, annotationTarget.asClass()); - continue; - case FIELD: - resolveFieldStereotype(annotationInstance, annotationTarget.asField()); - continue; - case METHOD: - resolveMethodStereotype(annotationInstance, annotationTarget.asMethod()); - continue; - } - throw new UnsupportedOperationException("don't know how to resolve a " + annotationTarget.kind() - + " stereotype: " + stereotypeTargetAnnotationInstance); - } - } - } - } - } - } - - private List stereotypes(DotName stereotypeTypeName) { - // we can't use streams, because Maven plugins can't run with lambdas and fail with IndexOutOfBounds - List list = new ArrayList<>(); - for (AnnotationInstance annotationInstance : jandex.getAnnotationInstances(stereotypeTypeName)) { - ClassInfo classInfo = annotationInstance.target().asClass(); - list.add(classInfo); - } - list.sort(new StereotypeLevel()); // resolve indirect stereotypes first - return list; - } - - private class StereotypeLevel implements Comparator { - @Override - public int compare(ClassInfo left, ClassInfo right) { - int leftLevel = stereotypeLevel(left); - int rightLevel = stereotypeLevel(right); - return (leftLevel == rightLevel) - ? left.name().compareTo(right.name()) - : (leftLevel - rightLevel); - } - } - - private int stereotypeLevel(ClassInfo stereotypeType) { - // we can't use streams, because Maven plugins can't run with lambdas and fail with IndexOutOfBounds - int max = 0; - for (AnnotationInstance annotationInstance : stereotypeType.classAnnotations()) { - int annotationLevel = stereotypeLevel(annotationInstance); - if (annotationLevel > max) { - max = annotationLevel; - } - } - return max + 1; - } - - private int stereotypeLevel(AnnotationInstance annotationInstance) { - if (STEREOTYPE_NESTING_LEVELS.containsKey(annotationInstance.name())) - return STEREOTYPE_NESTING_LEVELS.get(annotationInstance.name()); - STEREOTYPE_NESTING_LEVELS.put(annotationInstance.name(), 0); // prevent recursion - ClassInfo type = jandex.getClassInfo(annotationInstance.name()); - int annotationLevel = stereotypeLevel(type); - STEREOTYPE_NESTING_LEVELS.put(annotationInstance.name(), annotationLevel); - return annotationLevel; - } - - private void resolveClassStereotype(AnnotationInstance annotationInstance, ClassInfo targetClass) { - AnnotationInstance copy = jandex.copyAnnotationInstance(annotationInstance, targetClass); - jandex.addOrSkip(targetClass, copy); - } - - private void resolveFieldStereotype(AnnotationInstance annotationInstance, FieldInfo targetField) { - AnnotationInstance copy = jandex.copyAnnotationInstance(annotationInstance, targetField); - jandex.addOrSkip(targetField, copy); - } - - private void resolveMethodStereotype(AnnotationInstance annotationInstance, MethodInfo targetMethod) { - AnnotationInstance copy = jandex.copyAnnotationInstance(annotationInstance, targetMethod); - jandex.addOrSkip(targetMethod, copy); - } - - private static final DotName RETENTION = DotName.createSimple("java.lang.annotation.Retention"); -} diff --git a/power-annotations/common/src/main/java/org/jboss/jandex/JandexBackdoor.java b/power-annotations/common/src/main/java/org/jboss/jandex/JandexBackdoor.java deleted file mode 100644 index 496434ff3..000000000 --- a/power-annotations/common/src/main/java/org/jboss/jandex/JandexBackdoor.java +++ /dev/null @@ -1,116 +0,0 @@ -package org.jboss.jandex; - -import static com.github.t1.powerannotations.common.CommonUtils.with; -import static org.jboss.jandex.ReflectionUtils.get; -import static org.jboss.jandex.ReflectionUtils.isArraysArrayList; -import static org.jboss.jandex.ReflectionUtils.isUnmodifiable; -import static org.jboss.jandex.ReflectionUtils.modifiable; -import static org.jboss.jandex.ReflectionUtils.set; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.github.t1.powerannotations.common.CommonUtils; - -/** - * A lot of methods or fields in Jandex are package private. The methods in here "add functionality to Jandex" - * that needs access to the internals of Jandex, - * which is much better than using reflection or putting all of our own stuff in the same package. - * Sometimes even that is not enough and we need reflection. - */ -public class JandexBackdoor { - private JandexBackdoor() { - } - - public static Map> annotations(Index index) { - return modifiable(index.annotations); - } - - public static Map classes(Index index) { - return modifiable(index.classes); - } - - public static Map> annotations(ClassInfo classInfo) { - Map> map = get(classInfo, "annotations"); - if (map.isEmpty()) { // EMPTY_MAP is immutable - map = new HashMap<>(); - set(classInfo, "annotations", map); - } else if (isUnmodifiable(map)) - map = modifiable(map); - return map; - } - - public static void add(MethodInfo targetMethod, AnnotationInstance newInstance) { - AnnotationInstance[] copy = with(targetMethod.methodInternal().annotationArray(), newInstance); - replaceAnnotations(targetMethod, copy); - } - - public static void replace(AnnotationInstance newInstance, MethodInfo targetMethod) { - AnnotationInstance[] copy = replace(targetMethod.methodInternal().annotationArray(), newInstance); - replaceAnnotations(targetMethod, copy); - } - - private static void replaceAnnotations(MethodInfo targetMethod, AnnotationInstance[] copy) { - MethodInternal originalMethodInternal = targetMethod.methodInternal(); - MethodInternal newMethodInternal = withAnnotations(originalMethodInternal, copy); - targetMethod.setMethodInternal(newMethodInternal); - CommonUtils.replace(targetMethod.declaringClass().methodArray(), originalMethodInternal, newMethodInternal); - } - - private static MethodInternal withAnnotations(MethodInternal methodInternal, AnnotationInstance[] annotations) { - return new MethodInternal( - methodInternal.nameBytes(), - methodInternal.parameterNamesBytes(), - methodInternal.parameterArray(), - methodInternal.returnType(), - methodInternal.flags(), - methodInternal.receiverTypeField(), - methodInternal.typeParameterArray(), - methodInternal.exceptionArray(), - annotations, - methodInternal.defaultValue()); - } - - public static void add(FieldInfo targetField, AnnotationInstance newInstance) { - AnnotationInstance[] copy = with(targetField.fieldInternal().annotationArray(), newInstance); - replaceAnnotations(targetField, copy); - } - - public static void replace(FieldInfo targetField, AnnotationInstance newInstance) { - AnnotationInstance[] copy = replace(targetField.fieldInternal().annotationArray(), newInstance); - replaceAnnotations(targetField, copy); - } - - private static void replaceAnnotations(FieldInfo targetField, AnnotationInstance[] copy) { - FieldInternal originalFieldInternal = targetField.fieldInternal(); - FieldInternal newFieldInternal = new FieldInternal(originalFieldInternal.nameBytes(), originalFieldInternal.type(), - originalFieldInternal.flags(), copy); - targetField.setFieldInternal(newFieldInternal); - CommonUtils.replace(targetField.declaringClass().fieldArray(), originalFieldInternal, newFieldInternal); - } - - private static AnnotationInstance[] replace(AnnotationInstance[] original, AnnotationInstance newInstance) { - AnnotationInstance[] copy = Arrays.copyOf(original, original.length); - for (int i = 0; i < original.length; i++) { - if (copy[i].name().equals(newInstance.name())) { - copy[i] = newInstance; - return copy; - } - } - throw new RuntimeException("original element " + newInstance.name() + " not in array " + Arrays.toString(original)); - } - - public static List annotations(MethodInfo methodInfo) { - List list = methodInfo.methodInternal().annotations(); - if (isUnmodifiable(list)) - list = modifiable(list); - if (isArraysArrayList(list)) { - list = new ArrayList<>(list); - set(methodInfo.methodInternal(), "annotations", list); - } - return list; - } -} diff --git a/power-annotations/common/src/main/java/org/jboss/jandex/ReflectionUtils.java b/power-annotations/common/src/main/java/org/jboss/jandex/ReflectionUtils.java deleted file mode 100644 index 0211a6005..000000000 --- a/power-annotations/common/src/main/java/org/jboss/jandex/ReflectionUtils.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.jboss.jandex; - -import java.lang.reflect.Field; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -class ReflectionUtils { - private ReflectionUtils() { - } - - static T get(Object object, String fieldName) { - return get(object.getClass(), object, fieldName); - } - - static T get(Class type, Object object, String fieldName) { - try { - Field field = type.getDeclaredField(fieldName); - field.setAccessible(true); - @SuppressWarnings("unchecked") - T value = (T) field.get(object); - return value; - } catch (ReflectiveOperationException e) { - throw new RuntimeException("can't get field '" + fieldName + "'", e); - } - } - - static void set(Object object, String fieldName, Object value) { - set(object.getClass(), object, fieldName, value); - } - - static void set(Class type, Object object, String fieldName, Object value) { - try { - Field field = type.getDeclaredField(fieldName); - field.setAccessible(true); - field.set(object, value); - } catch (ReflectiveOperationException e) { - throw new RuntimeException("can't get field '" + fieldName + "'", e); - } - } - - static boolean isUnmodifiable(Map> map) { - return UNMODIFIABLE_MAP.equals(map.getClass()); - } - - static Map modifiable(Map map) { - return get(map, "m"); - } - - static boolean isUnmodifiable(List list) { - return UNMODIFIABLE_LIST.equals(list.getClass()) || UNMODIFIABLE_RANDOM_ACCESS_LIST.equals(list.getClass()); - } - - static List modifiable(List list) { - // UnmodifiableRandomAccessList is a subclass of UnmodifiableList - list = get(UNMODIFIABLE_LIST, list, "list"); - return list; - } - - static boolean isArraysArrayList(List list) { - return ARRAY_LIST.equals(list.getClass()); - } - - private static final Class UNMODIFIABLE_MAP = unmodifiableCollectionClass("Map"); - private static final Class UNMODIFIABLE_LIST = unmodifiableCollectionClass("List"); - private static final Class UNMODIFIABLE_RANDOM_ACCESS_LIST = unmodifiableCollectionClass("RandomAccessList"); - private static final Class ARRAY_LIST = classForName(Arrays.class.getName() + "$ArrayList"); - - private static Class unmodifiableCollectionClass(String type) { - return classForName(Collections.class.getName() + "$Unmodifiable" + type); - } - - private static Class classForName(String className) { - try { - return Class.forName(className); - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } - } -} diff --git a/power-annotations/maven-plugin/pom.xml b/power-annotations/maven-plugin/pom.xml deleted file mode 100644 index a43c88724..000000000 --- a/power-annotations/maven-plugin/pom.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - 4.0.0 - - - io.smallrye - smallrye-power-annotations-parent - 2.0.0-SNAPSHOT - - - power-jandex-maven-plugin - maven-plugin - Power Annotations: Jandex Maven Plugin - Replaces the `jandex-maven-plugin` to generate a Jandex index file, but with the Power Annotations resolved. - - - 3.5 - - - - true - - 3.8.5 - - - - - org.apache.maven.plugin-tools - maven-plugin-annotations - provided - - - org.apache.maven - maven-plugin-api - provided - - - javax.inject - javax.inject - - - javax.enterprise - cdi-api - - - - - org.apache.maven - maven-core - provided - - - javax.inject - javax.inject - - - - - jakarta.inject - jakarta.inject-api - provided - 2.0.1 - - - io.smallrye - power-annotations-jandex-common - ${project.version} - - - - - - - org.apache.maven.plugins - maven-plugin-plugin - 3.6.4 - - - - diff --git a/power-annotations/maven-plugin/src/main/java/com/github/t1/powerjandex/PowerJandexMojo.java b/power-annotations/maven-plugin/src/main/java/com/github/t1/powerjandex/PowerJandexMojo.java deleted file mode 100644 index 22e142ef2..000000000 --- a/power-annotations/maven-plugin/src/main/java/com/github/t1/powerjandex/PowerJandexMojo.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.github.t1.powerjandex; - -import static java.nio.file.FileVisitResult.CONTINUE; -import static java.nio.file.Files.createDirectories; -import static java.nio.file.Files.newInputStream; -import static java.nio.file.Files.newOutputStream; -import static java.nio.file.Files.walkFileTree; -import static org.apache.maven.plugins.annotations.LifecyclePhase.PROCESS_CLASSES; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.file.FileVisitResult; -import java.nio.file.Path; -import java.nio.file.SimpleFileVisitor; -import java.nio.file.attribute.BasicFileAttributes; - -import jakarta.inject.Inject; - -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.project.MavenProject; -import org.jboss.jandex.Index; -import org.jboss.jandex.IndexWriter; -import org.jboss.jandex.Indexer; - -import com.github.t1.powerannotations.common.JandexPrinter; -import com.github.t1.powerannotations.common.Logger; -import com.github.t1.powerannotations.common.PowerAnnotations; - -@Mojo(name = "power-jandex", defaultPhase = PROCESS_CLASSES, threadSafe = true) -public class PowerJandexMojo extends AbstractMojo { - - @Inject - @SuppressWarnings("CdiInjectionPointsInspection") - MavenProject project; - - private final MojoLogger log = new MojoLogger(); - - private class MojoLogger implements Logger { - @Override - public void info(String message) { - getLog().info(message); - } - } - - @Override - public void execute() { - PowerAnnotations.log = log; - - Index index = new Scanner().createIndex(); - - new PowerAnnotations(index).resolveAnnotations(); - - new JandexPrinter(index).run(); - - write(index); - } - - private Path baseDir() { - return project.getBasedir().toPath().resolve("target/classes"); - } - - private class Scanner { - private final Indexer indexer = new Indexer(); - - public Index createIndex() { - scanDirectory(baseDir()); - return indexer.complete(); - } - - public void scanDirectory(Path path) { - try { - walkFileTree(path, new SimpleFileVisitor() { - @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { - if (isClassFile(file)) - scanClassFile(file); - return CONTINUE; - } - }); - } catch (IOException e) { - throw new RuntimeException("failed to index " + path, e); - } - } - - private boolean isClassFile(Path file) { - return file.toString().endsWith(".class"); - } - - private void scanClassFile(Path path) { - try (InputStream inputStream = newInputStream(path)) { - indexer.index(inputStream); - } catch (IOException e) { - throw new RuntimeException("failed to index " + path, e); - } - } - } - - private void write(Index index) { - Path filePath = baseDir().resolve("META-INF/jandex.idx"); - log.info("write index to " + filePath); - try { - createDirectories(filePath.getParent()); - try (OutputStream outputStream = newOutputStream(filePath)) { - new IndexWriter(outputStream).write(index); - } - } catch (IOException e) { - throw new RuntimeException("can't write jandex to " + filePath, e); - } - } -} diff --git a/power-annotations/pom.xml b/power-annotations/pom.xml deleted file mode 100644 index 2f0785a2a..000000000 --- a/power-annotations/pom.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - 4.0.0 - - - io.smallrye - smallrye-graphql-parent - 2.0.0-SNAPSHOT - - - smallrye-power-annotations-parent - pom - Power Annotations: Parent - Power-Annotations is a generic mechanism for meta annotations, most notably stereotypes and mixins. - - - annotations - utils - tck - common - maven-plugin - scanner - - - - install - - - org.apache.maven.plugins - maven-compiler-plugin - - 11 - 11 - true - - - - org.apache.maven.plugins - maven-surefire-plugin - - - *Behavior - - - - - - diff --git a/power-annotations/scanner/pom.xml b/power-annotations/scanner/pom.xml deleted file mode 100644 index 779230cdb..000000000 --- a/power-annotations/scanner/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - 4.0.0 - - - io.smallrye - smallrye-power-annotations-parent - 2.0.0-SNAPSHOT - - - power-annotations-scanner - Power Annotations Jandex Runtime Scanner - Build a Jandex index at runtime from the classpath and resolve power annotations - - - - org.jboss - jandex - - - io.smallrye - power-annotations-jandex-common - ${project.version} - - - - org.junit.jupiter - junit-jupiter - test - - - org.assertj - assertj-core - test - - - diff --git a/power-annotations/scanner/src/main/java/com/github/t1/powerannotations/scanner/IndexBuilder.java b/power-annotations/scanner/src/main/java/com/github/t1/powerannotations/scanner/IndexBuilder.java deleted file mode 100644 index f710ddb04..000000000 --- a/power-annotations/scanner/src/main/java/com/github/t1/powerannotations/scanner/IndexBuilder.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.github.t1.powerannotations.scanner; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Optional; - -import org.jboss.jandex.Index; -import org.jboss.jandex.IndexReader; - -import com.github.t1.powerannotations.common.PowerAnnotations; - -public class IndexBuilder { - public static Index loadOrScan() { - return load().orElseGet(IndexBuilder::scan); - } - - @SuppressWarnings("UnusedReturnValue") - private static Optional load() { - try (InputStream inputStream = getClassLoader().getResourceAsStream("META-INF/jandex.idx")) { - return Optional.ofNullable(inputStream).map(IndexBuilder::load); - } catch (RuntimeException | IOException e) { - throw new RuntimeException("can't read index file", e); - } - } - - private static Index load(InputStream inputStream) { - try { - return new IndexReader(inputStream).read(); - } catch (RuntimeException | IOException e) { - throw new RuntimeException("can't read Jandex input stream", e); - } - } - - private static ClassLoader getClassLoader() { - ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - return (classLoader == null) ? ClassLoader.getSystemClassLoader() : classLoader; - } - - private static Index scan() { - Index index = new Scanner().scanClassPath(); - new PowerAnnotations(index).resolveAnnotations(); - return index; - } -} diff --git a/power-annotations/scanner/src/main/java/com/github/t1/powerannotations/scanner/IndexerConfig.java b/power-annotations/scanner/src/main/java/com/github/t1/powerannotations/scanner/IndexerConfig.java deleted file mode 100644 index 72a890d67..000000000 --- a/power-annotations/scanner/src/main/java/com/github/t1/powerannotations/scanner/IndexerConfig.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.github.t1.powerannotations.scanner; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Stream; - -class IndexerConfig { - private final List exclude = new ArrayList<>(); - - IndexerConfig() { - this("META-INF/jandex.properties"); - } - - IndexerConfig(String resource) { - try (InputStream inputStream = ClassLoader.getSystemClassLoader().getResourceAsStream(resource)) { - if (inputStream == null) - return; - Properties properties = new Properties(); - properties.load(inputStream); - loadExcludeConfig(properties); - } catch (IOException e) { - throw new RuntimeException("can't load " + resource, e); - } - } - - private void loadExcludeConfig(Properties properties) { - String excludeString = properties.getProperty("exclude", null); - if (excludeString != null) { - try { - Stream.of(excludeString.split("\\s+")) - .map(this::gavToRegex) - .forEach(this.exclude::add); - } catch (Exception e) { - throw new RuntimeException("can't parse exclude config", e); - } - } - } - - private String gavToRegex(String groupArtifact) { - Matcher matcher = Pattern.compile("(?[^:]+):(?[^:]+)").matcher(groupArtifact); - if (!matcher.matches()) - throw new RuntimeException("expect `group:artifact` but found `" + groupArtifact + "`"); - return ".*/" + matcher.group("group") + "/.*/" + matcher.group("artifact") + "-.*\\.jar"; - } - - public Stream excludes() { - return exclude.stream(); - } -} diff --git a/power-annotations/scanner/src/main/java/com/github/t1/powerannotations/scanner/Scanner.java b/power-annotations/scanner/src/main/java/com/github/t1/powerannotations/scanner/Scanner.java deleted file mode 100644 index 08f79001a..000000000 --- a/power-annotations/scanner/src/main/java/com/github/t1/powerannotations/scanner/Scanner.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.github.t1.powerannotations.scanner; - -import static com.github.t1.powerannotations.common.PowerAnnotations.*; -import static java.nio.charset.StandardCharsets.UTF_8; - -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URISyntaxException; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.stream.Stream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - -import org.jboss.jandex.Index; -import org.jboss.jandex.Indexer; - -public class Scanner { - - private final Indexer indexer = new Indexer(); - private final IndexerConfig config = new IndexerConfig(); - private int archivesIndexed; - private int classesIndexed; - - public Index scanClassPath() { - long t = System.currentTimeMillis(); - urls() - .distinct() - .filter(this::include) - .forEach(this::index); - Index index = indexer.complete(); - log.info("scanned " + archivesIndexed + " archives with " + classesIndexed + " classes " + - "in " + (System.currentTimeMillis() - t) + "ms"); - return index; - } - - private Stream urls() { - return Stream.of(System.getProperty("java.class.path") - .split(System.getProperty("path.separator"))) - .map(Scanner::toUrl); - } - - private static URL toUrl(String url) { - try { - return Paths.get(url).toUri().toURL(); - } catch (MalformedURLException e) { - throw new RuntimeException("invalid classpath url " + url, e); - } - } - - private boolean include(URL url) { - String urlString = url.toString(); - return config.excludes().noneMatch(urlString::matches); - } - - private void index(URL url) { - try { - long t0 = System.currentTimeMillis(); - int classesIndexedBefore = classesIndexed; - if (url.toString().endsWith(".jar") || url.toString().endsWith(".war")) - indexArchive(url.openStream()); - else - indexFolder(url); - log.info("indexed " + (classesIndexed - classesIndexedBefore) + " classes in " + url - + " in " + (System.currentTimeMillis() - t0) + " ms"); - } catch (IOException e) { - throw new RuntimeException("can't index " + url, e); - } - } - - private void indexArchive(InputStream inputStream) throws IOException { - archivesIndexed++; - ZipInputStream zipInputStream = new ZipInputStream(inputStream, UTF_8); - while (true) { - ZipEntry entry = zipInputStream.getNextEntry(); - if (entry == null) - break; - String entryName = entry.getName(); - indexFile(entryName, zipInputStream); - } - } - - private void indexFile(String fileName, InputStream inputStream) throws IOException { - if (fileName.endsWith(".class")) { - classesIndexed++; - indexer.index(inputStream); - } else if (fileName.endsWith(".war")) { - // necessary because of the Thorntail arquillian adapter - indexArchive(inputStream); - } - } - - private void indexFolder(URL url) throws IOException { - try { - Path folderPath = Paths.get(url.toURI()); - if (Files.isDirectory(folderPath)) { - try (Stream walk = Files.walk(folderPath)) { - walk.filter(Files::isRegularFile) - .forEach(this::indexFile); - } - } - } catch (URISyntaxException e) { - throw new RuntimeException("invalid folder url " + url, e); - } - } - - private void indexFile(Path path) { - try { - String entryName = path.getFileName().toString(); - indexFile(entryName, Files.newInputStream(path)); - } catch (IOException e) { - throw new RuntimeException("can't index path " + path, e); - } - } -} diff --git a/power-annotations/scanner/src/test/java/com/github/t1/powerannotations/scanner/IndexerConfigBehavior.java b/power-annotations/scanner/src/test/java/com/github/t1/powerannotations/scanner/IndexerConfigBehavior.java deleted file mode 100644 index b111834ee..000000000 --- a/power-annotations/scanner/src/test/java/com/github/t1/powerannotations/scanner/IndexerConfigBehavior.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.github.t1.powerannotations.scanner; - -import static org.assertj.core.api.Assertions.catchThrowable; -import static org.assertj.core.api.BDDAssertions.then; - -import org.junit.jupiter.api.Test; - -class IndexerConfigBehavior { - @Test - void shouldIgnoreUnknownResource() { - IndexerConfig unknown = new IndexerConfig("unknown"); - - then(unknown.excludes()).isEmpty(); - } - - @Test - void shouldLoadEmptyResource() { - IndexerConfig unknown = new IndexerConfig("META-INF/empty.properties"); - - then(unknown.excludes()).isEmpty(); - } - - @Test - void shouldLoadOtherPropertiesResource() { - IndexerConfig unknown = new IndexerConfig("META-INF/other.properties"); - - then(unknown.excludes()).isEmpty(); - } - - @Test - void shouldLoadOneExcludeConfig() { - IndexerConfig unknown = new IndexerConfig("META-INF/one-exclude.properties"); - - then(unknown.excludes()).containsExactly(".*/foo/.*/bar-.*\\.jar"); - } - - @Test - void shouldFailToLoadInvalidExcludeConfig() { - Throwable throwable = catchThrowable(() -> new IndexerConfig("META-INF/invalid-exclude.properties")); - - then(throwable) - .hasMessage("can't parse exclude config") - .hasRootCauseMessage("expect `group:artifact` but found `invalid`"); - } - - @Test - void shouldLoadMultiExcludeConfig() { - IndexerConfig unknown = new IndexerConfig("META-INF/multi-exclude.properties"); - - then(unknown.excludes()).containsExactly( - ".*/foo/.*/bar-.*\\.jar", - ".*/baz/.*/bee-.*\\.jar"); - } -} diff --git a/power-annotations/scanner/src/test/resources/META-INF/empty.properties b/power-annotations/scanner/src/test/resources/META-INF/empty.properties deleted file mode 100644 index e69de29bb..000000000 diff --git a/power-annotations/scanner/src/test/resources/META-INF/invalid-exclude.properties b/power-annotations/scanner/src/test/resources/META-INF/invalid-exclude.properties deleted file mode 100644 index b654114c1..000000000 --- a/power-annotations/scanner/src/test/resources/META-INF/invalid-exclude.properties +++ /dev/null @@ -1 +0,0 @@ -exclude=invalid diff --git a/power-annotations/scanner/src/test/resources/META-INF/multi-exclude.properties b/power-annotations/scanner/src/test/resources/META-INF/multi-exclude.properties deleted file mode 100644 index 287f2d33b..000000000 --- a/power-annotations/scanner/src/test/resources/META-INF/multi-exclude.properties +++ /dev/null @@ -1,2 +0,0 @@ -exclude=foo:bar \ - baz:bee diff --git a/power-annotations/scanner/src/test/resources/META-INF/one-exclude.properties b/power-annotations/scanner/src/test/resources/META-INF/one-exclude.properties deleted file mode 100644 index 9f2e4ab7b..000000000 --- a/power-annotations/scanner/src/test/resources/META-INF/one-exclude.properties +++ /dev/null @@ -1 +0,0 @@ -exclude=foo:bar diff --git a/power-annotations/scanner/src/test/resources/META-INF/other.properties b/power-annotations/scanner/src/test/resources/META-INF/other.properties deleted file mode 100644 index 0fb7e9ef0..000000000 --- a/power-annotations/scanner/src/test/resources/META-INF/other.properties +++ /dev/null @@ -1,2 +0,0 @@ -# suppress inspection "UnusedProperty" for whole file -something.else = true diff --git a/power-annotations/tck/pom.xml b/power-annotations/tck/pom.xml deleted file mode 100644 index 0a585defd..000000000 --- a/power-annotations/tck/pom.xml +++ /dev/null @@ -1,94 +0,0 @@ - - - 4.0.0 - - - io.smallrye - smallrye-power-annotations-parent - 2.0.0-SNAPSHOT - - - power-annotations-tck - Power Annotations: TCK - Test Compatibility Kit for Power Annotations, i.e. verifies that a Power Annotations implementation complies to the standard. - - - - io.smallrye - power-annotations - ${project.version} - - - - org.junit.jupiter - junit-jupiter - test - - - org.assertj - assertj-core - test - - - org.jboss - jandex - test - - - io.smallrye - smallrye-power-annotations-utils-api - ${project.version} - test - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - !InheritedAnnotationsTestSuite & !TypeToMemberAnnotationsTestSuite - - ${powerannotations.tck.argLine} - - - - - - - - utils-jandex - - true - - - - io.smallrye - smallrye-power-annotations-utils-jandex - ${project.version} - test - - - - - power-jandex-maven-plugin - - - - io.smallrye - power-jandex-maven-plugin - ${project.version} - - - - power-jandex - - - - - - - - - diff --git a/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/AnnotationValueTypeClasses.java b/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/AnnotationValueTypeClasses.java deleted file mode 100644 index d447e41d4..000000000 --- a/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/AnnotationValueTypeClasses.java +++ /dev/null @@ -1,158 +0,0 @@ -package com.github.t1.annotations.tck; - -import static java.lang.annotation.RetentionPolicy.CLASS; -import static java.lang.annotation.RetentionPolicy.RUNTIME; -import static java.lang.annotation.RetentionPolicy.SOURCE; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -public class AnnotationValueTypeClasses { - @Retention(RUNTIME) - public @interface DifferentValueTypesAnnotation { - boolean booleanValue() default false; - - byte byteValue() default 0; - - char charValue() default 0; - - short shortValue() default 0; - - int intValue() default 0; - - long longValue() default 0; - - float floatValue() default 0; - - double doubleValue() default 0; - - String stringValue() default ""; - - RetentionPolicy enumValue() default SOURCE; - - Class classValue() default Void.class; - - SomeAnnotation annotationValue() default @SomeAnnotation(""); - - boolean[] booleanArrayValue() default false; - - byte[] byteArrayValue() default 0; - - char[] charArrayValue() default 0; - - short[] shortArrayValue() default 0; - - int[] intArrayValue() default 0; - - long[] longArrayValue() default 0; - - double[] doubleArrayValue() default 0; - - float[] floatArrayValue() default 0; - - String[] stringArrayValue() default ""; - - RetentionPolicy[] enumArrayValue() default SOURCE; - - Class[] classArrayValue() default Void.class; - - SomeAnnotation[] annotationArrayValue() default @SomeAnnotation(""); - } - - @DifferentValueTypesAnnotation(booleanValue = true) - public static class AnnotatedWithBooleanValueClass { - } - - @DifferentValueTypesAnnotation(byteValue = 1) - public static class AnnotatedWithByteValueClass { - } - - @DifferentValueTypesAnnotation(charValue = 'a') - public static class AnnotatedWithCharValueClass { - } - - @DifferentValueTypesAnnotation(shortValue = 1234) - public static class AnnotatedWithShortValueClass { - } - - @DifferentValueTypesAnnotation(intValue = 42) - public static class AnnotatedWithIntValueClass { - } - - @DifferentValueTypesAnnotation(longValue = 44L) - public static class AnnotatedWithLongValueClass { - } - - @DifferentValueTypesAnnotation(floatValue = 1.2F) - public static class AnnotatedWithFloatValueClass { - } - - @DifferentValueTypesAnnotation(doubleValue = 12.34D) - public static class AnnotatedWithDoubleValueClass { - } - - @DifferentValueTypesAnnotation(stringValue = "foo") - public static class AnnotatedWithStringValueClass { - } - - @DifferentValueTypesAnnotation(enumValue = RUNTIME) - public static class AnnotatedWithEnumValueClass { - } - - @DifferentValueTypesAnnotation(classValue = String.class) - public static class AnnotatedWithClassValueClass { - } - - @DifferentValueTypesAnnotation(annotationValue = @SomeAnnotation("annotation-value")) - public static class AnnotatedWithAnnotationValueClass { - } - - @DifferentValueTypesAnnotation(booleanArrayValue = { true, false }) - public static class AnnotatedWithBooleanArrayValueClass { - } - - @DifferentValueTypesAnnotation(byteArrayValue = { 1, 2 }) - public static class AnnotatedWithByteArrayValueClass { - } - - @DifferentValueTypesAnnotation(charArrayValue = { 'a', 'b' }) - public static class AnnotatedWithCharArrayValueClass { - } - - @DifferentValueTypesAnnotation(shortArrayValue = { 1234, 1235 }) - public static class AnnotatedWithShortArrayValueClass { - } - - @DifferentValueTypesAnnotation(intArrayValue = { 42, 43 }) - public static class AnnotatedWithIntArrayValueClass { - } - - @DifferentValueTypesAnnotation(longArrayValue = { 44L, 45L }) - public static class AnnotatedWithLongArrayValueClass { - } - - @DifferentValueTypesAnnotation(floatArrayValue = { 1.2F, 1.3F }) - public static class AnnotatedWithFloatArrayValueClass { - } - - @DifferentValueTypesAnnotation(doubleArrayValue = { 12.34D, 12.35D }) - public static class AnnotatedWithDoubleArrayValueClass { - } - - @DifferentValueTypesAnnotation(stringArrayValue = { "foo", "bar" }) - public static class AnnotatedWithStringArrayValueClass { - } - - @DifferentValueTypesAnnotation(enumArrayValue = { RUNTIME, CLASS }) - public static class AnnotatedWithEnumArrayValueClass { - } - - @DifferentValueTypesAnnotation(classArrayValue = { String.class, Integer.class }) - public static class AnnotatedWithClassArrayValueClass { - } - - @DifferentValueTypesAnnotation(annotationArrayValue = { @SomeAnnotation("annotation-value1"), - @SomeAnnotation("annotation-value2") }) - public static class AnnotatedWithAnnotationArrayValueClass { - } -} diff --git a/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/CombinedAnnotationClasses.java b/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/CombinedAnnotationClasses.java deleted file mode 100644 index 35659fbdb..000000000 --- a/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/CombinedAnnotationClasses.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.github.t1.annotations.tck; - -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; - -import com.github.t1.annotations.Stereotype; - -public class CombinedAnnotationClasses { - @Stereotype - @SomeAnnotation("from-stereotype") - @Retention(RUNTIME) - public @interface SomeStereotype { - } - - @SomeStereotype - public interface SomeStereotypedInterface { - @SuppressWarnings("unused") - void foo(); - } - - @SomeStereotype - public static class SomeStereotypedClass { - @SuppressWarnings("unused") - public void foo() { - } - } - - @SomeAnnotation("from-sub-interface") - public interface SomeInheritingInterface extends SomeInheritedInterface { - } - - public interface SomeInheritedInterface { - @SuppressWarnings("unused") - void foo(); - } -} diff --git a/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/ContainingTypeClasses.java b/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/ContainingTypeClasses.java deleted file mode 100644 index 906d3ef2f..000000000 --- a/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/ContainingTypeClasses.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.github.t1.annotations.tck; - -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -public class ContainingTypeClasses { - - @Retention(RUNTIME) - public @interface SomeAnnotationWithoutTargetAnnotation { - } - - @Retention(RUNTIME) - @Target(TYPE) - public @interface SomeAnnotationWithOnlyTypeTargetAnnotation { - } - - @SomeAnnotation("class-annotation") - @SomeAnnotationWithoutTargetAnnotation - @SomeAnnotationWithOnlyTypeTargetAnnotation - public static class ClassWithField { - @SuppressWarnings("unused") - String someField; - } - - @RepeatableAnnotation(1) - @RepeatableAnnotation(2) - public static class ClassWithRepeatedAnnotationsForField { - @SuppressWarnings("unused") - String someField; - } - - @RepeatableAnnotation(2) - public static class ClassWithRepeatableAnnotationOnClassAndField { - @RepeatableAnnotation(1) - @SuppressWarnings("unused") - String someField; - } - - @SomeAnnotation("class-annotation") - public static class ClassWithAnnotationsOnClassAndField { - @SuppressWarnings("unused") - @RepeatableAnnotation(1) - String someField; - } - - @SomeAnnotation("class-annotation") - @SomeAnnotationWithoutTargetAnnotation - @SomeAnnotationWithOnlyTypeTargetAnnotation - public static class ClassWithMethod { - @SuppressWarnings("unused") - void someMethod() { - } - } - - @RepeatableAnnotation(1) - @RepeatableAnnotation(2) - public static class ClassWithRepeatedAnnotationsForMethod { - @SuppressWarnings("unused") - void someMethod() { - } - } - - @RepeatableAnnotation(2) - public static class ClassWithRepeatableAnnotationOnClassAndMethod { - @RepeatableAnnotation(1) - @SuppressWarnings("unused") - void someMethod() { - } - } - - @SomeAnnotation("class-annotation") - public static class ClassWithAnnotationsOnClassAndMethod { - @SuppressWarnings("unused") - @RepeatableAnnotation(1) - void someMethod() { - } - } -} diff --git a/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/DirectAnnotationClasses.java b/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/DirectAnnotationClasses.java deleted file mode 100644 index c857a8dd3..000000000 --- a/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/DirectAnnotationClasses.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.github.t1.annotations.tck; - -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; - -import com.github.t1.annotations.tck.MixinClasses.AnotherAnnotation; - -public class DirectAnnotationClasses { - @Retention(RUNTIME) - public @interface SomeAnnotationWithDefaultValue { - String valueWithDefault() default "default-value"; - } - - public static class SomeUnannotatedClass { - } - - @SomeAnnotation("class-annotation") - public static class SomeAnnotatedClass { - } - - @SomeAnnotation("interface-annotation") - @SomeAnnotationWithDefaultValue - public interface SomeAnnotatedInterface { - } - - public static class SomeClassWithUnannotatedField { - @SuppressWarnings("unused") - String foo; - } - - public static class SomeClassWithAnnotatedField { - @SuppressWarnings("unused") - @SomeAnnotation("field-annotation") - private String foo; - } - - public static class SomeClassWithUnannotatedMethod { - @SuppressWarnings("unused") - void foo(String x) { - } - } - - public static class SomeClassWithAnnotatedMethod { - @SuppressWarnings("unused") - @SomeAnnotation("method-annotation") - void foo(String x) { - } - } - - public interface SomeInterfaceWithAnnotatedMethod { - @SomeAnnotation("method-annotation") - void foo(@AnotherAnnotation String x); - } -} diff --git a/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/InheritedAnnotationClasses.java b/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/InheritedAnnotationClasses.java deleted file mode 100644 index dd2e5aa3f..000000000 --- a/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/InheritedAnnotationClasses.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.github.t1.annotations.tck; - -public class InheritedAnnotationClasses { - - @SomeAnnotation("1") - @RepeatableAnnotation(1) - public interface InheritingInterface extends Base, SideBase { - } - - @SomeAnnotation("2") - @RepeatableAnnotation(2) - public static class InheritingClass extends Super implements Base, SideBase { - } - - @SomeAnnotation("3") - @RepeatableAnnotation(3) - public static class Super { - @SomeAnnotation("4") - @RepeatableAnnotation(4) - public String field; - - @SomeAnnotation("5") - @RepeatableAnnotation(5) - public String method() { - return null; - } - } - - @SomeAnnotation("6") - @RepeatableAnnotation(6) - public interface Base extends SuperBase { - @SomeAnnotation("7") - @RepeatableAnnotation(7) - @Override - String method(); - } - - @SomeAnnotation("8") - @RepeatableAnnotation(8) - public interface SideBase { - } - - @SomeAnnotation("9") - @RepeatableAnnotation(9) - public interface SuperBase { - @SomeAnnotation("10") - @RepeatableAnnotation(10) - default String method() { - return null; - } - } -} diff --git a/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/MixinClasses.java b/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/MixinClasses.java deleted file mode 100644 index 12085c483..000000000 --- a/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/MixinClasses.java +++ /dev/null @@ -1,304 +0,0 @@ -package com.github.t1.annotations.tck; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import com.github.t1.annotations.MixinFor; -import com.github.t1.annotations.tck.MixinClasses.TypeAnnotationMixinClasses.SomeAnnotationWithoutValue; - -public class MixinClasses { - @Retention(RUNTIME) - public @interface AnotherAnnotation { - } - - public static class TypeAnnotationMixinClasses { - @Retention(RUNTIME) - public @interface SomeAnnotationWithoutValue { - } - - @SomeAnnotationWithoutValue - @SomeAnnotation("to-be-replaced") - @RepeatableAnnotation(2) - public static class SomeClassWithVariousAnnotations { - } - - @MixinFor(SomeClassWithVariousAnnotations.class) - @AnotherAnnotation - @SomeAnnotation("replacing") - @RepeatableAnnotation(1) - public static class MixinForSomeClassWithVariousAnnotations { - } - - @SomeAnnotationTargetedByMixin - @RepeatableAnnotation(1) - public static class SomeClassWithAnnotationTargetedByMixin { - } - - @Retention(RUNTIME) - @RepeatableAnnotation(3) - public @interface SomeAnnotationTargetedByMixin { - } - - @MixinFor(SomeAnnotationTargetedByMixin.class) - @SomeAnnotation("annotation-mixin") - @RepeatableAnnotation(2) - public static class MixinForAnnotation { - } - - @SomeAnnotationTargetedByMixin - @SomeAnnotation("original") - public static class OriginalAnnotatedTarget { - } - - public static class TargetClassWithTwoMixins { - } - - @MixinFor(TargetClassWithTwoMixins.class) - @SomeAnnotation("one") - static class MixinForTargetClassWithTwoMixins1 { - } - - @MixinFor(TargetClassWithTwoMixins.class) - @RepeatableAnnotation(2) - static class MixinForTargetClassWithTwoMixins2 { - } - - public static class TargetClassWithTwoNonRepeatableMixins { - } - - @MixinFor(TargetClassWithTwoNonRepeatableMixins.class) - @SomeAnnotation("two") - static class MixinForTargetClassWithTwoNonRepeatableMixins1 { - } - - @MixinFor(TargetClassWithTwoNonRepeatableMixins.class) - @SomeAnnotation("three") - static class MixinForTargetClassWithTwoNonRepeatableMixins2 { - } - - public static class TargetClassWithTwoRepeatableMixins { - } - - @MixinFor(TargetClassWithTwoRepeatableMixins.class) - @RepeatableAnnotation(1) - static class MixinForTargetClassWithTwoRepeatableMixins1 { - } - - @MixinFor(TargetClassWithTwoRepeatableMixins.class) - @RepeatableAnnotation(2) - static class MixinForTargetClassWithTwoRepeatableMixins2 { - } - } - - public static class AnnotatedFieldMixinClasses { - public static class SomeClassWithFieldWithVariousAnnotations { - @SuppressWarnings("unused") - @SomeAnnotationWithoutValue - @SomeAnnotation("to-be-replaced") - @RepeatableAnnotation(2) - String foo; - - @SuppressWarnings("unused") - String bar; - } - - @MixinFor(SomeClassWithFieldWithVariousAnnotations.class) - public static class MixinForSomeClassWithFieldWithVariousAnnotations { - @SuppressWarnings("unused") - @AnotherAnnotation - @SomeAnnotation("replacing") - @RepeatableAnnotation(1) - String foo; - } - - public static class TargetFieldClassWithTwoMixins { - @SuppressWarnings("unused") - String foo; - } - - @MixinFor(TargetFieldClassWithTwoMixins.class) - static class MixinForTargetFieldClassWithTwoMixins1 { - @SomeAnnotation("four") - @SuppressWarnings("unused") - String foo; - } - - @MixinFor(TargetFieldClassWithTwoMixins.class) - static class MixinForTargetFieldClassWithTwoMixins2 { - @RepeatableAnnotation(2) - @SuppressWarnings("unused") - String foo; - } - - public static class TargetFieldClassWithTwoNonRepeatableMixins { - @SuppressWarnings("unused") - String foo; - } - - @MixinFor(TargetFieldClassWithTwoNonRepeatableMixins.class) - static class MixinForTargetFieldClassWithTwoNonRepeatableMixins1 { - @SomeAnnotation("five") - @SuppressWarnings("unused") - String foo; - } - - @MixinFor(TargetFieldClassWithTwoNonRepeatableMixins.class) - static class MixinForTargetFieldClassWithTwoNonRepeatableMixins2 { - @SomeAnnotation("six") - @SuppressWarnings("unused") - String foo; - } - - public static class TargetFieldClassWithTwoRepeatableMixins { - @SuppressWarnings("unused") - String foo; - } - - @MixinFor(TargetFieldClassWithTwoRepeatableMixins.class) - static class MixinForTargetFieldClassWithTwoRepeatableMixins1 { - @RepeatableAnnotation(1) - @SuppressWarnings("unused") - String foo; - } - - @MixinFor(TargetFieldClassWithTwoRepeatableMixins.class) - static class MixinForTargetFieldClassWithTwoRepeatableMixins2 { - @RepeatableAnnotation(2) - @SuppressWarnings("unused") - String foo; - } - } - - public static class AnnotatedMethodMixinClasses { - public static class SomeClassWithMethodWithVariousAnnotations { - @SuppressWarnings("unused") - @SomeAnnotationWithoutValue - @SomeAnnotation("to-be-replaced") - @RepeatableAnnotation(2) - String foo() { - return "foo"; - } - - @SuppressWarnings("unused") - String bar() { - return "bar"; - } - } - - @MixinFor(SomeClassWithMethodWithVariousAnnotations.class) - public static class MixinForSomeClassWithMethodWithVariousAnnotations { - @SuppressWarnings("unused") - @AnotherAnnotation - @SomeAnnotation("replacing") - @RepeatableAnnotation(1) - String foo() { - return "foo"; - } - } - - public static class TargetMethodClassWithTwoMixins { - @SuppressWarnings("unused") - String foo() { - return "foo"; - } - } - - @MixinFor(TargetMethodClassWithTwoMixins.class) - static class MixinForTargetMethodClassWithTwoMixins1 { - @SomeAnnotation("seven") - @SuppressWarnings("unused") - String foo() { - return "foo"; - } - } - - @MixinFor(TargetMethodClassWithTwoMixins.class) - static class MixinForTargetMethodClassWithTwoMixins2 { - @RepeatableAnnotation(2) - @SuppressWarnings("unused") - String foo() { - return "foo"; - } - } - - public static class TargetMethodClassWithTwoNonRepeatableMixins { - @SuppressWarnings("unused") - String foo() { - return "foo"; - } - } - - @MixinFor(TargetMethodClassWithTwoNonRepeatableMixins.class) - interface MixinForTargetMethodClassWithTwoNonRepeatableMixins1 { - @SomeAnnotation("eight") - @SuppressWarnings("unused") - String foo(); - } - - @MixinFor(TargetMethodClassWithTwoNonRepeatableMixins.class) - interface MixinTargetMethodClassWithTwoNonRepeatableMixins2 { - @SomeAnnotation("nine") - @SuppressWarnings("unused") - String foo(); - } - - public static class TargetMethodClassWithTwoRepeatableMixins { - @SuppressWarnings("unused") - String foo() { - return "foo"; - } - } - - @MixinFor(TargetMethodClassWithTwoRepeatableMixins.class) - static class MixinForTargetMethodClassWithTwoRepeatableMixins1 { - @RepeatableAnnotation(1) - @SuppressWarnings("unused") - String foo() { - return "foo"; - } - } - - @MixinFor(TargetMethodClassWithTwoRepeatableMixins.class) - static class MixinForTargetMethodClassWithTwoRepeatableMixins2 { - @RepeatableAnnotation(2) - @SuppressWarnings("unused") - String foo() { - return "foo"; - } - } - } - - public static class AnnotationMixinClasses { - public static class ClassWithAnnotationsExtendedByMixIn { - @DirectAnnotation - @SuppressWarnings("unused") - Long field; - - @DirectAnnotation - @SuppressWarnings("unused") - Long method() { - return null; - } - } - - @Target({ METHOD, FIELD }) - @Retention(RUNTIME) - public @interface DirectAnnotation { - } - - @Retention(RUNTIME) - @Target({ ElementType.PARAMETER, FIELD, METHOD, ElementType.ANNOTATION_TYPE, ElementType.TYPE }) - public @interface MixedInAnnotation { - } - - @MixinFor(DirectAnnotation.class) - @MixedInAnnotation - public interface DirectAnnotationMixin { - } - } -} diff --git a/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/RepeatableAnnotation.java b/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/RepeatableAnnotation.java deleted file mode 100644 index b78453193..000000000 --- a/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/RepeatableAnnotation.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.github.t1.annotations.tck; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Repeatable; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import com.github.t1.annotations.tck.RepeatableAnnotation.RepeatableAnnotations; - -@Retention(RUNTIME) -@Target({ TYPE, FIELD, METHOD }) -@Repeatable(RepeatableAnnotations.class) -public @interface RepeatableAnnotation { - int value(); - - @Target({ TYPE, FIELD, METHOD }) - @Retention(RUNTIME) - @interface RepeatableAnnotations { - @SuppressWarnings("unused") - RepeatableAnnotation[] value(); - } -} diff --git a/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/RepeatableAnnotationClasses.java b/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/RepeatableAnnotationClasses.java deleted file mode 100644 index 555a69014..000000000 --- a/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/RepeatableAnnotationClasses.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.github.t1.annotations.tck; - -public class RepeatableAnnotationClasses { - @RepeatableAnnotation(1) - public static class UnrepeatedAnnotationClass { - @RepeatableAnnotation(10) - public String foo; - - @RepeatableAnnotation(20) - public void bar() { - } - } - - @RepeatableAnnotation(1) - @RepeatableAnnotation(2) - public static class RepeatedAnnotationClass { - @RepeatableAnnotation(11) - @RepeatableAnnotation(12) - public String foo; - - @RepeatableAnnotation(21) - @RepeatableAnnotation(22) - public void bar() { - } - } -} diff --git a/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/SomeAnnotation.java b/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/SomeAnnotation.java deleted file mode 100644 index 3c47b99d5..000000000 --- a/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/SomeAnnotation.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.github.t1.annotations.tck; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -@Retention(RUNTIME) -@Target({ TYPE, FIELD, METHOD }) -public @interface SomeAnnotation { - String value(); -} diff --git a/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/StereotypeClasses.java b/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/StereotypeClasses.java deleted file mode 100644 index 7a00a6265..000000000 --- a/power-annotations/tck/src/main/java/com/github/t1/annotations/tck/StereotypeClasses.java +++ /dev/null @@ -1,186 +0,0 @@ -package com.github.t1.annotations.tck; - -import static java.lang.annotation.ElementType.ANNOTATION_TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import com.github.t1.annotations.Stereotype; -import com.github.t1.annotations.tck.MixinClasses.AnotherAnnotation; - -public class StereotypeClasses { - @Retention(RUNTIME) - @Target(ANNOTATION_TYPE) - // i.e. not on TYPE - public @interface SomeMetaAnnotation { - } - - @Stereotype - @Retention(RUNTIME) - @AnotherAnnotation - @SomeAnnotation("from-stereotype") - @RepeatableAnnotation(1) - @RepeatableAnnotation(2) - @SomeMetaAnnotation - public @interface SomeStereotype { - } - - @Stereotype - @Retention(RUNTIME) - @SomeAnnotation("from-another-stereotype") - public @interface AnotherStereotype { - } - - @Stereotype - @Retention(RUNTIME) - @RepeatableAnnotation(1) - public @interface StereotypeWithOne { - } - - @Stereotype - @Retention(RUNTIME) - @RepeatableAnnotation(1) - @RepeatableAnnotation(2) - public @interface StereotypeWithTwo { - } - - @Stereotype - @Retention(RUNTIME) - @RepeatableAnnotation(1) - @RepeatableAnnotation(2) - @RepeatableAnnotation(3) - public @interface StereotypeWithThree { - } - - @Stereotype - @Retention(RUNTIME) - @RepeatableAnnotation(11) - public @interface AnotherStereotypeWithOne { - } - - @Stereotype - @Retention(RUNTIME) - @RepeatableAnnotation(11) - @RepeatableAnnotation(12) - public @interface AnotherStereotypeWithTwo { - } - - @Stereotype - @Retention(RUNTIME) - @SomeStereotype - public @interface SomeIndirectedStereotype { - } - - @Stereotype - @Retention(RUNTIME) - @SomeStereotype - public @interface SomeTardyIndirectedStereotype { - } - - @Stereotype - @Retention(RUNTIME) - @SomeIndirectedStereotype - public @interface SomeDoubleIndirectedStereotype { - } - - @SomeStereotype - @RepeatableAnnotation(5) - public static class StereotypedClass { - } - - @SomeStereotype - @SomeAnnotation("on-class") - public static class StereotypedClassWithSomeAnnotation { - } - - @SomeIndirectedStereotype - public static class IndirectlyStereotypedClass { - } - - @SomeTardyIndirectedStereotype - public static class TardyIndirectlyStereotypedClass { - } - - @SomeDoubleIndirectedStereotype - public static class DoubleIndirectlyStereotypedClass { - } - - @SomeStereotype - @AnotherStereotype - @RepeatableAnnotation(6) - public static class DoubleStereotypedClass { - } - - @StereotypeWithOne - @AnotherStereotypeWithOne - public static class MergeRepeatableAnnotationFromOneAndOne { - } - - @StereotypeWithOne - @AnotherStereotypeWithTwo - public static class MergeRepeatableAnnotationFromOneAndTwo { - } - - @StereotypeWithTwo - @AnotherStereotypeWithOne - public static class MergeRepeatableAnnotationFromTwoAndOne { - } - - @StereotypeWithTwo - @AnotherStereotypeWithTwo - public static class MergeRepeatableAnnotationFromTwoAndTwo { - } - - @StereotypeWithOne - @RepeatableAnnotation(2) - public static class MergeOneRepeatableAnnotationIntoOne { - } - - @StereotypeWithOne - @RepeatableAnnotation(21) - @RepeatableAnnotation(22) - public static class MergeOneRepeatableAnnotationIntoTwo { - } - - @StereotypeWithTwo - @RepeatableAnnotation(21) - public static class MergeTwoRepeatableAnnotationIntoOne { - } - - @StereotypeWithTwo - @RepeatableAnnotation(21) - @RepeatableAnnotation(22) - public static class MergeTwoRepeatableAnnotationIntoTwo { - } - - @StereotypeWithThree - @RepeatableAnnotation(21) - @RepeatableAnnotation(22) - @RepeatableAnnotation(23) - public static class MergeThreeRepeatableAnnotationIntoThree { - } - - @SuppressWarnings("unused") - public static class ClassWithStereotypedField { - @SomeStereotype - @SomeAnnotation("on-field") - @RepeatableAnnotation(7) - String foo; - boolean bar; - } - - @SuppressWarnings("unused") - public static class ClassWithStereotypedMethod { - @SomeStereotype - @SomeAnnotation("on-method") - @RepeatableAnnotation(7) - String foo() { - return "foo"; - } - - String bar() { - return "bar"; - } - } -} diff --git a/power-annotations/tck/src/test/java/test/AnnotationValueTypeBehavior.java b/power-annotations/tck/src/test/java/test/AnnotationValueTypeBehavior.java deleted file mode 100644 index 1a5588a12..000000000 --- a/power-annotations/tck/src/test/java/test/AnnotationValueTypeBehavior.java +++ /dev/null @@ -1,222 +0,0 @@ -package test; - -import static java.lang.annotation.RetentionPolicy.CLASS; -import static java.lang.annotation.RetentionPolicy.RUNTIME; -import static org.assertj.core.api.BDDAssertions.then; - -import java.util.Optional; -import java.util.stream.Stream; - -import org.junit.jupiter.api.Test; - -import com.github.t1.annotations.Annotations; -import com.github.t1.annotations.tck.AnnotationValueTypeClasses.AnnotatedWithAnnotationArrayValueClass; -import com.github.t1.annotations.tck.AnnotationValueTypeClasses.AnnotatedWithAnnotationValueClass; -import com.github.t1.annotations.tck.AnnotationValueTypeClasses.AnnotatedWithBooleanArrayValueClass; -import com.github.t1.annotations.tck.AnnotationValueTypeClasses.AnnotatedWithBooleanValueClass; -import com.github.t1.annotations.tck.AnnotationValueTypeClasses.AnnotatedWithByteArrayValueClass; -import com.github.t1.annotations.tck.AnnotationValueTypeClasses.AnnotatedWithByteValueClass; -import com.github.t1.annotations.tck.AnnotationValueTypeClasses.AnnotatedWithCharArrayValueClass; -import com.github.t1.annotations.tck.AnnotationValueTypeClasses.AnnotatedWithCharValueClass; -import com.github.t1.annotations.tck.AnnotationValueTypeClasses.AnnotatedWithClassArrayValueClass; -import com.github.t1.annotations.tck.AnnotationValueTypeClasses.AnnotatedWithClassValueClass; -import com.github.t1.annotations.tck.AnnotationValueTypeClasses.AnnotatedWithDoubleArrayValueClass; -import com.github.t1.annotations.tck.AnnotationValueTypeClasses.AnnotatedWithDoubleValueClass; -import com.github.t1.annotations.tck.AnnotationValueTypeClasses.AnnotatedWithEnumArrayValueClass; -import com.github.t1.annotations.tck.AnnotationValueTypeClasses.AnnotatedWithEnumValueClass; -import com.github.t1.annotations.tck.AnnotationValueTypeClasses.AnnotatedWithFloatArrayValueClass; -import com.github.t1.annotations.tck.AnnotationValueTypeClasses.AnnotatedWithFloatValueClass; -import com.github.t1.annotations.tck.AnnotationValueTypeClasses.AnnotatedWithIntArrayValueClass; -import com.github.t1.annotations.tck.AnnotationValueTypeClasses.AnnotatedWithIntValueClass; -import com.github.t1.annotations.tck.AnnotationValueTypeClasses.AnnotatedWithLongArrayValueClass; -import com.github.t1.annotations.tck.AnnotationValueTypeClasses.AnnotatedWithLongValueClass; -import com.github.t1.annotations.tck.AnnotationValueTypeClasses.AnnotatedWithShortArrayValueClass; -import com.github.t1.annotations.tck.AnnotationValueTypeClasses.AnnotatedWithShortValueClass; -import com.github.t1.annotations.tck.AnnotationValueTypeClasses.AnnotatedWithStringArrayValueClass; -import com.github.t1.annotations.tck.AnnotationValueTypeClasses.AnnotatedWithStringValueClass; -import com.github.t1.annotations.tck.AnnotationValueTypeClasses.DifferentValueTypesAnnotation; -import com.github.t1.annotations.tck.SomeAnnotation; - -class AnnotationValueTypeBehavior { - - @Test - void shouldGetBooleanAnnotationValue() { - DifferentValueTypesAnnotation annotation = getDifferentValueTypesAnnotation(AnnotatedWithBooleanValueClass.class); - - then(annotation.booleanValue()).isTrue(); - } - - @Test - void shouldGetByteAnnotationValue() { - DifferentValueTypesAnnotation annotation = getDifferentValueTypesAnnotation(AnnotatedWithByteValueClass.class); - - then(annotation.byteValue()).isEqualTo((byte) 1); - } - - @Test - void shouldGetCharAnnotationValue() { - DifferentValueTypesAnnotation annotation = getDifferentValueTypesAnnotation(AnnotatedWithCharValueClass.class); - - then(annotation.charValue()).isEqualTo('a'); - } - - @Test - void shouldGetShortAnnotationValue() { - DifferentValueTypesAnnotation annotation = getDifferentValueTypesAnnotation(AnnotatedWithShortValueClass.class); - - then(annotation.shortValue()).isEqualTo((short) 1234); - } - - @Test - void shouldGetIntAnnotationValue() { - DifferentValueTypesAnnotation annotation = getDifferentValueTypesAnnotation(AnnotatedWithIntValueClass.class); - - then(annotation.intValue()).isEqualTo(42); - } - - @Test - void shouldGetLongAnnotationValue() { - DifferentValueTypesAnnotation annotation = getDifferentValueTypesAnnotation(AnnotatedWithLongValueClass.class); - - then(annotation.longValue()).isEqualTo(44L); - } - - @Test - void shouldGetFloatAnnotationValue() { - DifferentValueTypesAnnotation annotation = getDifferentValueTypesAnnotation(AnnotatedWithFloatValueClass.class); - - then(annotation.floatValue()).isEqualTo(1.2F); - } - - @Test - void shouldGetDoubleAnnotationValue() { - DifferentValueTypesAnnotation annotation = getDifferentValueTypesAnnotation(AnnotatedWithDoubleValueClass.class); - - then(annotation.doubleValue()).isEqualTo(12.34); - } - - @Test - void shouldGetStringAnnotationValue() { - DifferentValueTypesAnnotation annotation = getDifferentValueTypesAnnotation(AnnotatedWithStringValueClass.class); - - then(annotation.stringValue()).isEqualTo("foo"); - } - - @Test - void shouldGetEnumAnnotationValue() { - DifferentValueTypesAnnotation annotation = getDifferentValueTypesAnnotation(AnnotatedWithEnumValueClass.class); - - then(annotation.enumValue()).isEqualTo(RUNTIME); - } - - @Test - void shouldGetClassAnnotationValue() { - DifferentValueTypesAnnotation annotation = getDifferentValueTypesAnnotation(AnnotatedWithClassValueClass.class); - - then(annotation.classValue()).isEqualTo(String.class); - } - - @Test - void shouldGetAnnotationAnnotationValue() { - DifferentValueTypesAnnotation annotation = getDifferentValueTypesAnnotation(AnnotatedWithAnnotationValueClass.class); - - then(annotation.annotationValue().value()).isEqualTo("annotation-value"); - } - - @Test - void shouldGetBooleanArrayAnnotationValue() { - DifferentValueTypesAnnotation annotation = getDifferentValueTypesAnnotation(AnnotatedWithBooleanArrayValueClass.class); - - then(annotation.booleanArrayValue()).contains(true, false); - } - - @Test - void shouldGetByteArrayAnnotationValue() { - DifferentValueTypesAnnotation annotation = getDifferentValueTypesAnnotation(AnnotatedWithByteArrayValueClass.class); - - then(annotation.byteArrayValue()).containsExactly((byte) 1, (byte) 2); - } - - @Test - void shouldGetCharArrayAnnotationValue() { - DifferentValueTypesAnnotation annotation = getDifferentValueTypesAnnotation(AnnotatedWithCharArrayValueClass.class); - - then(annotation.charArrayValue()).containsExactly('a', 'b'); - } - - @Test - void shouldGetShortArrayAnnotationValue() { - DifferentValueTypesAnnotation annotation = getDifferentValueTypesAnnotation(AnnotatedWithShortArrayValueClass.class); - - then(annotation.shortArrayValue()).containsExactly((short) 1234, (short) 1235); - } - - @Test - void shouldGetIntArrayAnnotationValue() { - DifferentValueTypesAnnotation annotation = getDifferentValueTypesAnnotation(AnnotatedWithIntArrayValueClass.class); - - then(annotation.intArrayValue()).containsExactly(42, 43); - } - - @Test - void shouldGetLongArrayAnnotationValue() { - DifferentValueTypesAnnotation annotation = getDifferentValueTypesAnnotation(AnnotatedWithLongArrayValueClass.class); - - then(annotation.longArrayValue()).containsExactly(44L, 45L); - } - - @Test - void shouldGetFloatArrayAnnotationValue() { - DifferentValueTypesAnnotation annotation = getDifferentValueTypesAnnotation(AnnotatedWithFloatArrayValueClass.class); - - then(annotation.floatArrayValue()).containsExactly(1.2F, 1.3F); - } - - @Test - void shouldGetDoubleArrayAnnotationValue() { - DifferentValueTypesAnnotation annotation = getDifferentValueTypesAnnotation(AnnotatedWithDoubleArrayValueClass.class); - - then(annotation.doubleArrayValue()).containsExactly(12.34, 12.35); - } - - @Test - void shouldGetStringArrayAnnotationValue() { - DifferentValueTypesAnnotation annotation = getDifferentValueTypesAnnotation(AnnotatedWithStringArrayValueClass.class); - - then(annotation.stringArrayValue()).containsExactly("foo", "bar"); - } - - @Test - void shouldGetEnumArrayAnnotationValue() { - DifferentValueTypesAnnotation annotation = getDifferentValueTypesAnnotation(AnnotatedWithEnumArrayValueClass.class); - - then(annotation.enumArrayValue()).containsExactly(RUNTIME, CLASS); - } - - @Test - void shouldGetClassArrayAnnotationValue() { - DifferentValueTypesAnnotation annotation = getDifferentValueTypesAnnotation(AnnotatedWithClassArrayValueClass.class); - - then(annotation.classArrayValue()).containsExactly(String.class, Integer.class); - } - - @Test - void shouldGetAnnotationArrayAnnotationValue() { - DifferentValueTypesAnnotation annotation = getDifferentValueTypesAnnotation( - AnnotatedWithAnnotationArrayValueClass.class); - - then(Stream.of(annotation.annotationArrayValue()).map(SomeAnnotation::value)) - .containsExactly("annotation-value1", "annotation-value2"); - } - - private DifferentValueTypesAnnotation getDifferentValueTypesAnnotation(Class type) { - Annotations annotations = Annotations.on(type); - - Optional annotation = annotations.get(DifferentValueTypesAnnotation.class); - - assert annotation.isPresent(); - DifferentValueTypesAnnotation someAnnotation = annotation.get(); - then(someAnnotation.annotationType()).isEqualTo(DifferentValueTypesAnnotation.class); - return someAnnotation; - } -} diff --git a/power-annotations/tck/src/test/java/test/CombinedBehavior.java b/power-annotations/tck/src/test/java/test/CombinedBehavior.java deleted file mode 100644 index 84e4becef..000000000 --- a/power-annotations/tck/src/test/java/test/CombinedBehavior.java +++ /dev/null @@ -1,47 +0,0 @@ -package test; - -import static org.assertj.core.api.BDDAssertions.then; - -import java.lang.annotation.Annotation; -import java.util.stream.Stream; - -import org.junit.jupiter.api.Test; - -import com.github.t1.annotations.Annotations; -import com.github.t1.annotations.tck.CombinedAnnotationClasses.SomeInheritingInterface; -import com.github.t1.annotations.tck.CombinedAnnotationClasses.SomeStereotypedClass; -import com.github.t1.annotations.tck.CombinedAnnotationClasses.SomeStereotypedInterface; -import com.github.t1.annotations.tck.SomeAnnotation; - -@TypeToMemberAnnotationsTestSuite -public class CombinedBehavior { - @Test - void shouldResolveInterfaceStereotypesBeforeTypeToMember() { - Annotations fooAnnotations = Annotations.onMethod(SomeStereotypedInterface.class, "foo"); - - Stream all = fooAnnotations.all(); - - then(all.map(Object::toString)).containsExactlyInAnyOrder( - "@" + SomeAnnotation.class.getName() + "(value = \"from-stereotype\")"); - } - - @Test - void shouldResolveClassStereotypesBeforeTypeToMember() { - Annotations fooAnnotations = Annotations.onMethod(SomeStereotypedClass.class, "foo"); - - Stream all = fooAnnotations.all(); - - then(all.map(Object::toString)).containsExactlyInAnyOrder( - "@" + SomeAnnotation.class.getName() + "(value = \"from-stereotype\")"); - } - - @Test - void shouldResolveInterfaceInheritedBeforeTypeToMember() { - Annotations fooAnnotations = Annotations.onMethod(SomeInheritingInterface.class, "foo"); - - Stream all = fooAnnotations.all(); - - then(all.map(Object::toString)).containsExactlyInAnyOrder( - "@" + SomeAnnotation.class.getName() + "(value = \"from-sub-interface\")"); - } -} diff --git a/power-annotations/tck/src/test/java/test/ContainingTypeBehavior.java b/power-annotations/tck/src/test/java/test/ContainingTypeBehavior.java deleted file mode 100644 index 7810b9891..000000000 --- a/power-annotations/tck/src/test/java/test/ContainingTypeBehavior.java +++ /dev/null @@ -1,159 +0,0 @@ -package test; - -import static org.assertj.core.api.BDDAssertions.then; - -import java.lang.annotation.Annotation; -import java.util.Optional; -import java.util.stream.Stream; - -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; - -import com.github.t1.annotations.Annotations; -import com.github.t1.annotations.tck.ContainingTypeClasses.ClassWithAnnotationsOnClassAndField; -import com.github.t1.annotations.tck.ContainingTypeClasses.ClassWithAnnotationsOnClassAndMethod; -import com.github.t1.annotations.tck.ContainingTypeClasses.ClassWithField; -import com.github.t1.annotations.tck.ContainingTypeClasses.ClassWithMethod; -import com.github.t1.annotations.tck.ContainingTypeClasses.ClassWithRepeatableAnnotationOnClassAndField; -import com.github.t1.annotations.tck.ContainingTypeClasses.ClassWithRepeatableAnnotationOnClassAndMethod; -import com.github.t1.annotations.tck.ContainingTypeClasses.ClassWithRepeatedAnnotationsForField; -import com.github.t1.annotations.tck.ContainingTypeClasses.ClassWithRepeatedAnnotationsForMethod; -import com.github.t1.annotations.tck.ContainingTypeClasses.SomeAnnotationWithOnlyTypeTargetAnnotation; -import com.github.t1.annotations.tck.ContainingTypeClasses.SomeAnnotationWithoutTargetAnnotation; -import com.github.t1.annotations.tck.RepeatableAnnotation; -import com.github.t1.annotations.tck.SomeAnnotation; - -@TypeToMemberAnnotationsTestSuite -public class ContainingTypeBehavior { - @Nested - class FieldAnnotations { - Annotations fieldAnnotations = Annotations.onField(ClassWithField.class, "someField"); - - @Test - void shouldGetFieldAnnotationFromClass() { - Optional annotation = fieldAnnotations.get(SomeAnnotation.class); - - assert annotation.isPresent(); - then(annotation.get().value()).isEqualTo("class-annotation"); - } - - @Test - void shouldNotGetFieldAnnotationWithoutTargetAnnotationFromClass() { - Optional annotation = fieldAnnotations - .get(SomeAnnotationWithoutTargetAnnotation.class); - - then(annotation).isEmpty(); - } - - @Test - void shouldNotGetFieldAnnotationWithOnlyTypeTargetAnnotationFromClass() { - Optional annotation = fieldAnnotations - .get(SomeAnnotationWithOnlyTypeTargetAnnotation.class); - - then(annotation).isEmpty(); - } - - @Test - void shouldNotGetAllFieldAnnotationFromClass() { - Optional annotation = fieldAnnotations.get(SomeAnnotation.class); - - assert annotation.isPresent(); - then(annotation.get().value()).isEqualTo("class-annotation"); - } - - @Test - void shouldGetRepeatableFieldAnnotationFromClass() { - Annotations annotations = Annotations.onField(ClassWithRepeatedAnnotationsForField.class, "someField"); - - Stream annotation = annotations.all(RepeatableAnnotation.class); - - then(annotation.map(RepeatableAnnotation::value)).containsExactly(1, 2); - } - - @Test - void shouldGetMoreRepeatableFieldAnnotationsFromClass() { - Annotations annotations = Annotations.onField(ClassWithRepeatableAnnotationOnClassAndField.class, "someField"); - - Stream annotation = annotations.all(RepeatableAnnotation.class); - - then(annotation.map(RepeatableAnnotation::value)).containsExactly(1, 2); - } - - @Test - void shouldOnlyGetAllFieldAnnotationAndNotFromClass() { - Annotations annotations = Annotations.onField(ClassWithAnnotationsOnClassAndField.class, "someField"); - - Stream list = annotations.all(); - - then(list.map(Object::toString)).containsExactlyInAnyOrder( - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + SomeAnnotation.class.getName() + "(value = \"class-annotation\")"); - } - } - - @Nested - class MethodAnnotations { - Annotations methodAnnotations = Annotations.onMethod(ClassWithMethod.class, "someMethod"); - - @Test - void shouldGetMethodAnnotationFromClass() { - Optional annotation = methodAnnotations.get(SomeAnnotation.class); - - assert annotation.isPresent(); - then(annotation.get().value()).isEqualTo("class-annotation"); - } - - @Test - void shouldNotGetMethodAnnotationWithoutTargetAnnotationFromClass() { - Optional annotation = methodAnnotations - .get(SomeAnnotationWithoutTargetAnnotation.class); - - then(annotation).isEmpty(); - } - - @Test - void shouldNotGetMethodAnnotationWithOnlyTypeTargetAnnotationFromClass() { - Optional annotation = methodAnnotations - .get(SomeAnnotationWithOnlyTypeTargetAnnotation.class); - - then(annotation).isEmpty(); - } - - @Test - void shouldNotGetAllMethodAnnotationFromClass() { - Optional annotation = methodAnnotations.get(SomeAnnotation.class); - - assert annotation.isPresent(); - then(annotation.get().value()).isEqualTo("class-annotation"); - } - - @Test - void shouldGetRepeatableMethodAnnotationFromClass() { - Annotations annotations = Annotations.onMethod(ClassWithRepeatedAnnotationsForMethod.class, "someMethod"); - - Stream annotation = annotations.all(RepeatableAnnotation.class); - - then(annotation.map(RepeatableAnnotation::value)).containsExactly(1, 2); - } - - @Test - void shouldGetMoreRepeatableMethodAnnotationsFromClass() { - Annotations annotations = Annotations.onMethod(ClassWithRepeatableAnnotationOnClassAndMethod.class, "someMethod"); - - Stream annotation = annotations.all(RepeatableAnnotation.class); - - then(annotation.map(RepeatableAnnotation::value)).containsExactly(1, 2); - } - - @Test - void shouldGetAllMethodAndClassAnnotations() { - Annotations annotations = Annotations.onMethod(ClassWithAnnotationsOnClassAndMethod.class, "someMethod"); - - Stream list = annotations.all(); - - then(list.map(Object::toString)).containsExactlyInAnyOrder( - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + SomeAnnotation.class.getName() + "(value = \"class-annotation\")"); - } - } -} diff --git a/power-annotations/tck/src/test/java/test/DirectAnnotationsBehavior.java b/power-annotations/tck/src/test/java/test/DirectAnnotationsBehavior.java deleted file mode 100644 index 0b1383765..000000000 --- a/power-annotations/tck/src/test/java/test/DirectAnnotationsBehavior.java +++ /dev/null @@ -1,206 +0,0 @@ -package test; - -import static org.assertj.core.api.Assertions.catchThrowable; -import static org.assertj.core.api.BDDAssertions.then; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.util.Optional; -import java.util.stream.Stream; - -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; - -import com.github.t1.annotations.Annotations; -import com.github.t1.annotations.tck.DirectAnnotationClasses.SomeAnnotatedClass; -import com.github.t1.annotations.tck.DirectAnnotationClasses.SomeAnnotatedInterface; -import com.github.t1.annotations.tck.DirectAnnotationClasses.SomeAnnotationWithDefaultValue; -import com.github.t1.annotations.tck.DirectAnnotationClasses.SomeClassWithAnnotatedField; -import com.github.t1.annotations.tck.DirectAnnotationClasses.SomeClassWithAnnotatedMethod; -import com.github.t1.annotations.tck.DirectAnnotationClasses.SomeClassWithUnannotatedField; -import com.github.t1.annotations.tck.DirectAnnotationClasses.SomeClassWithUnannotatedMethod; -import com.github.t1.annotations.tck.DirectAnnotationClasses.SomeInterfaceWithAnnotatedMethod; -import com.github.t1.annotations.tck.DirectAnnotationClasses.SomeUnannotatedClass; -import com.github.t1.annotations.tck.MixinClasses.AnotherAnnotation; -import com.github.t1.annotations.tck.SomeAnnotation; - -public class DirectAnnotationsBehavior { - - @Nested - class ClassAnnotations { - @Test - void shouldGetNoClassAnnotation() { - Annotations annotations = Annotations.on(SomeUnannotatedClass.class); - - thenEmpty(annotations); - } - - @Test - void shouldGetClassAnnotation() { - Annotations annotations = Annotations.on(SomeAnnotatedClass.class); - - Optional annotation = annotations.get(SomeAnnotation.class); - - thenIsSomeAnnotation(annotation, "class-annotation"); - } - - @Test - void shouldGetInterfaceAnnotation() { - Annotations annotations = Annotations.on(SomeAnnotatedInterface.class); - - Optional annotation = annotations.get(SomeAnnotation.class); - - thenIsSomeAnnotation(annotation, "interface-annotation"); - } - - @Test - void shouldGetDefaultValueOfClassAnnotation() { - Annotations annotations = Annotations.on(SomeAnnotatedInterface.class); - - Optional annotation = annotations.get(SomeAnnotationWithDefaultValue.class); - - assert annotation.isPresent(); - SomeAnnotationWithDefaultValue someAnnotation = annotation.get(); - then(someAnnotation.annotationType()).isEqualTo(SomeAnnotationWithDefaultValue.class); - then(someAnnotation.valueWithDefault()).isEqualTo("default-value"); - then(someAnnotation).isNotSameAs(SomeAnnotatedInterface.class.getAnnotation(SomeAnnotation.class)); - } - - @Test - void shouldGetAllTypeAnnotations() { - Annotations annotations = Annotations.on(SomeAnnotatedInterface.class); - - Stream list = annotations.all(); - - then(list.map(Object::toString)).containsExactlyInAnyOrder( - "@" + SomeAnnotationWithDefaultValue.class.getName(), - "@" + SomeAnnotation.class.getName() + "(value = \"interface-annotation\")"); - } - } - - @Nested - class FieldAnnotations { - @Test - void shouldGetNoFieldAnnotation() { - Annotations annotations = Annotations.onField(SomeClassWithUnannotatedField.class, "foo"); - - thenEmpty(annotations); - } - - @Test - void shouldFailToGetUnknownFieldAnnotation() { - Throwable throwable = catchThrowable(() -> Annotations.onField(SomeClassWithAnnotatedField.class, "bar")); - - then(throwable) - .isInstanceOf(RuntimeException.class) - .hasMessage("no field 'bar' in " + SomeClassWithAnnotatedField.class); // implementation detail? - } - - @Test - void shouldGetFieldAnnotation() { - Annotations annotations = Annotations.onField(SomeClassWithAnnotatedField.class, "foo"); - - Optional annotation = annotations.get(SomeAnnotation.class); - - thenIsSomeAnnotation(annotation, "field-annotation"); - } - } - - @Nested - class MethodAnnotations { - @Test - void shouldGetNoMethodAnnotation() { - Annotations annotations = Annotations.onMethod(SomeClassWithUnannotatedMethod.class, "foo", String.class); - - thenEmpty(annotations); - } - - @Test - void shouldGetMethodAnnotation() { - Annotations annotations = Annotations.onMethod(SomeClassWithAnnotatedMethod.class, "foo", String.class); - - Optional annotation = annotations.get(SomeAnnotation.class); - - thenIsSomeAnnotation(annotation, "method-annotation"); - } - - @Test - void shouldGetInterfaceMethodAnnotation() { - Annotations annotations = Annotations.onMethod(SomeInterfaceWithAnnotatedMethod.class, "foo", String.class); - - Optional annotation = annotations.get(SomeAnnotation.class); - - thenIsSomeAnnotation(annotation, "method-annotation"); - } - - @Test - void shouldGetAllMethodAnnotations() throws NoSuchMethodException { - Annotations annotations = Annotations.onMethod(SomeInterfaceWithAnnotatedMethod.class, "foo", String.class); - - Stream all = annotations.all(); - - // the parameter annotation must be there, but not represented as method annotation - then(fooMethod().getParameterAnnotations()[0][0].toString()) - .startsWith("@" + AnotherAnnotation.class.getName()); // `since` and `forRemoval` are JDK 9+ - then(all.map(Object::toString)).containsExactlyInAnyOrder( - "@" + SomeAnnotation.class.getName() + "(value = \"method-annotation\")"); - } - - private Method fooMethod() throws NoSuchMethodException { - return SomeInterfaceWithAnnotatedMethod.class.getDeclaredMethod("foo", String.class); - } - - @Test - void shouldFailToGetAnnotationsFromUnknownMethodName() { - Throwable throwable = catchThrowable( - () -> Annotations.onMethod(SomeClassWithAnnotatedMethod.class, "bar", String.class)); - - then(throwable) - .isInstanceOf(RuntimeException.class) - .hasMessage("no method bar(java.lang.String) in " + SomeClassWithAnnotatedMethod.class); // implementation detail? - } - - @Test - void shouldFailToGetAnnotationsFromMethodWithTooManyArguments() { - Throwable throwable = catchThrowable(() -> Annotations.onMethod(SomeClassWithAnnotatedMethod.class, "foo")); - - then(throwable) - .isInstanceOf(RuntimeException.class) - .hasMessage("no method foo() in " + SomeClassWithAnnotatedMethod.class); // implementation detail? - } - - @Test - void shouldFailToGetAnnotationsFromMethodWithTooFewArguments() { - Throwable throwable = catchThrowable( - () -> Annotations.onMethod(SomeClassWithAnnotatedMethod.class, "foo", String.class, int.class)); - - then(throwable) - .isInstanceOf(RuntimeException.class) - .hasMessage("no method foo(java.lang.String, int) in " + SomeClassWithAnnotatedMethod.class); // implementation detail? - } - - @Test - void shouldFailToGetAnnotationsFromMethodWithWrongArgumentType() { - Throwable throwable = catchThrowable( - () -> Annotations.onMethod(SomeClassWithAnnotatedMethod.class, "foo", int.class)); - - then(throwable) - .isInstanceOf(RuntimeException.class) - .hasMessage("no method foo(int) in " + SomeClassWithAnnotatedMethod.class); // implementation detail? - } - } - - void thenEmpty(Annotations annotations) { - then(annotations.all()).isEmpty(); - then(annotations.get(SomeAnnotation.class)).isEmpty(); - } - - void thenIsSomeAnnotation( - @SuppressWarnings("OptionalUsedAsFieldOrParameterType") Optional annotation, - String expectedValue) { - assert annotation.isPresent(); - SomeAnnotation someAnnotation = annotation.get(); - then(someAnnotation.annotationType()).isEqualTo(SomeAnnotation.class); - then(someAnnotation.value()).isEqualTo(expectedValue); - } -} diff --git a/power-annotations/tck/src/test/java/test/InheritedAnnotationsTestSuite.java b/power-annotations/tck/src/test/java/test/InheritedAnnotationsTestSuite.java deleted file mode 100644 index e77a3c187..000000000 --- a/power-annotations/tck/src/test/java/test/InheritedAnnotationsTestSuite.java +++ /dev/null @@ -1,12 +0,0 @@ -package test; - -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; - -import org.junit.jupiter.api.Tag; - -@Tag("InheritedAnnotationsTestSuite") -@Retention(RUNTIME) -public @interface InheritedAnnotationsTestSuite { -} diff --git a/power-annotations/tck/src/test/java/test/InheritedBehavior.java b/power-annotations/tck/src/test/java/test/InheritedBehavior.java deleted file mode 100644 index 654074dcf..000000000 --- a/power-annotations/tck/src/test/java/test/InheritedBehavior.java +++ /dev/null @@ -1,95 +0,0 @@ -package test; - -import static org.assertj.core.api.BDDAssertions.then; - -import java.lang.annotation.Annotation; -import java.util.stream.Stream; - -import org.junit.jupiter.api.Test; - -import com.github.t1.annotations.Annotations; -import com.github.t1.annotations.tck.InheritedAnnotationClasses.InheritingClass; -import com.github.t1.annotations.tck.InheritedAnnotationClasses.InheritingInterface; -import com.github.t1.annotations.tck.RepeatableAnnotation; -import com.github.t1.annotations.tck.SomeAnnotation; - -@InheritedAnnotationsTestSuite -public class InheritedBehavior { - - @Test - void shouldGetAllOnInterface() { - Annotations annotations = Annotations.on(InheritingInterface.class); - - Stream all = annotations.all(); - - then(all.map(Object::toString)).containsExactlyInAnyOrder( - "@" + SomeAnnotation.class.getName() + "(value = \"1\")", - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + RepeatableAnnotation.class.getName() + "(value = 6)", - "@" + RepeatableAnnotation.class.getName() + "(value = 8)", - "@" + RepeatableAnnotation.class.getName() + "(value = 9)"); - } - - @Test - void shouldGetAllOnInterfaceMethod() { - Annotations annotations = Annotations.onMethod(InheritingInterface.class, "method"); - - Stream all = annotations.all(); - - then(all.map(Object::toString)).containsExactlyInAnyOrder( - "@" + SomeAnnotation.class.getName() + "(value = \"10\")", - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + RepeatableAnnotation.class.getName() + "(value = 6)", - "@" + RepeatableAnnotation.class.getName() + "(value = 8)", - "@" + RepeatableAnnotation.class.getName() + "(value = 9)", - "@" + RepeatableAnnotation.class.getName() + "(value = 10)"); - } - - @Test - void shouldGetAllOnClass() { - Annotations annotations = Annotations.on(InheritingClass.class); - - Stream all = annotations.all(); - - then(all.map(Object::toString)).containsExactlyInAnyOrder( - "@" + SomeAnnotation.class.getName() + "(value = \"2\")", - "@" + RepeatableAnnotation.class.getName() + "(value = 2)", - "@" + RepeatableAnnotation.class.getName() + "(value = 3)", - "@" + RepeatableAnnotation.class.getName() + "(value = 6)", - "@" + RepeatableAnnotation.class.getName() + "(value = 8)", - "@" + RepeatableAnnotation.class.getName() + "(value = 9)"); - } - - @Test - void shouldGetAllOnField() { - Annotations annotations = Annotations.onField(InheritingClass.class, "field"); - - Stream all = annotations.all(); - - then(all.map(Object::toString)).containsExactlyInAnyOrder( - "@" + SomeAnnotation.class.getName() + "(value = \"4\")", - "@" + RepeatableAnnotation.class.getName() + "(value = 2)", - "@" + RepeatableAnnotation.class.getName() + "(value = 3)", - "@" + RepeatableAnnotation.class.getName() + "(value = 4)", - "@" + RepeatableAnnotation.class.getName() + "(value = 6)", - "@" + RepeatableAnnotation.class.getName() + "(value = 8)", - "@" + RepeatableAnnotation.class.getName() + "(value = 9)"); - } - - @Test - void shouldGetAllOnClassMethod() { - Annotations annotations = Annotations.onMethod(InheritingClass.class, "method"); - - Stream all = annotations.all(); - - then(all.map(Object::toString)).containsExactlyInAnyOrder( - "@" + SomeAnnotation.class.getName() + "(value = \"5\")", - "@" + RepeatableAnnotation.class.getName() + "(value = 2)", - "@" + RepeatableAnnotation.class.getName() + "(value = 3)", - "@" + RepeatableAnnotation.class.getName() + "(value = 5)", - "@" + RepeatableAnnotation.class.getName() + "(value = 6)", - "@" + RepeatableAnnotation.class.getName() + "(value = 8)", - "@" + RepeatableAnnotation.class.getName() + "(value = 10)", - "@" + RepeatableAnnotation.class.getName() + "(value = 9)"); - } -} diff --git a/power-annotations/tck/src/test/java/test/MixinBehavior.java b/power-annotations/tck/src/test/java/test/MixinBehavior.java deleted file mode 100644 index 07037db29..000000000 --- a/power-annotations/tck/src/test/java/test/MixinBehavior.java +++ /dev/null @@ -1,380 +0,0 @@ -package test; - -import static org.assertj.core.api.Assertions.catchThrowable; -import static org.assertj.core.api.BDDAssertions.then; - -import java.lang.annotation.Annotation; -import java.util.Optional; -import java.util.stream.Stream; - -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; - -import com.github.t1.annotations.AmbiguousAnnotationResolutionException; -import com.github.t1.annotations.Annotations; -import com.github.t1.annotations.tck.MixinClasses.AnnotatedFieldMixinClasses.SomeClassWithFieldWithVariousAnnotations; -import com.github.t1.annotations.tck.MixinClasses.AnnotatedFieldMixinClasses.TargetFieldClassWithTwoMixins; -import com.github.t1.annotations.tck.MixinClasses.AnnotatedFieldMixinClasses.TargetFieldClassWithTwoNonRepeatableMixins; -import com.github.t1.annotations.tck.MixinClasses.AnnotatedFieldMixinClasses.TargetFieldClassWithTwoRepeatableMixins; -import com.github.t1.annotations.tck.MixinClasses.AnnotatedMethodMixinClasses.SomeClassWithMethodWithVariousAnnotations; -import com.github.t1.annotations.tck.MixinClasses.AnnotatedMethodMixinClasses.TargetMethodClassWithTwoMixins; -import com.github.t1.annotations.tck.MixinClasses.AnnotatedMethodMixinClasses.TargetMethodClassWithTwoNonRepeatableMixins; -import com.github.t1.annotations.tck.MixinClasses.AnnotatedMethodMixinClasses.TargetMethodClassWithTwoRepeatableMixins; -import com.github.t1.annotations.tck.MixinClasses.AnnotationMixinClasses.ClassWithAnnotationsExtendedByMixIn; -import com.github.t1.annotations.tck.MixinClasses.AnnotationMixinClasses.DirectAnnotation; -import com.github.t1.annotations.tck.MixinClasses.AnnotationMixinClasses.MixedInAnnotation; -import com.github.t1.annotations.tck.MixinClasses.AnotherAnnotation; -import com.github.t1.annotations.tck.MixinClasses.TypeAnnotationMixinClasses.OriginalAnnotatedTarget; -import com.github.t1.annotations.tck.MixinClasses.TypeAnnotationMixinClasses.SomeAnnotationTargetedByMixin; -import com.github.t1.annotations.tck.MixinClasses.TypeAnnotationMixinClasses.SomeAnnotationWithoutValue; -import com.github.t1.annotations.tck.MixinClasses.TypeAnnotationMixinClasses.SomeClassWithAnnotationTargetedByMixin; -import com.github.t1.annotations.tck.MixinClasses.TypeAnnotationMixinClasses.SomeClassWithVariousAnnotations; -import com.github.t1.annotations.tck.MixinClasses.TypeAnnotationMixinClasses.TargetClassWithTwoMixins; -import com.github.t1.annotations.tck.MixinClasses.TypeAnnotationMixinClasses.TargetClassWithTwoNonRepeatableMixins; -import com.github.t1.annotations.tck.MixinClasses.TypeAnnotationMixinClasses.TargetClassWithTwoRepeatableMixins; -import com.github.t1.annotations.tck.RepeatableAnnotation; -import com.github.t1.annotations.tck.SomeAnnotation; - -public class MixinBehavior { - - @Nested - class ClassAnnotations { - Annotations annotations = Annotations.on(SomeClassWithVariousAnnotations.class); - - @Test - void shouldGetTargetClassAnnotation() { - Optional annotation = annotations.get(SomeAnnotationWithoutValue.class); - - then(annotation).isPresent(); - } - - @Test - void shouldGetMixinClassAnnotation() { - Optional annotation = annotations.get(AnotherAnnotation.class); - - then(annotation).isPresent(); - } - - @Test - void shouldGetReplacedClassAnnotation() { - Optional someAnnotation = annotations.get(SomeAnnotation.class); - - assert someAnnotation.isPresent(); - then(someAnnotation.get().value()).isEqualTo("replacing"); - } - - @Test - void shouldFailToGetRepeatedClassAnnotation() { - Throwable throwable = catchThrowable(() -> annotations.get(RepeatableAnnotation.class)); - - then(throwable).isInstanceOf(AmbiguousAnnotationResolutionException.class); - } - - @Test - void shouldGetAllClassAnnotations() { - Stream list = annotations.all(); - - then(list.map(Object::toString)).containsExactlyInAnyOrder( - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + SomeAnnotation.class.getName() + "(value = \"replacing\")", - "@" + AnotherAnnotation.class.getName(), - "@" + SomeAnnotationWithoutValue.class.getName(), - "@" + RepeatableAnnotation.class.getName() + "(value = 2)"); - } - - @Test - void shouldGetAllRepeatableClassAnnotations() { - Stream list = annotations.all(RepeatableAnnotation.class); - - then(list.map(Object::toString)).containsExactlyInAnyOrder( - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + RepeatableAnnotation.class.getName() + "(value = 2)"); - } - - Annotations annotationsFromAnnotationTargetedByMixin = Annotations.on(SomeClassWithAnnotationTargetedByMixin.class); - - @Test - void shouldGetMixedInAnnotation() { - Optional someAnnotation = annotationsFromAnnotationTargetedByMixin.get(SomeAnnotation.class); - - assert someAnnotation.isPresent(); - then(someAnnotation.get().value()).isEqualTo("annotation-mixin"); - } - - @Test - void shouldGetAllNonRepeatableMixedInAnnotations() { - Stream someAnnotation = annotationsFromAnnotationTargetedByMixin.all(SomeAnnotation.class); - - then(someAnnotation.map(Object::toString)).containsExactlyInAnyOrder( - "@" + SomeAnnotation.class.getName() + "(value = \"annotation-mixin\")"); - } - - @Test - void shouldGetAllRepeatableMixedInAnnotations() { - Stream repeatableAnnotations = annotationsFromAnnotationTargetedByMixin - .all(RepeatableAnnotation.class); - - then(repeatableAnnotations.map(Object::toString)).containsExactlyInAnyOrder( - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + RepeatableAnnotation.class.getName() + "(value = 2)"); - } - - @Test - void shouldGetAllMixedInAnnotation() { - Stream all = annotationsFromAnnotationTargetedByMixin.all(); - - then(all.map(Object::toString)).containsExactlyInAnyOrder( - "@" + SomeAnnotationTargetedByMixin.class.getName(), - "@" + SomeAnnotation.class.getName() + "(value = \"annotation-mixin\")", - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + RepeatableAnnotation.class.getName() + "(value = 2)"); - } - - @Test - void shouldOverwriteAnnotationWithAnnotationMixedIn() { - Annotations annotations = Annotations.on(OriginalAnnotatedTarget.class); - - Optional someAnnotation = annotations.get(SomeAnnotation.class); - - assert someAnnotation.isPresent(); - then(someAnnotation.get().value()).isEqualTo("annotation-mixin"); - } - - @Test - void shouldGetClassAnnotationFromMultipleMixins() { - Annotations annotations = Annotations.on(TargetClassWithTwoMixins.class); - - Optional someAnnotation = annotations.get(SomeAnnotation.class); - - assert someAnnotation.isPresent(); - then(someAnnotation.get().value()).isEqualTo("one"); - } - - @Test - void shouldGetOneOfDuplicateNonRepeatableClassAnnotationFromMultipleMixins() { - Annotations annotations = Annotations.on(TargetClassWithTwoNonRepeatableMixins.class); - - Optional someAnnotation = annotations.get(SomeAnnotation.class); - - assert someAnnotation.isPresent(); - then(someAnnotation.get().value()).isIn("two", "three"); - } - - @Test - void shouldFailToGetDuplicateRepeatableClassAnnotationFromMultipleMixins() { - Annotations annotations = Annotations.on(TargetClassWithTwoRepeatableMixins.class); - - Throwable throwable = catchThrowable(() -> annotations.get(RepeatableAnnotation.class)); - - then(throwable).isInstanceOf(AmbiguousAnnotationResolutionException.class); - } - } - - @Nested - class FieldAnnotations { - Annotations annotations = Annotations.onField(SomeClassWithFieldWithVariousAnnotations.class, "foo"); - - @Test - void shouldSkipUndefinedMixinFieldAnnotation() { - Annotations annotations = Annotations.onField(SomeClassWithFieldWithVariousAnnotations.class, "bar"); - - Optional someAnnotationWithoutValue = annotations.get(SomeAnnotationWithoutValue.class); - - then(someAnnotationWithoutValue).isNotPresent(); - } - - @Test - void shouldGetTargetFieldAnnotation() { - Optional someAnnotationWithoutValue = annotations.get(SomeAnnotationWithoutValue.class); - - then(someAnnotationWithoutValue).isPresent(); - } - - @Test - void shouldGetMixinFieldAnnotation() { - Optional anotherAnnotation = annotations.get(AnotherAnnotation.class); - - then(anotherAnnotation).isPresent(); - } - - @Test - void shouldGetReplacedFieldAnnotation() { - Optional annotation = annotations.get(SomeAnnotation.class); - - assert annotation.isPresent(); - then(annotation.get().value()).isEqualTo("replacing"); - } - - @Test - void shouldFailToGetRepeatableFieldAnnotation() { - Throwable throwable = catchThrowable(() -> annotations.get(RepeatableAnnotation.class)); - - then(throwable).isInstanceOf(AmbiguousAnnotationResolutionException.class); - } - - @Test - void shouldGetAllFieldAnnotations() { - Stream list = annotations.all(); - - then(list.map(Object::toString)).containsExactlyInAnyOrder( - "@" + AnotherAnnotation.class.getName(), - "@" + SomeAnnotationWithoutValue.class.getName(), - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + SomeAnnotation.class.getName() + "(value = \"replacing\")", - "@" + RepeatableAnnotation.class.getName() + "(value = 2)"); - } - - @Test - void shouldGetAllRepeatableFieldAnnotations() { - Stream list = annotations.all(RepeatableAnnotation.class); - - then(list.map(Object::toString)).containsExactlyInAnyOrder( - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + RepeatableAnnotation.class.getName() + "(value = 2)"); - } - - @Test - void shouldGetOneOfDuplicateFieldAnnotationsFromMultipleMixins() { - Annotations annotations = Annotations.onField(TargetFieldClassWithTwoMixins.class, "foo"); - - Optional someAnnotation = annotations.get(SomeAnnotation.class); - - assert someAnnotation.isPresent(); - then(someAnnotation.get().value()).isEqualTo("four"); - } - - @Test - void shouldGetOneRepeatableFieldAnnotationFromMultipleMixins() { - Annotations annotations = Annotations.onField(TargetFieldClassWithTwoNonRepeatableMixins.class, "foo"); - - Optional someAnnotation = annotations.get(SomeAnnotation.class); - - assert someAnnotation.isPresent(); - then(someAnnotation.get().value()).isIn("five", "six"); - } - - @Test - void shouldFailToGetDuplicateRepeatableFieldAnnotationFromMultipleMixins() { - Annotations annotations = Annotations.onField(TargetFieldClassWithTwoRepeatableMixins.class, "foo"); - - Throwable throwable = catchThrowable(() -> annotations.get(RepeatableAnnotation.class)); - - then(throwable).isInstanceOf(AmbiguousAnnotationResolutionException.class); - } - - @Test - void shouldMixIntoAnnotationUsedOnField() { - Annotations annotations = Annotations.onField(ClassWithAnnotationsExtendedByMixIn.class, "field"); - - then(annotations.get(DirectAnnotation.class)).isPresent(); - then(annotations.get(MixedInAnnotation.class)).isPresent(); - } - - // TODO test unknown field mixin - } - - @Nested - class MethodAnnotations { - Annotations annotations = Annotations.onMethod(SomeClassWithMethodWithVariousAnnotations.class, "foo"); - - @Test - void shouldSkipUndefinedMixinMethodAnnotation() { - Annotations annotations = Annotations.onMethod(SomeClassWithMethodWithVariousAnnotations.class, "bar"); - - Optional someAnnotationWithoutValue = annotations.get(SomeAnnotationWithoutValue.class); - - then(someAnnotationWithoutValue).isNotPresent(); - } - - @Test - void shouldGetTargetMethodAnnotation() { - Optional someAnnotationWithoutValue = annotations.get(SomeAnnotationWithoutValue.class); - - then(someAnnotationWithoutValue).isPresent(); - } - - @Test - void shouldGetMixinMethodAnnotation() { - Optional anotherAnnotation = annotations.get(AnotherAnnotation.class); - - then(anotherAnnotation).isPresent(); - } - - @Test - void shouldGetReplacedMethodAnnotation() { - Optional annotation = annotations.get(SomeAnnotation.class); - - assert annotation.isPresent(); - then(annotation.get().value()).isEqualTo("replacing"); - } - - @Test - void shouldFailToGetRepeatableMethodAnnotation() { - Throwable throwable = catchThrowable(() -> annotations.get(RepeatableAnnotation.class)); - - then(throwable).isInstanceOf(AmbiguousAnnotationResolutionException.class); - } - - @Test - void shouldGetAllMethodAnnotations() { - Stream list = annotations.all(); - - then(list.map(Object::toString)).containsExactlyInAnyOrder( - "@" + AnotherAnnotation.class.getName(), - "@" + SomeAnnotationWithoutValue.class.getName(), - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + SomeAnnotation.class.getName() + "(value = \"replacing\")", - "@" + RepeatableAnnotation.class.getName() + "(value = 2)"); - } - - @Test - void shouldGetAllRepeatableMethodAnnotations() { - Stream list = annotations.all(RepeatableAnnotation.class); - - then(list.map(Object::toString)).containsExactlyInAnyOrder( - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + RepeatableAnnotation.class.getName() + "(value = 2)"); - } - - @Test - void shouldGetMethodAnnotationFromMultipleMixins() { - Annotations annotations = Annotations.onMethod(TargetMethodClassWithTwoMixins.class, "foo"); - - Optional someAnnotation = annotations.get(SomeAnnotation.class); - - assert someAnnotation.isPresent(); - then(someAnnotation.get().value()).isEqualTo("seven"); - } - - @Test - void shouldGetOneOfDuplicateNonRepeatableMethodAnnotationFromMultipleMixins() { - Annotations annotations = Annotations.onMethod(TargetMethodClassWithTwoNonRepeatableMixins.class, "foo"); - - Optional someAnnotation = annotations.get(SomeAnnotation.class); - - assert someAnnotation.isPresent(); - then(someAnnotation.get().value()).isIn("eight", "nine"); - } - - @Test - void shouldFailToGetDuplicateRepeatableMethodAnnotationFromMultipleMixins() { - Annotations annotations = Annotations.onMethod(TargetMethodClassWithTwoRepeatableMixins.class, "foo"); - - Throwable throwable = catchThrowable(() -> annotations.get(RepeatableAnnotation.class)); - - then(throwable).isInstanceOf(AmbiguousAnnotationResolutionException.class); - } - - @Test - void shouldMixIntoAnnotationUsedOnMethod() { - Annotations annotations = Annotations.onMethod(ClassWithAnnotationsExtendedByMixIn.class, "method"); - - then(annotations.get(DirectAnnotation.class)).isPresent(); - then(annotations.get(MixedInAnnotation.class)).isPresent(); - } - - // TODO constructor mixins - // TODO parameter mixins - // TODO test unknown method mixin (name or args) - } -} diff --git a/power-annotations/tck/src/test/java/test/RepeatableAnnotationBehavior.java b/power-annotations/tck/src/test/java/test/RepeatableAnnotationBehavior.java deleted file mode 100644 index d4bbda0e3..000000000 --- a/power-annotations/tck/src/test/java/test/RepeatableAnnotationBehavior.java +++ /dev/null @@ -1,147 +0,0 @@ -package test; - -import static org.assertj.core.api.Assertions.catchThrowable; -import static org.assertj.core.api.BDDAssertions.then; - -import java.lang.annotation.Annotation; -import java.util.Optional; -import java.util.stream.Stream; - -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; - -import com.github.t1.annotations.AmbiguousAnnotationResolutionException; -import com.github.t1.annotations.Annotations; -import com.github.t1.annotations.tck.RepeatableAnnotation; -import com.github.t1.annotations.tck.RepeatableAnnotationClasses.RepeatedAnnotationClass; -import com.github.t1.annotations.tck.RepeatableAnnotationClasses.UnrepeatedAnnotationClass; - -/** - * Actually tests how the Annotations utils resolve repeatable annotations, not the power annotations implementation, - * but this is a prerequisite for many other tests. - */ -public class RepeatableAnnotationBehavior { - - @Test - void shouldGetSingleRepeatedClassAnnotation() { - Annotations annotations = Annotations.on(UnrepeatedAnnotationClass.class); - - Optional annotation = annotations.get(RepeatableAnnotation.class); - - assert annotation.isPresent(); - then(annotation.get().value()).isEqualTo(1); - } - - @Test - void shouldGetSingleRepeatedFieldAnnotation() { - Annotations annotations = Annotations.onField(UnrepeatedAnnotationClass.class, "foo"); - - Optional annotation = annotations.get(RepeatableAnnotation.class); - - assert annotation.isPresent(); - then(annotation.get().value()).isEqualTo(10); - } - - @Test - void shouldGetSingleRepeatedMethodAnnotation() { - Annotations annotations = Annotations.onMethod(UnrepeatedAnnotationClass.class, "bar"); - - Optional annotation = annotations.get(RepeatableAnnotation.class); - - assert annotation.isPresent(); - then(annotation.get().value()).isEqualTo(20); - } - - @Nested - class RepeatedClassAnnotationBehavior { - Annotations repeatedAnnotations = Annotations.on(RepeatedAnnotationClass.class); - - @Test - void shouldFailToGetRepeatingAnnotation() { - Throwable throwable = catchThrowable(() -> repeatedAnnotations.get(RepeatableAnnotation.class)); - - then(throwable) - .isInstanceOf(AmbiguousAnnotationResolutionException.class) - // TODO message detail about the target .hasMessageContaining(SomeClass.class.getName()) - .hasMessageContaining(RepeatableAnnotation.class.getName()); - } - - @Test - void shouldGetAll() { - Stream all = repeatedAnnotations.all(); - - then(all.map(Object::toString)).containsExactlyInAnyOrder( - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + RepeatableAnnotation.class.getName() + "(value = 2)"); - } - - @Test - void shouldGetTypedAll() { - Stream all = repeatedAnnotations.all(RepeatableAnnotation.class); - - then(all.map(RepeatableAnnotation::value)).containsExactlyInAnyOrder(1, 2); - } - } - - @Nested - class RepeatedFieldAnnotationBehavior { - Annotations repeatedAnnotations = Annotations.onField(RepeatedAnnotationClass.class, "foo"); - - @Test - void shouldFailToGetRepeatingAnnotation() { - Throwable throwable = catchThrowable(() -> repeatedAnnotations.get(RepeatableAnnotation.class)); - - then(throwable) - .isInstanceOf(AmbiguousAnnotationResolutionException.class) - // TODO message detail about the target .hasMessageContaining(SomeClass.class.getName()) - .hasMessageContaining(RepeatableAnnotation.class.getName()); - } - - @Test - void shouldGetAll() { - Stream all = repeatedAnnotations.all(); - - then(all.map(Object::toString)).containsExactlyInAnyOrder( - "@" + RepeatableAnnotation.class.getName() + "(value = 11)", - "@" + RepeatableAnnotation.class.getName() + "(value = 12)"); - } - - @Test - void shouldGetTypedAll() { - Stream all = repeatedAnnotations.all(RepeatableAnnotation.class); - - then(all.map(RepeatableAnnotation::value)).containsExactlyInAnyOrder(11, 12); - } - } - - @Nested - class RepeatedMethodAnnotationBehavior { - Annotations repeatedAnnotations = Annotations.onMethod(RepeatedAnnotationClass.class, "bar"); - - @Test - void shouldFailToGetRepeatingAnnotation() { - Throwable throwable = catchThrowable(() -> repeatedAnnotations.get(RepeatableAnnotation.class)); - - then(throwable) - .isInstanceOf(AmbiguousAnnotationResolutionException.class) - // TODO message detail about the target .hasMessageContaining(SomeClass.class.getName()) - .hasMessageContaining(RepeatableAnnotation.class.getName()); - } - - @Test - void shouldGetAll() { - Stream all = repeatedAnnotations.all(); - - then(all.map(Object::toString)).containsExactlyInAnyOrder( - "@" + RepeatableAnnotation.class.getName() + "(value = 21)", - "@" + RepeatableAnnotation.class.getName() + "(value = 22)"); - } - - @Test - void shouldGetTypedAll() { - Stream all = repeatedAnnotations.all(RepeatableAnnotation.class); - - then(all.map(RepeatableAnnotation::value)).containsExactlyInAnyOrder(21, 22); - } - } -} diff --git a/power-annotations/tck/src/test/java/test/StereotypeBehavior.java b/power-annotations/tck/src/test/java/test/StereotypeBehavior.java deleted file mode 100644 index dec416abc..000000000 --- a/power-annotations/tck/src/test/java/test/StereotypeBehavior.java +++ /dev/null @@ -1,382 +0,0 @@ -package test; - -import static java.util.stream.Collectors.toList; -import static org.assertj.core.api.BDDAssertions.then; - -import java.lang.annotation.Annotation; -import java.util.List; -import java.util.Objects; -import java.util.Optional; -import java.util.stream.Stream; - -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; - -import com.github.t1.annotations.Annotations; -import com.github.t1.annotations.tck.MixinClasses.AnotherAnnotation; -import com.github.t1.annotations.tck.RepeatableAnnotation; -import com.github.t1.annotations.tck.SomeAnnotation; -import com.github.t1.annotations.tck.StereotypeClasses.AnotherStereotype; -import com.github.t1.annotations.tck.StereotypeClasses.ClassWithStereotypedField; -import com.github.t1.annotations.tck.StereotypeClasses.ClassWithStereotypedMethod; -import com.github.t1.annotations.tck.StereotypeClasses.DoubleIndirectlyStereotypedClass; -import com.github.t1.annotations.tck.StereotypeClasses.DoubleStereotypedClass; -import com.github.t1.annotations.tck.StereotypeClasses.IndirectlyStereotypedClass; -import com.github.t1.annotations.tck.StereotypeClasses.MergeOneRepeatableAnnotationIntoOne; -import com.github.t1.annotations.tck.StereotypeClasses.MergeOneRepeatableAnnotationIntoTwo; -import com.github.t1.annotations.tck.StereotypeClasses.MergeRepeatableAnnotationFromOneAndOne; -import com.github.t1.annotations.tck.StereotypeClasses.MergeRepeatableAnnotationFromOneAndTwo; -import com.github.t1.annotations.tck.StereotypeClasses.MergeRepeatableAnnotationFromTwoAndOne; -import com.github.t1.annotations.tck.StereotypeClasses.MergeRepeatableAnnotationFromTwoAndTwo; -import com.github.t1.annotations.tck.StereotypeClasses.MergeThreeRepeatableAnnotationIntoThree; -import com.github.t1.annotations.tck.StereotypeClasses.MergeTwoRepeatableAnnotationIntoOne; -import com.github.t1.annotations.tck.StereotypeClasses.MergeTwoRepeatableAnnotationIntoTwo; -import com.github.t1.annotations.tck.StereotypeClasses.SomeDoubleIndirectedStereotype; -import com.github.t1.annotations.tck.StereotypeClasses.SomeIndirectedStereotype; -import com.github.t1.annotations.tck.StereotypeClasses.SomeStereotype; -import com.github.t1.annotations.tck.StereotypeClasses.SomeTardyIndirectedStereotype; -import com.github.t1.annotations.tck.StereotypeClasses.StereotypedClass; -import com.github.t1.annotations.tck.StereotypeClasses.StereotypedClassWithSomeAnnotation; -import com.github.t1.annotations.tck.StereotypeClasses.TardyIndirectlyStereotypedClass; - -public class StereotypeBehavior { - - @Nested - class StereotypedClasses { - Annotations annotations = Annotations.on(StereotypedClass.class); - - @Test - void shouldGetAnnotationFromClassStereotype() { - Optional someAnnotation = annotations.get(SomeAnnotation.class); - - assert someAnnotation.isPresent(); - then(someAnnotation.get().value()).isEqualTo("from-stereotype"); - } - - @Test - void shouldGetAllAnnotationsFromClassStereotype() { - Stream someAnnotation = annotations.all(); - - then(someAnnotation.map(Object::toString)).containsExactlyInAnyOrder( - "@" + RepeatableAnnotation.class.getName() + "(value = 5)", - "@" + AnotherAnnotation.class.getName(), - "@" + SomeStereotype.class.getName(), - "@" + SomeAnnotation.class.getName() + "(value = \"from-stereotype\")", - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + RepeatableAnnotation.class.getName() + "(value = 2)"); - } - - @Test - void shouldGetAllNonRepeatableAnnotationsFromClassStereotype() { - Stream someAnnotation = annotations.all(SomeAnnotation.class); - - then(someAnnotation.map(Objects::toString)).containsExactlyInAnyOrder( - "@" + SomeAnnotation.class.getName() + "(value = \"from-stereotype\")"); - } - - @Test - void shouldGetAllRepeatableAnnotationFromClassStereotype() { - Stream someAnnotation = annotations.all(RepeatableAnnotation.class); - - then(someAnnotation.map(Objects::toString)).containsExactlyInAnyOrder( - "@" + RepeatableAnnotation.class.getName() + "(value = 5)", - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + RepeatableAnnotation.class.getName() + "(value = 2)"); - } - - @Test - void shouldGetAllFromIndirectClassStereotype() { - Annotations annotations = Annotations.on(IndirectlyStereotypedClass.class); - - Stream all = annotations.all(); - - then(all.map(Objects::toString)).containsExactlyInAnyOrder( - "@" + SomeAnnotation.class.getName() + "(value = \"from-stereotype\")", - "@" + AnotherAnnotation.class.getName(), - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + RepeatableAnnotation.class.getName() + "(value = 2)", - "@" + SomeStereotype.class.getName(), - "@" + SomeIndirectedStereotype.class.getName()); - } - - @Test - void shouldGetAllFromIndirectClassStereotypeResolvedAlphabeticallyAfterSomeStereotype() { - Annotations annotations = Annotations.on(TardyIndirectlyStereotypedClass.class); - - Stream all = annotations.all(); - - then(all.map(Objects::toString)).containsExactlyInAnyOrder( - "@" + SomeAnnotation.class.getName() + "(value = \"from-stereotype\")", - "@" + AnotherAnnotation.class.getName(), - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + RepeatableAnnotation.class.getName() + "(value = 2)", - "@" + SomeStereotype.class.getName(), - "@" + SomeTardyIndirectedStereotype.class.getName()); - } - - @Test - void shouldGetAllFromDoubleIndirectClassStereotype() { - Annotations annotations = Annotations.on(DoubleIndirectlyStereotypedClass.class); - - Stream all = annotations.all(); - - then(all.map(Objects::toString)).containsExactlyInAnyOrder( - "@" + SomeAnnotation.class.getName() + "(value = \"from-stereotype\")", - "@" + AnotherAnnotation.class.getName(), - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + RepeatableAnnotation.class.getName() + "(value = 2)", - "@" + SomeStereotype.class.getName(), - "@" + SomeIndirectedStereotype.class.getName(), - "@" + SomeDoubleIndirectedStereotype.class.getName()); - } - - @Test - void shouldNotReplaceClassAnnotationWithStereotypedNonRepeatableAnnotation() { - Annotations annotations = Annotations.on(StereotypedClassWithSomeAnnotation.class); - - Optional someAnnotation = annotations.get(SomeAnnotation.class); - - assert someAnnotation.isPresent(); - then(someAnnotation.get().value()).isEqualTo("on-class"); - } - } - - @Nested - class DoubleStereotypedClasses { - Annotations annotations = Annotations.on(DoubleStereotypedClass.class); - - @Test - void shouldGetFirstOfAmbiguousAnnotationFromTwoStereotypes() { - Optional someAnnotation = annotations.get(SomeAnnotation.class); - - assert someAnnotation.isPresent(); - then(someAnnotation.get().value()).isIn( // both are allowed: - "from-stereotype", - "from-another-stereotype"); - } - - @Test - void shouldGetAllNonRepeatableAnnotationsFromTwoStereotypes() { - Stream someAnnotations = annotations.all(SomeAnnotation.class); - - then(someAnnotations.map(Objects::toString)).containsAnyOf( // both are allowed: - "@" + SomeAnnotation.class.getName() + "(value = \"from-stereotype\")", - "@" + SomeAnnotation.class.getName() + "(value = \"from-another-stereotype\")"); - } - } - - @Nested - class StereotypeMerging { - @Test - void shouldMergeRepeatableAnnotationFromOneAndOne() { - Annotations annotations = Annotations.on(MergeRepeatableAnnotationFromOneAndOne.class); - - Stream repeatableAnnotations = annotations.all(RepeatableAnnotation.class); - - then(repeatableAnnotations.map(Objects::toString)).containsExactlyInAnyOrder( - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + RepeatableAnnotation.class.getName() + "(value = 11)"); - } - - @Test - void shouldMergeRepeatableAnnotationFromOneAndTwo() { - Annotations annotations = Annotations.on(MergeRepeatableAnnotationFromOneAndTwo.class); - - Stream repeatableAnnotations = annotations.all(RepeatableAnnotation.class); - - then(repeatableAnnotations.map(Objects::toString)).containsExactlyInAnyOrder( - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + RepeatableAnnotation.class.getName() + "(value = 11)", - "@" + RepeatableAnnotation.class.getName() + "(value = 12)"); - } - - @Test - void shouldMergeRepeatableAnnotationFromTwoAndOne() { - Annotations annotations = Annotations.on(MergeRepeatableAnnotationFromTwoAndOne.class); - - Stream repeatableAnnotations = annotations.all(RepeatableAnnotation.class); - - then(repeatableAnnotations.map(Objects::toString)).containsExactlyInAnyOrder( - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + RepeatableAnnotation.class.getName() + "(value = 2)", - "@" + RepeatableAnnotation.class.getName() + "(value = 11)"); - } - - @Test - void shouldMergeRepeatableAnnotationFromTwoAndTwo() { - Annotations annotations = Annotations.on(MergeRepeatableAnnotationFromTwoAndTwo.class); - - Stream repeatableAnnotations = annotations.all(RepeatableAnnotation.class); - - then(repeatableAnnotations.map(Objects::toString)).containsExactlyInAnyOrder( - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + RepeatableAnnotation.class.getName() + "(value = 2)", - "@" + RepeatableAnnotation.class.getName() + "(value = 11)", - "@" + RepeatableAnnotation.class.getName() + "(value = 12)"); - } - - @Test - void shouldMergeOneRepeatableAnnotationIntoOne() { - Annotations annotations = Annotations.on(MergeOneRepeatableAnnotationIntoOne.class); - - Stream repeatableAnnotations = annotations.all(RepeatableAnnotation.class); - - then(repeatableAnnotations.map(Objects::toString)).containsExactlyInAnyOrder( - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + RepeatableAnnotation.class.getName() + "(value = 2)"); - } - - @Test - void shouldMergeOneRepeatableAnnotationIntoTwo() { - Annotations annotations = Annotations.on(MergeOneRepeatableAnnotationIntoTwo.class); - - Stream repeatableAnnotations = annotations.all(RepeatableAnnotation.class); - - then(repeatableAnnotations.map(Objects::toString)).containsExactlyInAnyOrder( - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + RepeatableAnnotation.class.getName() + "(value = 21)", - "@" + RepeatableAnnotation.class.getName() + "(value = 22)"); - } - - @Test - void shouldMergeTwoRepeatableAnnotationIntoOne() { - Annotations annotations = Annotations.on(MergeTwoRepeatableAnnotationIntoOne.class); - - Stream repeatableAnnotations = annotations.all(RepeatableAnnotation.class); - - then(repeatableAnnotations.map(Objects::toString)).containsExactlyInAnyOrder( - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + RepeatableAnnotation.class.getName() + "(value = 2)", - "@" + RepeatableAnnotation.class.getName() + "(value = 21)"); - } - - @Test - void shouldMergeTwoRepeatableAnnotationIntoTwo() { - Annotations annotations = Annotations.on(MergeTwoRepeatableAnnotationIntoTwo.class); - - Stream repeatableAnnotations = annotations.all(RepeatableAnnotation.class); - - then(repeatableAnnotations.map(Objects::toString)).containsExactlyInAnyOrder( - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + RepeatableAnnotation.class.getName() + "(value = 2)", - "@" + RepeatableAnnotation.class.getName() + "(value = 21)", - "@" + RepeatableAnnotation.class.getName() + "(value = 22)"); - } - - @Test - void shouldMergeThreeRepeatableAnnotationIntoThree() { - Annotations annotations = Annotations.on(MergeThreeRepeatableAnnotationIntoThree.class); - - Stream repeatableAnnotations = annotations.all(RepeatableAnnotation.class); - - then(repeatableAnnotations.map(Objects::toString)).containsExactlyInAnyOrder( - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + RepeatableAnnotation.class.getName() + "(value = 2)", - "@" + RepeatableAnnotation.class.getName() + "(value = 3)", - "@" + RepeatableAnnotation.class.getName() + "(value = 21)", - "@" + RepeatableAnnotation.class.getName() + "(value = 22)", - "@" + RepeatableAnnotation.class.getName() + "(value = 23)"); - } - - @Test - void shouldGetAllAnnotationsFromTwoStereotypes() { - Annotations annotations = Annotations.on(DoubleStereotypedClass.class); - - Stream all = annotations.all(); - - List list = all.map(Objects::toString).collect(toList()); - then(list).containsExactlyInAnyOrder( - "@" + SomeStereotype.class.getName(), - "@" + AnotherStereotype.class.getName(), - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + RepeatableAnnotation.class.getName() + "(value = 2)", - "@" + RepeatableAnnotation.class.getName() + "(value = 6)", - "@" + AnotherAnnotation.class.getName(), - "@" + SomeAnnotation.class.getName() + "(value = \"from-another-stereotype\")"); - } - } - - @Nested - class StereotypedFields { - Annotations annotations = Annotations.onField(ClassWithStereotypedField.class, "foo"); - - @Test - void shouldGetAnnotationFromFieldStereotype() { - Optional someAnnotation = annotations.get(AnotherAnnotation.class); - - assert someAnnotation.isPresent(); - } - - @Test - void shouldNotReplaceFieldAnnotationWithStereotypedNonRepeatableAnnotation() { - Optional someAnnotation = annotations.get(SomeAnnotation.class); - - assert someAnnotation.isPresent(); - then(someAnnotation.get().value()).isEqualTo("on-field"); - } - - @Test - void shouldGetAllAnnotationsFromFieldStereotype() { - Stream someAnnotation = annotations.all(); - - then(someAnnotation.map(Object::toString)).containsExactlyInAnyOrder( - "@" + RepeatableAnnotation.class.getName() + "(value = 7)", - "@" + AnotherAnnotation.class.getName(), - "@" + SomeStereotype.class.getName(), - "@" + SomeAnnotation.class.getName() + "(value = \"on-field\")", - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + RepeatableAnnotation.class.getName() + "(value = 2)"); - } - - @Test - void shouldGetAllAnnotationNonRepeatableTypedFromFieldStereotype() { - Stream someAnnotation = annotations.all(SomeAnnotation.class); - - then(someAnnotation.map(Objects::toString)).containsExactlyInAnyOrder( - "@" + SomeAnnotation.class.getName() + "(value = \"on-field\")"); - } - } - - @Nested - class StereotypedMethods { - Annotations annotations = Annotations.onMethod(ClassWithStereotypedMethod.class, "foo"); - - @Test - void shouldGetAnnotationFromMethodStereotype() { - Optional someAnnotation = annotations.get(AnotherAnnotation.class); - - assert someAnnotation.isPresent(); - } - - @Test - void shouldNotReplaceMethodAnnotationWithStereotypedNonRepeatableAnnotation() { - Optional someAnnotation = annotations.get(SomeAnnotation.class); - - assert someAnnotation.isPresent(); - then(someAnnotation.get().value()).isEqualTo("on-method"); - } - - @Test - void shouldGetAllAnnotationsFromMethodStereotype() { - Stream someAnnotation = annotations.all(); - - then(someAnnotation.map(Object::toString)).containsExactlyInAnyOrder( - "@" + RepeatableAnnotation.class.getName() + "(value = 7)", - "@" + AnotherAnnotation.class.getName(), - "@" + SomeStereotype.class.getName(), - "@" + SomeAnnotation.class.getName() + "(value = \"on-method\")", - "@" + RepeatableAnnotation.class.getName() + "(value = 1)", - "@" + RepeatableAnnotation.class.getName() + "(value = 2)"); - } - - @Test - void shouldGetAllAnnotationNonRepeatableTypedFromMethodStereotype() { - Stream someAnnotation = annotations.all(SomeAnnotation.class); - - then(someAnnotation.map(Objects::toString)).containsExactlyInAnyOrder( - "@" + SomeAnnotation.class.getName() + "(value = \"on-method\")"); - } - } - - // TODO parameter stereotypes -} diff --git a/power-annotations/tck/src/test/java/test/TypeToMemberAnnotationsTestSuite.java b/power-annotations/tck/src/test/java/test/TypeToMemberAnnotationsTestSuite.java deleted file mode 100644 index 9968b67de..000000000 --- a/power-annotations/tck/src/test/java/test/TypeToMemberAnnotationsTestSuite.java +++ /dev/null @@ -1,12 +0,0 @@ -package test; - -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; - -import org.junit.jupiter.api.Tag; - -@Tag("TypeToMemberAnnotationsTestSuite") -@Retention(RUNTIME) -public @interface TypeToMemberAnnotationsTestSuite { -} diff --git a/power-annotations/utils/api/pom.xml b/power-annotations/utils/api/pom.xml deleted file mode 100644 index b72f85f04..000000000 --- a/power-annotations/utils/api/pom.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - 4.0.0 - - io.smallrye - smallrye-power-annotations-utils-parent - 2.0.0-SNAPSHOT - - - smallrye-power-annotations-utils-api - Power Annotations: Utils :: API - The Utils API for working with annotations. Used by the TCK. - diff --git a/power-annotations/utils/api/src/main/java/com/github/t1/annotations/AmbiguousAnnotationResolutionException.java b/power-annotations/utils/api/src/main/java/com/github/t1/annotations/AmbiguousAnnotationResolutionException.java deleted file mode 100644 index 0a1e4c595..000000000 --- a/power-annotations/utils/api/src/main/java/com/github/t1/annotations/AmbiguousAnnotationResolutionException.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.github.t1.annotations; - -/** - * @see Annotations#get(Class) - */ -@SuppressWarnings("unused") -public class AmbiguousAnnotationResolutionException extends RuntimeException { - public AmbiguousAnnotationResolutionException() { - } - - public AmbiguousAnnotationResolutionException(String message) { - super(message); - } - - public AmbiguousAnnotationResolutionException(String message, Throwable cause) { - super(message, cause); - } - - public AmbiguousAnnotationResolutionException(Throwable cause) { - super(cause); - } - - public AmbiguousAnnotationResolutionException(String message, Throwable cause, boolean enableSuppression, - boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); - } -} diff --git a/power-annotations/utils/api/src/main/java/com/github/t1/annotations/Annotations.java b/power-annotations/utils/api/src/main/java/com/github/t1/annotations/Annotations.java deleted file mode 100644 index 7d8460357..000000000 --- a/power-annotations/utils/api/src/main/java/com/github/t1/annotations/Annotations.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.github.t1.annotations; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.Optional; -import java.util.stream.Stream; - -public interface Annotations { - static Annotations on(Class type) { - return AnnotationsLoader.INSTANCE.onType(type); - } - - static Annotations on(Field field) { - return onField(field.getDeclaringClass(), field.getName()); - } - - static Annotations onField(Class type, String fieldName) { - return AnnotationsLoader.INSTANCE.onField(type, fieldName); - } - - static Annotations on(Method method) { - return onMethod(method.getDeclaringClass(), method.getName(), method.getParameterTypes()); - } - - static Annotations onMethod(Class type, String methodName, Class... argTypes) { - return AnnotationsLoader.INSTANCE.onMethod(type, methodName, argTypes); - } - - /** - * Get all {@link Annotation} instances. - * If the annotation type is {@link java.lang.annotation.Repeatable}, the same type - * can show up several times, eventually with different properties. - */ - Stream all(); - - /** - * Get the 'strongest' {@link Annotation} instance of this type. - * Multiple annotations may be applicable, e.g. from several mixins or stereotypes. - * The annotation will be picked in this order: - *
    - *
  1. mixin
  2. - *
  3. target
  4. - *
  5. target stereotypes
  6. - *
  7. containing class
  8. - *
  9. containing class stereotypes
  10. - *
  11. containing package (TODO not yet implemented)
  12. - *
  13. containing package stereotypes (TODO not yet implemented)
  14. - *
- * If this order not sufficiently defined, e.g. because there are multiple repeatable annotations, - * or because there are multiple mixins or stereotypes with the same annotation, - * an {@link AmbiguousAnnotationResolutionException} is thrown. I.e. when an annotation is changed - * to be repeatable, all frameworks using this annotation will have to use {@link #all(Class)} instead - * (of course), but the semantics for the client code changes, which may break existing code. - */ - Optional get(Class type); - - /** - * Get all (eventually {@link java.lang.annotation.Repeatable repeatable}) - * {@link Annotation} instances of this type. - */ - Stream all(Class type); -} diff --git a/power-annotations/utils/api/src/main/java/com/github/t1/annotations/AnnotationsLoader.java b/power-annotations/utils/api/src/main/java/com/github/t1/annotations/AnnotationsLoader.java deleted file mode 100644 index 4e4b2f3be..000000000 --- a/power-annotations/utils/api/src/main/java/com/github/t1/annotations/AnnotationsLoader.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.github.t1.annotations; - -import java.util.Iterator; -import java.util.ServiceConfigurationError; -import java.util.ServiceLoader; - -/** - * SPI + Singleton for loading the implementation - */ -public abstract class AnnotationsLoader { - static final AnnotationsLoader INSTANCE = load(); - - private static AnnotationsLoader load() { - ServiceLoader loader = ServiceLoader.load(AnnotationsLoader.class); - Iterator iterator = loader.iterator(); - if (!iterator.hasNext()) - throw new ServiceConfigurationError("no " + AnnotationsLoader.class.getName() + " in classpath"); - AnnotationsLoader graphQlClientBuilder = iterator.next(); - if (iterator.hasNext()) - throw new ServiceConfigurationError("more than one " + AnnotationsLoader.class.getName() + " in classpath"); - return graphQlClientBuilder; - } - - public abstract Annotations onType(Class type); - - public abstract Annotations onField(Class type, String fieldName); - - public abstract Annotations onMethod(Class type, String methodName, Class... argTypes); -} diff --git a/power-annotations/utils/jandex/pom.xml b/power-annotations/utils/jandex/pom.xml deleted file mode 100644 index 56afa6fdb..000000000 --- a/power-annotations/utils/jandex/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - 4.0.0 - - - io.smallrye - smallrye-power-annotations-utils-parent - 2.0.0-SNAPSHOT - - - smallrye-power-annotations-utils-jandex - Power Annotations: Utils :: Jandex - Implementation of the utils for working with annotations base od Jandex. - - - - io.smallrye - smallrye-power-annotations-utils-api - ${project.version} - - - io.smallrye - power-annotations-scanner - ${project.version} - - - diff --git a/power-annotations/utils/jandex/src/main/java/com/github/t1/powerannotations/utils/jandex/AnnotationProxy.java b/power-annotations/utils/jandex/src/main/java/com/github/t1/powerannotations/utils/jandex/AnnotationProxy.java deleted file mode 100644 index c03dfaae0..000000000 --- a/power-annotations/utils/jandex/src/main/java/com/github/t1/powerannotations/utils/jandex/AnnotationProxy.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.github.t1.powerannotations.utils.jandex; - -import static com.github.t1.powerannotations.utils.jandex.JandexAnnotationsLoader.jandex; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Array; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.util.function.Function; - -import org.jboss.jandex.AnnotationInstance; -import org.jboss.jandex.AnnotationValue; -import org.jboss.jandex.ClassType; - -/** - * {@link #build() Builds} a {@link Proxy dynamic proxy} that delegates to three - * function objects for the implementation. - */ -class AnnotationProxy { - static Annotation proxy(AnnotationInstance annotationInstance) { - return new AnnotationProxy( - annotationInstance.name().toString(), - annotationInstance.toString(false), - name -> annotationInstance.valueWithDefault(jandex, name).value()) - .build(); - } - - private final String typeName; - private final String toString; - private final Function property; - - private AnnotationProxy(String typeName, String toString, Function property) { - this.typeName = typeName; - this.toString = toString; - this.property = property; - } - - private Annotation build() { - Class[] interfaces = new Class[] { getAnnotationType(), Annotation.class }; - return (Annotation) Proxy.newProxyInstance(getClassLoader(), interfaces, this::invoke); - } - - private Class getAnnotationType() { - return loadClass(typeName); - } - - private static Class loadClass(String typeName) { - try { - return getClassLoader().loadClass(typeName); - } catch (ClassNotFoundException e) { - throw new RuntimeException("can't load annotation type " + typeName, e); - } - } - - private static ClassLoader getClassLoader() { - ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - return (classLoader == null) ? ClassLoader.getSystemClassLoader() : classLoader; - } - - Object invoke(Object proxy, Method method, Object... args) { - String name = method.getName(); - if (method.getParameterCount() == 1 && "equals".equals(name)) - return toString.equals(args[0].toString()); - // no other methods on annotations can have arguments (except for one `wait`) - assert method.getParameterCount() == 0; - assert args == null || args.length == 0; - if ("hashCode".equals(name)) - return toString.hashCode(); - if ("annotationType".equals(name)) - return getAnnotationType(); - if ("toString".equals(name)) - return toString; - - Object value = property.apply(name); - - return toType(value, method.getReturnType()); - } - - private static Object toType(Object value, Class returnType) { - if (returnType.isAnnotation()) - return proxy((AnnotationInstance) value); - if (returnType.isEnum()) - return enumValue(returnType, (String) value); - if (returnType.equals(Class.class)) - return toClass(value); - if (returnType.isArray()) - return toArray(returnType.getComponentType(), (Object[]) value); - return value; - } - - private static > Enum enumValue(Class type, String value) { - @SuppressWarnings("unchecked") - Class enumType = (Class) type; - return Enum.valueOf(enumType, value); - } - - private static Class toClass(Object value) { - String className = ((ClassType) value).name().toString(); - - ClassLoader loader = Thread.currentThread().getContextClassLoader(); - try { - return Class.forName(className, true, loader); - } catch (ClassNotFoundException e) { - throw new RuntimeException("class not found '" + className + "'", e); - } - } - - private static Object toArray(Class componentType, Object[] values) { - Object array = Array.newInstance(componentType, values.length); - for (int i = 0; i < values.length; i++) - Array.set(array, i, toType(((AnnotationValue) values[i]).value(), componentType)); - return array; - } -} diff --git a/power-annotations/utils/jandex/src/main/java/com/github/t1/powerannotations/utils/jandex/JandexAnnotationsLoader.java b/power-annotations/utils/jandex/src/main/java/com/github/t1/powerannotations/utils/jandex/JandexAnnotationsLoader.java deleted file mode 100644 index 3996e7217..000000000 --- a/power-annotations/utils/jandex/src/main/java/com/github/t1/powerannotations/utils/jandex/JandexAnnotationsLoader.java +++ /dev/null @@ -1,178 +0,0 @@ -package com.github.t1.powerannotations.utils.jandex; - -import static com.github.t1.powerannotations.common.CommonUtils.signature; -import static com.github.t1.powerannotations.common.CommonUtils.toDotName; -import static org.jboss.jandex.AnnotationTarget.Kind.METHOD; - -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.function.Supplier; -import java.util.stream.Collector; -import java.util.stream.Stream; - -import org.jboss.jandex.AnnotationInstance; -import org.jboss.jandex.ClassInfo; -import org.jboss.jandex.DotName; -import org.jboss.jandex.FieldInfo; -import org.jboss.jandex.Index; -import org.jboss.jandex.MethodInfo; -import org.jboss.jandex.Type; -import org.jboss.jandex.Type.Kind; - -import com.github.t1.annotations.AmbiguousAnnotationResolutionException; -import com.github.t1.annotations.Annotations; -import com.github.t1.annotations.AnnotationsLoader; -import com.github.t1.powerannotations.common.Jandex; -import com.github.t1.powerannotations.scanner.IndexBuilder; - -public class JandexAnnotationsLoader extends AnnotationsLoader { - static final Index jandex = IndexBuilder.loadOrScan(); - - @Override - public Annotations onType(Class type) { - ClassInfo classInfo = getClassInfo(type); - - return new Annotations() { - @Override - public Stream all() { - return classInfo.classAnnotations().stream() - .flatMap(JandexAnnotationsLoader::resolveRepeatableAnnotations) - .map(JandexAnnotationsLoader::proxy); - } - - @Override - public Optional get(Class type) { - return all(type) - .collect(toOptionalOrThrow()); - } - - @Override - public Stream all(Class type) { - DotName typeName = toDotName(type); - return classInfo.classAnnotations().stream() - .flatMap(JandexAnnotationsLoader::resolveRepeatableAnnotations) - .filter(annotationInstance -> annotationInstance.name().equals(typeName)) - .map(JandexAnnotationsLoader::proxy); - } - }; - } - - @Override - public Annotations onField(Class type, String fieldName) { - ClassInfo classInfo = getClassInfo(type); - FieldInfo fieldInfo = classInfo.field(fieldName); - if (fieldInfo == null) - throw new RuntimeException("no field '" + fieldName + "' in class " + classInfo.name()); - - // Looks like a code duplicate, but ClassInfo, FieldInfo, and MethodInfo don't have a common interface - //noinspection DuplicatedCode - return new Annotations() { - @Override - public Stream all() { - return fieldInfo.annotations().stream() - .flatMap(JandexAnnotationsLoader::resolveRepeatableAnnotations) - .map(JandexAnnotationsLoader::proxy); - } - - @Override - public Optional get(Class type) { - return all(type).collect(toOptionalOrThrow()); - } - - @Override - public Stream all(Class type) { - DotName typeName = toDotName(type); - return fieldInfo.annotations().stream() - .flatMap(JandexAnnotationsLoader::resolveRepeatableAnnotations) - .filter(annotationInstance -> annotationInstance.name().equals(typeName)) - .map(JandexAnnotationsLoader::proxy); - } - }; - } - - @Override - public Annotations onMethod(Class type, String methodName, Class... argTypes) { - ClassInfo classInfo = getClassInfo(type); - Type[] jandexArgTypes = Stream.of(argTypes).map(Class::getName).map(JandexAnnotationsLoader::createClassType) - .toArray(Type[]::new); - MethodInfo methodInfo = classInfo.method(methodName, jandexArgTypes); - if (methodInfo == null) { - String[] argTypeNames = Stream.of(argTypes).map(Class::getName).toArray(String[]::new); - throw new RuntimeException("no method " + signature(methodName, argTypeNames) + " in class " + classInfo.name()); - } - - // Looks like a code duplicate, but ClassInfo, FieldInfo, and MethodInfo don't have a common interface - //noinspection DuplicatedCode - return new Annotations() { - @Override - public Stream all() { - return methodInfo.annotations().stream() - .filter(annotationInstance -> annotationInstance.target().kind() == METHOD) // not params - .flatMap(JandexAnnotationsLoader::resolveRepeatableAnnotations) - .map(JandexAnnotationsLoader::proxy); - } - - @Override - public Optional get(Class type) { - return all(type).collect(toOptionalOrThrow()); - } - - @Override - public Stream all(Class type) { - DotName typeName = toDotName(type); - return methodInfo.annotations().stream() - .flatMap(JandexAnnotationsLoader::resolveRepeatableAnnotations) - .filter(annotationInstance -> annotationInstance.name().equals(typeName)) - .map(JandexAnnotationsLoader::proxy); - } - }; - } - - private static Stream resolveRepeatableAnnotations(AnnotationInstance annotationInstance) { - return new Jandex(jandex).isRepeatedAnnotation(annotationInstance) - ? resolveRepeatableAnnotationsDo(annotationInstance) - : Stream.of(annotationInstance); - } - - private static Stream resolveRepeatableAnnotationsDo(AnnotationInstance annotationInstance) { - return Stream.of(annotationInstance.value().asNestedArray()); - } - - private ClassInfo getClassInfo(Class type) { - ClassInfo classInfo = jandex.getClassByName(toDotName(type)); - if (classInfo == null) - throw new RuntimeException("class not found in index: " + type.getName()); - return classInfo; - } - - private static Type createClassType(String name) { - return Type.create(DotName.createSimple(name), Kind.CLASS); - } - - private static T proxy(AnnotationInstance annotationInstance) { - //noinspection unchecked - return (T) AnnotationProxy.proxy(annotationInstance); - } - - private static Collector> toOptionalOrThrow() { - return Collector.of( - (Supplier>) ArrayList::new, - List::add, - (left, right) -> { - left.addAll(right); - return left; - }, - list -> { - switch (list.size()) { - case 0: - return Optional.empty(); - case 1: - return Optional.of(list.get(0)); - default: - throw new AmbiguousAnnotationResolutionException("expected one element maximum, but found " + list); - } - }); - } -} diff --git a/power-annotations/utils/jandex/src/main/resources/META-INF/jandex.properties b/power-annotations/utils/jandex/src/main/resources/META-INF/jandex.properties deleted file mode 100644 index 4786f2862..000000000 --- a/power-annotations/utils/jandex/src/main/resources/META-INF/jandex.properties +++ /dev/null @@ -1,16 +0,0 @@ -exclude=\ - net.bytebuddy:byte-buddy-agent \ - net.bytebuddy:byte-buddy \ - org.apiguardian:apiguardian-api \ - org.assertj:assertj-core \ - org.jboss:jandex \ - org.junit.jupiter:junit-jupiter-api \ - org.junit.jupiter:junit-jupiter-engine \ - org.junit.jupiter:junit-jupiter-params \ - org.junit.jupiter:junit-jupiter \ - org.junit.platform:junit-platform-commons \ - org.junit.platform:junit-platform-engine \ - org.mockito:mockito-core \ - org.mockito:mockito-junit-jupiter \ - org.objenesis:objenesis \ - org.opentest4j:opentest4j diff --git a/power-annotations/utils/jandex/src/main/resources/META-INF/services/com.github.t1.annotations.AnnotationsLoader b/power-annotations/utils/jandex/src/main/resources/META-INF/services/com.github.t1.annotations.AnnotationsLoader deleted file mode 100644 index c47a8f632..000000000 --- a/power-annotations/utils/jandex/src/main/resources/META-INF/services/com.github.t1.annotations.AnnotationsLoader +++ /dev/null @@ -1 +0,0 @@ -com.github.t1.powerannotations.utils.jandex.JandexAnnotationsLoader diff --git a/power-annotations/utils/pom.xml b/power-annotations/utils/pom.xml deleted file mode 100644 index 58c5a2ac6..000000000 --- a/power-annotations/utils/pom.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - 4.0.0 - - - io.smallrye - smallrye-power-annotations-parent - 2.0.0-SNAPSHOT - - - smallrye-power-annotations-utils-parent - pom - Power Annotations: Utils - Utils for working with annotations, i.e. currently an abstraction of the Jandex API. Used by the TCK. - - - api - jandex - - From 98d8e4f078c6a5941d1bbfea72a9581ec6c735e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Phillip=20Kr=C3=BCger?= Date: Mon, 27 Jun 2022 17:56:28 +1000 Subject: [PATCH 08/33] Update pom.xml --- pom.xml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/pom.xml b/pom.xml index ef1bd1b9e..175b2fc1d 100644 --- a/pom.xml +++ b/pom.xml @@ -85,7 +85,6 @@ server client tools - power-annotations docs @@ -487,13 +486,6 @@ server/integration-tests-jdk16 - - - --add-opens java.base/java.util=ALL-UNNAMED - - true - From 45d8647451d3f1ec8cf116a306aac1a0c8fdc196 Mon Sep 17 00:00:00 2001 From: Ladislav Thon Date: Fri, 24 Jun 2022 17:10:04 +0200 Subject: [PATCH 09/33] Finish removing Power Annotations --- docs/power-annotations.md | 87 --------------------------------------- mkdocs.yml | 2 - 2 files changed, 89 deletions(-) delete mode 100644 docs/power-annotations.md diff --git a/docs/power-annotations.md b/docs/power-annotations.md deleted file mode 100644 index e537b6d29..000000000 --- a/docs/power-annotations.md +++ /dev/null @@ -1,87 +0,0 @@ -Power Annotations -=========== - -Power-Annotations is actually independent of GraphQL. It’s a generic -mechanism for meta annotations. It consists of annotations you can put -on your code (these are meant to become a separate standard) and the -following implementations: - -1. A maven plugin to build a Jandex index file (and resolve all power - annotations). This replaces the `jandex-maven-plugin`. It currently - has fewer options, but as we only want to build what people actually - need, give us a call if you need more! - -2. A classpath scanner to build a Jandex index at runtime (and resolve - all power annotations). - -There’s also a TCK to test, if an implementation adheres to the standard -defined by the annotations. It uses an Utils API, so the TCK can also -verify implementations not using Jandex. This Annotation Utils API may -be convenient for your usage as well, as, e.g., it also resolves -repeated annotations. - -Annotations -=========== - -Stereotypes ------------ - -The simplest use-case for Stereotypes is renaming annotations, e.g. -`@Property` instead of `@JsonbProperty` (assuming your JSON-B -implementation supported Power Annotations). - -``` java -@Retention(RUNTIME) -@Stereotype -@JsonbProperty -public @interface Property {} -``` - -It gets much more interesting, when you add more annotations from other -(supporting) frameworks to your stereotype, e.g. `@XmlAttribute` from -JAX-B. Now you have one annotation instead of two with both having the -same semantics. - -Properly used, stereotypes are shortcuts describing the role the -annotated element has; functionally as well as a documentation. - -This is exactly what -[CDI-Stereotypes](https://jakarta.ee/specifications/cdi/2.0/cdi-spec-2.0.html#stereotypes) -do, but not restricted to CDI, i.e. the annotations used by any -framework that supports Power Annotations can be used with stereotypes. -We have our own `Stereotype` class; but as we don’t want to depend on -CDI and still not exclude CDI, any annotation named `Stereotype` will -work. - -Mixins ------- - -Say you have a class you want to add annotations to, but you can’t; -e.g., because it’s a class from some library or even from the JDK. You -can create your own class (or interface or even annotation) and annotate -it as `@MixinFor` the target class. The annotations you put on your -mixin class will work as if they were on the target class (if your -framework supports Power Annotations). - -This also works for annotations: say we’re developing an application -packed with annotations from JPA, which doesn’t support mixins (yet). -The application also uses a library that supports mixins but doesn’t -know about JPA, e.g. libraries like SmallRye GraphQL that use Jandex, -and you build the index with the `power-jandex-maven-plugin`. We want -all JPA `@Id` annotations to be recognized as synonyms for GraphQL `@Id` -annotations. We could create a simple mixin for the JPA annotation: - -``` java -@MixinFor(jakarta.persistence.Id.class) -@org.eclipse.microprofile.graphql.Id -public class PersistenceIdMixin {} -``` - -Voilà! MP GraphQL work as if all JPA `@Id` annotations were its own. - -> **Note** -> -> Mixins are a very powerful kind of magic: use them with caution and -> only when strictly necessary. Otherwise, the readers of your code will -> have a hard time to find out why something behaves as if an annotation -> was there, but it’s clearly not. If you can, use Stereotypes instead. diff --git a/mkdocs.yml b/mkdocs.yml index 749bb720c..80d548a06 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -8,8 +8,6 @@ nav: - Customizing JSON deserializers: 'custom-json-deserializers.md' - Directives: 'directives.md' - Custom error extensions: 'custom-error-extensions.md' -# - Power annotations: # Power annotations are unused right now -# - Power annotations: 'power-annotations.md' - Typesafe client: - Basic usage: 'typesafe-client-usage.md' - Reactive: 'typesafe-client-reactive-types.md' From d3474cf54650adca74da3c6ccd4e0e4f9a55dce1 Mon Sep 17 00:00:00 2001 From: Ladislav Thon Date: Mon, 27 Jun 2022 11:08:01 +0200 Subject: [PATCH 10/33] Update to Jandex 2.4.3 and avoid deprecated methods --- .../main/java/io/smallrye/graphql/schema/Annotations.java | 6 +++--- .../smallrye/graphql/schema/creator/ArgumentCreator.java | 6 +++--- .../io/smallrye/graphql/schema/creator/FieldCreator.java | 8 ++++---- .../smallrye/graphql/schema/creator/OperationCreator.java | 2 +- .../graphql/schema/creator/type/InputTypeCreator.java | 4 ++-- .../io/smallrye/graphql/schema/helper/GroupHelper.java | 4 ++-- .../io/smallrye/graphql/schema/helper/MethodHelper.java | 4 ++-- .../graphql/schema/helper/SourceOperationHelper.java | 2 +- pom.xml | 1 + .../io/smallrye/graphql/federation/impl/Federation.java | 2 +- 10 files changed, 20 insertions(+), 19 deletions(-) diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/Annotations.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/Annotations.java index 2a51f06d7..ee9587f45 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/Annotations.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/Annotations.java @@ -217,12 +217,12 @@ public static Annotations getAnnotationsForArray(org.jboss.jandex.Type typeInCol * @return annotation for this argument */ public static Annotations getAnnotationsForArgument(MethodInfo methodInfo, short pos) { - if (pos >= methodInfo.parameters().size()) { + if (pos >= methodInfo.parametersCount()) { throw new IndexOutOfBoundsException( "Parameter at position " + pos + " not found on method " + methodInfo.name()); } - final org.jboss.jandex.Type parameterType = methodInfo.parameters().get(pos); + final org.jboss.jandex.Type parameterType = methodInfo.parameterType(pos); Map annotationMap = getAnnotations(parameterType); @@ -451,7 +451,7 @@ private static Annotations getAnnotationsForInputField(FieldInfo fieldInfo, Meth annotationsForField.putAll(getTypeUseAnnotations(fieldInfo.type())); } if (methodInfo != null) { - List parameters = methodInfo.parameters(); + List parameters = methodInfo.parameterTypes(); if (!parameters.isEmpty()) { org.jboss.jandex.Type param = parameters.get(ZERO); annotationsForField.putAll(getTypeUseAnnotations(param)); diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/ArgumentCreator.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/ArgumentCreator.java index 2d2b9e0b9..4fd2b6b9a 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/ArgumentCreator.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/ArgumentCreator.java @@ -45,11 +45,11 @@ public ArgumentCreator(ReferenceCreator referenceCreator) { * @return an Argument */ public Optional createArgument(Operation operation, MethodInfo methodInfo, short position) { - if (position >= methodInfo.parameters().size()) { + if (position >= methodInfo.parametersCount()) { throw new SchemaBuilderException( "Can not create argument for parameter [" + position + "] " + "on method [" + methodInfo.declaringClass().name() + "#" + methodInfo.name() + "]: " - + "method has only " + methodInfo.parameters().size() + " parameters"); + + "method has only " + methodInfo.parametersCount() + " parameters"); } Annotations annotationsForThisArgument = Annotations.getAnnotationsForArgument(methodInfo, position); @@ -59,7 +59,7 @@ public Optional createArgument(Operation operation, MethodInfo methodI } // Argument Type - Type argumentType = methodInfo.parameters().get(position); + Type argumentType = methodInfo.parameterType(position); // Name String defaultName = methodInfo.parameterName(position); diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/FieldCreator.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/FieldCreator.java index 566ee75de..6656b67f7 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/FieldCreator.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/FieldCreator.java @@ -114,15 +114,15 @@ public Optional createFieldForParameter(MethodInfo method, short position String name = getFieldName(Direction.IN, annotationsForPojo, method.parameterName(position)); // Field Type - Type fieldType = getFieldType(fieldInfo, method.parameters().get(position)); + Type fieldType = getFieldType(fieldInfo, method.parameterType(position)); Reference reference = referenceCreator.createReferenceForPojoField(fieldType, - method.parameters().get(position), annotationsForPojo, Direction.IN, parentObjectReference); + method.parameterType(position), annotationsForPojo, Direction.IN, parentObjectReference); String fieldName = fieldInfo != null ? fieldInfo.name() : null; Field field = new Field(null, fieldName, name, reference); addDirectivesForBeanValidationConstraints(annotationsForPojo, field, parentObjectReference); - populateField(Direction.IN, field, fieldType, method.parameters().get(position), annotationsForPojo); + populateField(Direction.IN, field, fieldType, method.parameterType(position), annotationsForPojo); return Optional.of(field); @@ -249,7 +249,7 @@ private static void validateFieldType(Direction direction, MethodInfo methodInfo private static Type getMethodType(MethodInfo method, Direction direction) { if (direction.equals(Direction.IN)) { - return method.parameters().get(0); + return method.parameterType(0); } return getReturnType(method); } diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/OperationCreator.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/OperationCreator.java index 1f51741cc..a6daca01c 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/OperationCreator.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/OperationCreator.java @@ -78,7 +78,7 @@ public Operation createOperation(MethodInfo methodInfo, OperationType operationT } // Arguments - List parameters = methodInfo.parameters(); + List parameters = methodInfo.parameterTypes(); for (short i = 0; i < parameters.size(); i++) { Optional maybeArgument = argumentCreator.createArgument(operation, methodInfo, i); maybeArgument.ifPresent(operation::addArgument); diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/InputTypeCreator.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/InputTypeCreator.java index 8333ae0d4..348b320a9 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/InputTypeCreator.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/InputTypeCreator.java @@ -101,7 +101,7 @@ public MethodInfo findCreator(ClassInfo classInfo) { for (final MethodInfo constructor : classInfo.constructors()) { if (!Modifier.isPublic(constructor.flags())) continue; - if (constructor.parameters().isEmpty()) { + if (constructor.parameterTypes().isEmpty()) { return constructor; } if (constructor.hasAnnotation(Annotations.JAKARTA_JSONB_CREATOR) @@ -144,7 +144,7 @@ private void addFields(InputType inputType, ClassInfo classInfo, Reference refer } //Parameters of JsonbCreator - for (short i = 0; i < creator.parameters().size(); i++) { + for (short i = 0; i < creator.parametersCount(); i++) { String fieldName = creator.parameterName(i); FieldInfo fieldInfo = allFields.remove(fieldName); final Optional maybeField = fieldCreator.createFieldForParameter(creator, i, fieldInfo, reference); diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/helper/GroupHelper.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/helper/GroupHelper.java index 1d6ecf897..402fe7f96 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/helper/GroupHelper.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/helper/GroupHelper.java @@ -64,8 +64,8 @@ private static Optional getName(AnnotationInstance graphQLApiAnnotation) */ private static Optional getDescription(AnnotationInstance graphQLApiAnnotation) { ClassInfo apiClass = graphQLApiAnnotation.target().asClass(); - if (apiClass.annotations().containsKey(Annotations.DESCRIPTION)) { - List descriptionAnnotations = apiClass.annotations().get(Annotations.DESCRIPTION); + if (apiClass.annotationsMap().containsKey(Annotations.DESCRIPTION)) { + List descriptionAnnotations = apiClass.annotationsMap().get(Annotations.DESCRIPTION); if (descriptionAnnotations != null && !descriptionAnnotations.isEmpty()) { AnnotationValue value = descriptionAnnotations.get(0).value(); if (value != null && value.asString() != null && !value.asString().isEmpty()) { diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/helper/MethodHelper.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/helper/MethodHelper.java index 3b0311b60..0d463479e 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/helper/MethodHelper.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/helper/MethodHelper.java @@ -80,7 +80,7 @@ public static boolean isPropertyMethod(Direction direction, MethodInfo method) { */ private static boolean isSetter(MethodInfo method) { return method.returnType().kind() == Type.Kind.VOID - && method.parameters().size() == 1 + && method.parametersCount() == 1 && isSetterName(method.name()); } @@ -102,7 +102,7 @@ private static boolean isSetter(MethodInfo method) { */ private static boolean isPropertyAccessor(MethodInfo method) { return method.returnType().kind() != Type.Kind.VOID - && method.parameters().isEmpty() + && method.parameterTypes().isEmpty() && (method.hasAnnotation(Annotations.QUERY) || isGetterName(method.name())); } diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/helper/SourceOperationHelper.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/helper/SourceOperationHelper.java index 59d87d2a4..0cbe9f761 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/helper/SourceOperationHelper.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/helper/SourceOperationHelper.java @@ -54,7 +54,7 @@ private Map> scanAllSourceAnnotations(boolean if (target.kind().equals(AnnotationTarget.Kind.METHOD_PARAMETER)) { MethodParameterInfo methodParameter = target.asMethodParameter(); short position = methodParameter.position(); - Type returnType = methodParameter.method().parameters().get(position); + Type returnType = methodParameter.method().parameterType(position); if (forReturnType == null || Arrays.asList(forReturnType).contains(returnType.kind())) { DotName name = getName(returnType); sourceFields.computeIfAbsent(name, k -> new ArrayList<>()).add(methodParameter); diff --git a/pom.xml b/pom.xml index 175b2fc1d..ec7e0bf95 100644 --- a/pom.xml +++ b/pom.xml @@ -21,6 +21,7 @@ 4.0.1 1.3 + 2.4.3.Final 3.0.0-RC2 4.0.0-RC1 2.0.0-RC2 diff --git a/server/federation/runtime/src/main/java/io/smallrye/graphql/federation/impl/Federation.java b/server/federation/runtime/src/main/java/io/smallrye/graphql/federation/impl/Federation.java index 1de723a82..200e7abda 100644 --- a/server/federation/runtime/src/main/java/io/smallrye/graphql/federation/impl/Federation.java +++ b/server/federation/runtime/src/main/java/io/smallrye/graphql/federation/impl/Federation.java @@ -303,7 +303,7 @@ private void addFederatedEntityResolvers() { private static Method toReflectionMethod(MethodInfo methodInfo) { try { Class declaringClass = Class.forName(methodInfo.declaringClass().name().toString()); - Class[] parameterTypes = methodInfo.parameters().stream() + Class[] parameterTypes = methodInfo.parameterTypes().stream() .map(Type::asClassType) .map(Type::name) .map(DotName::toString) From 04574d4c7844a1ff770198ffaead47590853032a Mon Sep 17 00:00:00 2001 From: Ladislav Thon Date: Wed, 29 Jun 2022 14:35:23 +0200 Subject: [PATCH 11/33] Add note about locale-sensitive tests to the README --- README.adoc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.adoc b/README.adoc index 492cf2c24..2f4238047 100644 --- a/README.adoc +++ b/README.adoc @@ -26,6 +26,10 @@ SmallRye GraphQL is an implementation of mvn clean install ---- +Note that some tests perform locale-sensitive assertions. +If you use non-English locale, you need to adjust the command above. +For example: `LANG=C mvn clean install` + === Testing against the unreleased v 2.1-SNAPSHOT of MicroProfile GraphQL (You need to build that version of MicroProfile GraphQL locally first to make the snapshot versions available in your repository) From 896de9f4e2a08d41d7d901414e1317a02179b746 Mon Sep 17 00:00:00 2001 From: Craig Day Date: Mon, 18 Jul 2022 11:17:04 -0700 Subject: [PATCH 12/33] add support for GraphQL union type --- .../smallrye/graphql/schema/Annotations.java | 3 +- .../graphql/schema/SchemaBuilder.java | 13 ++- .../schema/creator/ReferenceCreator.java | 54 +++++++---- .../schema/creator/type/AbstractCreator.java | 31 +++++-- .../schema/creator/type/UnionCreator.java | 43 +++++++++ .../graphql/schema/model/ReferenceType.java | 7 +- .../smallrye/graphql/schema/model/Schema.java | 21 +++++ .../smallrye/graphql/schema/model/Type.java | 41 +++++++-- .../graphql/schema/model/UnionType.java | 24 +++++ .../java/io/smallrye/graphql/api/Union.java | 17 ++++ .../smallrye/graphql/bootstrap/Bootstrap.java | 37 +++++++- .../resolver/UnionOutputRegistry.java | 46 ++++++++++ .../execution/resolver/UnionResolver.java | 29 ++++++ .../execution/ExecutionUnionsTest.java | 90 +++++++++++++++++++ .../graphql/test/MemberOfManyUnions.java | 21 +++++ .../graphql/test/ObjectWithColor.java | 22 +++++ .../smallrye/graphql/test/ObjectWithName.java | 22 +++++ .../smallrye/graphql/test/TestEndpoint.java | 22 ++++- .../io/smallrye/graphql/test/TestUnion.java | 8 ++ .../graphql/test/UnionInterfaceOne.java | 9 ++ .../graphql/test/UnionInterfaceTwo.java | 9 ++ .../io/smallrye/graphql/test/UnionMember.java | 14 +++ .../graphql/test/UnionOfInterfaces.java | 7 ++ 23 files changed, 552 insertions(+), 38 deletions(-) create mode 100644 common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/UnionCreator.java create mode 100644 common/schema-model/src/main/java/io/smallrye/graphql/schema/model/UnionType.java create mode 100644 server/api/src/main/java/io/smallrye/graphql/api/Union.java create mode 100644 server/implementation/src/main/java/io/smallrye/graphql/execution/resolver/UnionOutputRegistry.java create mode 100644 server/implementation/src/main/java/io/smallrye/graphql/execution/resolver/UnionResolver.java create mode 100644 server/implementation/src/test/java/io/smallrye/graphql/execution/ExecutionUnionsTest.java create mode 100644 server/implementation/src/test/java/io/smallrye/graphql/test/MemberOfManyUnions.java create mode 100644 server/implementation/src/test/java/io/smallrye/graphql/test/ObjectWithColor.java create mode 100644 server/implementation/src/test/java/io/smallrye/graphql/test/ObjectWithName.java create mode 100644 server/implementation/src/test/java/io/smallrye/graphql/test/TestUnion.java create mode 100644 server/implementation/src/test/java/io/smallrye/graphql/test/UnionInterfaceOne.java create mode 100644 server/implementation/src/test/java/io/smallrye/graphql/test/UnionInterfaceTwo.java create mode 100644 server/implementation/src/test/java/io/smallrye/graphql/test/UnionMember.java create mode 100644 server/implementation/src/test/java/io/smallrye/graphql/test/UnionOfInterfaces.java diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/Annotations.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/Annotations.java index ee9587f45..a0c88dc72 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/Annotations.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/Annotations.java @@ -207,7 +207,7 @@ public static Annotations getAnnotationsForArray(org.jboss.jandex.Type typeInCol return new Annotations(annotationMap); } - // + // /** * Used when we are creating operation and arguments for these operations @@ -580,6 +580,7 @@ private static Map getAnnotationsWithFilter(org.jbo public static final DotName INPUT = DotName.createSimple("org.eclipse.microprofile.graphql.Input"); public static final DotName TYPE = DotName.createSimple("org.eclipse.microprofile.graphql.Type"); public static final DotName INTERFACE = DotName.createSimple("org.eclipse.microprofile.graphql.Interface"); + public static final DotName UNION = DotName.createSimple("io.smallrye.graphql.api.Union"); public static final DotName ENUM = DotName.createSimple("org.eclipse.microprofile.graphql.Enum"); public static final DotName ID = DotName.createSimple("org.eclipse.microprofile.graphql.Id"); public static final DotName DESCRIPTION = DotName.createSimple("org.eclipse.microprofile.graphql.Description"); diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/SchemaBuilder.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/SchemaBuilder.java index cf1711924..9efc63cd3 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/SchemaBuilder.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/SchemaBuilder.java @@ -2,6 +2,7 @@ import static io.smallrye.graphql.schema.Annotations.DIRECTIVE; +import io.smallrye.graphql.schema.creator.type.UnionCreator; import java.util.Collection; import java.util.List; import java.util.Optional; @@ -64,6 +65,7 @@ public class SchemaBuilder { private final ReferenceCreator referenceCreator; private final OperationCreator operationCreator; private final DirectiveTypeCreator directiveTypeCreator; + private final UnionCreator unionCreator; /** * This builds the Schema from Jandex @@ -98,6 +100,7 @@ private SchemaBuilder(TypeAutoNameStrategy autoNameStrategy) { typeCreator = new TypeCreator(referenceCreator, fieldCreator, operationCreator); interfaceCreator = new InterfaceCreator(referenceCreator, fieldCreator, operationCreator); directiveTypeCreator = new DirectiveTypeCreator(referenceCreator); + unionCreator = new UnionCreator(referenceCreator); } private Schema generateSchema() { @@ -130,7 +133,7 @@ private Schema generateSchema() { // Add all custom datafetchers addDataFetchers(schema); - // Reset the maps. + // Reset the maps. referenceCreator.clear(); return schema; @@ -162,6 +165,9 @@ private void addTypesToSchema(Schema schema) { // Add the interface types createAndAddToSchema(ReferenceType.INTERFACE, interfaceCreator, schema::addInterface); + // Add the union types + createAndAddToSchema(ReferenceType.UNION, unionCreator, schema::addUnion); + // Add the enum types createAndAddToSchema(ReferenceType.ENUM, enumCreator, schema::addEnum); } @@ -185,6 +191,11 @@ private void addOutstandingTypesToSchema(Schema schema) { keepGoing = true; } + // See if there is any unions we missed + if (findOutstandingAndAddToSchema(ReferenceType.UNION, unionCreator, schema::containsUnion, schema::addUnion)) { + keepGoing = true; + } + // See if there is any enums we missed if (findOutstandingAndAddToSchema(ReferenceType.ENUM, enumCreator, schema::containsEnum, schema::addEnum)) { diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/ReferenceCreator.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/ReferenceCreator.java index f2f7f1f0c..39eea5917 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/ReferenceCreator.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/ReferenceCreator.java @@ -34,9 +34,9 @@ /** * Here we create references to things that might not yet exist. - * + * * We store all references to be created later. - * + * * @author Phillip Kruger (phillip.kruger@redhat.com) */ public class ReferenceCreator { @@ -46,12 +46,14 @@ public class ReferenceCreator { private final Queue typeReferenceQueue = new ArrayDeque<>(); private final Queue enumReferenceQueue = new ArrayDeque<>(); private final Queue interfaceReferenceQueue = new ArrayDeque<>(); + private final Queue unionReferenceQueue = new ArrayDeque<>(); // Some maps we populate during scanning private final Map inputReferenceMap = new HashMap<>(); private final Map typeReferenceMap = new HashMap<>(); private final Map enumReferenceMap = new HashMap<>(); private final Map interfaceReferenceMap = new HashMap<>(); + private final Map unionReferenceMap = new HashMap<>(); private final TypeAutoNameStrategy autoNameStrategy; @@ -68,16 +70,18 @@ public void clear() { typeReferenceMap.clear(); enumReferenceMap.clear(); interfaceReferenceMap.clear(); + unionReferenceMap.clear(); inputReferenceQueue.clear(); typeReferenceQueue.clear(); enumReferenceQueue.clear(); interfaceReferenceQueue.clear(); + unionReferenceQueue.clear(); } /** * Get the values for a certain type - * + * * @param referenceType the type * @return the references */ @@ -87,7 +91,7 @@ public Queue values(ReferenceType referenceType) { /** * Get the Type auto name strategy - * + * * @return the strategy as supplied */ public TypeAutoNameStrategy getTypeAutoNameStrategy() { @@ -96,7 +100,7 @@ public TypeAutoNameStrategy getTypeAutoNameStrategy() { /** * Get a reference to a field type for an adapter on a field - * + * * @param direction the direction * @param fieldType the java type * @param annotations annotation on this operations method @@ -111,7 +115,7 @@ public Reference createReferenceForAdapter(Type fieldType, /** * Get a reference to a field type for an operation Direction is OUT on a field (and IN on an argument) In the case * of operations, there is no fields (only methods) - * + * * @param fieldType the java type * @param annotationsForMethod annotation on this operations method * @return a reference to the type @@ -123,7 +127,7 @@ public Reference createReferenceForOperationField(Type fieldType, Annotations an /** * Get a reference to a argument type for an operation Direction is IN on an argument (and OUT on a field) In the * case of operation, there is no field (only methods) - * + * * @param argumentType the java type * @param annotationsForThisArgument annotations on this argument * @return a reference to the argument @@ -145,9 +149,9 @@ public Reference createReferenceForSourceArgument(Type argumentType, Annotations /** * Get a reference to a field (method response) on an interface - * + * * Interfaces is only usable on Type, so the direction in OUT. - * + * * @param methodType the method response type * @param annotationsForThisMethod annotations on this method * @return a reference to the type @@ -159,9 +163,9 @@ public Reference createReferenceForInterfaceField(Type methodType, Annotations a /** * Get a reference to a Field Type for a InputType or Type. - * + * * We need both the type and the getter/setter method as both is applicable. - * + * * @param direction in or out * @param fieldType the field type * @param methodType the method type @@ -180,7 +184,7 @@ public Reference createReferenceForPojoField(Type fieldType, /** * This method create a reference to type that might not yet exist. It also store to be created later, if we do not * already know about it. - * + * * @param direction the direction (in or out) * @param classInfo the Java class * @param createAdapedToType create the type in the schema @@ -197,7 +201,7 @@ private Reference createReference(Direction direction, ReferenceType referenceType = getCorrectReferenceType(classInfo, annotationsForClass, direction); - if (referenceType.equals(ReferenceType.INTERFACE)) { + if (referenceType.equals(ReferenceType.INTERFACE) || referenceType.equals(ReferenceType.UNION)) { // Also check that we create all implementations Collection knownDirectImplementors = ScanningContext.getIndex() .getAllKnownImplementors(classInfo.name()); @@ -229,7 +233,7 @@ private Reference createReference(Direction direction, createReference(direction, impl, createAdapedToType, createAdapedWithType, parametrizedTypeArgumentsReferencesImpl, - true); + referenceType.equals(ReferenceType.INTERFACE)); } } @@ -276,8 +280,20 @@ private Reference createReference(Direction direction, private static boolean isInterface(ClassInfo classInfo, Annotations annotationsForClass) { boolean isJavaInterface = Classes.isInterface(classInfo); if (isJavaInterface) { - if (annotationsForClass.containsOneOfTheseAnnotations(Annotations.TYPE, Annotations.INPUT)) { - // This should be mapped to a type/input and not an interface + if (annotationsForClass.containsOneOfTheseAnnotations(Annotations.TYPE, Annotations.INPUT, Annotations.UNION)) { + // This should be mapped to a type/input/union and not an interface + return false; + } + return true; + } + return false; + } + + private static boolean isUnion(ClassInfo classInfo, Annotations annotationsForClass) { + boolean isJavaInterface = Classes.isInterface(classInfo); + if (isJavaInterface) { + if (annotationsForClass.containsOneOfTheseAnnotations(Annotations.TYPE, Annotations.INPUT, Annotations.INTERFACE)) { + // This should be mapped to a type/input/interface and not a union return false; } return true; @@ -468,6 +484,8 @@ private Map getReferenceMap(ReferenceType referenceType) { return inputReferenceMap; case INTERFACE: return interfaceReferenceMap; + case UNION: + return unionReferenceMap; case TYPE: return typeReferenceMap; default: @@ -483,6 +501,8 @@ private Queue getReferenceQueue(ReferenceType referenceType) { return inputReferenceQueue; case INTERFACE: return interfaceReferenceQueue; + case UNION: + return unionReferenceQueue; case TYPE: return typeReferenceQueue; default: @@ -493,6 +513,8 @@ private Queue getReferenceQueue(ReferenceType referenceType) { private static ReferenceType getCorrectReferenceType(ClassInfo classInfo, Annotations annotations, Direction direction) { if (isInterface(classInfo, annotations)) { return ReferenceType.INTERFACE; + } else if (isUnion(classInfo, annotations)) { + return ReferenceType.UNION; } else if (Classes.isEnum(classInfo)) { return ReferenceType.ENUM; } else if (direction.equals(Direction.IN)) { diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/AbstractCreator.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/AbstractCreator.java index 5374b565f..ce5a2e944 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/AbstractCreator.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/AbstractCreator.java @@ -67,8 +67,8 @@ public Type create(ClassInfo classInfo, Reference reference) { // Fields addFields(type, classInfo, reference); - // Interfaces - addInterfaces(type, classInfo, reference); + // Interfaces/Unions + addPolymorphicTypes(type, classInfo, reference); // Operations addOperations(type, classInfo); @@ -85,19 +85,25 @@ private void addDirectives(Type type, ClassInfo classInfo) { type.setDirectiveInstances(directives.buildDirectiveInstances(classInfo::classAnnotation)); } - private void addInterfaces(Type type, ClassInfo classInfo, Reference reference) { + private void addPolymorphicTypes(Type type, ClassInfo classInfo, Reference reference) { List interfaceNames = classInfo.interfaceTypes(); for (org.jboss.jandex.Type interfaceType : interfaceNames) { + String interfaceFullName = interfaceType.name().toString(); // Ignore java interfaces (like Serializable) - if (InterfaceCreator.canAddInterfaceIntoScheme(interfaceType.name().toString())) { + // TODO: should this check be renamed now that it is used for both union and interface checks? + if (InterfaceCreator.canAddInterfaceIntoScheme(interfaceFullName)) { ClassInfo interfaceInfo = ScanningContext.getIndex().getClassByName(interfaceType.name()); if (interfaceInfo != null) { Annotations annotationsForInterface = Annotations.getAnnotationsForClass(interfaceInfo); Reference interfaceRef = referenceCreator.createReferenceForInterfaceField(interfaceType, annotationsForInterface, reference); - type.addInterface(interfaceRef); - // add all parent interfaces recursively as GraphQL schema requires it - addInterfaces(type, interfaceInfo, reference); + if (annotationsForInterface.containsOneOfTheseAnnotations(Annotations.UNION)) { + type.addUnion(interfaceRef); + } else { + type.addInterface(interfaceRef); + // add all parent interfaces recursively as GraphQL schema requires it + addPolymorphicTypes(type, interfaceInfo, reference); + } } } } @@ -134,6 +140,17 @@ protected Map toOperations(Map methodParameterInfos = sourceFields.get(DotName.createSimple(className)); + for (MethodParameterInfo methodParameterInfo : methodParameterInfos) { + MethodInfo methodInfo = methodParameterInfo.method(); + Operation o = operationCreator.createOperation(methodInfo, OperationType.QUERY, type); + operations.put(o.getName(), o); + } + } + } return operations; } } diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/UnionCreator.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/UnionCreator.java new file mode 100644 index 000000000..1c07a7baf --- /dev/null +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/UnionCreator.java @@ -0,0 +1,43 @@ +package io.smallrye.graphql.schema.creator.type; + +import io.smallrye.graphql.schema.Annotations; +import io.smallrye.graphql.schema.creator.ReferenceCreator; +import io.smallrye.graphql.schema.helper.DescriptionHelper; +import io.smallrye.graphql.schema.helper.TypeNameHelper; +import io.smallrye.graphql.schema.model.Reference; +import io.smallrye.graphql.schema.model.ReferenceType; +import io.smallrye.graphql.schema.model.UnionType; +import org.jboss.jandex.ClassInfo; +import org.jboss.logging.Logger; + +import java.util.Optional; + +public class UnionCreator implements Creator { + + private static final Logger LOG = Logger.getLogger(UnionCreator.class.getName()); + + private final ReferenceCreator referenceCreator; + + public UnionCreator(ReferenceCreator referenceCreator) { + this.referenceCreator = referenceCreator; + } + + @Override + public UnionType create(ClassInfo classInfo, Reference reference) { + LOG.debug("Creating union from " + classInfo.name().toString()); + + Annotations annotations = Annotations.getAnnotationsForClass(classInfo); + + // Name + String name = TypeNameHelper.getAnyTypeName(classInfo, + annotations, + referenceCreator.getTypeAutoNameStrategy(), + ReferenceType.UNION, + reference.getClassParametrizedTypes()); + + // Description + Optional maybeDescription = DescriptionHelper.getDescriptionForType(annotations); + + return new UnionType(classInfo.name().toString(), name, maybeDescription.orElse(null)); + } +} diff --git a/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/ReferenceType.java b/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/ReferenceType.java index 6da3491f2..94f82e0a2 100644 --- a/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/ReferenceType.java +++ b/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/ReferenceType.java @@ -2,9 +2,9 @@ /** * Type of reference - * + * * Because we refer to types before they might exist, we need an indication of the type - * + * * @author Phillip Kruger (phillip.kruger@redhat.com) */ public enum ReferenceType { @@ -12,5 +12,6 @@ public enum ReferenceType { TYPE, ENUM, INTERFACE, + UNION, SCALAR -} \ No newline at end of file +} diff --git a/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/Schema.java b/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/Schema.java index bae397673..f1418d312 100644 --- a/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/Schema.java +++ b/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/Schema.java @@ -29,6 +29,7 @@ public final class Schema implements Serializable { private Map inputs = new HashMap<>(); private Map types = new HashMap<>(); private Map interfaces = new HashMap<>(); + private Map unions = new HashMap<>(); private Map enums = new HashMap<>(); private Map errors = new HashMap<>(); @@ -201,6 +202,26 @@ public boolean hasInterfaces() { return !this.interfaces.isEmpty(); } + public Map getUnions() { + return unions; + } + + public void setUnions(Map unions) { + this.unions = unions; + } + + public void addUnion(UnionType unionType) { + this.unions.put(unionType.getName(), unionType); + } + + public boolean containsUnion(String name) { + return this.unions.containsKey(name); + } + + public boolean hasUnions() { + return !this.unions.isEmpty(); + } + public Map getEnums() { return enums; } diff --git a/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/Type.java b/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/Type.java index 29846a2cb..ea0a5dc08 100644 --- a/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/Type.java +++ b/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/Type.java @@ -7,19 +7,19 @@ /** * Represent a GraphQL Type. - * + * * A Type is one of the options for a response, it's a complex type that contains * fields that itself is of a certain type. - * + * * It's a Java Bean that we only care about the getter methods and properties. - * + * * A Type is a java bean with fields, but can optionally also have operations (queries) * that is done with the Source annotation. - * + * * A Type can also optionally implements interfaces. - * + * * @see Object - * + * * @author Phillip Kruger (phillip.kruger@redhat.com) */ public final class Type extends Reference { @@ -33,6 +33,7 @@ public final class Type extends Reference { private Map batchOperations = new LinkedHashMap<>(); private Set interfaces = new LinkedHashSet<>(); + private Set unionMemberships = new LinkedHashSet<>(); public Type() { } @@ -131,13 +132,37 @@ public boolean isInterface() { } public void setIsInterface(boolean isInterface) { - isInterface = isInterface; + this.isInterface = isInterface; + } + + public Set getUnionMemberships() { + return unionMemberships; + } + + public void addUnion(Reference unionType) { + this.unionMemberships.add(unionType); + } + + public boolean hasUnionMemberships() { + return !this.unionMemberships.isEmpty(); + } + + public boolean isMemberOfUnion(Reference unionType) { + for (Reference u : unionMemberships) { + if (u.getName().equals(unionType.getName()) + && u.getClassName().equals(unionType.getClassName()) + && u.getGraphQLClassName().equals(unionType.getGraphQLClassName())) { + return true; + } + } + return false; } @Override public String toString() { return "Type{" + "description=" + description + ", isInterface=" + isInterface + ", fields=" + fields + ", operations=" - + operations + ", batchOperations=" + batchOperations + ", interfaces=" + interfaces + '}'; + + operations + ", batchOperations=" + batchOperations + ", interfaces=" + interfaces + ", unionMemberships=" + + unionMemberships + '}'; } } diff --git a/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/UnionType.java b/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/UnionType.java new file mode 100644 index 000000000..0edf1b437 --- /dev/null +++ b/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/UnionType.java @@ -0,0 +1,24 @@ +package io.smallrye.graphql.schema.model; + +public final class UnionType extends Reference { + + private String description; + + public UnionType(String className, String name, String description) { + super(className, name, ReferenceType.UNION); + this.description = description; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Override + public String toString() { + return "UnionType{" + "description=" + description + '}'; + } +} diff --git a/server/api/src/main/java/io/smallrye/graphql/api/Union.java b/server/api/src/main/java/io/smallrye/graphql/api/Union.java new file mode 100644 index 000000000..32fd25bad --- /dev/null +++ b/server/api/src/main/java/io/smallrye/graphql/api/Union.java @@ -0,0 +1,17 @@ +package io.smallrye.graphql.api; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import io.smallrye.common.annotation.Experimental; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +@Retention(RUNTIME) +@Target(TYPE) +@Experimental("Allow you to mark an interface as a GraphQL Union. Not covered by the specification. " + + "Subject to change.") +public @interface Union { + + String value() default ""; +} diff --git a/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/Bootstrap.java b/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/Bootstrap.java index 49d9f9a71..62ac2e3d9 100644 --- a/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/Bootstrap.java +++ b/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/Bootstrap.java @@ -43,6 +43,7 @@ import graphql.schema.GraphQLScalarType; import graphql.schema.GraphQLSchema; import graphql.schema.GraphQLTypeReference; +import graphql.schema.GraphQLUnionType; import graphql.schema.visibility.BlockedFields; import graphql.schema.visibility.GraphqlFieldVisibility; import io.smallrye.graphql.SmallRyeGraphQLServerMessages; @@ -54,6 +55,8 @@ import io.smallrye.graphql.execution.event.EventEmitter; import io.smallrye.graphql.execution.resolver.InterfaceOutputRegistry; import io.smallrye.graphql.execution.resolver.InterfaceResolver; +import io.smallrye.graphql.execution.resolver.UnionOutputRegistry; +import io.smallrye.graphql.execution.resolver.UnionResolver; import io.smallrye.graphql.json.JsonBCreator; import io.smallrye.graphql.json.JsonInputRegistry; import io.smallrye.graphql.scalar.GraphQLScalarTypes; @@ -71,6 +74,7 @@ import io.smallrye.graphql.schema.model.ReferenceType; import io.smallrye.graphql.schema.model.Schema; import io.smallrye.graphql.schema.model.Type; +import io.smallrye.graphql.schema.model.UnionType; import io.smallrye.graphql.schema.model.Wrapper; import io.smallrye.graphql.spi.ClassloadingService; import io.smallrye.graphql.spi.LookupService; @@ -90,6 +94,7 @@ public class Bootstrap { private final Set directiveTypes = new LinkedHashSet<>(); private final Map enumMap = new HashMap<>(); private final Map interfaceMap = new HashMap<>(); + private final Map unionMap = new HashMap<>(); private final Map inputMap = new HashMap<>(); private final Map typeMap = new HashMap<>(); @@ -151,6 +156,7 @@ private void generateGraphQLSchema() { createGraphQLDirectiveTypes(); createGraphQLEnumTypes(); createGraphQLInterfaceTypes(); + createGraphQLUnionTypes(); createGraphQLObjectTypes(); createGraphQLInputObjectTypes(); @@ -161,6 +167,7 @@ private void generateGraphQLSchema() { schemaBuilder.additionalDirectives(directiveTypes); schemaBuilder.additionalTypes(new HashSet<>(enumMap.values())); schemaBuilder.additionalTypes(new HashSet<>(interfaceMap.values())); + schemaBuilder.additionalTypes(new HashSet<>(unionMap.values())); schemaBuilder.additionalTypes(new HashSet<>(typeMap.values())); schemaBuilder.additionalTypes(new HashSet<>(inputMap.values())); @@ -403,6 +410,33 @@ private void createGraphQLInterfaceType(Type interfaceType) { this.interfaceMap.put(interfaceType.getName(), graphQLInterfaceType); } + private void createGraphQLUnionTypes() { + // We can't create unions if there are no types to be a member of them + if (schema.hasUnions() && schema.hasTypes()) { + for (UnionType unionType : schema.getUnions().values()) { + createGraphQLUnionType(unionType); + } + } + } + + private void createGraphQLUnionType(UnionType unionType) { + GraphQLUnionType.Builder unionTypeBuilder = GraphQLUnionType.newUnionType() + .name(unionType.getName()) + .description(unionType.getDescription()); + + // Members + for (Type type : schema.getTypes().values()) { + if (type.isMemberOfUnion(unionType)) { + unionTypeBuilder.possibleType(GraphQLTypeReference.typeRef(type.getName())); + } + } + + GraphQLUnionType graphQLUnionType = unionTypeBuilder.build(); + // To resolve the concrete class + this.codeRegistryBuilder.typeResolver(graphQLUnionType, new UnionResolver(unionType)); + this.unionMap.put(unionType.getName(), graphQLUnionType); + } + private void createGraphQLInputObjectTypes() { if (schema.hasInputs()) { for (InputType inputType : schema.getInputs().values()) { @@ -498,8 +532,9 @@ private void createGraphQLObjectType(Type type) { GraphQLObjectType graphQLObjectType = objectTypeBuilder.build(); typeMap.put(type.getName(), graphQLObjectType); - // Register this output for interface type resolving + // Register this output for interface/union type resolving InterfaceOutputRegistry.register(type, graphQLObjectType); + UnionOutputRegistry.register(type, graphQLObjectType); } private GraphQLDirective createGraphQLDirectiveFrom(DirectiveInstance directiveInstance) { diff --git a/server/implementation/src/main/java/io/smallrye/graphql/execution/resolver/UnionOutputRegistry.java b/server/implementation/src/main/java/io/smallrye/graphql/execution/resolver/UnionOutputRegistry.java new file mode 100644 index 000000000..60201e1aa --- /dev/null +++ b/server/implementation/src/main/java/io/smallrye/graphql/execution/resolver/UnionOutputRegistry.java @@ -0,0 +1,46 @@ +package io.smallrye.graphql.execution.resolver; + +import graphql.schema.GraphQLObjectType; +import io.smallrye.graphql.schema.model.Reference; +import io.smallrye.graphql.schema.model.Type; +import io.smallrye.graphql.schema.model.UnionType; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +public class UnionOutputRegistry { + + private static final Map> unionMap = new HashMap<>(); + + private UnionOutputRegistry() { + } + + public static void register(Type type, GraphQLObjectType graphQLObjectType) { + if (type.hasUnionMemberships()) { + Set memberships = type.getUnionMemberships(); + for (Reference i : memberships) { + String union = i.getName(); + Map concreteMap = getConcreteMap(union); + concreteMap.put(type.getClassName(), graphQLObjectType); + unionMap.put(union, concreteMap); + } + } + } + + public static GraphQLObjectType getGraphQLObjectType(UnionType unionType, String concreteName) { + String union = unionType.getName(); + if (unionMap.containsKey(union)) { + return unionMap.get(union).get(concreteName); + } + return null; + } + + private static Map getConcreteMap(String union) { + if (unionMap.containsKey(union)) { + return unionMap.get(union); + } else { + return new HashMap<>(); + } + } +} diff --git a/server/implementation/src/main/java/io/smallrye/graphql/execution/resolver/UnionResolver.java b/server/implementation/src/main/java/io/smallrye/graphql/execution/resolver/UnionResolver.java new file mode 100644 index 000000000..295fbbd41 --- /dev/null +++ b/server/implementation/src/main/java/io/smallrye/graphql/execution/resolver/UnionResolver.java @@ -0,0 +1,29 @@ +package io.smallrye.graphql.execution.resolver; + +import static io.smallrye.graphql.SmallRyeGraphQLServerMessages.msg; + +import graphql.TypeResolutionEnvironment; +import graphql.schema.GraphQLObjectType; +import graphql.schema.TypeResolver; +import io.smallrye.graphql.schema.model.UnionType; + +public class UnionResolver implements TypeResolver { + + private final UnionType unionType; + + public UnionResolver(UnionType unionType) { + this.unionType = unionType; + } + + @Override + public GraphQLObjectType getType(TypeResolutionEnvironment tre) { + String concreteClassName = tre.getObject().getClass().getName(); + + GraphQLObjectType graphQLObjectType = UnionOutputRegistry.getGraphQLObjectType(unionType, concreteClassName); + if (graphQLObjectType != null) { + return graphQLObjectType; + } else { + throw msg.concreteClassNotFoundForInterface(concreteClassName, unionType.getName()); + } + } +} diff --git a/server/implementation/src/test/java/io/smallrye/graphql/execution/ExecutionUnionsTest.java b/server/implementation/src/test/java/io/smallrye/graphql/execution/ExecutionUnionsTest.java new file mode 100644 index 000000000..23b0c3557 --- /dev/null +++ b/server/implementation/src/test/java/io/smallrye/graphql/execution/ExecutionUnionsTest.java @@ -0,0 +1,90 @@ +package io.smallrye.graphql.execution; + +import jakarta.json.JsonObject; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test against unions + * + * @author Craig Day (cday@zendesk.com) + */ +public class ExecutionUnionsTest extends ExecutionTestBase { + + @Test + public void testBasicUnion() { + JsonObject data = executeAndGetData(TEST_BASIC_UNION); + JsonObject testObject = data.getJsonObject("basicUnion"); + + assertNotNull(testObject); + + assertFalse(testObject.isNull("name"), "name should not be null"); + assertEquals("my name", testObject.getString("name")); + } + + @Test + public void testUnionOfInterfacesReturningDirectImplementer() { + JsonObject data = executeAndGetData(TEST_NESTED_INTERFACE_DIRECT_IMPL); + JsonObject testObject = data.getJsonObject("unionOfInterfacesDirectImplementor"); + + assertNotNull(testObject); + + assertFalse(testObject.isNull("message"), "message should not be null"); + assertEquals("im in many unions", testObject.getString("message")); + } + + @Test + public void testUnionOfInterfacesReturningNestedInterfaceImpl1() { + JsonObject data = executeAndGetData(TEST_NESTED_INTERFACE_1); + JsonObject testObject = data.getJsonObject("unionOfInterfacesNestedInterface1"); + + assertNotNull(testObject); + + assertFalse(testObject.isNull("name"), "name should not be null"); + assertEquals("my name", testObject.getString("name")); + } + + @Test + public void testUnionOfInterfacesReturningNestedInterfaceImpl2() { + JsonObject data = executeAndGetData(TEST_NESTED_INTERFACE_2); + JsonObject testObject = data.getJsonObject("unionOfInterfacesNestedInterface2"); + + assertNotNull(testObject); + + assertFalse(testObject.isNull("color"), "color should not be null"); + assertEquals("purple", testObject.getString("color")); + } + + private static final String TEST_BASIC_UNION = "{\n" + + " basicUnion {\n" + + " ... on UnionMember {\n" + + " name\n" + + " }\n" + + " }\n" + + "}"; + + private static final String TEST_NESTED_INTERFACE_DIRECT_IMPL = "{\n" + + " unionOfInterfacesDirectImplementor {\n" + + " ... on MemberOfManyUnions {\n" + + " message\n" + + " }\n" + + " }\n" + + "}"; + + private static final String TEST_NESTED_INTERFACE_1 = "{\n" + + " unionOfInterfacesNestedInterface1 {\n" + + " ... on ObjectWithName {\n" + + " name\n" + + " }\n" + + " }\n" + + "}"; + + private static final String TEST_NESTED_INTERFACE_2 = "{\n" + + " unionOfInterfacesNestedInterface2 {\n" + + " ... on ObjectWithColor {\n" + + " color\n" + + " }\n" + + " }\n" + + "}"; +} diff --git a/server/implementation/src/test/java/io/smallrye/graphql/test/MemberOfManyUnions.java b/server/implementation/src/test/java/io/smallrye/graphql/test/MemberOfManyUnions.java new file mode 100644 index 000000000..f1c19ec5b --- /dev/null +++ b/server/implementation/src/test/java/io/smallrye/graphql/test/MemberOfManyUnions.java @@ -0,0 +1,21 @@ +package io.smallrye.graphql.test; + +public class MemberOfManyUnions implements TestUnion, UnionOfInterfaces { + + private String message; + + public MemberOfManyUnions() { + } + + public MemberOfManyUnions(String message) { + this.message = message; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/server/implementation/src/test/java/io/smallrye/graphql/test/ObjectWithColor.java b/server/implementation/src/test/java/io/smallrye/graphql/test/ObjectWithColor.java new file mode 100644 index 000000000..a7fede8cf --- /dev/null +++ b/server/implementation/src/test/java/io/smallrye/graphql/test/ObjectWithColor.java @@ -0,0 +1,22 @@ +package io.smallrye.graphql.test; + +public class ObjectWithColor implements UnionInterfaceTwo { + + private String color; + + public ObjectWithColor() { + } + + public ObjectWithColor(String color) { + this.color = color; + } + + @Override + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } +} diff --git a/server/implementation/src/test/java/io/smallrye/graphql/test/ObjectWithName.java b/server/implementation/src/test/java/io/smallrye/graphql/test/ObjectWithName.java new file mode 100644 index 000000000..97ce68ce4 --- /dev/null +++ b/server/implementation/src/test/java/io/smallrye/graphql/test/ObjectWithName.java @@ -0,0 +1,22 @@ +package io.smallrye.graphql.test; + +public class ObjectWithName implements UnionInterfaceOne { + + private String name; + + public ObjectWithName() { + } + + public ObjectWithName(String name) { + this.name = name; + } + + @Override + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/server/implementation/src/test/java/io/smallrye/graphql/test/TestEndpoint.java b/server/implementation/src/test/java/io/smallrye/graphql/test/TestEndpoint.java index 2e32ac883..edc70762f 100644 --- a/server/implementation/src/test/java/io/smallrye/graphql/test/TestEndpoint.java +++ b/server/implementation/src/test/java/io/smallrye/graphql/test/TestEndpoint.java @@ -16,7 +16,7 @@ /** * Basic test endpoint - * + * * @author Phillip Kruger (phillip.kruger@redhat.com) */ @GraphQLApi @@ -57,6 +57,26 @@ public InterfaceWithOneGenericsParam getGeneric2() { return new ClassWithOneGenericsParam<>(22, "my name"); } + @Query + public TestUnion basicUnion() { + return new UnionMember("my name"); + } + + @Query + public UnionOfInterfaces unionOfInterfacesDirectImplementor() { + return new MemberOfManyUnions("im in many unions"); + } + + @Query + public UnionOfInterfaces unionOfInterfacesNestedInterface1() { + return new ObjectWithName("my name"); + } + + @Query + public UnionOfInterfaces unionOfInterfacesNestedInterface2() { + return new ObjectWithColor("purple"); + } + // This method will be ignored, with a WARN in the log, due to below duplicate @Name("timestamp") public TestSource getTestSource(@Source TestObject testObject, String indicator) { diff --git a/server/implementation/src/test/java/io/smallrye/graphql/test/TestUnion.java b/server/implementation/src/test/java/io/smallrye/graphql/test/TestUnion.java new file mode 100644 index 000000000..95e55acdb --- /dev/null +++ b/server/implementation/src/test/java/io/smallrye/graphql/test/TestUnion.java @@ -0,0 +1,8 @@ +package io.smallrye.graphql.test; + +import io.smallrye.graphql.api.Union; + +@Union +public interface TestUnion { + +} diff --git a/server/implementation/src/test/java/io/smallrye/graphql/test/UnionInterfaceOne.java b/server/implementation/src/test/java/io/smallrye/graphql/test/UnionInterfaceOne.java new file mode 100644 index 000000000..6da821593 --- /dev/null +++ b/server/implementation/src/test/java/io/smallrye/graphql/test/UnionInterfaceOne.java @@ -0,0 +1,9 @@ +package io.smallrye.graphql.test; + +import org.eclipse.microprofile.graphql.Interface; + +@Interface +public interface UnionInterfaceOne extends UnionOfInterfaces { + + String getName(); +} diff --git a/server/implementation/src/test/java/io/smallrye/graphql/test/UnionInterfaceTwo.java b/server/implementation/src/test/java/io/smallrye/graphql/test/UnionInterfaceTwo.java new file mode 100644 index 000000000..f1674cbce --- /dev/null +++ b/server/implementation/src/test/java/io/smallrye/graphql/test/UnionInterfaceTwo.java @@ -0,0 +1,9 @@ +package io.smallrye.graphql.test; + +import org.eclipse.microprofile.graphql.Interface; + +@Interface +public interface UnionInterfaceTwo extends UnionOfInterfaces { + + String getColor(); +} diff --git a/server/implementation/src/test/java/io/smallrye/graphql/test/UnionMember.java b/server/implementation/src/test/java/io/smallrye/graphql/test/UnionMember.java new file mode 100644 index 000000000..33ac6c1b6 --- /dev/null +++ b/server/implementation/src/test/java/io/smallrye/graphql/test/UnionMember.java @@ -0,0 +1,14 @@ +package io.smallrye.graphql.test; + +public class UnionMember implements TestUnion { + + String name; + + public UnionMember(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} diff --git a/server/implementation/src/test/java/io/smallrye/graphql/test/UnionOfInterfaces.java b/server/implementation/src/test/java/io/smallrye/graphql/test/UnionOfInterfaces.java new file mode 100644 index 000000000..180c8450c --- /dev/null +++ b/server/implementation/src/test/java/io/smallrye/graphql/test/UnionOfInterfaces.java @@ -0,0 +1,7 @@ +package io.smallrye.graphql.test; + +import io.smallrye.graphql.api.Union; + +@Union +public interface UnionOfInterfaces { +} From 3a6e274e11bb3cd0511d213794df584684a7da8e Mon Sep 17 00:00:00 2001 From: Craig Day Date: Tue, 19 Jul 2022 08:36:40 -0700 Subject: [PATCH 13/33] format and impsort --- .../graphql/schema/SchemaBuilder.java | 2 +- .../schema/creator/type/UnionCreator.java | 9 +++--- .../graphql/schema/model/UnionType.java | 30 +++++++++---------- .../java/io/smallrye/graphql/api/Union.java | 7 +++-- .../smallrye/graphql/bootstrap/Bootstrap.java | 4 +-- .../resolver/UnionOutputRegistry.java | 8 ++--- .../execution/ExecutionUnionsTest.java | 5 ++-- .../io/smallrye/graphql/test/UnionMember.java | 14 ++++----- 8 files changed, 41 insertions(+), 38 deletions(-) diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/SchemaBuilder.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/SchemaBuilder.java index 9efc63cd3..529bdc3ec 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/SchemaBuilder.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/SchemaBuilder.java @@ -2,7 +2,6 @@ import static io.smallrye.graphql.schema.Annotations.DIRECTIVE; -import io.smallrye.graphql.schema.creator.type.UnionCreator; import java.util.Collection; import java.util.List; import java.util.Optional; @@ -29,6 +28,7 @@ import io.smallrye.graphql.schema.creator.type.InputTypeCreator; import io.smallrye.graphql.schema.creator.type.InterfaceCreator; import io.smallrye.graphql.schema.creator.type.TypeCreator; +import io.smallrye.graphql.schema.creator.type.UnionCreator; import io.smallrye.graphql.schema.helper.BeanValidationDirectivesHelper; import io.smallrye.graphql.schema.helper.Directives; import io.smallrye.graphql.schema.helper.GroupHelper; diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/UnionCreator.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/UnionCreator.java index 1c07a7baf..0df64f3af 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/UnionCreator.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/UnionCreator.java @@ -1,5 +1,10 @@ package io.smallrye.graphql.schema.creator.type; +import java.util.Optional; + +import org.jboss.jandex.ClassInfo; +import org.jboss.logging.Logger; + import io.smallrye.graphql.schema.Annotations; import io.smallrye.graphql.schema.creator.ReferenceCreator; import io.smallrye.graphql.schema.helper.DescriptionHelper; @@ -7,10 +12,6 @@ import io.smallrye.graphql.schema.model.Reference; import io.smallrye.graphql.schema.model.ReferenceType; import io.smallrye.graphql.schema.model.UnionType; -import org.jboss.jandex.ClassInfo; -import org.jboss.logging.Logger; - -import java.util.Optional; public class UnionCreator implements Creator { diff --git a/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/UnionType.java b/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/UnionType.java index 0edf1b437..2a94845c7 100644 --- a/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/UnionType.java +++ b/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/UnionType.java @@ -2,23 +2,23 @@ public final class UnionType extends Reference { - private String description; + private String description; - public UnionType(String className, String name, String description) { - super(className, name, ReferenceType.UNION); - this.description = description; - } + public UnionType(String className, String name, String description) { + super(className, name, ReferenceType.UNION); + this.description = description; + } - public String getDescription() { - return description; - } + public String getDescription() { + return description; + } - public void setDescription(String description) { - this.description = description; - } + public void setDescription(String description) { + this.description = description; + } - @Override - public String toString() { - return "UnionType{" + "description=" + description + '}'; - } + @Override + public String toString() { + return "UnionType{" + "description=" + description + '}'; + } } diff --git a/server/api/src/main/java/io/smallrye/graphql/api/Union.java b/server/api/src/main/java/io/smallrye/graphql/api/Union.java index 32fd25bad..11edc91bd 100644 --- a/server/api/src/main/java/io/smallrye/graphql/api/Union.java +++ b/server/api/src/main/java/io/smallrye/graphql/api/Union.java @@ -3,15 +3,16 @@ import static java.lang.annotation.ElementType.TYPE; import static java.lang.annotation.RetentionPolicy.RUNTIME; -import io.smallrye.common.annotation.Experimental; import java.lang.annotation.Retention; import java.lang.annotation.Target; +import io.smallrye.common.annotation.Experimental; + @Retention(RUNTIME) @Target(TYPE) @Experimental("Allow you to mark an interface as a GraphQL Union. Not covered by the specification. " + - "Subject to change.") + "Subject to change.") public @interface Union { - String value() default ""; + String value() default ""; } diff --git a/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/Bootstrap.java b/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/Bootstrap.java index 62ac2e3d9..66da3fdcb 100644 --- a/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/Bootstrap.java +++ b/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/Bootstrap.java @@ -421,8 +421,8 @@ private void createGraphQLUnionTypes() { private void createGraphQLUnionType(UnionType unionType) { GraphQLUnionType.Builder unionTypeBuilder = GraphQLUnionType.newUnionType() - .name(unionType.getName()) - .description(unionType.getDescription()); + .name(unionType.getName()) + .description(unionType.getDescription()); // Members for (Type type : schema.getTypes().values()) { diff --git a/server/implementation/src/main/java/io/smallrye/graphql/execution/resolver/UnionOutputRegistry.java b/server/implementation/src/main/java/io/smallrye/graphql/execution/resolver/UnionOutputRegistry.java index 60201e1aa..cd7973817 100644 --- a/server/implementation/src/main/java/io/smallrye/graphql/execution/resolver/UnionOutputRegistry.java +++ b/server/implementation/src/main/java/io/smallrye/graphql/execution/resolver/UnionOutputRegistry.java @@ -1,14 +1,14 @@ package io.smallrye.graphql.execution.resolver; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + import graphql.schema.GraphQLObjectType; import io.smallrye.graphql.schema.model.Reference; import io.smallrye.graphql.schema.model.Type; import io.smallrye.graphql.schema.model.UnionType; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - public class UnionOutputRegistry { private static final Map> unionMap = new HashMap<>(); diff --git a/server/implementation/src/test/java/io/smallrye/graphql/execution/ExecutionUnionsTest.java b/server/implementation/src/test/java/io/smallrye/graphql/execution/ExecutionUnionsTest.java index 23b0c3557..f36a24a30 100644 --- a/server/implementation/src/test/java/io/smallrye/graphql/execution/ExecutionUnionsTest.java +++ b/server/implementation/src/test/java/io/smallrye/graphql/execution/ExecutionUnionsTest.java @@ -1,9 +1,10 @@ package io.smallrye.graphql.execution; +import static org.junit.jupiter.api.Assertions.*; + import jakarta.json.JsonObject; -import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; /** * Test against unions diff --git a/server/implementation/src/test/java/io/smallrye/graphql/test/UnionMember.java b/server/implementation/src/test/java/io/smallrye/graphql/test/UnionMember.java index 33ac6c1b6..88b9a163f 100644 --- a/server/implementation/src/test/java/io/smallrye/graphql/test/UnionMember.java +++ b/server/implementation/src/test/java/io/smallrye/graphql/test/UnionMember.java @@ -2,13 +2,13 @@ public class UnionMember implements TestUnion { - String name; + String name; - public UnionMember(String name) { - this.name = name; - } + public UnionMember(String name) { + this.name = name; + } - public String getName() { - return name; - } + public String getName() { + return name; + } } From 0b159a8d1167abc73b8731b2cfed1a6a7ad56299 Mon Sep 17 00:00:00 2001 From: Phillip Kruger Date: Wed, 20 Jul 2022 13:36:21 +1000 Subject: [PATCH 14/33] Upgraded GraphiQL version Signed-off-by: Phillip Kruger --- ui/graphiql/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/graphiql/pom.xml b/ui/graphiql/pom.xml index 097894fd1..e67c87983 100644 --- a/ui/graphiql/pom.xml +++ b/ui/graphiql/pom.xml @@ -16,7 +16,7 @@ graphql-ui 18.1.0 - 1.8.8 + 1.9.13 7.5.5 @@ -168,4 +168,4 @@ - \ No newline at end of file + From 481a8dda7d544bfc6df021ae9b5f38bfed3ba5f4 Mon Sep 17 00:00:00 2001 From: Phillip Kruger Date: Wed, 20 Jul 2022 12:11:45 +1000 Subject: [PATCH 15/33] Fix issue with public Collection fields Signed-off-by: Phillip Kruger --- .../io/smallrye/graphql/schema/creator/ReferenceCreator.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/ReferenceCreator.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/ReferenceCreator.java index 39eea5917..9fa74cc82 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/ReferenceCreator.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/ReferenceCreator.java @@ -312,6 +312,11 @@ private Reference getReference(Direction direction, fieldType = methodType; } + // In some case, like public fields, there are not method + if (methodType == null) { + methodType = fieldType; + } + String fieldTypeName = fieldType.name().toString(); if (annotations != null && annotations.containsOneOfTheseAnnotations(Annotations.ID)) { From af8b3bc70c6e36a67f6f5aeb5d972170b8db9055 Mon Sep 17 00:00:00 2001 From: Phillip Kruger Date: Wed, 20 Jul 2022 11:24:20 +1000 Subject: [PATCH 16/33] Add support for wildcard types (? extends Something) Signed-off-by: Phillip Kruger --- .../smallrye/graphql/schema/creator/ReferenceCreator.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/ReferenceCreator.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/ReferenceCreator.java index 9fa74cc82..789bf8e15 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/ReferenceCreator.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/ReferenceCreator.java @@ -14,6 +14,7 @@ import org.jboss.jandex.ParameterizedType; import org.jboss.jandex.Type; import org.jboss.jandex.TypeVariable; +import org.jboss.jandex.WildcardType; import org.jboss.logging.Logger; import io.smallrye.graphql.schema.Annotations; @@ -343,6 +344,11 @@ private Reference getReference(Direction direction, List fieldArguments = parameterizedFieldType.arguments(); ParameterizedType entryType = ParameterizedType.create(Classes.ENTRY, fieldArguments.toArray(Type[]::new), null); return getReference(direction, entryType, entryType, annotations, parentObjectReference); + } else if (fieldType.kind().equals(Type.Kind.WILDCARD_TYPE)) { + // + WildcardType wildcardType = fieldType.asWildcardType(); + Type extendsBound = wildcardType.extendsBound(); + return getReference(direction, extendsBound, extendsBound, annotations, parentObjectReference); } else if (fieldType.kind().equals(Type.Kind.CLASS)) { ClassInfo classInfo = ScanningContext.getIndex().getClassByName(fieldType.name()); if (classInfo != null) { From a713b4e89cd075ded3040717e41c9fa031ef81b3 Mon Sep 17 00:00:00 2001 From: Jan Martiska Date: Fri, 8 Jul 2022 10:31:50 +0200 Subject: [PATCH 17/33] Properly resolve enum in a field with type variable --- .../impl/typesafe/reflection/TypeInfo.java | 7 +++- .../tck/graphql/typesafe/EnumBehavior.java | 42 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/client/implementation/src/main/java/io/smallrye/graphql/client/impl/typesafe/reflection/TypeInfo.java b/client/implementation/src/main/java/io/smallrye/graphql/client/impl/typesafe/reflection/TypeInfo.java index a69d71e39..1492ab2e9 100644 --- a/client/implementation/src/main/java/io/smallrye/graphql/client/impl/typesafe/reflection/TypeInfo.java +++ b/client/implementation/src/main/java/io/smallrye/graphql/client/impl/typesafe/reflection/TypeInfo.java @@ -195,7 +195,12 @@ public boolean isPrimitive() { } public boolean isEnum() { - return ifClass(Class::isEnum); + if (type instanceof TypeVariable) { + Class resolved = resolveTypeVariable(); + return resolved.isEnum(); + } else { + return ifClass(Class::isEnum); + } } public Optional scalarConstructor() { diff --git a/client/tck/src/main/java/tck/graphql/typesafe/EnumBehavior.java b/client/tck/src/main/java/tck/graphql/typesafe/EnumBehavior.java index cc66e901e..5da2dda8f 100644 --- a/client/tck/src/main/java/tck/graphql/typesafe/EnumBehavior.java +++ b/client/tck/src/main/java/tck/graphql/typesafe/EnumBehavior.java @@ -14,6 +14,31 @@ class EnumBehavior { private final TypesafeGraphQLClientFixture fixture = TypesafeGraphQLClientFixture.load(); + public static class DescribedValue { + + public DescribedValue() { + } + + T value; + String description; + + public T getValue() { + return value; + } + + public void setValue(T value) { + this.value = value; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + } + enum Episode { NEWHOPE, EMPIRE, @@ -68,4 +93,21 @@ void shouldCallEnumFilterQuery() { then(fixture.variables()).isEqualTo("{'episode':'JEDI'}"); then(characters).containsExactly("Luke", "Darth"); } + + @GraphQLClientApi + interface EpisodeGenericApi { + DescribedValue describedEpisode(); + } + + @Test + void shouldCallGenericQuery() { + fixture.returnsData("'describedEpisode':{'value':'NEWHOPE','description':'Episode 4'}"); + EpisodeGenericApi api = fixture.build(EpisodeGenericApi.class); + + DescribedValue episode = api.describedEpisode(); + + then(fixture.query()).isEqualTo("query describedEpisode { describedEpisode {value description} }"); + then(episode.description).isEqualTo("Episode 4"); + then(episode.value).isEqualTo(NEWHOPE); + } } From f724a283e23affe6a71a55db6fa68ad40600b831 Mon Sep 17 00:00:00 2001 From: Jan Martiska Date: Mon, 25 Jul 2022 14:52:01 +0200 Subject: [PATCH 18/33] Release 2.0.0.RC5 --- .github/project.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/project.yml b/.github/project.yml index f1633f3e2..b84aef378 100644 --- a/.github/project.yml +++ b/.github/project.yml @@ -1,4 +1,4 @@ name: SmallRye GraphQL release: - current-version: 2.0.0.RC4 + current-version: 2.0.0.RC5 next-version: 2.0.0-SNAPSHOT From 39589efd21e601e4863c34c9414338d6ae346494 Mon Sep 17 00:00:00 2001 From: SmallRye CI Date: Mon, 25 Jul 2022 13:00:48 +0000 Subject: [PATCH 19/33] Update Gradle plugin version --- tools/gradle-plugin/gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/gradle-plugin/gradle.properties b/tools/gradle-plugin/gradle.properties index aa9004044..ddcd49b27 100644 --- a/tools/gradle-plugin/gradle.properties +++ b/tools/gradle-plugin/gradle.properties @@ -1 +1 @@ -version=2.0.0.RC4 +version=2.0.0.RC5 From 39c1d92c25e40b82fc8e1c9efa84b650049d8371 Mon Sep 17 00:00:00 2001 From: SmallRye CI Date: Mon, 25 Jul 2022 13:04:54 +0000 Subject: [PATCH 20/33] [maven-release-plugin] prepare release 2.0.0.RC5 --- client/api/pom.xml | 2 +- client/generator-test/pom.xml | 2 +- client/generator/pom.xml | 2 +- client/implementation-vertx/pom.xml | 2 +- client/implementation/pom.xml | 2 +- client/pom.xml | 2 +- client/tck/pom.xml | 2 +- common/pom.xml | 2 +- common/schema-builder/pom.xml | 2 +- common/schema-model/pom.xml | 2 +- docs/pom.xml | 2 +- pom.xml | 4 ++-- release/pom.xml | 2 +- server/api/pom.xml | 2 +- server/federation/api/pom.xml | 2 +- server/federation/pom.xml | 2 +- server/federation/runtime/pom.xml | 2 +- server/implementation-cdi/pom.xml | 2 +- server/implementation-servlet/pom.xml | 2 +- server/implementation/pom.xml | 2 +- server/integration-tests-jdk16/pom.xml | 2 +- server/integration-tests/pom.xml | 2 +- server/pom.xml | 2 +- server/runner/pom.xml | 2 +- server/tck/pom.xml | 2 +- tools/gradle-plugin/pom.xml | 2 +- tools/maven-plugin-tests/pom.xml | 2 +- tools/maven-plugin/pom.xml | 2 +- tools/pom.xml | 2 +- ui/graphiql/pom.xml | 2 +- ui/pom.xml | 2 +- 31 files changed, 32 insertions(+), 32 deletions(-) diff --git a/client/api/pom.xml b/client/api/pom.xml index 779a6e7ab..7cd8214e6 100644 --- a/client/api/pom.xml +++ b/client/api/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-client-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 smallrye-graphql-client-api diff --git a/client/generator-test/pom.xml b/client/generator-test/pom.xml index f86b907dc..d46f8e680 100644 --- a/client/generator-test/pom.xml +++ b/client/generator-test/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-client-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 smallrye-graphql-client-generator-test diff --git a/client/generator/pom.xml b/client/generator/pom.xml index 9de0f02ba..0b1f1ac0e 100644 --- a/client/generator/pom.xml +++ b/client/generator/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-client-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 smallrye-graphql-client-generator diff --git a/client/implementation-vertx/pom.xml b/client/implementation-vertx/pom.xml index 9d7714dc7..0cb1e0d62 100644 --- a/client/implementation-vertx/pom.xml +++ b/client/implementation-vertx/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-client-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 smallrye-graphql-client-implementation-vertx diff --git a/client/implementation/pom.xml b/client/implementation/pom.xml index 285b1ba29..e5dca2e00 100644 --- a/client/implementation/pom.xml +++ b/client/implementation/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-client-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 smallrye-graphql-client diff --git a/client/pom.xml b/client/pom.xml index 6c1a96076..cf190a850 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 smallrye-graphql-client-parent diff --git a/client/tck/pom.xml b/client/tck/pom.xml index 45aa93492..7e06c646c 100644 --- a/client/tck/pom.xml +++ b/client/tck/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-client-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 smallrye-graphql-client-tck diff --git a/common/pom.xml b/common/pom.xml index 594405c1f..1301de27a 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 smallrye-graphql-common-parent diff --git a/common/schema-builder/pom.xml b/common/schema-builder/pom.xml index ade061002..576542a53 100644 --- a/common/schema-builder/pom.xml +++ b/common/schema-builder/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-common-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 smallrye-graphql-schema-builder diff --git a/common/schema-model/pom.xml b/common/schema-model/pom.xml index c333a077c..176e5023e 100644 --- a/common/schema-model/pom.xml +++ b/common/schema-model/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-common-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 smallrye-graphql-schema-model diff --git a/docs/pom.xml b/docs/pom.xml index f7eca527e..3f4586ac8 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 smallrye-graphql-documentation diff --git a/pom.xml b/pom.xml index ec7e0bf95..187c41029 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ smallrye-graphql-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 pom SmallRye: GraphQL Parent @@ -77,7 +77,7 @@ scm:git:git@github.com:smallrye/smallrye-graphql.git scm:git:git@github.com:smallrye/smallrye-graphql.git https://github.com/smallrye/smallrye-graphql/ - HEAD + 2.0.0.RC5 diff --git a/release/pom.xml b/release/pom.xml index 52fc08839..794e77ea8 100644 --- a/release/pom.xml +++ b/release/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 smallrye-graphql-release diff --git a/server/api/pom.xml b/server/api/pom.xml index 88ad21399..001dc2b6e 100644 --- a/server/api/pom.xml +++ b/server/api/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 smallrye-graphql-api diff --git a/server/federation/api/pom.xml b/server/federation/api/pom.xml index 07b68ca56..86efce1cf 100644 --- a/server/federation/api/pom.xml +++ b/server/federation/api/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-federation-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 ../pom.xml diff --git a/server/federation/pom.xml b/server/federation/pom.xml index dcef61c7f..950b19a37 100644 --- a/server/federation/pom.xml +++ b/server/federation/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 ../pom.xml diff --git a/server/federation/runtime/pom.xml b/server/federation/runtime/pom.xml index c7a0425fd..c6ccb10bd 100644 --- a/server/federation/runtime/pom.xml +++ b/server/federation/runtime/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-federation-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 ../pom.xml diff --git a/server/implementation-cdi/pom.xml b/server/implementation-cdi/pom.xml index dc1ba4c87..c34f0ed4d 100644 --- a/server/implementation-cdi/pom.xml +++ b/server/implementation-cdi/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 smallrye-graphql-cdi diff --git a/server/implementation-servlet/pom.xml b/server/implementation-servlet/pom.xml index ccce3f1d3..d1e7b822b 100644 --- a/server/implementation-servlet/pom.xml +++ b/server/implementation-servlet/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 smallrye-graphql-servlet diff --git a/server/implementation/pom.xml b/server/implementation/pom.xml index e790627e1..5e9a0d296 100644 --- a/server/implementation/pom.xml +++ b/server/implementation/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 smallrye-graphql diff --git a/server/integration-tests-jdk16/pom.xml b/server/integration-tests-jdk16/pom.xml index 786942cac..ac928f6b5 100644 --- a/server/integration-tests-jdk16/pom.xml +++ b/server/integration-tests-jdk16/pom.xml @@ -3,7 +3,7 @@ smallrye-graphql-server-parent io.smallrye - 2.0.0-SNAPSHOT + 2.0.0.RC5 4.0.0 diff --git a/server/integration-tests/pom.xml b/server/integration-tests/pom.xml index 93d6ca7bd..e33479c1d 100644 --- a/server/integration-tests/pom.xml +++ b/server/integration-tests/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 4.0.0 diff --git a/server/pom.xml b/server/pom.xml index 089d585fb..68b8686d4 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 smallrye-graphql-server-parent diff --git a/server/runner/pom.xml b/server/runner/pom.xml index bc36930b3..923196a3e 100644 --- a/server/runner/pom.xml +++ b/server/runner/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 smallrye-graphql-runner diff --git a/server/tck/pom.xml b/server/tck/pom.xml index 4bb98d70a..48d27cfdc 100644 --- a/server/tck/pom.xml +++ b/server/tck/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 smallrye-graphql-tck diff --git a/tools/gradle-plugin/pom.xml b/tools/gradle-plugin/pom.xml index 9aec5f616..ff797f5af 100644 --- a/tools/gradle-plugin/pom.xml +++ b/tools/gradle-plugin/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-tools-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 4.0.0 diff --git a/tools/maven-plugin-tests/pom.xml b/tools/maven-plugin-tests/pom.xml index aa35c1eb3..07b80712b 100644 --- a/tools/maven-plugin-tests/pom.xml +++ b/tools/maven-plugin-tests/pom.xml @@ -3,7 +3,7 @@ io.smallrye smallrye-graphql-tools-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 4.0.0 diff --git a/tools/maven-plugin/pom.xml b/tools/maven-plugin/pom.xml index b0faa4095..501cf5a64 100644 --- a/tools/maven-plugin/pom.xml +++ b/tools/maven-plugin/pom.xml @@ -3,7 +3,7 @@ io.smallrye smallrye-graphql-tools-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 4.0.0 diff --git a/tools/pom.xml b/tools/pom.xml index 9d8efc9c0..64c0486e2 100644 --- a/tools/pom.xml +++ b/tools/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 smallrye-graphql-tools-parent diff --git a/ui/graphiql/pom.xml b/ui/graphiql/pom.xml index e67c87983..fc05c25de 100644 --- a/ui/graphiql/pom.xml +++ b/ui/graphiql/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-ui-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 smallrye-graphql-ui-graphiql diff --git a/ui/pom.xml b/ui/pom.xml index 6fe38304f..68e759b6a 100644 --- a/ui/pom.xml +++ b/ui/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0-SNAPSHOT + 2.0.0.RC5 smallrye-graphql-ui-parent From 4ba62cc69ef29942e6b3ee64662940077928bcc4 Mon Sep 17 00:00:00 2001 From: SmallRye CI Date: Mon, 25 Jul 2022 13:04:55 +0000 Subject: [PATCH 21/33] [maven-release-plugin] prepare for next development iteration --- client/api/pom.xml | 2 +- client/generator-test/pom.xml | 2 +- client/generator/pom.xml | 2 +- client/implementation-vertx/pom.xml | 2 +- client/implementation/pom.xml | 2 +- client/pom.xml | 2 +- client/tck/pom.xml | 2 +- common/pom.xml | 2 +- common/schema-builder/pom.xml | 2 +- common/schema-model/pom.xml | 2 +- docs/pom.xml | 2 +- pom.xml | 4 ++-- release/pom.xml | 2 +- server/api/pom.xml | 2 +- server/federation/api/pom.xml | 2 +- server/federation/pom.xml | 2 +- server/federation/runtime/pom.xml | 2 +- server/implementation-cdi/pom.xml | 2 +- server/implementation-servlet/pom.xml | 2 +- server/implementation/pom.xml | 2 +- server/integration-tests-jdk16/pom.xml | 2 +- server/integration-tests/pom.xml | 2 +- server/pom.xml | 2 +- server/runner/pom.xml | 2 +- server/tck/pom.xml | 2 +- tools/gradle-plugin/pom.xml | 2 +- tools/maven-plugin-tests/pom.xml | 2 +- tools/maven-plugin/pom.xml | 2 +- tools/pom.xml | 2 +- ui/graphiql/pom.xml | 2 +- ui/pom.xml | 2 +- 31 files changed, 32 insertions(+), 32 deletions(-) diff --git a/client/api/pom.xml b/client/api/pom.xml index 7cd8214e6..779a6e7ab 100644 --- a/client/api/pom.xml +++ b/client/api/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-client-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT smallrye-graphql-client-api diff --git a/client/generator-test/pom.xml b/client/generator-test/pom.xml index d46f8e680..f86b907dc 100644 --- a/client/generator-test/pom.xml +++ b/client/generator-test/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-client-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT smallrye-graphql-client-generator-test diff --git a/client/generator/pom.xml b/client/generator/pom.xml index 0b1f1ac0e..9de0f02ba 100644 --- a/client/generator/pom.xml +++ b/client/generator/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-client-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT smallrye-graphql-client-generator diff --git a/client/implementation-vertx/pom.xml b/client/implementation-vertx/pom.xml index 0cb1e0d62..9d7714dc7 100644 --- a/client/implementation-vertx/pom.xml +++ b/client/implementation-vertx/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-client-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT smallrye-graphql-client-implementation-vertx diff --git a/client/implementation/pom.xml b/client/implementation/pom.xml index e5dca2e00..285b1ba29 100644 --- a/client/implementation/pom.xml +++ b/client/implementation/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-client-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT smallrye-graphql-client diff --git a/client/pom.xml b/client/pom.xml index cf190a850..6c1a96076 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT smallrye-graphql-client-parent diff --git a/client/tck/pom.xml b/client/tck/pom.xml index 7e06c646c..45aa93492 100644 --- a/client/tck/pom.xml +++ b/client/tck/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-client-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT smallrye-graphql-client-tck diff --git a/common/pom.xml b/common/pom.xml index 1301de27a..594405c1f 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT smallrye-graphql-common-parent diff --git a/common/schema-builder/pom.xml b/common/schema-builder/pom.xml index 576542a53..ade061002 100644 --- a/common/schema-builder/pom.xml +++ b/common/schema-builder/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-common-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT smallrye-graphql-schema-builder diff --git a/common/schema-model/pom.xml b/common/schema-model/pom.xml index 176e5023e..c333a077c 100644 --- a/common/schema-model/pom.xml +++ b/common/schema-model/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-common-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT smallrye-graphql-schema-model diff --git a/docs/pom.xml b/docs/pom.xml index 3f4586ac8..f7eca527e 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT smallrye-graphql-documentation diff --git a/pom.xml b/pom.xml index 187c41029..ec7e0bf95 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ smallrye-graphql-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT pom SmallRye: GraphQL Parent @@ -77,7 +77,7 @@ scm:git:git@github.com:smallrye/smallrye-graphql.git scm:git:git@github.com:smallrye/smallrye-graphql.git https://github.com/smallrye/smallrye-graphql/ - 2.0.0.RC5 + HEAD diff --git a/release/pom.xml b/release/pom.xml index 794e77ea8..52fc08839 100644 --- a/release/pom.xml +++ b/release/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT smallrye-graphql-release diff --git a/server/api/pom.xml b/server/api/pom.xml index 001dc2b6e..88ad21399 100644 --- a/server/api/pom.xml +++ b/server/api/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT smallrye-graphql-api diff --git a/server/federation/api/pom.xml b/server/federation/api/pom.xml index 86efce1cf..07b68ca56 100644 --- a/server/federation/api/pom.xml +++ b/server/federation/api/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-federation-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT ../pom.xml diff --git a/server/federation/pom.xml b/server/federation/pom.xml index 950b19a37..dcef61c7f 100644 --- a/server/federation/pom.xml +++ b/server/federation/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT ../pom.xml diff --git a/server/federation/runtime/pom.xml b/server/federation/runtime/pom.xml index c6ccb10bd..c7a0425fd 100644 --- a/server/federation/runtime/pom.xml +++ b/server/federation/runtime/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-federation-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT ../pom.xml diff --git a/server/implementation-cdi/pom.xml b/server/implementation-cdi/pom.xml index c34f0ed4d..dc1ba4c87 100644 --- a/server/implementation-cdi/pom.xml +++ b/server/implementation-cdi/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT smallrye-graphql-cdi diff --git a/server/implementation-servlet/pom.xml b/server/implementation-servlet/pom.xml index d1e7b822b..ccce3f1d3 100644 --- a/server/implementation-servlet/pom.xml +++ b/server/implementation-servlet/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT smallrye-graphql-servlet diff --git a/server/implementation/pom.xml b/server/implementation/pom.xml index 5e9a0d296..e790627e1 100644 --- a/server/implementation/pom.xml +++ b/server/implementation/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT smallrye-graphql diff --git a/server/integration-tests-jdk16/pom.xml b/server/integration-tests-jdk16/pom.xml index ac928f6b5..786942cac 100644 --- a/server/integration-tests-jdk16/pom.xml +++ b/server/integration-tests-jdk16/pom.xml @@ -3,7 +3,7 @@ smallrye-graphql-server-parent io.smallrye - 2.0.0.RC5 + 2.0.0-SNAPSHOT 4.0.0 diff --git a/server/integration-tests/pom.xml b/server/integration-tests/pom.xml index e33479c1d..93d6ca7bd 100644 --- a/server/integration-tests/pom.xml +++ b/server/integration-tests/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT 4.0.0 diff --git a/server/pom.xml b/server/pom.xml index 68b8686d4..089d585fb 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT smallrye-graphql-server-parent diff --git a/server/runner/pom.xml b/server/runner/pom.xml index 923196a3e..bc36930b3 100644 --- a/server/runner/pom.xml +++ b/server/runner/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT smallrye-graphql-runner diff --git a/server/tck/pom.xml b/server/tck/pom.xml index 48d27cfdc..4bb98d70a 100644 --- a/server/tck/pom.xml +++ b/server/tck/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT smallrye-graphql-tck diff --git a/tools/gradle-plugin/pom.xml b/tools/gradle-plugin/pom.xml index ff797f5af..9aec5f616 100644 --- a/tools/gradle-plugin/pom.xml +++ b/tools/gradle-plugin/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-tools-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT 4.0.0 diff --git a/tools/maven-plugin-tests/pom.xml b/tools/maven-plugin-tests/pom.xml index 07b80712b..aa35c1eb3 100644 --- a/tools/maven-plugin-tests/pom.xml +++ b/tools/maven-plugin-tests/pom.xml @@ -3,7 +3,7 @@ io.smallrye smallrye-graphql-tools-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT 4.0.0 diff --git a/tools/maven-plugin/pom.xml b/tools/maven-plugin/pom.xml index 501cf5a64..b0faa4095 100644 --- a/tools/maven-plugin/pom.xml +++ b/tools/maven-plugin/pom.xml @@ -3,7 +3,7 @@ io.smallrye smallrye-graphql-tools-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT 4.0.0 diff --git a/tools/pom.xml b/tools/pom.xml index 64c0486e2..9d8efc9c0 100644 --- a/tools/pom.xml +++ b/tools/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT smallrye-graphql-tools-parent diff --git a/ui/graphiql/pom.xml b/ui/graphiql/pom.xml index fc05c25de..e67c87983 100644 --- a/ui/graphiql/pom.xml +++ b/ui/graphiql/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-ui-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT smallrye-graphql-ui-graphiql diff --git a/ui/pom.xml b/ui/pom.xml index 68e759b6a..6fe38304f 100644 --- a/ui/pom.xml +++ b/ui/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0.RC5 + 2.0.0-SNAPSHOT smallrye-graphql-ui-parent From 51c05fbb25729a52ce94a9e2fc83a97811791277 Mon Sep 17 00:00:00 2001 From: Craig Day Date: Mon, 25 Jul 2022 08:33:19 -0700 Subject: [PATCH 22/33] default no-arg constructor for union type for quarkus --- .../main/java/io/smallrye/graphql/schema/model/UnionType.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/UnionType.java b/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/UnionType.java index 2a94845c7..82a3c9c67 100644 --- a/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/UnionType.java +++ b/common/schema-model/src/main/java/io/smallrye/graphql/schema/model/UnionType.java @@ -4,6 +4,9 @@ public final class UnionType extends Reference { private String description; + public UnionType() { + } + public UnionType(String className, String name, String description) { super(className, name, ReferenceType.UNION); this.description = description; From eca463cd358346e7089eb94784ba0e1c4c30e938 Mon Sep 17 00:00:00 2001 From: Jan Martiska Date: Tue, 26 Jul 2022 08:41:29 +0200 Subject: [PATCH 23/33] Prepare release 2.0.0.RC6 --- .github/project.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/project.yml b/.github/project.yml index b84aef378..0e633000c 100644 --- a/.github/project.yml +++ b/.github/project.yml @@ -1,4 +1,4 @@ name: SmallRye GraphQL release: - current-version: 2.0.0.RC5 + current-version: 2.0.0.RC6 next-version: 2.0.0-SNAPSHOT From cf6c50f1aa760b9bc19eda6c812c544698fdffdd Mon Sep 17 00:00:00 2001 From: SmallRye CI Date: Tue, 26 Jul 2022 06:51:13 +0000 Subject: [PATCH 24/33] Update Gradle plugin version --- tools/gradle-plugin/gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/gradle-plugin/gradle.properties b/tools/gradle-plugin/gradle.properties index ddcd49b27..0f50270d7 100644 --- a/tools/gradle-plugin/gradle.properties +++ b/tools/gradle-plugin/gradle.properties @@ -1 +1 @@ -version=2.0.0.RC5 +version=2.0.0.RC6 From 1320120d1572732162981112cbf3b3cbf47f66c2 Mon Sep 17 00:00:00 2001 From: SmallRye CI Date: Tue, 26 Jul 2022 06:55:12 +0000 Subject: [PATCH 25/33] [maven-release-plugin] prepare release 2.0.0.RC6 --- client/api/pom.xml | 2 +- client/generator-test/pom.xml | 2 +- client/generator/pom.xml | 2 +- client/implementation-vertx/pom.xml | 2 +- client/implementation/pom.xml | 2 +- client/pom.xml | 2 +- client/tck/pom.xml | 2 +- common/pom.xml | 2 +- common/schema-builder/pom.xml | 2 +- common/schema-model/pom.xml | 2 +- docs/pom.xml | 2 +- pom.xml | 4 ++-- release/pom.xml | 2 +- server/api/pom.xml | 2 +- server/federation/api/pom.xml | 2 +- server/federation/pom.xml | 2 +- server/federation/runtime/pom.xml | 2 +- server/implementation-cdi/pom.xml | 2 +- server/implementation-servlet/pom.xml | 2 +- server/implementation/pom.xml | 2 +- server/integration-tests-jdk16/pom.xml | 2 +- server/integration-tests/pom.xml | 2 +- server/pom.xml | 2 +- server/runner/pom.xml | 2 +- server/tck/pom.xml | 2 +- tools/gradle-plugin/pom.xml | 2 +- tools/maven-plugin-tests/pom.xml | 2 +- tools/maven-plugin/pom.xml | 2 +- tools/pom.xml | 2 +- ui/graphiql/pom.xml | 2 +- ui/pom.xml | 2 +- 31 files changed, 32 insertions(+), 32 deletions(-) diff --git a/client/api/pom.xml b/client/api/pom.xml index 779a6e7ab..b56069233 100644 --- a/client/api/pom.xml +++ b/client/api/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-client-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 smallrye-graphql-client-api diff --git a/client/generator-test/pom.xml b/client/generator-test/pom.xml index f86b907dc..295fcdf60 100644 --- a/client/generator-test/pom.xml +++ b/client/generator-test/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-client-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 smallrye-graphql-client-generator-test diff --git a/client/generator/pom.xml b/client/generator/pom.xml index 9de0f02ba..02553e620 100644 --- a/client/generator/pom.xml +++ b/client/generator/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-client-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 smallrye-graphql-client-generator diff --git a/client/implementation-vertx/pom.xml b/client/implementation-vertx/pom.xml index 9d7714dc7..a92ca504f 100644 --- a/client/implementation-vertx/pom.xml +++ b/client/implementation-vertx/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-client-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 smallrye-graphql-client-implementation-vertx diff --git a/client/implementation/pom.xml b/client/implementation/pom.xml index 285b1ba29..d94fcda62 100644 --- a/client/implementation/pom.xml +++ b/client/implementation/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-client-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 smallrye-graphql-client diff --git a/client/pom.xml b/client/pom.xml index 6c1a96076..ff45bd7b8 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 smallrye-graphql-client-parent diff --git a/client/tck/pom.xml b/client/tck/pom.xml index 45aa93492..460459765 100644 --- a/client/tck/pom.xml +++ b/client/tck/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-client-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 smallrye-graphql-client-tck diff --git a/common/pom.xml b/common/pom.xml index 594405c1f..a6fc977d5 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 smallrye-graphql-common-parent diff --git a/common/schema-builder/pom.xml b/common/schema-builder/pom.xml index ade061002..e9b0f34c9 100644 --- a/common/schema-builder/pom.xml +++ b/common/schema-builder/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-common-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 smallrye-graphql-schema-builder diff --git a/common/schema-model/pom.xml b/common/schema-model/pom.xml index c333a077c..7866d9db4 100644 --- a/common/schema-model/pom.xml +++ b/common/schema-model/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-common-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 smallrye-graphql-schema-model diff --git a/docs/pom.xml b/docs/pom.xml index f7eca527e..a897af9f2 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 smallrye-graphql-documentation diff --git a/pom.xml b/pom.xml index ec7e0bf95..bb72b5e7a 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ smallrye-graphql-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 pom SmallRye: GraphQL Parent @@ -77,7 +77,7 @@ scm:git:git@github.com:smallrye/smallrye-graphql.git scm:git:git@github.com:smallrye/smallrye-graphql.git https://github.com/smallrye/smallrye-graphql/ - HEAD + 2.0.0.RC6 diff --git a/release/pom.xml b/release/pom.xml index 52fc08839..900dd5d13 100644 --- a/release/pom.xml +++ b/release/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 smallrye-graphql-release diff --git a/server/api/pom.xml b/server/api/pom.xml index 88ad21399..98696445c 100644 --- a/server/api/pom.xml +++ b/server/api/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 smallrye-graphql-api diff --git a/server/federation/api/pom.xml b/server/federation/api/pom.xml index 07b68ca56..317702810 100644 --- a/server/federation/api/pom.xml +++ b/server/federation/api/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-federation-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 ../pom.xml diff --git a/server/federation/pom.xml b/server/federation/pom.xml index dcef61c7f..1d7a0a212 100644 --- a/server/federation/pom.xml +++ b/server/federation/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 ../pom.xml diff --git a/server/federation/runtime/pom.xml b/server/federation/runtime/pom.xml index c7a0425fd..6a456636e 100644 --- a/server/federation/runtime/pom.xml +++ b/server/federation/runtime/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-federation-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 ../pom.xml diff --git a/server/implementation-cdi/pom.xml b/server/implementation-cdi/pom.xml index dc1ba4c87..f0f6a7ed1 100644 --- a/server/implementation-cdi/pom.xml +++ b/server/implementation-cdi/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 smallrye-graphql-cdi diff --git a/server/implementation-servlet/pom.xml b/server/implementation-servlet/pom.xml index ccce3f1d3..865671faa 100644 --- a/server/implementation-servlet/pom.xml +++ b/server/implementation-servlet/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 smallrye-graphql-servlet diff --git a/server/implementation/pom.xml b/server/implementation/pom.xml index e790627e1..3465fbffc 100644 --- a/server/implementation/pom.xml +++ b/server/implementation/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 smallrye-graphql diff --git a/server/integration-tests-jdk16/pom.xml b/server/integration-tests-jdk16/pom.xml index 786942cac..d944790c8 100644 --- a/server/integration-tests-jdk16/pom.xml +++ b/server/integration-tests-jdk16/pom.xml @@ -3,7 +3,7 @@ smallrye-graphql-server-parent io.smallrye - 2.0.0-SNAPSHOT + 2.0.0.RC6 4.0.0 diff --git a/server/integration-tests/pom.xml b/server/integration-tests/pom.xml index 93d6ca7bd..7738228af 100644 --- a/server/integration-tests/pom.xml +++ b/server/integration-tests/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 4.0.0 diff --git a/server/pom.xml b/server/pom.xml index 089d585fb..c13b4b616 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 smallrye-graphql-server-parent diff --git a/server/runner/pom.xml b/server/runner/pom.xml index bc36930b3..d7549e2ce 100644 --- a/server/runner/pom.xml +++ b/server/runner/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 smallrye-graphql-runner diff --git a/server/tck/pom.xml b/server/tck/pom.xml index 4bb98d70a..306c8b236 100644 --- a/server/tck/pom.xml +++ b/server/tck/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 smallrye-graphql-tck diff --git a/tools/gradle-plugin/pom.xml b/tools/gradle-plugin/pom.xml index 9aec5f616..01eb14fa7 100644 --- a/tools/gradle-plugin/pom.xml +++ b/tools/gradle-plugin/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-tools-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 4.0.0 diff --git a/tools/maven-plugin-tests/pom.xml b/tools/maven-plugin-tests/pom.xml index aa35c1eb3..2949c3649 100644 --- a/tools/maven-plugin-tests/pom.xml +++ b/tools/maven-plugin-tests/pom.xml @@ -3,7 +3,7 @@ io.smallrye smallrye-graphql-tools-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 4.0.0 diff --git a/tools/maven-plugin/pom.xml b/tools/maven-plugin/pom.xml index b0faa4095..f3cdcb089 100644 --- a/tools/maven-plugin/pom.xml +++ b/tools/maven-plugin/pom.xml @@ -3,7 +3,7 @@ io.smallrye smallrye-graphql-tools-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 4.0.0 diff --git a/tools/pom.xml b/tools/pom.xml index 9d8efc9c0..79e9561c5 100644 --- a/tools/pom.xml +++ b/tools/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 smallrye-graphql-tools-parent diff --git a/ui/graphiql/pom.xml b/ui/graphiql/pom.xml index e67c87983..092c2d7dd 100644 --- a/ui/graphiql/pom.xml +++ b/ui/graphiql/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-ui-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 smallrye-graphql-ui-graphiql diff --git a/ui/pom.xml b/ui/pom.xml index 6fe38304f..dbbd18769 100644 --- a/ui/pom.xml +++ b/ui/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0-SNAPSHOT + 2.0.0.RC6 smallrye-graphql-ui-parent From f8dff2e57f631874d9bb931b65ad9b243f81184f Mon Sep 17 00:00:00 2001 From: SmallRye CI Date: Tue, 26 Jul 2022 06:55:12 +0000 Subject: [PATCH 26/33] [maven-release-plugin] prepare for next development iteration --- client/api/pom.xml | 2 +- client/generator-test/pom.xml | 2 +- client/generator/pom.xml | 2 +- client/implementation-vertx/pom.xml | 2 +- client/implementation/pom.xml | 2 +- client/pom.xml | 2 +- client/tck/pom.xml | 2 +- common/pom.xml | 2 +- common/schema-builder/pom.xml | 2 +- common/schema-model/pom.xml | 2 +- docs/pom.xml | 2 +- pom.xml | 4 ++-- release/pom.xml | 2 +- server/api/pom.xml | 2 +- server/federation/api/pom.xml | 2 +- server/federation/pom.xml | 2 +- server/federation/runtime/pom.xml | 2 +- server/implementation-cdi/pom.xml | 2 +- server/implementation-servlet/pom.xml | 2 +- server/implementation/pom.xml | 2 +- server/integration-tests-jdk16/pom.xml | 2 +- server/integration-tests/pom.xml | 2 +- server/pom.xml | 2 +- server/runner/pom.xml | 2 +- server/tck/pom.xml | 2 +- tools/gradle-plugin/pom.xml | 2 +- tools/maven-plugin-tests/pom.xml | 2 +- tools/maven-plugin/pom.xml | 2 +- tools/pom.xml | 2 +- ui/graphiql/pom.xml | 2 +- ui/pom.xml | 2 +- 31 files changed, 32 insertions(+), 32 deletions(-) diff --git a/client/api/pom.xml b/client/api/pom.xml index b56069233..779a6e7ab 100644 --- a/client/api/pom.xml +++ b/client/api/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-client-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT smallrye-graphql-client-api diff --git a/client/generator-test/pom.xml b/client/generator-test/pom.xml index 295fcdf60..f86b907dc 100644 --- a/client/generator-test/pom.xml +++ b/client/generator-test/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-client-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT smallrye-graphql-client-generator-test diff --git a/client/generator/pom.xml b/client/generator/pom.xml index 02553e620..9de0f02ba 100644 --- a/client/generator/pom.xml +++ b/client/generator/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-client-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT smallrye-graphql-client-generator diff --git a/client/implementation-vertx/pom.xml b/client/implementation-vertx/pom.xml index a92ca504f..9d7714dc7 100644 --- a/client/implementation-vertx/pom.xml +++ b/client/implementation-vertx/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-client-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT smallrye-graphql-client-implementation-vertx diff --git a/client/implementation/pom.xml b/client/implementation/pom.xml index d94fcda62..285b1ba29 100644 --- a/client/implementation/pom.xml +++ b/client/implementation/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-client-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT smallrye-graphql-client diff --git a/client/pom.xml b/client/pom.xml index ff45bd7b8..6c1a96076 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT smallrye-graphql-client-parent diff --git a/client/tck/pom.xml b/client/tck/pom.xml index 460459765..45aa93492 100644 --- a/client/tck/pom.xml +++ b/client/tck/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-client-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT smallrye-graphql-client-tck diff --git a/common/pom.xml b/common/pom.xml index a6fc977d5..594405c1f 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT smallrye-graphql-common-parent diff --git a/common/schema-builder/pom.xml b/common/schema-builder/pom.xml index e9b0f34c9..ade061002 100644 --- a/common/schema-builder/pom.xml +++ b/common/schema-builder/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-common-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT smallrye-graphql-schema-builder diff --git a/common/schema-model/pom.xml b/common/schema-model/pom.xml index 7866d9db4..c333a077c 100644 --- a/common/schema-model/pom.xml +++ b/common/schema-model/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-common-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT smallrye-graphql-schema-model diff --git a/docs/pom.xml b/docs/pom.xml index a897af9f2..f7eca527e 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT smallrye-graphql-documentation diff --git a/pom.xml b/pom.xml index bb72b5e7a..ec7e0bf95 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ smallrye-graphql-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT pom SmallRye: GraphQL Parent @@ -77,7 +77,7 @@ scm:git:git@github.com:smallrye/smallrye-graphql.git scm:git:git@github.com:smallrye/smallrye-graphql.git https://github.com/smallrye/smallrye-graphql/ - 2.0.0.RC6 + HEAD diff --git a/release/pom.xml b/release/pom.xml index 900dd5d13..52fc08839 100644 --- a/release/pom.xml +++ b/release/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT smallrye-graphql-release diff --git a/server/api/pom.xml b/server/api/pom.xml index 98696445c..88ad21399 100644 --- a/server/api/pom.xml +++ b/server/api/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT smallrye-graphql-api diff --git a/server/federation/api/pom.xml b/server/federation/api/pom.xml index 317702810..07b68ca56 100644 --- a/server/federation/api/pom.xml +++ b/server/federation/api/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-federation-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT ../pom.xml diff --git a/server/federation/pom.xml b/server/federation/pom.xml index 1d7a0a212..dcef61c7f 100644 --- a/server/federation/pom.xml +++ b/server/federation/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT ../pom.xml diff --git a/server/federation/runtime/pom.xml b/server/federation/runtime/pom.xml index 6a456636e..c7a0425fd 100644 --- a/server/federation/runtime/pom.xml +++ b/server/federation/runtime/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-federation-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT ../pom.xml diff --git a/server/implementation-cdi/pom.xml b/server/implementation-cdi/pom.xml index f0f6a7ed1..dc1ba4c87 100644 --- a/server/implementation-cdi/pom.xml +++ b/server/implementation-cdi/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT smallrye-graphql-cdi diff --git a/server/implementation-servlet/pom.xml b/server/implementation-servlet/pom.xml index 865671faa..ccce3f1d3 100644 --- a/server/implementation-servlet/pom.xml +++ b/server/implementation-servlet/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT smallrye-graphql-servlet diff --git a/server/implementation/pom.xml b/server/implementation/pom.xml index 3465fbffc..e790627e1 100644 --- a/server/implementation/pom.xml +++ b/server/implementation/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT smallrye-graphql diff --git a/server/integration-tests-jdk16/pom.xml b/server/integration-tests-jdk16/pom.xml index d944790c8..786942cac 100644 --- a/server/integration-tests-jdk16/pom.xml +++ b/server/integration-tests-jdk16/pom.xml @@ -3,7 +3,7 @@ smallrye-graphql-server-parent io.smallrye - 2.0.0.RC6 + 2.0.0-SNAPSHOT 4.0.0 diff --git a/server/integration-tests/pom.xml b/server/integration-tests/pom.xml index 7738228af..93d6ca7bd 100644 --- a/server/integration-tests/pom.xml +++ b/server/integration-tests/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT 4.0.0 diff --git a/server/pom.xml b/server/pom.xml index c13b4b616..089d585fb 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT smallrye-graphql-server-parent diff --git a/server/runner/pom.xml b/server/runner/pom.xml index d7549e2ce..bc36930b3 100644 --- a/server/runner/pom.xml +++ b/server/runner/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT smallrye-graphql-runner diff --git a/server/tck/pom.xml b/server/tck/pom.xml index 306c8b236..4bb98d70a 100644 --- a/server/tck/pom.xml +++ b/server/tck/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-server-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT smallrye-graphql-tck diff --git a/tools/gradle-plugin/pom.xml b/tools/gradle-plugin/pom.xml index 01eb14fa7..9aec5f616 100644 --- a/tools/gradle-plugin/pom.xml +++ b/tools/gradle-plugin/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-tools-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT 4.0.0 diff --git a/tools/maven-plugin-tests/pom.xml b/tools/maven-plugin-tests/pom.xml index 2949c3649..aa35c1eb3 100644 --- a/tools/maven-plugin-tests/pom.xml +++ b/tools/maven-plugin-tests/pom.xml @@ -3,7 +3,7 @@ io.smallrye smallrye-graphql-tools-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT 4.0.0 diff --git a/tools/maven-plugin/pom.xml b/tools/maven-plugin/pom.xml index f3cdcb089..b0faa4095 100644 --- a/tools/maven-plugin/pom.xml +++ b/tools/maven-plugin/pom.xml @@ -3,7 +3,7 @@ io.smallrye smallrye-graphql-tools-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT 4.0.0 diff --git a/tools/pom.xml b/tools/pom.xml index 79e9561c5..9d8efc9c0 100644 --- a/tools/pom.xml +++ b/tools/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT smallrye-graphql-tools-parent diff --git a/ui/graphiql/pom.xml b/ui/graphiql/pom.xml index 092c2d7dd..e67c87983 100644 --- a/ui/graphiql/pom.xml +++ b/ui/graphiql/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-ui-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT smallrye-graphql-ui-graphiql diff --git a/ui/pom.xml b/ui/pom.xml index dbbd18769..6fe38304f 100644 --- a/ui/pom.xml +++ b/ui/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.0.0.RC6 + 2.0.0-SNAPSHOT smallrye-graphql-ui-parent From c3d233c132beee3b4fe16195c910c0390009c14a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Aug 2022 06:59:07 +0000 Subject: [PATCH 27/33] Bump jakarta.annotation-api from 2.1.0 to 2.1.1 Bumps [jakarta.annotation-api](https://github.com/eclipse-ee4j/common-annotations-api) from 2.1.0 to 2.1.1. - [Release notes](https://github.com/eclipse-ee4j/common-annotations-api/releases) - [Commits](https://github.com/eclipse-ee4j/common-annotations-api/compare/2.1.0...2.1.1) --- updated-dependencies: - dependency-name: jakarta.annotation:jakarta.annotation-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ec7e0bf95..af81b8a13 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ 0.33.0 2.0.4 3.0.2 - 2.1.0 + 2.1.1 5.0.0 2.0.0 From 903746fe830e5f3dc65dddcf2f45cd6b1fc68b94 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Aug 2022 07:13:46 +0000 Subject: [PATCH 28/33] Bump mockito-junit-jupiter from 4.5.1 to 4.6.1 Bumps [mockito-junit-jupiter](https://github.com/mockito/mockito) from 4.5.1 to 4.6.1. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v4.5.1...v4.6.1) --- updated-dependencies: - dependency-name: org.mockito:mockito-junit-jupiter dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index af81b8a13..58bb8cbab 100644 --- a/pom.xml +++ b/pom.xml @@ -49,7 +49,7 @@ 2.2.21 2.13.3 4.6.0 - 4.5.1 + 4.6.1 ${project.basedir}/tck/target/site/jacoco-aggregate/jacoco.xml,${project.basedir}/../tck/target/site/jacoco-aggregate/jacoco.xml From c7f96e9277b0264a7ca48a64ee2cdabbf756c72f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Aug 2022 07:43:09 +0000 Subject: [PATCH 29/33] Bump version.jetty from 11.0.9 to 11.0.11 Bumps `version.jetty` from 11.0.9 to 11.0.11. Updates `jetty-bom` from 11.0.9 to 11.0.11 - [Release notes](https://github.com/eclipse/jetty.project/releases) - [Commits](https://github.com/eclipse/jetty.project/compare/jetty-11.0.9...jetty-11.0.11) Updates `websocket-jakarta-client` from 11.0.9 to 11.0.11 Updates `websocket-jakarta-server` from 11.0.9 to 11.0.11 --- updated-dependencies: - dependency-name: org.eclipse.jetty:jetty-bom dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.eclipse.jetty.websocket:websocket-jakarta-client dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.eclipse.jetty.websocket:websocket-jakarta-server dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index af81b8a13..9e9aedb8e 100644 --- a/pom.xml +++ b/pom.xml @@ -41,7 +41,7 @@ 1.0.0.CR4 - 11.0.9 + 11.0.11 3.0.0-RC1 8.0.0.Alpha3 4.0.2 @@ -49,7 +49,7 @@ 2.2.21 2.13.3 4.6.0 - 4.5.1 + 4.6.1 ${project.basedir}/tck/target/site/jacoco-aggregate/jacoco.xml,${project.basedir}/../tck/target/site/jacoco-aggregate/jacoco.xml From 72bfb8f66253e2c4a83ce6cfaa047c456966ddb5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Aug 2022 07:43:11 +0000 Subject: [PATCH 30/33] Bump bson from 4.6.0 to 4.7.1 Bumps [bson](https://github.com/mongodb/mongo-java-driver) from 4.6.0 to 4.7.1. - [Release notes](https://github.com/mongodb/mongo-java-driver/releases) - [Commits](https://github.com/mongodb/mongo-java-driver/compare/r4.6.0...r4.7.1) --- updated-dependencies: - dependency-name: org.mongodb:bson dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 58bb8cbab..ecc0caefd 100644 --- a/pom.xml +++ b/pom.xml @@ -48,7 +48,7 @@ 4.0.0.CR1 2.2.21 2.13.3 - 4.6.0 + 4.7.1 4.6.1 ${project.basedir}/tck/target/site/jacoco-aggregate/jacoco.xml,${project.basedir}/../tck/target/site/jacoco-aggregate/jacoco.xml From fd87f3aa1aa0bdd2c54f07f959afd639464ee01b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Aug 2022 09:16:00 +0000 Subject: [PATCH 31/33] Bump arquillian-jetty-embedded-11 from 1.0.0.CR4 to 1.0.0.Final Bumps [arquillian-jetty-embedded-11](https://github.com/arquillian/arquillian-container-jetty) from 1.0.0.CR4 to 1.0.0.Final. - [Release notes](https://github.com/arquillian/arquillian-container-jetty/releases) - [Commits](https://github.com/arquillian/arquillian-container-jetty/compare/1.0.0.CR4...1.0.0.Final) --- updated-dependencies: - dependency-name: org.jboss.arquillian.container:arquillian-jetty-embedded-11 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9e9aedb8e..fa1e940fe 100644 --- a/pom.xml +++ b/pom.xml @@ -40,7 +40,7 @@ 4.3.1 - 1.0.0.CR4 + 1.0.0.Final 11.0.11 3.0.0-RC1 8.0.0.Alpha3 From cb659dbc712d116206ad09166e3629ecdbd1f55d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Aug 2022 09:21:13 +0000 Subject: [PATCH 32/33] Bump version.smallrye-mutiny from 1.4.0 to 1.7.0 Bumps `version.smallrye-mutiny` from 1.4.0 to 1.7.0. Updates `mutiny` from 1.4.0 to 1.7.0 - [Release notes](https://github.com/smallrye/smallrye-mutiny/releases) - [Commits](https://github.com/smallrye/smallrye-mutiny/compare/1.4.0...1.7.0) Updates `mutiny-smallrye-context-propagation` from 1.4.0 to 1.7.0 - [Release notes](https://github.com/smallrye/smallrye-mutiny/releases) - [Commits](https://github.com/smallrye/smallrye-mutiny/compare/1.4.0...1.7.0) --- updated-dependencies: - dependency-name: io.smallrye.reactive:mutiny dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: io.smallrye.reactive:mutiny-smallrye-context-propagation dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 9e9aedb8e..b0beffc6e 100644 --- a/pom.xml +++ b/pom.xml @@ -25,9 +25,9 @@ 3.0.0-RC2 4.0.0-RC1 2.0.0-RC2 - 1.4.0 + 1.7.0 2.0.0-RC1 - 1.1.0 + 1.1.2 0.33.0 2.0.4 3.0.2 From a56a1c2af9cfe990c9ac450acced552c4a5ab227 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Aug 2022 09:27:00 +0000 Subject: [PATCH 33/33] Bump maven-deploy-plugin from 3.0.0-M2 to 3.0.0 Bumps [maven-deploy-plugin](https://github.com/apache/maven-deploy-plugin) from 3.0.0-M2 to 3.0.0. - [Release notes](https://github.com/apache/maven-deploy-plugin/releases) - [Commits](https://github.com/apache/maven-deploy-plugin/compare/maven-deploy-plugin-3.0.0-M2...maven-deploy-plugin-3.0.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-deploy-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- tools/gradle-plugin/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/gradle-plugin/pom.xml b/tools/gradle-plugin/pom.xml index 9aec5f616..221cbfe28 100644 --- a/tools/gradle-plugin/pom.xml +++ b/tools/gradle-plugin/pom.xml @@ -123,7 +123,7 @@ org.apache.maven.plugins maven-deploy-plugin - 3.0.0-M2 + 3.0.0 true