### Question:
Classes { public static <T> T instanciate(Class<? extends T> clazz) { try { return clazz.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new IllegalStateException("Cannot instanciate class " + clazz.getName() + ": " + e.getMessage(), e); } } private  Classes(); static T instanciate(Class<? extends T> clazz); static boolean isPresent(String className); static Class<?> forName(String className); static T getValueFromProtectedField(Object object, String fieldName);  }### Answer:
@Test void successful_instanciation() { Instanciable instance = Classes.instanciate(Instanciable.class); assertThat(instance).isExactlyInstanceOf(Instanciable.class); }
@Test void failed_instanciation() { assertThatExceptionOfType(IllegalStateException.class) .isThrownBy(() -> Classes.instanciate(Uninstanciable.class)) .withMessage("Cannot instanciate class " + Uninstanciable.class.getName() + ": Class " + Classes.class.getName() + " can not access a member of class " + Uninstanciable.class.getName() + " with modifiers \"private\"" ); }