|
1 | 1 | /** |
2 | 2 | * Copyright 2016 Yurii Rashkovskii |
3 | | - * |
| 3 | + * <p> |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
6 | 6 | * You may obtain a copy of the License at |
7 | | - * |
8 | | - * http://www.apache.org/licenses/LICENSE-2.0 |
9 | | - * |
| 7 | + * <p> |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * <p> |
10 | 10 | * Unless required by applicable law or agreed to in writing, software |
11 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
22 | 22 | import graphql.annotations.annotationTypes.GraphQLTypeResolver; |
23 | 23 | import graphql.annotations.processor.GraphQLAnnotations; |
24 | 24 | import graphql.annotations.processor.exceptions.GraphQLAnnotationsException; |
25 | | -import graphql.schema.GraphQLInputObjectType; |
26 | | -import graphql.schema.GraphQLObjectType; |
27 | | -import graphql.schema.GraphQLSchema; |
28 | | -import graphql.schema.TypeResolver; |
| 25 | +import graphql.schema.*; |
29 | 26 | import org.testng.annotations.BeforeMethod; |
30 | 27 | import org.testng.annotations.Test; |
31 | 28 |
|
@@ -297,19 +294,19 @@ public void testInputAndOutputWithSameName() { |
297 | 294 | // arrange + act |
298 | 295 | GraphQLSchema schema = newSchema().query(this.graphQLAnnotations.object(QueryInputAndOutput.class)).build(); |
299 | 296 | // assert |
300 | | - assertEquals(schema.getQueryType().getFieldDefinition("getHero").getType().getName(), "hero"); |
301 | | - assertEquals(schema.getQueryType().getFieldDefinition("getString").getArgument("input").getType().getName(), "Inputhero"); |
302 | | - assertEquals(((GraphQLInputObjectType) schema.getQueryType().getFieldDefinition("getString") |
303 | | - .getArgument("input").getType()).getField("skill").getType().getName(), "InputSkill"); |
| 297 | + assertEquals(((GraphQLNamedType) (schema.getQueryType().getFieldDefinition("getHero").getType())).getName(), "hero"); |
| 298 | + assertEquals(((GraphQLNamedType) schema.getQueryType().getFieldDefinition("getString").getArgument("input").getType()).getName(), "Inputhero"); |
| 299 | + assertEquals(((GraphQLNamedType) ((GraphQLInputObjectType) schema.getQueryType().getFieldDefinition("getString") |
| 300 | + .getArgument("input").getType()).getField("skill").getType()).getName(), "InputSkill"); |
304 | 301 | } |
305 | 302 |
|
306 | 303 | @Test |
307 | 304 | public void testInputAndOutputSameClass() { |
308 | 305 | // arrange + act |
309 | 306 | GraphQLSchema schema = newSchema().query(this.graphQLAnnotations.object(QueryInputAndOutput2.class)).build(); |
310 | 307 | // assert |
311 | | - assertEquals(schema.getQueryType().getFieldDefinition("getSkill").getType().getName(), "Skill"); |
312 | | - assertEquals(schema.getQueryType().getFieldDefinition("getA").getArgument("skill").getType().getName(), "InputSkill"); |
| 308 | + assertEquals(((GraphQLNamedType) schema.getQueryType().getFieldDefinition("getSkill").getType()).getName(), "Skill"); |
| 309 | + assertEquals(((GraphQLNamedType) schema.getQueryType().getFieldDefinition("getA").getArgument("skill").getType()).getName(), "InputSkill"); |
313 | 310 | } |
314 | 311 |
|
315 | 312 | @GraphQLName("A") |
@@ -366,11 +363,11 @@ public void testInputAndOutputWithSameNameWithChildrenWithSameName() { |
366 | 363 | // arrange + act |
367 | 364 | GraphQLSchema schema = newSchema().query(this.graphQLAnnotations.object(QuerySameNameWithChildren.class)).build(); |
368 | 365 | // assert |
369 | | - assertEquals(schema.getQueryType().getFieldDefinition("getAout").getType().getName(), "A"); |
370 | | - assertEquals(schema.getQueryType().getFieldDefinition("getAout").getType().getClass(), GraphQLObjectType.class); |
371 | | - assertEquals(schema.getQueryType().getFieldDefinition("getBout").getType().getName(), "B"); |
| 366 | + assertEquals(((GraphQLNamedType) schema.getQueryType().getFieldDefinition("getAout").getType()).getName(), "A"); |
| 367 | + assertEquals(((GraphQLNamedType) schema.getQueryType().getFieldDefinition("getAout").getType()).getClass(), GraphQLObjectType.class); |
| 368 | + assertEquals(((GraphQLNamedType) schema.getQueryType().getFieldDefinition("getBout").getType()).getName(), "B"); |
372 | 369 | assertEquals(schema.getQueryType().getFieldDefinition("getBout").getType().getClass(), GraphQLObjectType.class); |
373 | | - assertEquals(schema.getQueryType().getFieldDefinition("getA").getArgument("input").getType().getName(), "InputA"); |
| 370 | + assertEquals(((GraphQLNamedType) schema.getQueryType().getFieldDefinition("getA").getArgument("input").getType()).getName(), "InputA"); |
374 | 371 | assertEquals(schema.getQueryType().getFieldDefinition("getA").getArgument("input").getType().getClass(), GraphQLInputObjectType.class); |
375 | 372 | assertEquals(schema.getQueryType().getFieldDefinition("getB").getArgument("input").getType().getClass(), GraphQLInputObjectType.class); |
376 | 373 |
|
|
0 commit comments