@Test void testGetScriptVariables() { Script script = when(mock(Script.class).getContent()).thenReturn("lorum ${x} ipsum ${y.z}").getMock(); assertEquals(newLinkedHashSet(asList("x", "y")), getScriptVariables(script)); }
public static Set<String> getScriptVariables(Script script) { Set<String> scriptExpressions = new LinkedHashSet<>(); Configuration configuration = new Configuration(VERSION); configuration.setTemplateExceptionHandler( (te, env, out) -> { if (te instanceof InvalidReferenceException) { scriptExpressions.add(te.getBlamedExpressionString()); return; } throw te; }); try { Template template = new Template(null, new StringReader(script.getContent()), configuration); template.process(emptyMap(), new StringWriter()); } catch (TemplateException | IOException e) { throw new GenerateScriptException( "Error processing parameters for script [" + script.getName() + "]. " + e.getMessage()); } return scriptExpressions; }
ScriptUtils { public static Set<String> getScriptVariables(Script script) { Set<String> scriptExpressions = new LinkedHashSet<>(); Configuration configuration = new Configuration(VERSION); configuration.setTemplateExceptionHandler( (te, env, out) -> { if (te instanceof InvalidReferenceException) { scriptExpressions.add(te.getBlamedExpressionString()); return; } throw te; }); try { Template template = new Template(null, new StringReader(script.getContent()), configuration); template.process(emptyMap(), new StringWriter()); } catch (TemplateException | IOException e) { throw new GenerateScriptException( "Error processing parameters for script [" + script.getName() + "]. " + e.getMessage()); } return scriptExpressions; } }
ScriptUtils { public static Set<String> getScriptVariables(Script script) { Set<String> scriptExpressions = new LinkedHashSet<>(); Configuration configuration = new Configuration(VERSION); configuration.setTemplateExceptionHandler( (te, env, out) -> { if (te instanceof InvalidReferenceException) { scriptExpressions.add(te.getBlamedExpressionString()); return; } throw te; }); try { Template template = new Template(null, new StringReader(script.getContent()), configuration); template.process(emptyMap(), new StringWriter()); } catch (TemplateException | IOException e) { throw new GenerateScriptException( "Error processing parameters for script [" + script.getName() + "]. " + e.getMessage()); } return scriptExpressions; } private  ScriptUtils(); }
ScriptUtils { public static Set<String> getScriptVariables(Script script) { Set<String> scriptExpressions = new LinkedHashSet<>(); Configuration configuration = new Configuration(VERSION); configuration.setTemplateExceptionHandler( (te, env, out) -> { if (te instanceof InvalidReferenceException) { scriptExpressions.add(te.getBlamedExpressionString()); return; } throw te; }); try { Template template = new Template(null, new StringReader(script.getContent()), configuration); template.process(emptyMap(), new StringWriter()); } catch (TemplateException | IOException e) { throw new GenerateScriptException( "Error processing parameters for script [" + script.getName() + "]. " + e.getMessage()); } return scriptExpressions; } private  ScriptUtils(); static String generateScript(Script script, Map<String, Object> parameterValues); static boolean hasScriptVariable(Script script, String variable); static Set<String> getScriptVariables(Script script); }
ScriptUtils { public static Set<String> getScriptVariables(Script script) { Set<String> scriptExpressions = new LinkedHashSet<>(); Configuration configuration = new Configuration(VERSION); configuration.setTemplateExceptionHandler( (te, env, out) -> { if (te instanceof InvalidReferenceException) { scriptExpressions.add(te.getBlamedExpressionString()); return; } throw te; }); try { Template template = new Template(null, new StringReader(script.getContent()), configuration); template.process(emptyMap(), new StringWriter()); } catch (TemplateException | IOException e) { throw new GenerateScriptException( "Error processing parameters for script [" + script.getName() + "]. " + e.getMessage()); } return scriptExpressions; } private  ScriptUtils(); static String generateScript(Script script, Map<String, Object> parameterValues); static boolean hasScriptVariable(Script script, String variable); static Set<String> getScriptVariables(Script script);  }