### Question:
ReflectionUtils { public static <T> T newInstance(Class<T> cls, Object... args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { Constructor<T> declaredConstructor = args.length == 0 ? getConstructor(cls) : getConstructor(cls, args); boolean accessible = declaredConstructor.isAccessible(); if (accessible) { return declaredConstructor.newInstance(args); } else { declaredConstructor.setAccessible(true); try { return declaredConstructor.newInstance(args); } finally { declaredConstructor.setAccessible(accessible); } } } private  ReflectionUtils(); @SuppressWarnings("unchecked") static Class<T> wrapPrimitive(Class<T> clazz); static Class<?>[] toClass(Object... array); static Object[] toArgs(Function<Class<?>, Object> valueSupplier, Class<?>... array); static T getDefault(Class<T> type); static Constructor<T> getConstructor(Class<T> cls, Class<?>... argsTypes); static Constructor<T> getConstructorOptional(int mandatoryCount, Class<T> cls, Class<?>... argsTypes); static T newInstance(Class<T> cls, Object... args); static T newInstanceOptionalArgs(Class<T> cls, Object... args); static T newInstanceOptionalArgs(int mandatoryCount, Class<T> cls, Object... args); static Object invoke(Method method, Object obj, Object... args); static Object get(Field field, Object obj); static void set(Field field, Object obj, Object value); static Class<?> getFirstGenericType(Field field); static Method getMethod(Class<?> declaringClass, String name, Class... types);  }### Answer:
@Test public void testNewInstance() throws NoSuchMethodException, IllegalAccessException, InstantiationException, InvocationTargetException { TestClass testClass = ReflectionUtils.newInstance(TestClass.class); assertThat(testClass).isExactlyInstanceOf(TestClass.class); }