use of com.tvd12.ezyhttp.server.graphql.GraphQLSchema in project ezyhttp by youngmonkeys.
the class GraphQLSchemaParserTest method testZeroNameLength.
@Test
public void testZeroNameLength() {
// given
GraphQLSchemaParser parser = new GraphQLSchemaParser();
String query = "{q1 q2{{}}}";
// when
GraphQLSchema schema = parser.parseQuery(query);
// then
Asserts.assertEquals(schema.getQueryDefinitions().size(), 2);
Asserts.assertEquals(schema.getQueryDefinitions().get(0).getName(), "q1");
Asserts.assertEquals(schema.getQueryDefinitions().get(1).getName(), "q2");
Asserts.assertEquals(schema.getQueryDefinitions().get(1).getFields().get(0).getName(), null);
Asserts.assertEquals(schema.getQueryDefinitions().get(1).getFields().get(0).getFields().get(0).getName(), null);
}
use of com.tvd12.ezyhttp.server.graphql.GraphQLSchema in project ezyhttp by youngmonkeys.
the class GraphQLSchemaParserTest method testParseSchema2.
@Test
public void testParseSchema2() {
// given
GraphQLSchemaParser parser = new GraphQLSchemaParser();
String query = "{q1 q2}";
// when
GraphQLSchema schema = parser.parseQuery(query);
// then
Asserts.assertEquals(schema.getQueryDefinitions().size(), 2);
Asserts.assertEquals(schema.getQueryDefinitions().get(0).getName(), "q1");
Asserts.assertEquals(schema.getQueryDefinitions().get(1).getName(), "q2");
}
use of com.tvd12.ezyhttp.server.graphql.GraphQLSchema in project ezyhttp by youngmonkeys.
the class GraphQLSchemaParserTest method testStandardize5.
@Test
public void testStandardize5() {
// given
GraphQLSchemaParser parser = new GraphQLSchemaParser();
// when
GraphQLSchema schema = parser.parseQuery(null);
// then
Asserts.assertEquals(schema.getQueryDefinitions().size(), 0);
}
use of com.tvd12.ezyhttp.server.graphql.GraphQLSchema in project ezyhttp by youngmonkeys.
the class GraphQLSchemaParserTest method testStandardize4.
@Test
public void testStandardize4() {
// given
GraphQLSchemaParser parser = new GraphQLSchemaParser();
String[] queries = { "{queryName{field1 field2}}", "{queryName{field1+field2}}", "{queryName{field1,field2}}", " { queryName { field1 field2 } } ", " {\n\tqueryName {\n\t\tfield1\n\t\tfield2\n\t}\n}", "{ queryName \t{field1\t \n \t + \n \t field2} \t\n\t}", "query { queryName \t{field1\t \n \t + \n \t field2} \t\n\t}" };
int numQueries = queries.length;
GraphQLSchema[] schemas = new GraphQLSchema[numQueries];
// when
for (int i = 0; i < numQueries; ++i) {
schemas[i] = parser.parseQuery(queries[i]);
}
// then
for (int i = 0; i < numQueries; ++i) {
Asserts.assertEquals(schemas[i].getQueryDefinitions().size(), 1);
Asserts.assertEquals(schemas[i].getQueryDefinitions().get(0).getName(), "queryName");
Asserts.assertEquals(schemas[i].getQueryDefinitions().get(0).getFields().size(), 2);
}
}
use of com.tvd12.ezyhttp.server.graphql.GraphQLSchema in project ezyhttp by youngmonkeys.
the class GraphQLSchemaParserTest method testStandardize3.
@Test
public void testStandardize3() {
// given
GraphQLSchemaParser parser = new GraphQLSchemaParser();
String[] queries = { "{queryName}", "{ queryName}", "{queryName }", "{ queryName }", "{ \tqueryName\t}", "{ \tqueryName\t }", "{\t queryName \t}", "{ \t \t queryName \t \t \t\t\t}", "{\n\tqueryName\n}", "{ queryName, }", "{ queryName+ }", "{ queryName\t }" };
int numQueries = queries.length;
GraphQLSchema[] schemas = new GraphQLSchema[numQueries];
// when
for (int i = 0; i < numQueries; ++i) {
schemas[i] = parser.parseQuery(queries[i]);
}
// then
for (int i = 0; i < numQueries; ++i) {
Asserts.assertEquals(schemas[i].getQueryDefinitions().size(), 1);
Asserts.assertEquals(schemas[i].getQueryDefinitions().get(0).getName(), "queryName");
}
}
Aggregations