### Question:
GraphQLEndpoint extends Application { @POST @Path(Constants.ENDPOINT_API) @Consumes(Constants.MEDIA_TYPE_GRAPHQL) @Produces(MediaType.APPLICATION_JSON) public Response postGraphQLRequestAsGraphQLQuery(String body) { if (body == null) { body = ""; } ExecutionResult executionResult = graphQLEngine.executeQuery(body); Map<String, Object> result = executionResult.toSpecification(); return Response.ok(result) .build(); }  @Override Set<Object> getSingletons(); @GET @Path(Constants.ENDPOINT_SCHEMA) @Produces(MediaType.TEXT_PLAIN) Response getGraphQLSchema(); @GET @Path(Constants.ENDPOINT_API) @Produces(MediaType.APPLICATION_JSON) Response getGraphQLRequest(@QueryParam(Constants.PARAM_QUERY) String query,
                                      @QueryParam(Constants.PARAM_OPERATION_NAME) String operationName,
                                      @QueryParam(Constants.PARAM_VARIABLES) String jsonVars); @POST @Path(Constants.ENDPOINT_API) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response postGraphQLRequestAsJson(Map<String, Object> body); @POST @Path(Constants.ENDPOINT_API) @Consumes(Constants.MEDIA_TYPE_GRAPHQL) @Produces(MediaType.APPLICATION_JSON) Response postGraphQLRequestAsGraphQLQuery(String body);  }### Answer:
@Test public void postGraphQLRequestAsGraphQLQuery_with_query_should_return_ok_with_data() { ExecutionResult expectedExecutionResult = new ExecutionResultImpl(expectedOkResult, null); Map expectedOutput = expectedExecutionResult.toSpecification(); when(graphQLEngine.executeQuery(eq(query))) .thenReturn(expectedExecutionResult); Response response = graphQLEndpoint.postGraphQLRequestAsGraphQLQuery(query); verify(graphQLEngine, times(1)) .executeQuery(eq(query)); assertThat(response, hasStatus(Response.Status.OK)); assertThat(response, hasEntity()); assertEquals(response.getEntity(), expectedOutput); }
@Test public void postGraphQLRequestAsGraphQLQuery_without_query_should_return_ok_with_errors() { ExecutionResult expectedExecutionResult = new ExecutionResultImpl(Collections.singletonList(invalidSyntaxError)); Map expectedOutput = expectedExecutionResult.toSpecification(); when(graphQLEngine.executeQuery(eq(""))) .thenReturn(expectedExecutionResult); Response response = graphQLEndpoint.postGraphQLRequestAsGraphQLQuery(null); verify(graphQLEngine, times(1)) .executeQuery(eq("")); assertThat(response, hasStatus(Response.Status.OK)); assertThat(response, hasEntity()); assertEquals(response.getEntity(), expectedOutput); }