use of com.twosigma.beakerx.kernel.EvaluatorParameters in project beakerx by twosigma.
the class KotlinEvaluatorTest method evaluatePlot_shouldCreatePlotObject.
@Test
public void evaluatePlot_shouldCreatePlotObject() throws Exception {
// given
Map<String, Object> paramMap = new HashMap<>();
paramMap.put(IMPORTS, asList("import com.twosigma.beakerx.chart.xychart.*"));
evaluator.setShellOptions(new EvaluatorParameters(paramMap));
String code = "val plot = Plot()\n" + "plot.setTitle(\"test title\");\n" + "plot.display();";
SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
// when
TryResult evaluate = evaluator.evaluate(seo, code);
// then
assertThat(evaluate.result()).isNull();
}
use of com.twosigma.beakerx.kernel.EvaluatorParameters in project beakerx by twosigma.
the class KotlinEvaluatorTest method javaImports_shouldBeAdjustedForKotlin.
@Test
public void javaImports_shouldBeAdjustedForKotlin() throws Exception {
// given
Map<String, Object> paramMap = new HashMap<>();
// This import tests both "static" removal and "object" escaping.
List<String> imports = asList("import static com.twosigma.beakerx.kotlin.evaluator.object.ImportTestHelper.staticMethod");
paramMap.put(IMPORTS, imports);
EvaluatorParameters kernelParameters = new EvaluatorParameters(paramMap);
// when
evaluator.setShellOptions(kernelParameters);
String code = "val x = staticMethod()";
SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
TryResult evaluate = evaluator.evaluate(seo, code);
// then
assertThat(evaluate.result()).isNull();
}
use of com.twosigma.beakerx.kernel.EvaluatorParameters in project beakerx by twosigma.
the class GroovyEvaluatorTest method initClassStubData.
@BeforeClass
public static void initClassStubData() throws IOException {
GroovyDefaultVariables var = new GroovyDefaultVariables();
HashMap<String, Object> params = new HashMap<>();
params.put(IMPORTS, var.getImports());
params.put(CLASSPATH, var.getClassPath());
EvaluatorParameters kernelParameters = new EvaluatorParameters(params);
GroovyEvaluator groovyEvaluator = new GroovyEvaluator("123", "345", cellExecutor(), getTestTempFolderFactory(), kernelParameters);
groovyEvaluator.setShellOptions(kernelParameters);
groovyClassLoader = newEvaluator(groovyEvaluator.getImports(), groovyEvaluator.getClasspath(), groovyEvaluator.getOutDir(), icz, newParentClassLoader(groovyEvaluator.getClasspath()));
scriptBinding = new Binding();
scriptBinding.setVariable("beaker", NamespaceClient.getBeaker("345"));
groovyKernel = new GroovyKernelMock("groovyEvaluatorTest", groovyEvaluator);
KernelManager.register(groovyKernel);
}
use of com.twosigma.beakerx.kernel.EvaluatorParameters in project beakerx by twosigma.
the class GroovyCompleteHandlerTest method setUpClass.
@BeforeClass
public static void setUpClass() {
GroovyEvaluator groovyEvaluator = new GroovyEvaluator("id", "sid", cellExecutor(), EvaluatorTest.getTestTempFolderFactory(), new EvaluatorParameters(new HashedMap()));
groovyKernel = new GroovyKernelMock("sid", groovyEvaluator);
}
Aggregations