@Test public void loadClassTest() { assertEquals(String.class, loadClass(String.class.getCanonicalName(), classLoader)); assertEquals(int.class, loadClass(int.class.getCanonicalName(), classLoader)); assertEquals(RuleScenarioRunnerHelperTest.class, loadClass(RuleScenarioRunnerHelperTest.class.getCanonicalName(), classLoader)); assertEquals(EnumTest.class, loadClass(EnumTest.class.getCanonicalName(), classLoader)); assertThatThrownBy(() -> loadClass(null, classLoader)) .isInstanceOf(ScenarioException.class) .hasMessage("Impossible to load class null"); assertThatThrownBy(() -> loadClass("NotExistingClass", classLoader)) .isInstanceOf(ScenarioException.class) .hasMessage("Impossible to load class NotExistingClass"); }
@SuppressWarnings("unchecked") public static <T> Class<T> loadClass(String className, ClassLoader classLoader) { if (isPrimitive(className)) { return (Class<T>) primitiveMap.get(className); } try { return (Class<T>) classLoader.loadClass(className); } catch (ClassNotFoundException | NullPointerException e) { throw new ScenarioException(new StringBuilder().append("Impossible to load class ").append(className).toString(), e); } }
ScenarioBeanUtil { @SuppressWarnings("unchecked") public static <T> Class<T> loadClass(String className, ClassLoader classLoader) { if (isPrimitive(className)) { return (Class<T>) primitiveMap.get(className); } try { return (Class<T>) classLoader.loadClass(className); } catch (ClassNotFoundException | NullPointerException e) { throw new ScenarioException(new StringBuilder().append("Impossible to load class ").append(className).toString(), e); } } }
ScenarioBeanUtil { @SuppressWarnings("unchecked") public static <T> Class<T> loadClass(String className, ClassLoader classLoader) { if (isPrimitive(className)) { return (Class<T>) primitiveMap.get(className); } try { return (Class<T>) classLoader.loadClass(className); } catch (ClassNotFoundException | NullPointerException e) { throw new ScenarioException(new StringBuilder().append("Impossible to load class ").append(className).toString(), e); } } private  ScenarioBeanUtil(); }
ScenarioBeanUtil { @SuppressWarnings("unchecked") public static <T> Class<T> loadClass(String className, ClassLoader classLoader) { if (isPrimitive(className)) { return (Class<T>) primitiveMap.get(className); } try { return (Class<T>) classLoader.loadClass(className); } catch (ClassNotFoundException | NullPointerException e) { throw new ScenarioException(new StringBuilder().append("Impossible to load class ").append(className).toString(), e); } } private  ScenarioBeanUtil(); static T fillBean(String className, Map<List<String>, Object> params, ClassLoader classLoader); @SuppressWarnings("unchecked") static T fillBean(ValueWrapper<Object> initialInstance, String className, Map<List<String>, Object> params, ClassLoader classLoader); static ScenarioBeanWrapper<?> navigateToObject(Object rootObject, List<String> steps); static ScenarioBeanWrapper<?> navigateToObject(Object rootObject, List<String> steps, boolean createIfNull); static Object convertValue(String className, Object cleanValue, ClassLoader classLoader); static String revertValue(Object cleanValue); @SuppressWarnings("unchecked") static Class<T> loadClass(String className, ClassLoader classLoader); static Field getField(Class<?> clazz, String fieldName); }
ScenarioBeanUtil { @SuppressWarnings("unchecked") public static <T> Class<T> loadClass(String className, ClassLoader classLoader) { if (isPrimitive(className)) { return (Class<T>) primitiveMap.get(className); } try { return (Class<T>) classLoader.loadClass(className); } catch (ClassNotFoundException | NullPointerException e) { throw new ScenarioException(new StringBuilder().append("Impossible to load class ").append(className).toString(), e); } } private  ScenarioBeanUtil(); static T fillBean(String className, Map<List<String>, Object> params, ClassLoader classLoader); @SuppressWarnings("unchecked") static T fillBean(ValueWrapper<Object> initialInstance, String className, Map<List<String>, Object> params, ClassLoader classLoader); static ScenarioBeanWrapper<?> navigateToObject(Object rootObject, List<String> steps); static ScenarioBeanWrapper<?> navigateToObject(Object rootObject, List<String> steps, boolean createIfNull); static Object convertValue(String className, Object cleanValue, ClassLoader classLoader); static String revertValue(Object cleanValue); @SuppressWarnings("unchecked") static Class<T> loadClass(String className, ClassLoader classLoader); static Field getField(Class<?> clazz, String fieldName);  }