### Question:
ReflectionUtils { public static Object instantiateWrapperArray(Class<?> type, String[] values) { logger.entering(new Object[] { type, values }); validateParams(type, values); boolean condition = (isWrapperArray(type) || hasOneArgStringConstructor(type.getComponentType())); checkArgument(condition, type.getName() + " is neither awrapper type nor has a 1 arg String constructor defined."); Class<?> componentType = type.getComponentType(); Object arrayToReturn = Array.newInstance(componentType, values.length); for (int i = 0; i < values.length; i++) { try { Array.set(arrayToReturn, i, componentType.getConstructor(String.class).newInstance(values[i])); } catch (ArrayIndexOutOfBoundsException | IllegalArgumentException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) { throw new ReflectionException(e); } } logger.exiting(arrayToReturn); return arrayToReturn; } private  ReflectionUtils(); static boolean hasOneArgStringConstructor(Class<?> type); static boolean hasDefaultConstructor(Class<?> type); static Object instantiateDefaultCustomTypeArray(DefaultCustomType type, String[] values); static Object instantiatePrimitiveArray(Class<?> type, String[] values); static Object instantiatePrimitiveObject(Class<?> type, Object objectToInvokeUpon, String valueToAssign); static Object instantiateWrapperArray(Class<?> type, String[] values); static Object instantiateWrapperObject(Class<?> type, Object objectToInvokeUpon, String valueToAssign); static boolean isPrimitiveArray(Class<?> type); static boolean isWrapperArray(Class<?> type);  }### Answer:
@Test(groups = "unit") public void testInstantiateWrapperArray() { Object wrapperArray = ReflectionUtils.instantiateWrapperArray(Integer[].class, new String[] { "1" }); assertTrue(wrapperArray != null); assertTrue(wrapperArray instanceof Integer[]); assertTrue(((Integer[]) wrapperArray).length == 1); assertTrue(((Integer[]) wrapperArray)[0].intValue() == 1); }
@Test(groups = "unit") public void testInstantiateWrapperArrayNonWrapperClass() { Object wrapperArray = ReflectionUtils.instantiateWrapperArray(PhoneyClass[].class, new String[] { "1" }); assertTrue(wrapperArray != null); assertTrue(wrapperArray instanceof PhoneyClass[]); assertTrue(((PhoneyClass[]) wrapperArray).length == 1); }
@Test(groups = "unit", expectedExceptions = { IllegalArgumentException.class }) public void testInstantiateWrapperArrayErrorCondition1() { ReflectionUtils.instantiateWrapperArray(Integer.class, new String[] { "1" }); }
@Test(groups = "unit", expectedExceptions = { IllegalArgumentException.class }) public void testInstantiateWrapperArrayErrorCondition2() { ReflectionUtils.instantiateWrapperArray(null, new String[] { "1" }); }
@Test(groups = "unit", expectedExceptions = { IllegalArgumentException.class }) public void testInstantiateWrapperArrayErrorCondition3() { ReflectionUtils.instantiateWrapperArray(DefaultCustomTypeTest.class, new String[] { "1" }); }
@Test(groups = "unit", expectedExceptions = { IllegalArgumentException.class }) public void testInstantiateWrapperArrayErrorCondition4() { ReflectionUtils.instantiateWrapperArray(int.class, new String[] { "1" }); }
@Test(groups = "unit", expectedExceptions = { IllegalArgumentException.class }) public void testInstantiateWrapperArrayErrorCondition5() { ReflectionUtils.instantiateWrapperArray(Integer[].class, null); }
@Test(groups = "unit", expectedExceptions = { IllegalArgumentException.class }) public void testInstantiateWrapperArrayErrorCondition6() { ReflectionUtils.instantiateWrapperArray(Integer[].class, new String[] {}); }
@Test(groups = "unit", expectedExceptions = { ReflectionException.class }) public void testInstantiateWrapperArrayErrorCondition7() { ReflectionUtils.instantiateWrapperArray(Integer[].class, new String[] { "selion" }); }