@@ -0,0 +1,2917 @@
+package com.tesco.mewbase;%0A%0Aimport com.tesco.mewbase.bson.BsonObject;%0Aimport com.tesco.mewbase.client.Client;%0Aimport com.tesco.mewbase.client.Connection;%0Aimport com.tesco.mewbase.client.ConnectionOptions;%0Aimport com.tesco.mewbase.client.Producer;%0Aimport com.tesco.mewbase.client.impl.ClientImpl;%0Aimport com.tesco.mewbase.common.SubDescriptor;%0Aimport com.tesco.mewbase.server.Server;%0Aimport com.tesco.mewbase.server.ServerOptions;%0Aimport com.tesco.mewbase.server.impl.ServerImpl;%0Aimport io.vertx.ext.unit.Async;%0Aimport io.vertx.ext.unit.TestContext;%0Aimport io.vertx.ext.unit.junit.VertxUnitRunner;%0Aimport org.junit.After;%0Aimport org.junit.Assert;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport java.util.concurrent.CompletableFuture;%0Aimport java.util.concurrent.ExecutionException;%0A%0A/**%0A * Created by Jamie on 14/10/2016.%0A */%0A@RunWith(VertxUnitRunner.class)%0Apublic class QueryTest %7B%0A    private final static Logger log = LoggerFactory.getLogger(FunctionTest.class);%0A%0A    private static final String TEST_STREAM1 = %22com.tesco.basket%22;%0A    private static final String TEST_BINDER1 = %22baskets%22;%0A%0A    private Server server;%0A    private Client client;%0A%0A    @Before%0A    public void before() throws Exception %7B%0A        log.trace(%22in before%22);%0A        server = new ServerImpl(new ServerOptions());%0A        CompletableFuture%3CVoid%3E cfStart = server.start();%0A        cfStart.get();%0A        client = new ClientImpl();%0A    %7D%0A%0A    @After%0A    public void after() throws Exception %7B%0A        log.trace(%22in after%22);%0A        client.close().get();%0A        server.stop().get();%0A    %7D%0A%0A    @Test%0A    public void testGetById(TestContext context) throws Exception %7B%0A        String docId = %22testdoc1%22;%0A%0A        insertDocument(TEST_BINDER1, new BsonObject().put(%22id%22, docId).put(%22foo%22, %22bar%22)).get();%0A%0A        Connection conn = client.connect(new ConnectionOptions()).get();%0A        BsonObject doc = conn.getByID(TEST_BINDER1, docId).get();%0A%0A        Assert.assertEquals(docId, doc.getString(%22id%22));%0A        Assert.assertEquals(%22bar%22, doc.getString(%22bar%22));%0A    %7D%0A%0A    private CompletableFuture%3CVoid%3E insertDocument(String binder, BsonObject document) throws Exception %7B%0A        CompletableFuture%3CVoid%3E cf = new CompletableFuture%3C%3E();%0A%0A        SubDescriptor descriptor = new SubDescriptor().setChannel(TEST_STREAM1);%0A        server.installFunction(%22inserterfunc%22, descriptor, (ctx, re) -%3E %7B%0A            CompletableFuture%3CVoid%3E cfUpsert = ctx.upsert(binder, document);%0A            cfUpsert.thenRun(() -%3E %7B%0A                server.deleteFunction(%22inserterfunc%22);%0A                cf.complete(null);%0A            %7D);%0A        %7D);%0A%0A        Connection conn = client.connect(new ConnectionOptions()).get();%0A        Producer prod = conn.createProducer(TEST_STREAM1);%0A%0A        prod.emit(new BsonObject().put(%22foo%22, %22bar%22)).get();%0A%0A        return cf;%0A    %7D%0A%7D%0A

Create test for getById query