package io.vlingo.xoom.graphql.integration;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLOperationRequest;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLRequest;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
import io.vlingo.xoom.actors.World;
import io.vlingo.xoom.http.resource.Client;
import io.vlingo.xoom.http.resource.Server;
public class BookStoreTest {
private static final String host = "localhost";
private static final int port = 8080;
private static World world;
private static Server server;
private static Client client;
private Response performRequest(final GraphQLOperationRequest request, final GraphQLResponseProjection responseProjection) {
final GraphQLRequest graphQLRequest = new GraphQLRequest(request, responseProjection);
final String graphQLQuery = graphQLRequest.toHttpJsonBody();
final AccessResponseConsumer responseConsumer = new AccessResponseConsumer();
.and(URI.create("/graphql"))
.and(RequestHeader.contentLength(graphQLQuery))
.and(RequestHeader.keepAlive())
.and(Body.from(graphQLQuery)))
.andFinallyConsume(responseConsumer::consume);
return responseConsumer.accessResponse();
public static void setUp() throws Exception {
world = World.startWithDefaults("xoom-graphql-test");
GraphQLProcessor processor = TestBootstrap.newProcessor(world.stage());
GraphQLResource graphQLResource = new GraphQLResource(world.stage(), processor);
server = Server.startWith(world.stage(), Resources.are(graphQLResource.routes()), port, Configuration.Sizing.define(),
new Configuration.Timing(4L, 2L, 100L));
Address address = Address.from(Host.of(host), port, AddressType.NONE);
client = Client.using(Client.Configuration.defaultedKeepAliveExceptFor(world.stage(), address, new UnknownResponseConsumer()));