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.List;

import org.junit.Test;

import com.google.common.collect.ImmutableList;

import uk.co.bristlecone.voltdb.wrapgen.source.RunParameter;
import uk.co.bristlecone.voltdb.wrapgen.builder.ProcData;
import uk.co.bristlecone.voltdb.wrapgen.source.ProcReturnType;

public class ProcDataTest {
  private final static String TEST_NAME = "testName";
  private final static List<RunParameter> TEST_PARAMETERS = ImmutableList.of(RunParameter.of("testType", "testName"));
  private final static ProcReturnType TEST_RETURN_TYPE = ProcReturnType.VOLTABLE_ARRAY;

  @Test
  public void builderInstantiatesClassCorrectly() {
    ProcData testee = new ProcData.Builder().setName(TEST_NAME)
        .setParameters(TEST_PARAMETERS)
        .setReturnType(TEST_RETURN_TYPE)
        .build();
    assertThat(testee.name(), is(equalTo(TEST_NAME)));
    assertThat(testee.parameters(), is(equalTo(TEST_PARAMETERS)));
    assertThat(testee.returnType(), is(equalTo(TEST_RETURN_TYPE)));
  }

  @Test(expected = IllegalArgumentException.class)
  public void builderThrowsOnNullName() {
    new ProcData.Builder().setName(null);
  }

  @Test(expected = IllegalArgumentException.class)
  public void builderThrowsOnEmptyName() {
    new ProcData.Builder().setName("");
  }

  @Test(expected = IllegalArgumentException.class)
  public void builderThrowsOnNullParameters() {
    new ProcData.Builder().setParameters(null);
  }

  @Test(expected = IllegalArgumentException.class)
  public void builderThrowsOnNullReturnType() {
    new ProcData.Builder().setReturnType(null);
  }
}
@@ -331,78 +331,22 @@
 rce.
-RunParameter;%0Aimport uk.co.bristlecone.voltdb.wrapgen.builder.ProcData
+ProcReturnType
 ;%0Aim
@@ -390,30 +390,28 @@
 .source.
-ProcReturnType
+RunParameter
 ;%0A%0Apubli
@@ -693,16 +693,82 @@
 E_ARRAY;
+%0A  private final static String TEST_PACKAGE_NAME = %22test.package%22;
 %0A%0A  @Tes
@@ -966,16 +966,59 @@
 N_TYPE)%0A
+        .setPackageName(TEST_PACKAGE_NAME)%0A
         
@@ -1145,24 +1145,24 @@
 AMETERS)));%0A
-
     assertTh
@@ -1217,16 +1217,86 @@
 YPE)));%0A
+    assertThat(testee.packageName(), is(equalTo(TEST_PACKAGE_NAME)));%0A
   %7D%0A%0A  @

test packageName, setPackageName in ProcData builder