AbstractObjectConverter extends com.tngtech.junit.dataprovider.convert.AbstractObjectConverter<V> { @Override protected void checkIfArgumentsMatchParameterTypes(Object[] arguments, Class<?>[] parameterTypes) { checkNotNull(arguments, "'arguments' must not be null"); checkNotNull(parameterTypes, "'testMethod' must not be null"); checkArgument(parameterTypes.length == arguments.length, "Expected %d arguments for test method but got %d.", parameterTypes.length, arguments.length); super.checkIfArgumentsMatchParameterTypes(arguments, parameterTypes); }  @Override abstract Object[] convert(V data, boolean isVarargs, Class<?>[] parameterTypes);  }
@Test(expected = NullPointerException.class) public void testCheckIfArgumentsMatchParameterTypesShouldThrowNullPointerExceptionIfArgumentsIsNull() { underTest.checkIfArgumentsMatchParameterTypes(null, new Class<?>[0]); }
@Test(expected = NullPointerException.class) public void testCheckIfArgumentsMatchParameterTypesShouldThrowNullPointerExceptionIfParameterTypesIsNull() { underTest.checkIfArgumentsMatchParameterTypes(new Object[0], null); }
@Test(expected = IllegalArgumentException.class) public void testCheckIfArgumentsMatchParameterTypesShouldThrowIllegalArgumentExceptionIfLengthOfArgumentsAndParameterTypesDoesNotMatch() { Object[] arguments = new Object[0]; Class<?>[] parameterTypes = new Class<?>[] { int.class, String.class, boolean.class }; underTest.checkIfArgumentsMatchParameterTypes(arguments, parameterTypes); }
@Test(expected = IllegalArgumentException.class) public void testCheckIfArgumentsMatchParameterTypesShouldThrowIllegalArgumentExceptionIfSingleArgumentIsNotAssignableToParameterType() { Object[] arguments = new Object[] { "1" }; Class<?>[] parameterTypes = new Class<?>[] { int.class }; underTest.checkIfArgumentsMatchParameterTypes(arguments, parameterTypes); }
@Test(expected = IllegalArgumentException.class) public void testCheckIfArgumentsMatchParameterTypesShouldThrowIllegalArgumentExceptionIfAnyArgumentTypeIsNotAssignableToParameterType() { Object[] arguments = new Object[] { 2, "2", 2l }; Class<?>[] parameterTypes = new Class<?>[] { int.class, String.class, boolean.class }; underTest.checkIfArgumentsMatchParameterTypes(arguments, parameterTypes); }
@Test public void testCheckIfArgumentsMatchParameterTypesShouldNotThrowExceptionIfSingleArgumentTypeEqualsParameterType() { Object[] arguments = new Object[] { 'a' }; Class<?>[] parameterTypes = new Class<?>[] { Character.class }; underTest.checkIfArgumentsMatchParameterTypes(arguments, parameterTypes); }
@Test public void testCheckIfArgumentsMatchParameterTypesShouldNotThrowExceptionIfEveryArgumentTypeEqualsParameterTypesExactly() { Object[] arguments = new Object[] { "b", Boolean.FALSE }; Class<?>[] parameterTypes = new Class<?>[] { String.class, Boolean.class }; underTest.checkIfArgumentsMatchParameterTypes(arguments, parameterTypes); }
@Test public void testCheckIfArgumentsMatchParameterTypesShouldNotThrowExceptionIfArgumentsIsAreAssignableToParameterTypes() { Object[] arguments = new Object[] { 1l, 2 }; Class<?>[] parameterTypes = new Class<?>[] { Number.class, Number.class }; underTest.checkIfArgumentsMatchParameterTypes(arguments, parameterTypes); }
@Test public void testCheckIfArgumentsMatchParameterTypesShouldNotThrowExceptionIfArgumentsAreWrappedPrimitivesOfParameterTypes() { Object[] arguments = new Object[] { Boolean.FALSE, 'a', (byte) 2, (short) 3, 4, 5l, 6.6f, 7.7 }; Class<?>[] parameterTypes = new Class<?>[] { boolean.class, char.class, byte.class, short.class, int.class, long.class, float.class, double.class }; underTest.checkIfArgumentsMatchParameterTypes(arguments, parameterTypes); }
@Test public void testCheckIfArgumentsMatchParameterTypesShouldBeAwareOfWideningPrimitiveConversionsOfByte() { Object[] arguments = new Object[] { (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5 }; Class<?>[] parameterTypes = new Class<?>[] { short.class, int.class, long.class, float.class, double.class }; underTest.checkIfArgumentsMatchParameterTypes(arguments, parameterTypes); }
@Test public void testCheckIfArgumentsMatchParameterTypesShouldBeAwareOfWideningPrimitiveConversionsOfShort() { Object[] arguments = new Object[] { (short) 1, (short) 2, (short) 3, (short) 4 }; Class<?>[] parameterTypes = new Class<?>[] { int.class, long.class, float.class, double.class }; underTest.checkIfArgumentsMatchParameterTypes(arguments, parameterTypes); }
@Test public void testCheckIfArgumentsMatchParameterTypesShouldBeAwareOfWideningPrimitiveConversionsOfChar() { Object[] arguments = new Object[] { (char) 1, (char) 2, (char) 3, (char) 4 }; Class<?>[] parameterTypes = new Class<?>[] { int.class, long.class, float.class, double.class }; underTest.checkIfArgumentsMatchParameterTypes(arguments, parameterTypes); }
@Test public void testCheckIfArgumentsMatchParameterTypesShouldBeAwareOfWideningPrimitiveConversionsOfInt() { Object[] arguments = new Object[] { 1, 2, 3 }; Class<?>[] parameterTypes = new Class<?>[] { long.class, float.class, double.class }; underTest.checkIfArgumentsMatchParameterTypes(arguments, parameterTypes); }
@Test public void testCheckIfArgumentsMatchParameterTypesShouldBeAwareOfWideningPrimitiveConversionsOfFloat() { Object[] arguments = new Object[] { 1.1f }; Class<?>[] parameterTypes = new Class<?>[] { double.class }; underTest.checkIfArgumentsMatchParameterTypes(arguments, parameterTypes); }
@Test public void testCheckIfArgumentsMatchParameterTypesShouldBeAwareOfWideningPrimitiveConversionsOfLong() { Object[] arguments = new Object[] { 1l, 2l }; Class<?>[] parameterTypes = new Class<?>[] { float.class, double.class }; underTest.checkIfArgumentsMatchParameterTypes(arguments, parameterTypes); }
@Test(expected = IllegalArgumentException.class) public void testCheckIfArgumentsMatchParameterTypesShouldThrowExceptionForNonWideningConversionsOfLong() { Object[] arguments = new Object[] { (long) 1 }; Class<?>[] parameterTypes = new Class<?>[] { int.class }; underTest.checkIfArgumentsMatchParameterTypes(arguments, parameterTypes); }