SingleArgConverter extends com.tngtech.junit.dataprovider.convert.SingleArgConverter { @Override public Object[] convert(Object data, boolean isVarargs, Class<?>[] parameterTypes) { checkArgument(parameterTypes.length == 1, "Object[] dataprovider just supports single argument test method but found %d parameters", parameterTypes.length); return super.convert(data, isVarargs, parameterTypes); }  @Override Object[] convert(Object data, boolean isVarargs, Class<?>[] parameterTypes);  }
@Test(expected = IllegalArgumentException.class) public void testConvertShouldThrowIllegalArgumentExceptionIfParameterTypesSizeIsZero() { Object data = 1; Class<?>[] parameterTypes = new Class<?>[] {}; underTest.convert(data, false, parameterTypes); }
@Test(expected = IllegalArgumentException.class) public void testConvertShouldThrowIllegalArgumentExceptionIfParameterTypesSizeGreaterThanOne() { Object data = 2L; Class<?>[] parameterTypes = new Class<?>[] { int.class, String.class, Long.class }; underTest.convert(data, false, parameterTypes); }
@Test(expected = IllegalArgumentException.class) public void testConvertShouldThrowIllegalArgumentExceptionIfVarargsIsTrue() { Object data = 3.0; Class<?>[] parameterTypes = new Class<?>[] { double.class }; underTest.convert(data, true, parameterTypes); }
@Test public void testConvertShouldWrapInputIntoArryAndReturnItIfPreconditionsMet() { Object data = "4"; Class<?>[] parameterTypes = new Class<?>[] { String.class }; Object[] result = underTest.convert(data, false, parameterTypes); assertThat(result).containsExactly("4"); }