BaseExpressionEvaluator extends AbstractExpressionEvaluator { @Override protected Object createObject(String className, List<String> genericClasses) { if (ScenarioSimulationSharedUtils.isMap(className)) { return new HashMap(); } else { try { return classLoader.loadClass(className).newInstance(); } catch (Exception e) { throw new IllegalArgumentException("Impossible to instantiate " + className, e); } } } BaseExpressionEvaluator(ClassLoader classLoader); @Override String fromObjectToExpression(Object value);  }
@Test public void createObjectTest() { assertNotNull(expressionEvaluator.createObject(String.class.getCanonicalName(), Collections.emptyList())); assertTrue(expressionEvaluator.createObject(Map.class.getCanonicalName(), Arrays.asList(String.class.getCanonicalName(), String.class.getCanonicalName())) instanceof Map); Assertions.assertThatThrownBy(() -> expressionEvaluator.createObject("com.invalid.class.Name", Collections.emptyList())).isInstanceOf(IllegalArgumentException.class) .hasMessage("Impossible to instantiate com.invalid.class.Name"); }