ReflectionUtil { public static <T> T getObj(String className, Class<T> clazz) { return doGetObjWithArgs(className, clazz); } private  ReflectionUtil(); static T getObj(String className, Class<T> clazz); static T getObjWithArgs(String className, Class<T> clazz, ConstructorArgument<?>... args); static ConstructorArgument<T> constructorArgument(T value, Class<T> clazz);  }
@Test public void testGetObj() { assertTrue(ReflectionUtil.getObj(ArrayList.class.getName(), List.class) instanceof ArrayList); assertEquals(new ArrayList<>(), ReflectionUtil.getObj(ArrayList.class.getName(), List.class)); }
@Test(expected = SamzaException.class) public void testGetObjNoClass() { ReflectionUtil.getObj("not.a.class", Set.class); }
@Test(expected = SamzaException.class) public void testGetObjInvalidConstructor() { ReflectionUtil.getObj(WithTwoArgConstructor.class.getName(), Object.class); }