public ExecutionInput build() { return new ExecutionInput(query, operationName, context, root, variables, dataLoaderRegistry); } }
public ExecutionInput build() { return new ExecutionInput(query, operationName, context, root, variables, dataLoaderRegistry); } }
protected ExecutionInput createExecutionInput(GraphQLRequest graphQLRequest) { return new ExecutionInput( graphQLRequest.getQuery(), graphQLRequest.getOperationName(), context, root, graphQLRequest.getVariables() ); } }
@Test public void validDatafetcher_queryForValues_returnsValidValues() throws Exception { //Arrange ExecutionInput executionInput = new ExecutionInput("{ objs(first:2) { edges { cursor node { id, val } } } }", null, "CONTEXT", null, null); //Act ExecutionResult result = graphQL.execute(executionInput); Map<String, Map<String, List<Map<String, Map<String, Object>>>>> data = result.getData(); List<Map<String, Map<String, Object>>> edges = data.get("objs").get("edges"); //Assert assertEquals(edges.get(0).get("node").get("val"), "1"); assertEquals(edges.get(1).get("node").get("val"), "2"); }
@Test public void validDatafetcher_queryForHasNextPage_returnsTrue() throws Exception { //Arrange ExecutionInput executionInput = new ExecutionInput("{ objs(first:2) { pageInfo { hasNextPage } } }", null, "CONTEXT", null, null); //Act ExecutionResult result = graphQL.execute(executionInput); Map<String, Map<String, Map<String, Map<String, Object>>>> data = result.getData(); //Assert assertEquals(data.get("objs").get("pageInfo").get("hasNextPage"), true); } }
@Test public void fetchConnectionAsync() throws Exception { //Arrange ExecutionInput executionInput = new ExecutionInput("{ objsAsync(first:2) { edges { cursor } } }", null, "CONTEXT", null, null); //Act ExecutionResult result = graphQL.execute(executionInput); Map<String, Map<String, List<Map<String, Map<String, Object>>>>> data = result.getData(); List<Map<String, Map<String, Object>>> edges = data.get("objsAsync").get("edges"); //Assert assertEquals(edges.get(0).get("cursor"), "1"); assertEquals(edges.get(1).get("cursor"), "2"); }
@Test public void validDatafetcher_queryForCursors_getValidCursors() throws Exception { //Arrange ExecutionInput executionInput = new ExecutionInput("{ objs(first:2) { edges { cursor } } }", null, "CONTEXT", null, null); //Act ExecutionResult result = graphQL.execute(executionInput); Map<String, Map<String, List<Map<String, Map<String, Object>>>>> data = result.getData(); List<Map<String, Map<String, Object>>> edges = data.get("objs").get("edges"); //Assert assertEquals(edges.get(0).get("cursor"), "1"); assertEquals(edges.get(1).get("cursor"), "2"); }
@Test public void validDatafetcher_queryForHasPreviousPage_returnsFalse() throws Exception { //Arrange ExecutionInput executionInput = new ExecutionInput("{ objs(first:2) { pageInfo { hasPreviousPage } } }", null, "CONTEXT", null, null); //Act ExecutionResult result = graphQL.execute(executionInput); Map<String, Map<String, Map<String, Map<String, Object>>>> data = result.getData(); //Assert assertEquals(data.get("objs").get("pageInfo").get("hasPreviousPage"), false); }