From 110e160e7ee46bf36c9a65c84117e5b21ee16d0a Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Wed, 4 Aug 2021 08:20:21 -0400 Subject: [PATCH 1/4] (deps) Updating to use latest graphql-java:17.0 library In 17.0, GraphQLBatched and non-standard Scalars (BigInteger, BigDecimal, Char, Byte, Long, Short) were all removed. Accordingly, removed from here --- build.gradle | 2 +- gradle.properties | 2 +- .../annotationTypes/GraphQLBatched.java | 25 ---- .../BatchedMethodDataFetcher.java | 40 ------ .../dataFetchers/MethodDataFetcher.java | 3 +- .../fieldBuilders/DirectivesBuilder.java | 4 +- .../method/MethodDataFetcherBuilder.java | 6 +- .../method/MethodTypeBuilder.java | 11 +- .../typeFunctions/BatchedTypeFunction.java | 60 --------- .../typeFunctions/BigDecimalFunction.java | 43 ------- .../typeFunctions/BigIntegerFunction.java | 43 ------- .../processor/typeFunctions/ByteFunction.java | 42 ------ .../processor/typeFunctions/CharFunction.java | 43 ------- .../typeFunctions/DefaultTypeFunction.java | 6 - .../processor/typeFunctions/LongFunction.java | 45 ------- .../typeFunctions/ShortFunction.java | 43 ------- .../annotations/GraphQLBatchedTest.java | 120 ------------------ .../GraphQLDirectiveCreationTest.java | 12 +- ...DirectivesViaAnnotationDefinitionTest.java | 20 +-- ...aphQLDirectivesViaClassDefinitionTest.java | 10 +- .../annotations/GraphQLObjectTest.java | 8 +- .../DirectiveArgumentCreatorTest.java | 10 +- .../creation/DirectiveCreatorTest.java | 2 +- .../fieldBuilders/DirectivesBuilderTest.java | 16 +-- .../BigDecimalFunctionTests.java | 34 ----- .../BigIntegerFunctionTests.java | 34 ----- .../typeFunctions/ByteFunctionTests.java | 32 ----- .../typeFunctions/CharFunctionTests.java | 32 ----- .../typeFunctions/LongFunctionTests.java | 31 ----- .../typeFunctions/ShortFunctionTests.java | 32 ----- 30 files changed, 46 insertions(+), 765 deletions(-) delete mode 100644 src/main/java/graphql/annotations/annotationTypes/GraphQLBatched.java delete mode 100644 src/main/java/graphql/annotations/dataFetchers/BatchedMethodDataFetcher.java delete mode 100644 src/main/java/graphql/annotations/processor/typeFunctions/BatchedTypeFunction.java delete mode 100644 src/main/java/graphql/annotations/processor/typeFunctions/BigDecimalFunction.java delete mode 100644 src/main/java/graphql/annotations/processor/typeFunctions/BigIntegerFunction.java delete mode 100644 src/main/java/graphql/annotations/processor/typeFunctions/ByteFunction.java delete mode 100644 src/main/java/graphql/annotations/processor/typeFunctions/CharFunction.java delete mode 100644 src/main/java/graphql/annotations/processor/typeFunctions/LongFunction.java delete mode 100644 src/main/java/graphql/annotations/processor/typeFunctions/ShortFunction.java delete mode 100644 src/test/java/graphql/annotations/GraphQLBatchedTest.java delete mode 100644 src/test/java/graphql/annotations/processor/typeFunctions/BigDecimalFunctionTests.java delete mode 100644 src/test/java/graphql/annotations/processor/typeFunctions/BigIntegerFunctionTests.java delete mode 100644 src/test/java/graphql/annotations/processor/typeFunctions/ByteFunctionTests.java delete mode 100644 src/test/java/graphql/annotations/processor/typeFunctions/CharFunctionTests.java delete mode 100644 src/test/java/graphql/annotations/processor/typeFunctions/LongFunctionTests.java delete mode 100644 src/test/java/graphql/annotations/processor/typeFunctions/ShortFunctionTests.java diff --git a/build.gradle b/build.gradle index 6d05adea..1acc4fce 100644 --- a/build.gradle +++ b/build.gradle @@ -54,7 +54,7 @@ gradle.projectsEvaluated { dependencies { compile 'javax.validation:validation-api:1.1.0.Final' - compile 'com.graphql-java:graphql-java:16.2' + compile 'com.graphql-java:graphql-java:17.0' // OSGi compileOnly 'org.osgi:org.osgi.core:6.0.0' diff --git a/gradle.properties b/gradle.properties index 103bfc28..a7c04cdc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,4 +5,4 @@ org.gradle.daemon=true org.gradle.parallel=true org.gradle.jvmargs=-Dfile.encoding=UTF-8 -version = 8.5 +version = 9.0 diff --git a/src/main/java/graphql/annotations/annotationTypes/GraphQLBatched.java b/src/main/java/graphql/annotations/annotationTypes/GraphQLBatched.java deleted file mode 100644 index e3c20fdf..00000000 --- a/src/main/java/graphql/annotations/annotationTypes/GraphQLBatched.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright 2016 Yurii Rashkovskii - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - */ -package graphql.annotations.annotationTypes; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target({ElementType.METHOD, ElementType.FIELD}) -@Retention(RetentionPolicy.RUNTIME) -public @interface GraphQLBatched { -} diff --git a/src/main/java/graphql/annotations/dataFetchers/BatchedMethodDataFetcher.java b/src/main/java/graphql/annotations/dataFetchers/BatchedMethodDataFetcher.java deleted file mode 100644 index 5f4c3a89..00000000 --- a/src/main/java/graphql/annotations/dataFetchers/BatchedMethodDataFetcher.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright 2016 Yurii Rashkovskii - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - */ -package graphql.annotations.dataFetchers; - -import graphql.annotations.processor.ProcessingElementsContainer; -import graphql.annotations.processor.typeFunctions.TypeFunction; -import graphql.execution.batched.Batched; -import graphql.schema.DataFetchingEnvironment; - -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; - -public class BatchedMethodDataFetcher extends MethodDataFetcher { - - - public BatchedMethodDataFetcher(Method method, TypeFunction typeFunction, ProcessingElementsContainer container) { - super(method,typeFunction, container); - if (!Modifier.isStatic(method.getModifiers())) { - throw new IllegalArgumentException("Batched method should be static"); - } - } - - @Batched - @Override - public Object get(DataFetchingEnvironment environment) { - return super.get(environment); - } -} diff --git a/src/main/java/graphql/annotations/dataFetchers/MethodDataFetcher.java b/src/main/java/graphql/annotations/dataFetchers/MethodDataFetcher.java index 7ba39f7d..5a756662 100644 --- a/src/main/java/graphql/annotations/dataFetchers/MethodDataFetcher.java +++ b/src/main/java/graphql/annotations/dataFetchers/MethodDataFetcher.java @@ -12,7 +12,6 @@ */ package graphql.annotations.dataFetchers; -import graphql.annotations.annotationTypes.GraphQLBatched; import graphql.annotations.annotationTypes.GraphQLConstructor; import graphql.annotations.annotationTypes.GraphQLInvokeDetached; import graphql.annotations.annotationTypes.GraphQLName; @@ -69,7 +68,7 @@ public T get(DataFetchingEnvironment environment) { T obj; if (Modifier.isStatic(method.getModifiers())) { return (T) method.invoke(null, invocationArgs(environment, container)); - } else if (method.isAnnotationPresent(GraphQLBatched.class) || method.isAnnotationPresent(GraphQLInvokeDetached.class)) { + } else if (method.isAnnotationPresent(GraphQLInvokeDetached.class)) { obj = newInstance((Class) method.getDeclaringClass()); } else if (!method.getDeclaringClass().isInstance(environment.getSource())) { obj = newInstance((Class) method.getDeclaringClass(), environment.getSource()); diff --git a/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/DirectivesBuilder.java b/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/DirectivesBuilder.java index 1f94f6a3..0082f5f5 100644 --- a/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/DirectivesBuilder.java +++ b/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/DirectivesBuilder.java @@ -97,7 +97,7 @@ private GraphQLDirective transformArgs(GraphQLDirective graphQLDirective, Annota for (int i = annotation.annotationType().getDeclaredMethods().length; i < arguments.size(); i++) { int finalI = i; - directiveBuilder.argument(arguments.get(i).transform(builder -> builder.value(arguments.get(finalI).getDefaultValue()))); + directiveBuilder.argument(arguments.get(i).transform(builder -> builder.value(arguments.get(finalI).getArgumentDefaultValue().getValue()))); } return directiveBuilder.build(); } @@ -118,7 +118,7 @@ private GraphQLDirective transformArgs(GraphQLDirective graphQLDirective, String for (int i = argumentValues.length; i < arguments.size(); i++) { int finalI = i; - directiveBuilder.argument(arguments.get(i).transform(builder -> builder.value(arguments.get(finalI).getDefaultValue()))); + directiveBuilder.argument(arguments.get(i).transform(builder -> builder.value(arguments.get(finalI).getArgumentDefaultValue().getValue()))); } return directiveBuilder.build(); } diff --git a/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/method/MethodDataFetcherBuilder.java b/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/method/MethodDataFetcherBuilder.java index 348266f1..ee40d9fb 100644 --- a/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/method/MethodDataFetcherBuilder.java +++ b/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/method/MethodDataFetcherBuilder.java @@ -14,11 +14,9 @@ */ package graphql.annotations.processor.retrievers.fieldBuilders.method; -import graphql.annotations.annotationTypes.GraphQLBatched; import graphql.annotations.annotationTypes.GraphQLDataFetcher; import graphql.annotations.annotationTypes.GraphQLRelayMutation; import graphql.annotations.connection.GraphQLConnection; -import graphql.annotations.dataFetchers.BatchedMethodDataFetcher; import graphql.annotations.dataFetchers.MethodDataFetcher; import graphql.annotations.dataFetchers.RelayMutationMethodDataFetcher; import graphql.annotations.processor.ProcessingElementsContainer; @@ -62,9 +60,7 @@ public MethodDataFetcherBuilder(Method method, GraphQLOutputType outputType, Typ public DataFetcher build() { GraphQLDataFetcher dataFetcher = method.getAnnotation(GraphQLDataFetcher.class); DataFetcher actualDataFetcher; - if (dataFetcher == null && method.getAnnotation(GraphQLBatched.class) != null) { - actualDataFetcher = new BatchedMethodDataFetcher(method, typeFunction, container); - } else if (dataFetcher == null) { + if (dataFetcher == null) { actualDataFetcher = new MethodDataFetcher(method, typeFunction, container); } else { actualDataFetcher = dataFetcherConstructor.constructDataFetcher(method.getName(), dataFetcher); diff --git a/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/method/MethodTypeBuilder.java b/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/method/MethodTypeBuilder.java index ebdae92f..b81cf599 100644 --- a/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/method/MethodTypeBuilder.java +++ b/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/method/MethodTypeBuilder.java @@ -14,10 +14,8 @@ */ package graphql.annotations.processor.retrievers.fieldBuilders.method; -import graphql.annotations.annotationTypes.GraphQLBatched; import graphql.annotations.processor.ProcessingElementsContainer; import graphql.annotations.processor.retrievers.fieldBuilders.Builder; -import graphql.annotations.processor.typeFunctions.BatchedTypeFunction; import graphql.annotations.processor.typeFunctions.TypeFunction; import graphql.schema.GraphQLOutputType; import graphql.schema.GraphQLType; @@ -42,14 +40,7 @@ public MethodTypeBuilder(Method method, TypeFunction typeFunction, ProcessingEle public GraphQLType build() { AnnotatedType annotatedReturnType = method.getAnnotatedReturnType(); - TypeFunction typeFunction; - if (method.getAnnotation(GraphQLBatched.class) != null) { - typeFunction = new BatchedTypeFunction(this.typeFunction); - } else { - typeFunction = this.typeFunction; - } - - return typeFunction.buildType(isInput,method.getReturnType(), annotatedReturnType, container); + return this.typeFunction.buildType(isInput,method.getReturnType(), annotatedReturnType, container); } } diff --git a/src/main/java/graphql/annotations/processor/typeFunctions/BatchedTypeFunction.java b/src/main/java/graphql/annotations/processor/typeFunctions/BatchedTypeFunction.java deleted file mode 100644 index 2733de72..00000000 --- a/src/main/java/graphql/annotations/processor/typeFunctions/BatchedTypeFunction.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright 2016 Yurii Rashkovskii - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - */ -package graphql.annotations.processor.typeFunctions; - -import graphql.annotations.processor.ProcessingElementsContainer; -import graphql.schema.GraphQLType; - -import java.lang.reflect.AnnotatedParameterizedType; -import java.lang.reflect.AnnotatedType; -import java.lang.reflect.ParameterizedType; -import java.util.List; - -public class BatchedTypeFunction implements TypeFunction { - private TypeFunction defaultTypeFunction; - - public BatchedTypeFunction(TypeFunction defaultTypeFunction) { - this.defaultTypeFunction = defaultTypeFunction; - } - - @Override - public String getTypeName(Class aClass, AnnotatedType annotatedType) { - return defaultTypeFunction.getTypeName(aClass, annotatedType); - } - - @Override - public boolean canBuildType(final Class aClass, final AnnotatedType type) { - return defaultTypeFunction.canBuildType(aClass, type); - } - - @Override - public GraphQLType buildType(boolean input, Class aClass, AnnotatedType annotatedType, ProcessingElementsContainer container) { - if (!aClass.isAssignableFrom(List.class)) { - throw new IllegalArgumentException("Batched method should return a List"); - } - if (!(annotatedType instanceof AnnotatedParameterizedType)) { - throw new IllegalArgumentException("Batched should return parameterized type"); - } - AnnotatedParameterizedType parameterizedType = (AnnotatedParameterizedType) annotatedType; - AnnotatedType arg = parameterizedType.getAnnotatedActualTypeArguments()[0]; - Class klass; - if (arg.getType() instanceof ParameterizedType) { - klass = (Class) ((ParameterizedType) (arg.getType())).getRawType(); - } else { - klass = (Class) arg.getType(); - } - return defaultTypeFunction.buildType(input, klass, arg,container); - } -} diff --git a/src/main/java/graphql/annotations/processor/typeFunctions/BigDecimalFunction.java b/src/main/java/graphql/annotations/processor/typeFunctions/BigDecimalFunction.java deleted file mode 100644 index e5e3f730..00000000 --- a/src/main/java/graphql/annotations/processor/typeFunctions/BigDecimalFunction.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright 2016 Yurii Rashkovskii - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - */ -package graphql.annotations.processor.typeFunctions; - -import graphql.Scalars; -import graphql.annotations.processor.ProcessingElementsContainer; -import graphql.schema.GraphQLType; - -import java.lang.reflect.AnnotatedType; -import java.math.BigDecimal; - -public class BigDecimalFunction implements TypeFunction { - @Override - public String getTypeName(Class aClass, AnnotatedType annotatedType) { - return Scalars.GraphQLBigDecimal.getName(); - } - - @Override - public boolean canBuildType(Class aClass, AnnotatedType annotatedType) { - return aClass == BigDecimal.class; - } - - @Override - public GraphQLType buildType(boolean input, Class aClass, AnnotatedType annotatedType, ProcessingElementsContainer container) { - return buildType(input, aClass, annotatedType); - } - - private GraphQLType buildType(boolean inputType, Class aClass, AnnotatedType annotatedType) { - return Scalars.GraphQLBigDecimal; - } -} diff --git a/src/main/java/graphql/annotations/processor/typeFunctions/BigIntegerFunction.java b/src/main/java/graphql/annotations/processor/typeFunctions/BigIntegerFunction.java deleted file mode 100644 index 34cc2d11..00000000 --- a/src/main/java/graphql/annotations/processor/typeFunctions/BigIntegerFunction.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright 2016 Yurii Rashkovskii - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - */ -package graphql.annotations.processor.typeFunctions; - -import graphql.Scalars; -import graphql.annotations.processor.ProcessingElementsContainer; -import graphql.schema.GraphQLType; - -import java.lang.reflect.AnnotatedType; -import java.math.BigInteger; - -public class BigIntegerFunction implements TypeFunction { - @Override - public String getTypeName(Class aClass, AnnotatedType annotatedType) { - return Scalars.GraphQLBigInteger.getName(); - } - - @Override - public boolean canBuildType(Class aClass, AnnotatedType annotatedType) { - return aClass == BigInteger.class; - } - - @Override - public GraphQLType buildType(boolean input, Class aClass, AnnotatedType annotatedType, ProcessingElementsContainer container) { - return buildType(input, aClass, annotatedType); - } - - private GraphQLType buildType(boolean inputType, Class aClass, AnnotatedType annotatedType) { - return Scalars.GraphQLBigInteger; - } -} diff --git a/src/main/java/graphql/annotations/processor/typeFunctions/ByteFunction.java b/src/main/java/graphql/annotations/processor/typeFunctions/ByteFunction.java deleted file mode 100644 index 2a58473f..00000000 --- a/src/main/java/graphql/annotations/processor/typeFunctions/ByteFunction.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright 2016 Yurii Rashkovskii - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - */ -package graphql.annotations.processor.typeFunctions; - -import graphql.Scalars; -import graphql.annotations.processor.ProcessingElementsContainer; -import graphql.schema.GraphQLType; - -import java.lang.reflect.AnnotatedType; - -public class ByteFunction implements TypeFunction { - @Override - public String getTypeName(Class aClass, AnnotatedType annotatedType) { - return Scalars.GraphQLByte.getName(); - } - - @Override - public boolean canBuildType(Class aClass, AnnotatedType annotatedType) { - return aClass == Byte.class; - } - - @Override - public GraphQLType buildType(boolean input, Class aClass, AnnotatedType annotatedType, ProcessingElementsContainer container) { - return buildType(input, aClass, annotatedType); - } - - private GraphQLType buildType(boolean inputType, Class aClass, AnnotatedType annotatedType) { - return Scalars.GraphQLByte; - } -} diff --git a/src/main/java/graphql/annotations/processor/typeFunctions/CharFunction.java b/src/main/java/graphql/annotations/processor/typeFunctions/CharFunction.java deleted file mode 100644 index ba2ebb1c..00000000 --- a/src/main/java/graphql/annotations/processor/typeFunctions/CharFunction.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright 2016 Yurii Rashkovskii - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - */ -package graphql.annotations.processor.typeFunctions; - -import graphql.Scalars; -import graphql.annotations.processor.ProcessingElementsContainer; -import graphql.schema.GraphQLType; - -import java.lang.reflect.AnnotatedType; - -public class CharFunction implements TypeFunction { - - @Override - public String getTypeName(Class aClass, AnnotatedType annotatedType) { - return Scalars.GraphQLChar.getName(); - } - - @Override - public boolean canBuildType(Class aClass, AnnotatedType annotatedType) { - return aClass == Character.class; - } - - @Override - public GraphQLType buildType(boolean input, Class aClass, AnnotatedType annotatedType, ProcessingElementsContainer container) { - return buildType(input, aClass, annotatedType); - } - - private GraphQLType buildType(boolean inputType, Class aClass, AnnotatedType annotatedType) { - return Scalars.GraphQLChar; - } -} diff --git a/src/main/java/graphql/annotations/processor/typeFunctions/DefaultTypeFunction.java b/src/main/java/graphql/annotations/processor/typeFunctions/DefaultTypeFunction.java index b02c4703..99fe159a 100644 --- a/src/main/java/graphql/annotations/processor/typeFunctions/DefaultTypeFunction.java +++ b/src/main/java/graphql/annotations/processor/typeFunctions/DefaultTypeFunction.java @@ -55,12 +55,6 @@ public void activate() { typeFunctions.add(new BooleanFunction()); typeFunctions.add(new FloatFunction()); typeFunctions.add(new IntegerFunction()); - typeFunctions.add(new LongFunction()); - typeFunctions.add(new ByteFunction()); - typeFunctions.add(new ShortFunction()); - typeFunctions.add(new BigIntegerFunction()); - typeFunctions.add(new BigDecimalFunction()); - typeFunctions.add(new CharFunction()); typeFunctions.add(new IterableFunction(DefaultTypeFunction.this)); typeFunctions.add(new ArrayFunction(DefaultTypeFunction.this)); typeFunctions.add(new StreamFunction(DefaultTypeFunction.this)); diff --git a/src/main/java/graphql/annotations/processor/typeFunctions/LongFunction.java b/src/main/java/graphql/annotations/processor/typeFunctions/LongFunction.java deleted file mode 100644 index 06618c46..00000000 --- a/src/main/java/graphql/annotations/processor/typeFunctions/LongFunction.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright 2016 Yurii Rashkovskii - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - */ -package graphql.annotations.processor.typeFunctions; - -import graphql.Scalars; -import graphql.annotations.processor.ProcessingElementsContainer; -import graphql.schema.GraphQLType; - -import java.lang.reflect.AnnotatedType; - - -class LongFunction implements TypeFunction { - - @Override - public String getTypeName(Class aClass, AnnotatedType annotatedType) { - return Scalars.GraphQLLong.getName(); - } - - @Override - public boolean canBuildType(Class aClass, AnnotatedType annotatedType) { - return aClass == Long.class || aClass == long.class; - } - - @Override - public GraphQLType buildType(boolean input, Class aClass, AnnotatedType annotatedType, ProcessingElementsContainer container) { - return buildType(input,aClass,annotatedType); - } - - private GraphQLType buildType(boolean inputType, Class aClass, AnnotatedType annotatedType) { - return Scalars.GraphQLLong; - } - -} diff --git a/src/main/java/graphql/annotations/processor/typeFunctions/ShortFunction.java b/src/main/java/graphql/annotations/processor/typeFunctions/ShortFunction.java deleted file mode 100644 index 9f608c64..00000000 --- a/src/main/java/graphql/annotations/processor/typeFunctions/ShortFunction.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright 2016 Yurii Rashkovskii - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - */ -package graphql.annotations.processor.typeFunctions; - -import graphql.Scalars; -import graphql.annotations.processor.ProcessingElementsContainer; -import graphql.schema.GraphQLType; - -import java.lang.reflect.AnnotatedType; - -public class ShortFunction implements TypeFunction { - @Override - public String getTypeName(Class aClass, AnnotatedType annotatedType) { - return Scalars.GraphQLShort.getName(); - } - - @Override - public boolean canBuildType(Class aClass, AnnotatedType annotatedType) { - return aClass == Short.class; - } - - @Override - public GraphQLType buildType(boolean input, Class aClass, AnnotatedType annotatedType, ProcessingElementsContainer container) { - return buildType(input, aClass, annotatedType); - } - - private GraphQLType buildType(boolean inputType, Class aClass, AnnotatedType annotatedType) { - return Scalars.GraphQLShort; - } -} - diff --git a/src/test/java/graphql/annotations/GraphQLBatchedTest.java b/src/test/java/graphql/annotations/GraphQLBatchedTest.java deleted file mode 100644 index 213b6f18..00000000 --- a/src/test/java/graphql/annotations/GraphQLBatchedTest.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * Copyright 2016 Yurii Rashkovskii - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - */ -package graphql.annotations; - -import graphql.ExceptionWhileDataFetching; -import graphql.ExecutionResult; -import graphql.GraphQL; -import graphql.annotations.annotationTypes.GraphQLBatched; -import graphql.annotations.annotationTypes.GraphQLField; -import graphql.annotations.processor.GraphQLAnnotations; -import graphql.execution.batched.BatchedExecutionStrategy; -import graphql.schema.GraphQLObjectType; -import graphql.schema.GraphQLSchema; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import static graphql.Scalars.GraphQLString; -import static graphql.annotations.AnnotationsSchemaCreator.newAnnotationsSchema; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -@SuppressWarnings("unchecked") -public class GraphQLBatchedTest { - - private GraphQLAnnotations graphQLAnnotations; - - @BeforeMethod - public void init() { - this.graphQLAnnotations = new GraphQLAnnotations(); - } - - public static class SimpleBatchedField { - @GraphQLField - @GraphQLBatched - public static List a() { - return Arrays.asList("one", "two"); - } - } - - public static class TestBatchedObject { - @GraphQLField - public List fields() { - return Arrays.asList(new SimpleBatchedField(), new SimpleBatchedField()); - } - } - - @Test - public void batchedDataFetcher() throws Throwable { - GraphQLObjectType nestedObject = this.graphQLAnnotations.object(SimpleBatchedField.class); - assertEquals(nestedObject.getFieldDefinition("a").getType(), GraphQLString); - - GraphQLSchema schema = newAnnotationsSchema().query(TestBatchedObject.class).build(); - GraphQL graphql = GraphQL.newGraphQL(schema).queryExecutionStrategy(new BatchedExecutionStrategy()).build(); - ExecutionResult result = graphql.execute("{ fields { a } }", new TestBatchedObject()); - List errors = result.getErrors(); - for (Object e : errors) { - throw ((ExceptionWhileDataFetching) e).getException(); - } - assertTrue(result.getErrors().isEmpty()); - Map data = (Map) result.getData(); - List> fields = (List) data.get("fields"); - assertEquals(fields.get(0).get("a"), "one"); - assertEquals(fields.get(1).get("a"), "two"); - } - - public static class NoStaticBatchedField { - @GraphQLField - @GraphQLBatched - public List a() { - return Arrays.asList("one", "two"); - } - } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void noStaticField() { - GraphQLObjectType object = this.graphQLAnnotations.object(NoStaticBatchedField.class); - } - - public static class NoListBatchedField { - @GraphQLField - @GraphQLBatched - public String a() { - return "one"; - } - } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void noListField() { - GraphQLObjectType object = this.graphQLAnnotations.object(NoStaticBatchedField.class); - } - - public static class NoParameterizedBatchedField { - @GraphQLField - @GraphQLBatched - public List a() { - return Arrays.asList("one", "two"); - } - } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void noParameterizedReturnField() { - GraphQLObjectType object = this.graphQLAnnotations.object(NoStaticBatchedField.class); - } -} diff --git a/src/test/java/graphql/annotations/GraphQLDirectiveCreationTest.java b/src/test/java/graphql/annotations/GraphQLDirectiveCreationTest.java index e00acbb0..027b6d97 100644 --- a/src/test/java/graphql/annotations/GraphQLDirectiveCreationTest.java +++ b/src/test/java/graphql/annotations/GraphQLDirectiveCreationTest.java @@ -81,17 +81,17 @@ public void directive_suppliedDirectiveClass_returnCorrectDirective() { assertNotNull(isActive); assertEquals(isActive.getName(), "isActive"); assertEquals(isActive.getType(), GraphQLBoolean); - assertEquals(isActive.getDefaultValue(), true); + assertEquals(isActive.getArgumentDefaultValue().getValue(), true); GraphQLArgument suffixToAdd = directive.getArgument("suffixToAdd"); assertNotNull(suffixToAdd); assertEquals(suffixToAdd.getType(), GraphQLString); assertEquals(suffixToAdd.getDescription(), "adds suffix to the string"); - assertEquals(suffixToAdd.getDefaultValue(), ""); + assertEquals(suffixToAdd.getArgumentDefaultValue().getValue(), ""); GraphQLArgument noDefaultValue = directive.getArgument("noDefaultValue"); assertNotNull(noDefaultValue); - assertNull(noDefaultValue.getDefaultValue()); + assertNull(noDefaultValue.getArgumentDefaultValue().getValue()); } /** @@ -137,13 +137,13 @@ public void directive_suppliedDirectiveMethodContainer_returnCorrectDirective() assertNotNull(isActive); assertEquals(isActive.getName(), "isActive"); assertEquals(isActive.getType(), GraphQLBoolean); - assertNull(isActive.getDefaultValue()); + assertNull(isActive.getArgumentDefaultValue().getValue()); GraphQLArgument suffixToAdd = suffix.getArgument("suffix"); assertNotNull(suffixToAdd); assertEquals(suffixToAdd.getType(), GraphQLString); assertEquals("the suffix", suffixToAdd.getDescription()); - assertNull(suffixToAdd.getDefaultValue()); + assertNull(suffixToAdd.getArgumentDefaultValue().getValue()); } @@ -182,7 +182,7 @@ public void directive_suppliedDirectiveAnnotation_returnCorrectDirective() { assertNotNull(isActive); assertEquals(isActive.getName(), "isActive"); assertEquals(isActive.getType(), GraphQLBoolean); - assertEquals(true,isActive.getDefaultValue()); + assertEquals(true,isActive.getArgumentDefaultValue().getValue()); } @Test(expectedExceptions = GraphQLAnnotationsException.class) diff --git a/src/test/java/graphql/annotations/GraphQLDirectivesViaAnnotationDefinitionTest.java b/src/test/java/graphql/annotations/GraphQLDirectivesViaAnnotationDefinitionTest.java index bb234144..bf46037c 100644 --- a/src/test/java/graphql/annotations/GraphQLDirectivesViaAnnotationDefinitionTest.java +++ b/src/test/java/graphql/annotations/GraphQLDirectivesViaAnnotationDefinitionTest.java @@ -57,7 +57,7 @@ public static class UpperWiring implements AnnotationsDirectiveWiring { @Override public GraphQLFieldDefinition onField(AnnotationsWiringEnvironment environment) { GraphQLFieldDefinition field = (GraphQLFieldDefinition) environment.getElement(); - boolean isActive = (boolean) environment.getDirective().getArgument("isActive").getValue(); + boolean isActive = (boolean) environment.getDirective().getArgument("isActive").getArgumentValue().getValue(); CodeRegistryUtil.wrapDataFetcher(field, environment, (((dataFetchingEnvironment, value) -> { if (value instanceof String && isActive) { return ((String) value).toUpperCase(); @@ -73,17 +73,17 @@ public static class SuffixWiring implements AnnotationsDirectiveWiring { @Override public GraphQLInputObjectField onInputObjectField(AnnotationsWiringEnvironment environment) { GraphQLInputObjectField field = (GraphQLInputObjectField) environment.getElement(); - boolean isActive = (boolean) environment.getDirective().getArgument("isActive").getValue(); + boolean isActive = (boolean) environment.getDirective().getArgument("isActive").getArgumentValue().getValue(); if (!isActive) return field; - String suffix = (String) environment.getDirective().getArgument("suffix").getValue(); + String suffix = (String) environment.getDirective().getArgument("suffix").getArgumentValue().getValue(); return field.transform(builder -> builder.name(field.getName() + suffix)); } @Override public GraphQLFieldDefinition onField(AnnotationsWiringEnvironment environment) { GraphQLFieldDefinition field = (GraphQLFieldDefinition) environment.getElement(); - String suffix = (String) environment.getDirective().getArgument("suffix").getValue(); - boolean isActive = (boolean) environment.getDirective().getArgument("isActive").getValue(); + String suffix = (String) environment.getDirective().getArgument("suffix").getArgumentValue().getValue(); + boolean isActive = (boolean) environment.getDirective().getArgument("isActive").getArgumentValue().getValue(); if (!isActive) return field; CodeRegistryUtil.wrapDataFetcher(field, environment, (dataFetchingEnvironment, value) -> { if (value instanceof String) { @@ -98,8 +98,8 @@ public GraphQLFieldDefinition onField(AnnotationsWiringEnvironment environment) @Override public GraphQLArgument onArgument(AnnotationsWiringEnvironment environment) { GraphQLArgument element = (GraphQLArgument) environment.getElement(); - String suffix = (String) environment.getDirective().getArgument("suffix").getValue(); - boolean isActive = (boolean) environment.getDirective().getArgument("isActive").getValue(); + String suffix = (String) environment.getDirective().getArgument("suffix").getArgumentValue().getValue(); + boolean isActive = (boolean) environment.getDirective().getArgument("isActive").getArgumentValue().getValue(); if (!isActive) return element; return element.transform(builder -> builder.name(element.getName() + suffix)); } @@ -107,9 +107,9 @@ public GraphQLArgument onArgument(AnnotationsWiringEnvironment environment) { @Override public GraphQLInputObjectType onInputObjectType(AnnotationsWiringEnvironment environment) { GraphQLInputObjectType element = (GraphQLInputObjectType) environment.getElement(); - boolean isActive = (boolean) environment.getDirective().getArgument("isActive").getValue(); + boolean isActive = (boolean) environment.getDirective().getArgument("isActive").getArgumentValue().getValue(); if (!isActive) return element; - String suffix = (String) environment.getDirective().getArgument("suffix").getValue(); + String suffix = (String) environment.getDirective().getArgument("suffix").getArgumentValue().getValue(); return element; } } @@ -118,7 +118,7 @@ public static class DirectiveWithListWiring implements AnnotationsDirectiveWirin @Override public GraphQLFieldDefinition onField(AnnotationsWiringEnvironment environment) { GraphQLFieldDefinition field = (GraphQLFieldDefinition) environment.getElement(); - String[] list= (String[]) environment.getDirective().getArgument("list").getValue(); + String[] list= (String[]) environment.getDirective().getArgument("list").getArgumentValue().getValue(); CodeRegistryUtil.wrapDataFetcher(field, environment, (dataFetchingEnvironment, value) -> value + list[0]); return field; } diff --git a/src/test/java/graphql/annotations/GraphQLDirectivesViaClassDefinitionTest.java b/src/test/java/graphql/annotations/GraphQLDirectivesViaClassDefinitionTest.java index 30ff45ba..f3117194 100644 --- a/src/test/java/graphql/annotations/GraphQLDirectivesViaClassDefinitionTest.java +++ b/src/test/java/graphql/annotations/GraphQLDirectivesViaClassDefinitionTest.java @@ -52,7 +52,7 @@ public static class UpperWiring implements AnnotationsDirectiveWiring { @Override public GraphQLFieldDefinition onField(AnnotationsWiringEnvironment environment) { GraphQLFieldDefinition field = (GraphQLFieldDefinition) environment.getElement(); - boolean isActive = (boolean) environment.getDirective().getArgument("isActive").getValue(); + boolean isActive = (boolean) environment.getDirective().getArgument("isActive").getArgumentValue().getValue(); CodeRegistryUtil.wrapDataFetcher(field, environment, (((dataFetchingEnvironment, value) -> { if (value instanceof String && isActive) { return ((String) value).toUpperCase(); @@ -68,14 +68,14 @@ public static class SuffixWiring implements AnnotationsDirectiveWiring { @Override public GraphQLInputObjectField onInputObjectField(AnnotationsWiringEnvironment environment) { GraphQLInputObjectField field = (GraphQLInputObjectField) environment.getElement(); - String suffix = (String) environment.getDirective().getArgument("suffix").getValue(); + String suffix = (String) environment.getDirective().getArgument("suffix").getArgumentValue().getValue(); return field.transform(builder -> builder.name(field.getName() + suffix)); } @Override public GraphQLFieldDefinition onField(AnnotationsWiringEnvironment environment) { GraphQLFieldDefinition field = (GraphQLFieldDefinition) environment.getElement(); - String suffix = (String) environment.getDirective().getArgument("suffix").getValue(); + String suffix = (String) environment.getDirective().getArgument("suffix").getArgumentValue().getValue(); CodeRegistryUtil.wrapDataFetcher(field, environment, (dataFetchingEnvironment, value) -> { if (value instanceof String) { return value + suffix; @@ -89,14 +89,14 @@ public GraphQLFieldDefinition onField(AnnotationsWiringEnvironment environment) @Override public GraphQLArgument onArgument(AnnotationsWiringEnvironment environment) { GraphQLArgument element = (GraphQLArgument) environment.getElement(); - String suffix = (String) environment.getDirective().getArgument("suffix").getValue(); + String suffix = (String) environment.getDirective().getArgument("suffix").getArgumentValue().getValue(); return element.transform(builder -> builder.name(element.getName() + suffix)); } @Override public GraphQLInputObjectType onInputObjectType(AnnotationsWiringEnvironment environment) { GraphQLInputObjectType element = (GraphQLInputObjectType) environment.getElement(); - String suffix = (String) environment.getDirective().getArgument("suffix").getValue(); + String suffix = (String) environment.getDirective().getArgument("suffix").getArgumentValue().getValue(); return element; } } diff --git a/src/test/java/graphql/annotations/GraphQLObjectTest.java b/src/test/java/graphql/annotations/GraphQLObjectTest.java index 299a64d8..246d3473 100644 --- a/src/test/java/graphql/annotations/GraphQLObjectTest.java +++ b/src/test/java/graphql/annotations/GraphQLObjectTest.java @@ -352,15 +352,15 @@ public Type id() { } } - public static class TestObjectBridgMethod extends TestObjectBridgMethodParent { + public static class TestObjectBridgMethod extends TestObjectBridgMethodParent { public TestObjectBridgMethod() { - super(1L); + super("1"); } @Override @GraphQLField - public Long id() { + public String id() { return super.id(); } } @@ -370,7 +370,7 @@ public void methodInheritanceWithGenerics() { GraphQLSchema schema = newAnnotationsSchema().query(TestObjectBridgMethod.class).build(); ExecutionResult result = GraphQL.newGraphQL(schema).build().execute("{id}", new TestObjectBridgMethod()); - assertEquals(((Map) result.getData()).get("id"), 1L); + assertEquals(((Map) result.getData()).get("id"), "1"); } public interface Iface { diff --git a/src/test/java/graphql/annotations/directives/creation/DirectiveArgumentCreatorTest.java b/src/test/java/graphql/annotations/directives/creation/DirectiveArgumentCreatorTest.java index fa5f2b68..3ca67618 100644 --- a/src/test/java/graphql/annotations/directives/creation/DirectiveArgumentCreatorTest.java +++ b/src/test/java/graphql/annotations/directives/creation/DirectiveArgumentCreatorTest.java @@ -86,7 +86,7 @@ public void getArgument_goodFieldSupplied_correctArgumentCreated() throws NoSuch GraphQLArgument isActive = directiveArgumentCreator.getArgument(this.getClass().getDeclaredField("isActive"), DirectiveArgumentCreatorTest.class); // Assert assertEquals(isActive.getName(), "isActive"); - assertEquals(isActive.getDefaultValue(), true); + assertEquals(isActive.getArgumentDefaultValue().getValue(), true); assertEquals(isActive.getDescription(), "isActive"); assertEquals(isActive.getType(), GraphQLBoolean); } @@ -100,7 +100,7 @@ public void getArgument_goodMethodSuppliedWithoutGraphQLName_correctArgumentCrea // Assert assertEquals(argument.getName(), "suffix"); - assertEquals(argument.getDefaultValue(), "bla"); + assertEquals(argument.getArgumentDefaultValue().getValue(), "bla"); assertEquals(argument.getDescription(), null); assertEquals(argument.getType(), GraphQLString); } @@ -112,7 +112,7 @@ public void getArgument_goodMethodSuppliedWithGraphQLData_correctArgumentCreated // Assert assertEquals(argument.getName(), "suffix1"); - assertEquals(argument.getDefaultValue(), null); + assertEquals(argument.getArgumentDefaultValue().getValue(), null); assertEquals(argument.getDescription(), "bla"); assertEquals(argument.getType(), GraphQLString); } @@ -139,7 +139,7 @@ public void getArgument_goodParameterSuppliedWithoutGraphQLName_correctArgumentC // Assert assertEquals(argument.getName(), "arg0"); - assertEquals(argument.getDefaultValue(), null); + assertEquals(argument.getArgumentDefaultValue().getValue(), null); assertEquals(argument.getDescription(), null); assertEquals(argument.getType(), GraphQLString); } @@ -151,7 +151,7 @@ public void getArgument_goodParameterSuppliedWithGraphQLData_correctArgumentCrea // Assert assertEquals(argument.getName(), "suffix"); - assertEquals(argument.getDefaultValue(), null); + assertEquals(argument.getArgumentDefaultValue().getValue(), null); assertEquals(argument.getDescription(), "the suffix"); assertEquals(argument.getType(), GraphQLString); } diff --git a/src/test/java/graphql/annotations/directives/creation/DirectiveCreatorTest.java b/src/test/java/graphql/annotations/directives/creation/DirectiveCreatorTest.java index d1e70cdc..2519384e 100644 --- a/src/test/java/graphql/annotations/directives/creation/DirectiveCreatorTest.java +++ b/src/test/java/graphql/annotations/directives/creation/DirectiveCreatorTest.java @@ -85,6 +85,6 @@ public void getDirective_goodDirectiveClass_directiveIsCorrect() { assertNotNull(isActive); assertEquals(isActive.getName(), "isActive"); assertEquals(isActive.getType(), GraphQLBoolean); - assertEquals(isActive.getDefaultValue(), true); + assertEquals(isActive.getArgumentDefaultValue().getValue(), true); } } diff --git a/src/test/java/graphql/annotations/processor/retrievers/fieldBuilders/DirectivesBuilderTest.java b/src/test/java/graphql/annotations/processor/retrievers/fieldBuilders/DirectivesBuilderTest.java index 513c08af..fc170f48 100644 --- a/src/test/java/graphql/annotations/processor/retrievers/fieldBuilders/DirectivesBuilderTest.java +++ b/src/test/java/graphql/annotations/processor/retrievers/fieldBuilders/DirectivesBuilderTest.java @@ -116,7 +116,7 @@ public void testDecoratedField_directivesAreInRegistry_directivesAreBuilt() thro assertEquals(graphQLDirectives[1].getName(), "upperCase"); assertFalse(graphQLDirectives[1].getArguments().isEmpty()); assertEquals(graphQLDirectives[1].getArguments().get(0).getName(), "myArg"); - assertEquals(graphQLDirectives[1].getArguments().get(0).getValue(), "DefaultString"); + assertEquals(graphQLDirectives[1].getArguments().get(0).getArgumentValue().getValue(), "DefaultString"); assertEquals(graphQLDirectives[2].getName(), "lowerCase"); assertTrue(graphQLDirectives[2].getArguments().isEmpty()); @@ -141,7 +141,7 @@ public void testDecoratedFieldWithArguments_directivesAreInRegistry_directivesAr assertEquals(graphQLDirectives[0].getName(), "upperCase"); assertFalse(graphQLDirectives[0].getArguments().isEmpty()); assertEquals(graphQLDirectives[0].getArguments().get(0).getName(), "myArg"); - assertEquals(graphQLDirectives[0].getArguments().get(0).getValue(), "This is a string"); + assertEquals(graphQLDirectives[0].getArguments().get(0).getArgumentValue().getValue(), "This is a string"); assertEquals(graphQLDirectives[1].getName(), "lowerCase"); assertTrue(graphQLDirectives[1].getArguments().isEmpty()); } @@ -221,10 +221,10 @@ public void testDecoratedFieldWithArguments_moreArgumentsThanArgumentsValues_dir assertEquals(graphQLDirectives[0].getArguments().size(), 2); assertEquals(graphQLDirectives[0].getArguments().get(0).getName(), "arg"); - assertEquals(graphQLDirectives[0].getArguments().get(0).getValue(), "This is a string"); + assertEquals(graphQLDirectives[0].getArguments().get(0).getArgumentValue().getValue(), "This is a string"); assertEquals(graphQLDirectives[0].getArguments().get(1).getName(), "arg2"); - assertEquals(graphQLDirectives[0].getArguments().get(1).getValue(), "5"); + assertEquals(graphQLDirectives[0].getArguments().get(1).getArgumentValue().getValue(), "5"); } // Argument @@ -264,7 +264,7 @@ public void testDecoratedArgument_directivesAreInRegistry_directivesAreBuilt() t assertEquals(graphQLDirectives[1].getName(), "upperCase"); assertFalse(graphQLDirectives[1].getArguments().isEmpty()); assertEquals(graphQLDirectives[1].getArguments().get(0).getName(), "myArg"); - assertEquals(graphQLDirectives[1].getArguments().get(0).getValue(), "DefaultString"); + assertEquals(graphQLDirectives[1].getArguments().get(0).getArgumentValue().getValue(), "DefaultString"); } @Test @@ -286,7 +286,7 @@ public void testDecoratedParameterWithArguments_directivesAreInRegistry_directiv assertEquals(graphQLDirectives[0].getName(), "upperCase"); assertFalse(graphQLDirectives[0].getArguments().isEmpty()); assertEquals(graphQLDirectives[0].getArguments().get(0).getName(), "myArg"); - assertEquals(graphQLDirectives[0].getArguments().get(0).getValue(), "This is a string"); + assertEquals(graphQLDirectives[0].getArguments().get(0).getArgumentValue().getValue(), "This is a string"); } // Class @@ -327,7 +327,7 @@ public void testDecoratedClass_directivesAreInRegistry_directivesAreBuilt() thro assertEquals(graphQLDirectives[1].getName(), "upperCase"); assertFalse(graphQLDirectives[1].getArguments().isEmpty()); assertEquals(graphQLDirectives[1].getArguments().get(0).getName(), "myArg"); - assertEquals(graphQLDirectives[1].getArguments().get(0).getValue(), "DefaultString"); + assertEquals(graphQLDirectives[1].getArguments().get(0).getArgumentValue().getValue(), "DefaultString"); assertEquals(graphQLDirectives[2].getName(), "lowerCase"); assertTrue(graphQLDirectives[2].getArguments().isEmpty()); @@ -352,7 +352,7 @@ public void testDecoratedClassWithArguments_directivesAreInRegistry_directivesAr assertEquals(graphQLDirectives[0].getName(), "upperCase"); assertFalse(graphQLDirectives[0].getArguments().isEmpty()); assertEquals(graphQLDirectives[0].getArguments().get(0).getName(), "myArg"); - assertEquals(graphQLDirectives[0].getArguments().get(0).getValue(), "This is a string"); + assertEquals(graphQLDirectives[0].getArguments().get(0).getArgumentValue().getValue(), "This is a string"); assertEquals(graphQLDirectives[1].getName(), "lowerCase"); assertTrue(graphQLDirectives[1].getArguments().isEmpty()); } diff --git a/src/test/java/graphql/annotations/processor/typeFunctions/BigDecimalFunctionTests.java b/src/test/java/graphql/annotations/processor/typeFunctions/BigDecimalFunctionTests.java deleted file mode 100644 index 40816ea8..00000000 --- a/src/test/java/graphql/annotations/processor/typeFunctions/BigDecimalFunctionTests.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright 2016 Yurii Rashkovskii - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - */ -package graphql.annotations.processor.typeFunctions; - -import org.testng.annotations.Test; - -import java.math.BigDecimal; - -import static graphql.Scalars.GraphQLBigDecimal; -import static graphql.annotations.processor.typeFunctions.DefaultTypeFunctionTestHelper.testedDefaultTypeFunction; -import static org.testng.Assert.assertEquals; - -public class BigDecimalFunctionTests { - @Test - public void buildType_bigDecimalType_returnsGraphQLBigDecimal() { - //arrange - DefaultTypeFunction instance = testedDefaultTypeFunction(); - - //act+assert - assertEquals(instance.buildType(BigDecimal.class, null, null), GraphQLBigDecimal); - } -} diff --git a/src/test/java/graphql/annotations/processor/typeFunctions/BigIntegerFunctionTests.java b/src/test/java/graphql/annotations/processor/typeFunctions/BigIntegerFunctionTests.java deleted file mode 100644 index 8293ca5b..00000000 --- a/src/test/java/graphql/annotations/processor/typeFunctions/BigIntegerFunctionTests.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright 2016 Yurii Rashkovskii - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - */ -package graphql.annotations.processor.typeFunctions; - -import org.testng.annotations.Test; - -import java.math.BigInteger; - -import static graphql.Scalars.GraphQLBigInteger; -import static graphql.annotations.processor.typeFunctions.DefaultTypeFunctionTestHelper.testedDefaultTypeFunction; -import static org.testng.Assert.assertEquals; - -public class BigIntegerFunctionTests { - @Test - public void buildType_bigIntegerType_returnsGraphQLBigInteger() { - //arrange - DefaultTypeFunction instance = testedDefaultTypeFunction(); - - //act+assert - assertEquals(instance.buildType(BigInteger.class, null, null), GraphQLBigInteger); - } -} diff --git a/src/test/java/graphql/annotations/processor/typeFunctions/ByteFunctionTests.java b/src/test/java/graphql/annotations/processor/typeFunctions/ByteFunctionTests.java deleted file mode 100644 index 4a733331..00000000 --- a/src/test/java/graphql/annotations/processor/typeFunctions/ByteFunctionTests.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright 2016 Yurii Rashkovskii - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - */ -package graphql.annotations.processor.typeFunctions; - -import org.testng.annotations.Test; - -import static graphql.Scalars.GraphQLByte; -import static graphql.annotations.processor.typeFunctions.DefaultTypeFunctionTestHelper.testedDefaultTypeFunction; -import static org.testng.Assert.assertEquals; - -public class ByteFunctionTests { - @Test - public void buildType_byteType_returnsGraphQLByte() { - //arrange - DefaultTypeFunction instance = testedDefaultTypeFunction(); - - //act+assert - assertEquals(instance.buildType(Byte.class, null,null), GraphQLByte); - } -} diff --git a/src/test/java/graphql/annotations/processor/typeFunctions/CharFunctionTests.java b/src/test/java/graphql/annotations/processor/typeFunctions/CharFunctionTests.java deleted file mode 100644 index 7d057037..00000000 --- a/src/test/java/graphql/annotations/processor/typeFunctions/CharFunctionTests.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright 2016 Yurii Rashkovskii - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - */ -package graphql.annotations.processor.typeFunctions; - -import org.testng.annotations.Test; - -import static graphql.Scalars.GraphQLChar; -import static graphql.annotations.processor.typeFunctions.DefaultTypeFunctionTestHelper.testedDefaultTypeFunction; -import static org.testng.Assert.assertEquals; - -public class CharFunctionTests { - @Test - public void buildType_characterType_returnsGraphQLChar() { - //arrange - DefaultTypeFunction instance = testedDefaultTypeFunction(); - - //act+assert - assertEquals(instance.buildType(Character.class, null, null), GraphQLChar); - } -} diff --git a/src/test/java/graphql/annotations/processor/typeFunctions/LongFunctionTests.java b/src/test/java/graphql/annotations/processor/typeFunctions/LongFunctionTests.java deleted file mode 100644 index a06822e1..00000000 --- a/src/test/java/graphql/annotations/processor/typeFunctions/LongFunctionTests.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright 2016 Yurii Rashkovskii - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - */ -package graphql.annotations.processor.typeFunctions; - - -import org.testng.annotations.Test; - -import static graphql.Scalars.GraphQLLong; -import static graphql.annotations.processor.typeFunctions.DefaultTypeFunctionTestHelper.testedDefaultTypeFunction; -import static org.testng.Assert.assertEquals; - -public class LongFunctionTests { - @Test - public void buildType_longType_returnsGraphQLLong() { - DefaultTypeFunction instance = testedDefaultTypeFunction(); - assertEquals(instance.buildType(long.class, null,null), GraphQLLong); - assertEquals(instance.buildType(Long.class, null,null), GraphQLLong); - } -} diff --git a/src/test/java/graphql/annotations/processor/typeFunctions/ShortFunctionTests.java b/src/test/java/graphql/annotations/processor/typeFunctions/ShortFunctionTests.java deleted file mode 100644 index 9e38b59f..00000000 --- a/src/test/java/graphql/annotations/processor/typeFunctions/ShortFunctionTests.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright 2016 Yurii Rashkovskii - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - */ -package graphql.annotations.processor.typeFunctions; - -import org.testng.annotations.Test; - -import static graphql.Scalars.GraphQLShort; -import static graphql.annotations.processor.typeFunctions.DefaultTypeFunctionTestHelper.testedDefaultTypeFunction; -import static org.testng.Assert.assertEquals; - -public class ShortFunctionTests { - @Test - public void buildType_shortType_returnsGraphQLShort() { - //arrange - DefaultTypeFunction instance = testedDefaultTypeFunction(); - - //act+assert - assertEquals(instance.buildType(Short.class, null, null), GraphQLShort); - } -} From abd33e370893053402e6ddb53d1195070dbdf714 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Wed, 4 Aug 2021 08:20:21 -0400 Subject: [PATCH 2/4] (deps) Updating to latest graphql-java:17.1 (deps) Adding graphql-java-extended-scalars 17.0 for non-standard scalars (BigInteger, BigDecimal, Char, Byte, Long, Short). Removing GraphQLBatched as the deprecated `BatchedExecutionStrategy` was finally removed from graphql-java --- build.gradle | 4 +- .../typeFunctions/BigDecimalFunction.java | 42 ++++++++++++++++++ .../typeFunctions/BigIntegerFunction.java | 42 ++++++++++++++++++ .../processor/typeFunctions/ByteFunction.java | 41 +++++++++++++++++ .../processor/typeFunctions/CharFunction.java | 42 ++++++++++++++++++ .../processor/typeFunctions/LongFunction.java | 44 +++++++++++++++++++ .../typeFunctions/ShortFunction.java | 42 ++++++++++++++++++ .../BigDecimalFunctionTests.java | 34 ++++++++++++++ .../BigIntegerFunctionTests.java | 33 ++++++++++++++ .../typeFunctions/ByteFunctionTests.java | 32 ++++++++++++++ .../typeFunctions/CharFunctionTests.java | 32 ++++++++++++++ .../typeFunctions/LongFunctionTests.java | 31 +++++++++++++ .../typeFunctions/ShortFunctionTests.java | 32 ++++++++++++++ 13 files changed, 450 insertions(+), 1 deletion(-) create mode 100644 src/main/java/graphql/annotations/processor/typeFunctions/BigDecimalFunction.java create mode 100644 src/main/java/graphql/annotations/processor/typeFunctions/BigIntegerFunction.java create mode 100644 src/main/java/graphql/annotations/processor/typeFunctions/ByteFunction.java create mode 100644 src/main/java/graphql/annotations/processor/typeFunctions/CharFunction.java create mode 100644 src/main/java/graphql/annotations/processor/typeFunctions/LongFunction.java create mode 100644 src/main/java/graphql/annotations/processor/typeFunctions/ShortFunction.java create mode 100644 src/test/java/graphql/annotations/processor/typeFunctions/BigDecimalFunctionTests.java create mode 100644 src/test/java/graphql/annotations/processor/typeFunctions/BigIntegerFunctionTests.java create mode 100644 src/test/java/graphql/annotations/processor/typeFunctions/ByteFunctionTests.java create mode 100644 src/test/java/graphql/annotations/processor/typeFunctions/CharFunctionTests.java create mode 100644 src/test/java/graphql/annotations/processor/typeFunctions/LongFunctionTests.java create mode 100644 src/test/java/graphql/annotations/processor/typeFunctions/ShortFunctionTests.java diff --git a/build.gradle b/build.gradle index 1acc4fce..caaef010 100644 --- a/build.gradle +++ b/build.gradle @@ -54,7 +54,9 @@ gradle.projectsEvaluated { dependencies { compile 'javax.validation:validation-api:1.1.0.Final' - compile 'com.graphql-java:graphql-java:17.0' + compile 'com.graphql-java:graphql-java:17.1' + compile 'com.graphql-java:graphql-java-extended-scalars:17.0' + // OSGi compileOnly 'org.osgi:org.osgi.core:6.0.0' diff --git a/src/main/java/graphql/annotations/processor/typeFunctions/BigDecimalFunction.java b/src/main/java/graphql/annotations/processor/typeFunctions/BigDecimalFunction.java new file mode 100644 index 00000000..87ff183e --- /dev/null +++ b/src/main/java/graphql/annotations/processor/typeFunctions/BigDecimalFunction.java @@ -0,0 +1,42 @@ +/** + * Copyright 2016 Yurii Rashkovskii + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + */ +package graphql.annotations.processor.typeFunctions; + +import graphql.annotations.processor.ProcessingElementsContainer; +import graphql.scalars.ExtendedScalars; +import graphql.schema.GraphQLType; +import java.lang.reflect.AnnotatedType; +import java.math.BigDecimal; + +public class BigDecimalFunction implements TypeFunction { + @Override + public String getTypeName(Class aClass, AnnotatedType annotatedType) { + return ExtendedScalars.GraphQLBigDecimal.getName(); + } + + @Override + public boolean canBuildType(Class aClass, AnnotatedType annotatedType) { + return aClass == BigDecimal.class; + } + + @Override + public GraphQLType buildType(boolean input, Class aClass, AnnotatedType annotatedType, ProcessingElementsContainer container) { + return buildType(input, aClass, annotatedType); + } + + private GraphQLType buildType(boolean inputType, Class aClass, AnnotatedType annotatedType) { + return ExtendedScalars.GraphQLBigDecimal; + } +} diff --git a/src/main/java/graphql/annotations/processor/typeFunctions/BigIntegerFunction.java b/src/main/java/graphql/annotations/processor/typeFunctions/BigIntegerFunction.java new file mode 100644 index 00000000..73ffb37a --- /dev/null +++ b/src/main/java/graphql/annotations/processor/typeFunctions/BigIntegerFunction.java @@ -0,0 +1,42 @@ +/** + * Copyright 2016 Yurii Rashkovskii + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + */ +package graphql.annotations.processor.typeFunctions; + +import graphql.annotations.processor.ProcessingElementsContainer; +import graphql.scalars.ExtendedScalars; +import graphql.schema.GraphQLType; +import java.lang.reflect.AnnotatedType; +import java.math.BigInteger; + +public class BigIntegerFunction implements TypeFunction { + @Override + public String getTypeName(Class aClass, AnnotatedType annotatedType) { + return ExtendedScalars.GraphQLBigInteger.getName(); + } + + @Override + public boolean canBuildType(Class aClass, AnnotatedType annotatedType) { + return aClass == BigInteger.class; + } + + @Override + public GraphQLType buildType(boolean input, Class aClass, AnnotatedType annotatedType, ProcessingElementsContainer container) { + return buildType(input, aClass, annotatedType); + } + + private GraphQLType buildType(boolean inputType, Class aClass, AnnotatedType annotatedType) { + return ExtendedScalars.GraphQLBigInteger; + } +} diff --git a/src/main/java/graphql/annotations/processor/typeFunctions/ByteFunction.java b/src/main/java/graphql/annotations/processor/typeFunctions/ByteFunction.java new file mode 100644 index 00000000..1eecd33a --- /dev/null +++ b/src/main/java/graphql/annotations/processor/typeFunctions/ByteFunction.java @@ -0,0 +1,41 @@ +/** + * Copyright 2016 Yurii Rashkovskii + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + */ +package graphql.annotations.processor.typeFunctions; + +import graphql.annotations.processor.ProcessingElementsContainer; +import graphql.scalars.ExtendedScalars; +import graphql.schema.GraphQLType; +import java.lang.reflect.AnnotatedType; + +public class ByteFunction implements TypeFunction { + @Override + public String getTypeName(Class aClass, AnnotatedType annotatedType) { + return ExtendedScalars.GraphQLByte.getName(); + } + + @Override + public boolean canBuildType(Class aClass, AnnotatedType annotatedType) { + return aClass == Byte.class; + } + + @Override + public GraphQLType buildType(boolean input, Class aClass, AnnotatedType annotatedType, ProcessingElementsContainer container) { + return buildType(input, aClass, annotatedType); + } + + private GraphQLType buildType(boolean inputType, Class aClass, AnnotatedType annotatedType) { + return ExtendedScalars.GraphQLByte; + } +} diff --git a/src/main/java/graphql/annotations/processor/typeFunctions/CharFunction.java b/src/main/java/graphql/annotations/processor/typeFunctions/CharFunction.java new file mode 100644 index 00000000..664521e2 --- /dev/null +++ b/src/main/java/graphql/annotations/processor/typeFunctions/CharFunction.java @@ -0,0 +1,42 @@ +/** + * Copyright 2016 Yurii Rashkovskii + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + */ +package graphql.annotations.processor.typeFunctions; + +import graphql.annotations.processor.ProcessingElementsContainer; +import graphql.scalars.ExtendedScalars; +import graphql.schema.GraphQLType; +import java.lang.reflect.AnnotatedType; + +public class CharFunction implements TypeFunction { + + @Override + public String getTypeName(Class aClass, AnnotatedType annotatedType) { + return ExtendedScalars.GraphQLChar.getName(); + } + + @Override + public boolean canBuildType(Class aClass, AnnotatedType annotatedType) { + return aClass == Character.class; + } + + @Override + public GraphQLType buildType(boolean input, Class aClass, AnnotatedType annotatedType, ProcessingElementsContainer container) { + return buildType(input, aClass, annotatedType); + } + + private GraphQLType buildType(boolean inputType, Class aClass, AnnotatedType annotatedType) { + return ExtendedScalars.GraphQLChar; + } +} diff --git a/src/main/java/graphql/annotations/processor/typeFunctions/LongFunction.java b/src/main/java/graphql/annotations/processor/typeFunctions/LongFunction.java new file mode 100644 index 00000000..ed92f6f4 --- /dev/null +++ b/src/main/java/graphql/annotations/processor/typeFunctions/LongFunction.java @@ -0,0 +1,44 @@ +/** + * Copyright 2016 Yurii Rashkovskii + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + */ +package graphql.annotations.processor.typeFunctions; + +import graphql.annotations.processor.ProcessingElementsContainer; +import graphql.scalars.ExtendedScalars; +import graphql.schema.GraphQLType; +import java.lang.reflect.AnnotatedType; + + +class LongFunction implements TypeFunction { + + @Override + public String getTypeName(Class aClass, AnnotatedType annotatedType) { + return ExtendedScalars.GraphQLLong.getName(); + } + + @Override + public boolean canBuildType(Class aClass, AnnotatedType annotatedType) { + return aClass == Long.class || aClass == long.class; + } + + @Override + public GraphQLType buildType(boolean input, Class aClass, AnnotatedType annotatedType, ProcessingElementsContainer container) { + return buildType(input,aClass,annotatedType); + } + + private GraphQLType buildType(boolean inputType, Class aClass, AnnotatedType annotatedType) { + return ExtendedScalars.GraphQLLong; + } + +} diff --git a/src/main/java/graphql/annotations/processor/typeFunctions/ShortFunction.java b/src/main/java/graphql/annotations/processor/typeFunctions/ShortFunction.java new file mode 100644 index 00000000..4582c631 --- /dev/null +++ b/src/main/java/graphql/annotations/processor/typeFunctions/ShortFunction.java @@ -0,0 +1,42 @@ +/** + * Copyright 2016 Yurii Rashkovskii + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + */ +package graphql.annotations.processor.typeFunctions; + +import graphql.annotations.processor.ProcessingElementsContainer; +import graphql.scalars.ExtendedScalars; +import graphql.schema.GraphQLType; +import java.lang.reflect.AnnotatedType; + +public class ShortFunction implements TypeFunction { + @Override + public String getTypeName(Class aClass, AnnotatedType annotatedType) { + return ExtendedScalars.GraphQLShort.getName(); + } + + @Override + public boolean canBuildType(Class aClass, AnnotatedType annotatedType) { + return aClass == Short.class; + } + + @Override + public GraphQLType buildType(boolean input, Class aClass, AnnotatedType annotatedType, ProcessingElementsContainer container) { + return buildType(input, aClass, annotatedType); + } + + private GraphQLType buildType(boolean inputType, Class aClass, AnnotatedType annotatedType) { + return ExtendedScalars.GraphQLShort; + } +} + diff --git a/src/test/java/graphql/annotations/processor/typeFunctions/BigDecimalFunctionTests.java b/src/test/java/graphql/annotations/processor/typeFunctions/BigDecimalFunctionTests.java new file mode 100644 index 00000000..2c6b85fc --- /dev/null +++ b/src/test/java/graphql/annotations/processor/typeFunctions/BigDecimalFunctionTests.java @@ -0,0 +1,34 @@ +/** + * Copyright 2016 Yurii Rashkovskii + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + */ +package graphql.annotations.processor.typeFunctions; + +import org.testng.annotations.Test; + +import java.math.BigDecimal; + +import static graphql.annotations.processor.typeFunctions.DefaultTypeFunctionTestHelper.testedDefaultTypeFunction; +import static graphql.scalars.ExtendedScalars.GraphQLBigDecimal; +import static org.testng.Assert.assertEquals; + +public class BigDecimalFunctionTests { + @Test + public void buildType_bigDecimalType_returnsGraphQLBigDecimal() { + //arrange + DefaultTypeFunction instance = testedDefaultTypeFunction(); + + //act+assert + assertEquals(instance.buildType(BigDecimal.class, null, null), GraphQLBigDecimal); + } +} diff --git a/src/test/java/graphql/annotations/processor/typeFunctions/BigIntegerFunctionTests.java b/src/test/java/graphql/annotations/processor/typeFunctions/BigIntegerFunctionTests.java new file mode 100644 index 00000000..915602f6 --- /dev/null +++ b/src/test/java/graphql/annotations/processor/typeFunctions/BigIntegerFunctionTests.java @@ -0,0 +1,33 @@ +/** + * Copyright 2016 Yurii Rashkovskii + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + */ +package graphql.annotations.processor.typeFunctions; + +import static graphql.annotations.processor.typeFunctions.DefaultTypeFunctionTestHelper.testedDefaultTypeFunction; +import static graphql.scalars.ExtendedScalars.GraphQLBigInteger; +import static org.testng.Assert.assertEquals; + +import java.math.BigInteger; +import org.testng.annotations.Test; + +public class BigIntegerFunctionTests { + @Test + public void buildType_bigIntegerType_returnsGraphQLBigInteger() { + //arrange + DefaultTypeFunction instance = testedDefaultTypeFunction(); + + //act+assert + assertEquals(instance.buildType(BigInteger.class, null, null), GraphQLBigInteger); + } +} diff --git a/src/test/java/graphql/annotations/processor/typeFunctions/ByteFunctionTests.java b/src/test/java/graphql/annotations/processor/typeFunctions/ByteFunctionTests.java new file mode 100644 index 00000000..ebe90f04 --- /dev/null +++ b/src/test/java/graphql/annotations/processor/typeFunctions/ByteFunctionTests.java @@ -0,0 +1,32 @@ +/** + * Copyright 2016 Yurii Rashkovskii + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + */ +package graphql.annotations.processor.typeFunctions; + +import static graphql.annotations.processor.typeFunctions.DefaultTypeFunctionTestHelper.testedDefaultTypeFunction; +import static graphql.scalars.ExtendedScalars.GraphQLByte; +import static org.testng.Assert.assertEquals; + +import org.testng.annotations.Test; + +public class ByteFunctionTests { + @Test + public void buildType_byteType_returnsGraphQLByte() { + //arrange + DefaultTypeFunction instance = testedDefaultTypeFunction(); + + //act+assert + assertEquals(instance.buildType(Byte.class, null,null), GraphQLByte); + } +} diff --git a/src/test/java/graphql/annotations/processor/typeFunctions/CharFunctionTests.java b/src/test/java/graphql/annotations/processor/typeFunctions/CharFunctionTests.java new file mode 100644 index 00000000..50ed3914 --- /dev/null +++ b/src/test/java/graphql/annotations/processor/typeFunctions/CharFunctionTests.java @@ -0,0 +1,32 @@ +/** + * Copyright 2016 Yurii Rashkovskii + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + */ +package graphql.annotations.processor.typeFunctions; + +import static graphql.annotations.processor.typeFunctions.DefaultTypeFunctionTestHelper.testedDefaultTypeFunction; +import static graphql.scalars.ExtendedScalars.GraphQLChar; +import static org.testng.Assert.assertEquals; + +import org.testng.annotations.Test; + +public class CharFunctionTests { + @Test + public void buildType_characterType_returnsGraphQLChar() { + //arrange + DefaultTypeFunction instance = testedDefaultTypeFunction(); + + //act+assert + assertEquals(instance.buildType(Character.class, null, null), GraphQLChar); + } +} diff --git a/src/test/java/graphql/annotations/processor/typeFunctions/LongFunctionTests.java b/src/test/java/graphql/annotations/processor/typeFunctions/LongFunctionTests.java new file mode 100644 index 00000000..9223da81 --- /dev/null +++ b/src/test/java/graphql/annotations/processor/typeFunctions/LongFunctionTests.java @@ -0,0 +1,31 @@ +/** + * Copyright 2016 Yurii Rashkovskii + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + */ +package graphql.annotations.processor.typeFunctions; + + +import static graphql.annotations.processor.typeFunctions.DefaultTypeFunctionTestHelper.testedDefaultTypeFunction; +import static graphql.scalars.ExtendedScalars.GraphQLLong; +import static org.testng.Assert.assertEquals; + +import org.testng.annotations.Test; + +public class LongFunctionTests { + @Test + public void buildType_longType_returnsGraphQLLong() { + DefaultTypeFunction instance = testedDefaultTypeFunction(); + assertEquals(instance.buildType(long.class, null,null), GraphQLLong); + assertEquals(instance.buildType(Long.class, null,null), GraphQLLong); + } +} diff --git a/src/test/java/graphql/annotations/processor/typeFunctions/ShortFunctionTests.java b/src/test/java/graphql/annotations/processor/typeFunctions/ShortFunctionTests.java new file mode 100644 index 00000000..bd98e2ba --- /dev/null +++ b/src/test/java/graphql/annotations/processor/typeFunctions/ShortFunctionTests.java @@ -0,0 +1,32 @@ +/** + * Copyright 2016 Yurii Rashkovskii + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + */ +package graphql.annotations.processor.typeFunctions; + +import static graphql.annotations.processor.typeFunctions.DefaultTypeFunctionTestHelper.testedDefaultTypeFunction; +import static graphql.scalars.ExtendedScalars.GraphQLShort; +import static org.testng.Assert.assertEquals; + +import org.testng.annotations.Test; + +public class ShortFunctionTests { + @Test + public void buildType_shortType_returnsGraphQLShort() { + //arrange + DefaultTypeFunction instance = testedDefaultTypeFunction(); + + //act+assert + assertEquals(instance.buildType(Short.class, null, null), GraphQLShort); + } +} From db974fd2cb8dfa4d1f1afe739ec6511a9bec4924 Mon Sep 17 00:00:00 2001 From: yarinvk Date: Fri, 20 Aug 2021 16:34:07 +0300 Subject: [PATCH 3/4] remove prod configuration of environment --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 51d9e491..dcec49e9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,6 @@ on: [push] jobs: build: runs-on: ubuntu-latest - environment: prod steps: - uses: actions/checkout@v2 - name: Set up JDK 8 From 6ac2d53762cb678e045d4fc896619a668b4e2271 Mon Sep 17 00:00:00 2001 From: yarinvk Date: Fri, 20 Aug 2021 20:03:17 +0300 Subject: [PATCH 4/4] version 9.0 --- .github/workflows/build.yml | 4 +--- README.md | 4 ++-- .../processor/typeFunctions/DefaultTypeFunction.java | 6 ++++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dcec49e9..55e9f135 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ name: Build -on: [push] +on: [push, pull_request] jobs: build: @@ -19,8 +19,6 @@ jobs: run: chmod +x gradlew - name: Build with Gradle run: ./gradlew build - - name: Test with Gradle - run: ./gradlew test - name: Publish Test Report uses: mikepenz/action-junit-report@v2 if: always() # always run even if the previous step fails diff --git a/README.md b/README.md index 4cc4c17c..a37b826c 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ If you would like to use a tool that creates a graphql spring boot server using ```groovy dependencies { - compile "io.github.graphql-java:graphql-java-annotations:8.5" + compile "io.github.graphql-java:graphql-java-annotations:9.0" } ``` @@ -47,7 +47,7 @@ dependencies { io.github.graphql-java graphql-java-annotations - 8.5 + 9.0 ``` diff --git a/src/main/java/graphql/annotations/processor/typeFunctions/DefaultTypeFunction.java b/src/main/java/graphql/annotations/processor/typeFunctions/DefaultTypeFunction.java index 99fe159a..b02c4703 100644 --- a/src/main/java/graphql/annotations/processor/typeFunctions/DefaultTypeFunction.java +++ b/src/main/java/graphql/annotations/processor/typeFunctions/DefaultTypeFunction.java @@ -55,6 +55,12 @@ public void activate() { typeFunctions.add(new BooleanFunction()); typeFunctions.add(new FloatFunction()); typeFunctions.add(new IntegerFunction()); + typeFunctions.add(new LongFunction()); + typeFunctions.add(new ByteFunction()); + typeFunctions.add(new ShortFunction()); + typeFunctions.add(new BigIntegerFunction()); + typeFunctions.add(new BigDecimalFunction()); + typeFunctions.add(new CharFunction()); typeFunctions.add(new IterableFunction(DefaultTypeFunction.this)); typeFunctions.add(new ArrayFunction(DefaultTypeFunction.this)); typeFunctions.add(new StreamFunction(DefaultTypeFunction.this));