Test update to make it work also in the Gradle project
@@ -6,11 +6,14 @@ package org.allGraphQLCases;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import java.util.Arrays;
import java.util.List;
import org.allGraphQLCases.client.AllFieldCases;
import org.allGraphQLCases.client.Character;
import org.allGraphQLCases.client.MyQueryType;
+import org.allGraphQLCases.client.MyQueryTypeExecutor;
+import org.allGraphQLCases.client.__Field;
import org.allGraphQLCases.client.__Schema;
import org.allGraphQLCases.client.__Type;
import org.junit.jupiter.api.Test;
@@ -29,39 +32,45 @@ import com.graphql_java_generator.exception.GraphQLRequestPreparationException;
@Execution(ExecutionMode.CONCURRENT)
public class IntrospectionIT {
- MyQueryType myQuery = new MyQueryType(Main.GRAPHQL_ENDPOINT);
+ MyQueryTypeExecutor myQuery = new MyQueryTypeExecutor(Main.GRAPHQL_ENDPOINT);
+
+ static String[] AllFieldCases_FIELDS = { "id", "name", "forname", "age", "aFloat", "date", "dates", "nbComments",
+ "comments", "booleans", "aliases", "planets", "friends", "oneWithIdSubType", "listWithIdSubTypes",
+ "oneWithoutIdSubType", "listWithoutIdSubTypes" };
+ static List<String> AllFieldCases_FIELDNAMES = Arrays.asList(AllFieldCases_FIELDS);
@Test
void testSchema() throws GraphQLRequestExecutionException, GraphQLRequestPreparationException {
// Go, go, go
- __Schema schema = myQuery.__schema("{types {name fields {name type {name}}}}");
+ __Schema schema = myQuery.__schema("{types {name fields(includeDeprecated:true) {name type {name}}}}");
// Verification
assertEquals(44, schema.getTypes().size());
assertEquals("AllFieldCases", schema.getTypes().get(0).getName());
- // With the maven compilation, the order from the GraphQL schema is kept.
- // But with the gradle build, the field are returned in alphabetical order?!
- // As this test is run against the maven and the gradle implementation (see the gradle plugin), we need to be
- // compliant with both sort orders.
- assertTrue(schema.getTypes().get(0).getFields().get(0).getName().contentEquals("id")
- || schema.getTypes().get(0).getFields().get(0).getName().contentEquals("aliases"));
+ // As the order of fields seems to depend on the way this is compile, let's use a rough method to check the
+ // field names
+ assertEquals(AllFieldCases_FIELDS.length, schema.getTypes().get(0).getFields().size());
+ for (__Field f : schema.getTypes().get(0).getFields()) {
+ assertTrue(AllFieldCases_FIELDNAMES.contains(f.getName()));
+ }
}
@Test
void testType() throws GraphQLRequestExecutionException, GraphQLRequestPreparationException {
// Go, go, go
- __Type type = myQuery.__type("{name fields {name type {name}}}", "AllFieldCases");
+ __Type type = myQuery.__type("{name fields(includeDeprecated:true) {name type {name}}}", "AllFieldCases");
// Verification
+
assertEquals("AllFieldCases", type.getName());
- // With the maven compilation, the order from the GraphQL schema is kept.
- // But with the gradle build, the field are returned in alphabetical order?!
- // As this test is run against the maven and the gradle implementation (see the gradle plugin), we need to be
- // compliant with both sort orders.
- assertTrue(
- type.getFields().get(0).getName().equals("id") || type.getFields().get(0).getName().equals("aliases"));
+ // As the order of fields seems to depend on the way this is compile, let's use a rough method to check the
+ // field names
+ assertEquals(AllFieldCases_FIELDS.length, type.getFields().size());
+ for (__Field f : type.getFields()) {
+ assertTrue(AllFieldCases_FIELDNAMES.contains(f.getName()));
+ }
}
@Test
