return (ScriptProcess) process;
}
public void testAdd() throws ScriptException, IOException {
ScriptProcess process = createProcess("add");
assertEquals("title", "JavaScript Addition Process", process.getTitle());
assertEquals("correct description", "Process that accepts two numbers and returns their sum.", process.getDescription());
// test inputs
Map<String, Parameter<?>> inputs = process.getInputs();
assertTrue("first in inputs", inputs.containsKey("first"));
Parameter<?> first = inputs.get("first");
assertEquals("first title", "First Operand", first.getTitle().toString());
assertEquals("first description", "The first operand.", first.getDescription().toString());
assertEquals("first type", Float.class, first.getType());
assertTrue("second in inputs", inputs.containsKey("first"));
Parameter<?> second = inputs.get("second");
assertEquals("second title", "Second Operand", second.getTitle().toString());
assertEquals("second description", "The second operand.", second.getDescription().toString());
assertEquals("second type", Float.class, second.getType());
// test outputs
Map<String, Parameter<?>> outputs = process.getOutputs();
assertTrue("sum in outputs", outputs.containsKey("sum"));
Parameter<?> sumParam = outputs.get("sum");
assertEquals("sum title", "Sum", sumParam.getTitle().toString());
assertEquals("sum description", "The sum of the two inputs", sumParam.getDescription().toString());
assertEquals("sum type", Float.class, sumParam.getType());
// test execute
Map<String, Object> input = new HashMap<String, Object>();
input.put("first", 2.0);
input.put("second", 4.0);
Map<String,Object> result = process.execute(input, null);
assertNotNull("add result", result);
assertTrue("sum in results", result.containsKey("sum"));
Object sum = result.get("sum");
assertEquals("correct sum", 6.0, (Double) sum, 0.0);
}