### Question:
FunctionScriptLoader { public RowTransformer getRowTransformer(String scriptName) { return (Row input) -> { if (input == null) { return null; } Reader content = load(ROW_SCRIPT_FOLDER, scriptName); try { Bindings bindings = ScriptingEnvironmentProvider.create(manager, this.scriptEngineBindings, input); return (Row) engine.eval(content, bindings); } catch (ScriptException ex) { throw new IllegalStateException("Cannot evaluate script: " + scriptName, ex); } }; } FunctionScriptLoader(String baseFolder, Map<String, Object> scriptEngineBindings);  FunctionScriptLoader(); static FunctionScriptLoader create(String baseFolder, Map<String, Object> scriptEngineBindings); ColumnTransformer getColumnTransformer(String scriptName); ColumnTransformer createFromScript(String script); ColumnTransformer createFromScript(Reader script); RowTransformer getRowTransformer(String scriptName); abstract Reader load(String scriptFolder, String name); Map<String, Object> getScriptEngineBindings(); static final String COLUMN_SCRIPT_FOLDER; static final String ROW_SCRIPT_FOLDER; }### Answer:
@Test public void rowTransfomerLoadingAndExecution() throws Exception { Row input = new Row(); input.addColumn(-1, "chief", "duke"); RowTransformer function = this.cut.getRowTransformer("noop"); assertNotNull(function); Row transformedEntries = function.execute(input); assertThat(transformedEntries, is(input)); }
@Test public void nullInputIsIgnored() { RowTransformer rowTransformer = this.cut.getRowTransformer("does-not-matter"); Row output = rowTransformer.execute(null); assertNull(output); }
@Test public void bindingsAvailable() { Row input = new Row(); final String inputValue = "duke"; input.addColumn(-1, "name", inputValue); RowTransformer function = this.cut.getRowTransformer("bindings"); Row output = function.execute(input); assertNotNull(output); final Column outputColumn = output.getColumnByName("synthetic"); assertNotNull(outputColumn); assertThat(outputColumn.getValue(), is(inputValue)); }
@Test public void counterIsWorking() { Row input = new Row(); input.useMemory(new Memory()); final String inputValue = "duke"; input.addColumn(-1, "name", inputValue); RowTransformer function = this.cut.getRowTransformer("count"); Row output = function.execute(input); assertNotNull(output); Memory memory = output.getMemory(); assertNotNull(memory); assertThat(memory.counterValue(), is(1l)); }
@Test public void propertyIsStoredInMemory() { Row input = new Row(); input.useMemory(new Memory()); final String inputValue = "duke"; input.addColumn(-1, "name", inputValue); RowTransformer function = this.cut.getRowTransformer("store"); Row output = function.execute(input); Memory memory = output.getMemory(); assertThat(memory.get("from"), is("script")); }