@Test void should_throw_exception_for_unsupported_script_context() { ScriptContext<?> unknownCtx = mock(ScriptContext.class); assertThrows(IllegalStateException.class, () -> scriptEngine.compile("test", "test code", unknownCtx, emptyMap())); }
@Override public <T> T compile(String scriptName, String scriptCode, ScriptContext<T> context, Map<String, String> params) { Expression expression = serializer.deserialize(scriptCode); if (CONTEXTS.containsKey(context)) { return context.factoryClazz.cast(CONTEXTS.get(context).apply(expression)); } throw new IllegalStateException(String.format("Script context is currently not supported: " + "all supported contexts [%s], given context [%s] ", CONTEXTS, context)); }
ExpressionScriptEngine implements ScriptEngine { @Override public <T> T compile(String scriptName, String scriptCode, ScriptContext<T> context, Map<String, String> params) { Expression expression = serializer.deserialize(scriptCode); if (CONTEXTS.containsKey(context)) { return context.factoryClazz.cast(CONTEXTS.get(context).apply(expression)); } throw new IllegalStateException(String.format("Script context is currently not supported: " + "all supported contexts [%s], given context [%s] ", CONTEXTS, context)); } }
ExpressionScriptEngine implements ScriptEngine { @Override public <T> T compile(String scriptName, String scriptCode, ScriptContext<T> context, Map<String, String> params) { Expression expression = serializer.deserialize(scriptCode); if (CONTEXTS.containsKey(context)) { return context.factoryClazz.cast(CONTEXTS.get(context).apply(expression)); } throw new IllegalStateException(String.format("Script context is currently not supported: " + "all supported contexts [%s], given context [%s] ", CONTEXTS, context)); }  }
ExpressionScriptEngine implements ScriptEngine { @Override public <T> T compile(String scriptName, String scriptCode, ScriptContext<T> context, Map<String, String> params) { Expression expression = serializer.deserialize(scriptCode); if (CONTEXTS.containsKey(context)) { return context.factoryClazz.cast(CONTEXTS.get(context).apply(expression)); } throw new IllegalStateException(String.format("Script context is currently not supported: " + "all supported contexts [%s], given context [%s] ", CONTEXTS, context)); }  @Override String getType(); @Override T compile(String scriptName,
                       String scriptCode,
                       ScriptContext<T> context,
                       Map<String, String> params); @Override Set<ScriptContext<?>> getSupportedContexts(); }
ExpressionScriptEngine implements ScriptEngine { @Override public <T> T compile(String scriptName, String scriptCode, ScriptContext<T> context, Map<String, String> params) { Expression expression = serializer.deserialize(scriptCode); if (CONTEXTS.containsKey(context)) { return context.factoryClazz.cast(CONTEXTS.get(context).apply(expression)); } throw new IllegalStateException(String.format("Script context is currently not supported: " + "all supported contexts [%s], given context [%s] ", CONTEXTS, context)); }  @Override String getType(); @Override T compile(String scriptName,
                       String scriptCode,
                       ScriptContext<T> context,
                       Map<String, String> params); @Override Set<ScriptContext<?>> getSupportedContexts(); static final String EXPRESSION_LANG_NAME; }