Search in sources :

Example 1 with GraphQLSchema

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);
}
Also used : GraphQLSchemaParser(com.tvd12.ezyhttp.server.graphql.GraphQLSchemaParser) GraphQLSchema(com.tvd12.ezyhttp.server.graphql.GraphQLSchema) Test(org.testng.annotations.Test)

Example 2 with GraphQLSchema

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");
}
Also used : GraphQLSchemaParser(com.tvd12.ezyhttp.server.graphql.GraphQLSchemaParser) GraphQLSchema(com.tvd12.ezyhttp.server.graphql.GraphQLSchema) Test(org.testng.annotations.Test)

Example 3 with GraphQLSchema

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);
}
Also used : GraphQLSchemaParser(com.tvd12.ezyhttp.server.graphql.GraphQLSchemaParser) GraphQLSchema(com.tvd12.ezyhttp.server.graphql.GraphQLSchema) Test(org.testng.annotations.Test)

Example 4 with GraphQLSchema

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);
    }
}
Also used : GraphQLSchemaParser(com.tvd12.ezyhttp.server.graphql.GraphQLSchemaParser) GraphQLSchema(com.tvd12.ezyhttp.server.graphql.GraphQLSchema) Test(org.testng.annotations.Test)

Example 5 with GraphQLSchema

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");
    }
}
Also used : GraphQLSchemaParser(com.tvd12.ezyhttp.server.graphql.GraphQLSchemaParser) GraphQLSchema(com.tvd12.ezyhttp.server.graphql.GraphQLSchema) Test(org.testng.annotations.Test)

Aggregations

GraphQLSchema (com.tvd12.ezyhttp.server.graphql.GraphQLSchema)9 Test (org.testng.annotations.Test)9 GraphQLSchemaParser (com.tvd12.ezyhttp.server.graphql.GraphQLSchemaParser)8