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.ProcReturnType;
import uk.co.bristlecone.voltdb.wrapgen.source.RunParameter;

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;
  private final static String TEST_PACKAGE_NAME = "test.package";
  private final static String TEST_CLASS_JAVADOC = "Class JavaDoc goes here";

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

  @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);
  }

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

  @Test(expected = IllegalArgumentException.class)
  public void builderThrowsIfAnyFieldsAreNotSet() {
    new ProcData.Builder().build();
  }
}
@@ -539,20 +539,16 @@
 ST_PARAM
-ETER
 S = Immu
@@ -585,24 +585,30 @@
 test
-Type%22, %22testName
+.pkg%22, %22AClass%22, %22aVar
 %22));
@@ -998,20 +998,16 @@
 ST_PARAM
-ETER
 S)%0A     
@@ -1264,12 +1264,8 @@
 ARAM
-ETER
 S)))

Update ProcDataTest to use updated RunParameter definition