package uk.co.bristlecone.voltdb.wrapgen.builder;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;

import java.util.function.Function;

import org.junit.Test;
import org.junit.runner.RunWith;

import mockit.Expectations;
import mockit.Mocked;
import mockit.integration.junit4.JMockit;

@RunWith(JMockit.class)
public class RunnerBuilderTest {

  // @formatter:off
  private static final String PROC_DATA_PACKAGE_NAME = "mock.package.name";
  private static final String PROC_DATA_CLASS_NAME = "MockStoredProcedureName";
  private static final String EXPECTED_CLASS_WITH_IDENTITY_NAMERS = "" 
      + String.format("package %s;\n", PROC_DATA_PACKAGE_NAME)
      + String.format("\n")
      + String.format("import uk.co.bristlecone.voltdb.wrapgen.runner.VoltRunner;\n")
      + String.format("\n")
      + String.format("/**\n")
      + String.format(" * An instance of this class can be used to run the <code>%s</code> ", PROC_DATA_CLASS_NAME)
        + String.format("VoltDB stored procedure. This stored procedure's JavaDoc is:\n")
      + String.format(" *\n")
      + String.format(" * <blockquote>null</blockquote>\n")
      + String.format(" *\n")
      + String.format(" * <strong>This class is automatically generated. Manual edits will be overwritten.</strong>\n")
      + String.format(" *\n")
      + String.format(" * @author voltdb-wrapgen\n")
      + String.format(" */\n")
      + String.format("@VoltRunner\n")
      + String.format("public class %s {\n", PROC_DATA_CLASS_NAME)
      + String.format("}\n");
  // @formatter:on

  @Test
  public void builderCreatesClassAsExpected(@Mocked final ProcData mockProcData) {
    // @formatter:off
    new Expectations() {{
      mockProcData.packageName(); result = PROC_DATA_PACKAGE_NAME;
      mockProcData.name(); result = PROC_DATA_CLASS_NAME;
    }};
    // @formatter:on

    VoltRunnerJavaSource testee = new RunnerBuilder(mockProcData, Function.identity(), Function.identity()).build();

    assertThat(testee.source(), is(equalTo(EXPECTED_CLASS_WITH_IDENTITY_NAMERS)));
  }
}

@@ -674,17 +674,16 @@
 ERS = %22%22
- 
 %0A      +
@@ -800,58 +800,489 @@
 ort 
-uk.co.bristlecone.voltdb.wrapgen.runner.VoltRunner
+java.io.IOException;%5Cn%22)%0A      + String.format(%22import java.util.concurrent.CompletableFuture;%5Cn%22)%0A      + String.format(%22import org.voltdb.client.ClientResponse;%5Cn%22)%0A      + String.format(%22import org.voltdb.client.NoConnectionsException;%5Cn%22)%0A      + String.format(%22import org.voltdb.client.ProcedureCallback;%5Cn%22)%0A      + String.format(%22import uk.co.bristlecone.voltdb.wrapgen.runner.VoltRunner;%5Cn%22)%0A      + String.format(%22import uk.co.bristlecone.voltdb.wrapgen.runner.WrapgenUtil
 ;%5Cn%22
@@ -2004,24 +2004,514 @@
 CLASS_NAME)%0A
+      + String.format(%22  CompletableFuture%3CClientResponse%3E run() throws NoConnectionsException, IOException %7B%5Cn%22)%0A      + String.format(%22    CompletableFuture%3CClientResponse%3E result = new CompletableFuture%3CClientResponse%3E();%5Cn%22)%0A      + String.format(%22    ProcedureCallback handler = WrapgenUtil.getHandler(result);%5Cn%22)%0A      + String.format(%22    client.callProcedure(handler, %5C%22MockStoredProcedureName%5C%22, );%5Cn%22)%0A      + String.format(%22    return result;%5Cn%22)%0A      + String.format(%22  %7D%5Cn%22)%0A
       + Stri
@@ -2846,16 +2846,22 @@
 on%0A%0A    
+final 
 VoltRunn
@@ -2955,16 +2955,25 @@
 ntity())
+%0A        
 .build()

Change RunnerBuilderTest to expect run() method