Search in sources :

Example 1 with EvaluatorParameters

use of com.twosigma.beakerx.kernel.EvaluatorParameters in project beakerx by twosigma.

the class GroovyOutputContainerTest method setUp.

@Before
public void setUp() throws Exception {
    BaseEvaluator evaluator = TestGroovyEvaluator.groovyEvaluator();
    groovyKernel = new KernelTest("GroovyOutputContainerTest", evaluator);
    groovyEvaluatorManager = new EvaluatorManager(groovyKernel, evaluator);
    groovyEvaluatorManager.setShellOptions(new EvaluatorParameters(new HashMap()));
    KernelManager.register(groovyKernel);
}
Also used : EvaluatorParameters(com.twosigma.beakerx.kernel.EvaluatorParameters) KernelTest(com.twosigma.beakerx.KernelTest) HashMap(java.util.HashMap) EvaluatorManager(com.twosigma.beakerx.evaluator.EvaluatorManager) BaseEvaluator(com.twosigma.beakerx.evaluator.BaseEvaluator) Before(org.junit.Before)

Example 2 with EvaluatorParameters

use of com.twosigma.beakerx.kernel.EvaluatorParameters in project beakerx by twosigma.

the class JavaEvaluatorAutocompleteImportTest method setUpClass.

@BeforeClass
public static void setUpClass() throws Exception {
    HashMap<String, Object> map = new HashMap<>();
    map.put(IMPORTS, new JavaDefaultVariables().getImports());
    EvaluatorParameters kernelParameters = new EvaluatorParameters(map);
    groovyEvaluator = new JavaEvaluator("id", "sid", cellExecutor(), getTestTempFolderFactory(), kernelParameters);
}
Also used : EvaluatorParameters(com.twosigma.beakerx.kernel.EvaluatorParameters) HashMap(java.util.HashMap) JavaDefaultVariables(com.twosigma.beakerx.javash.kernel.JavaDefaultVariables) JavaEvaluator(com.twosigma.beakerx.javash.evaluator.JavaEvaluator) BeforeClass(org.junit.BeforeClass)

Example 3 with EvaluatorParameters

use of com.twosigma.beakerx.kernel.EvaluatorParameters in project beakerx by twosigma.

the class DataSourcesMagicCommand method dataSource.

protected MagicCommandOutcomeItem dataSource(String source, String command) {
    String[] parts = command.split(" ");
    if (parts.length != 2) {
        return new MagicCommandOutput(MagicCommandOutcomeItem.Status.ERROR, WRONG_FORMAT_MSG);
    } else if (!parts[1].contains("jdbc:")) {
        return new MagicCommandOutput(MagicCommandOutcomeItem.Status.ERROR, "Incorrect jdbc url.");
    }
    HashMap<String, Object> params = new HashMap<>();
    params.put(source, parts[1]);
    this.kernel.setShellOptions(new EvaluatorParameters(params));
    return new MagicCommandOutput(MagicCommandOutcomeItem.Status.OK);
}
Also used : EvaluatorParameters(com.twosigma.beakerx.kernel.EvaluatorParameters) MagicCommandOutput(com.twosigma.beakerx.kernel.magic.command.outcome.MagicCommandOutput) HashMap(java.util.HashMap)

Example 4 with EvaluatorParameters

use of com.twosigma.beakerx.kernel.EvaluatorParameters in project beakerx by twosigma.

the class EvaluatorManagerTest method setUp.

@Before
public void setUp() throws Exception {
    evaluator = new EvaluatorTest();
    evaluatorManager = new EvaluatorManager(kernel, evaluator);
    evaluatorManager.setShellOptions(new EvaluatorParameters(new HashMap()));
}
Also used : EvaluatorParameters(com.twosigma.beakerx.kernel.EvaluatorParameters) HashMap(java.util.HashMap) Before(org.junit.Before)

Example 5 with EvaluatorParameters

use of com.twosigma.beakerx.kernel.EvaluatorParameters in project beakerx by twosigma.

the class ScalaEvaluatorTest method javaImports_shouldBeAdjustedForScala.

@Test
public void javaImports_shouldBeAdjustedForScala() throws Exception {
    // given
    Map<String, Object> paramMap = new HashMap<>();
    // This import tests both "static" removal and "object" escaping.
    List<String> imports = Arrays.asList("import static com.twosigma.beakerx.scala.evaluator.object.ImportTestHelper.staticMethod");
    paramMap.put(IMPORTS, imports);
    EvaluatorParameters kernelParameters = new EvaluatorParameters(paramMap);
    // when
    scalaEvaluator.setShellOptions(kernelParameters);
    String code = "val x = staticMethod()";
    SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
    TryResult evaluate = scalaEvaluator.evaluate(seo, code);
    // then
    assertThat(evaluate.result()).isNull();
}
Also used : EvaluatorParameters(com.twosigma.beakerx.kernel.EvaluatorParameters) HashMap(java.util.HashMap) TryResult(com.twosigma.beakerx.TryResult) SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject) SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject) Test(org.junit.Test)

Aggregations

EvaluatorParameters (com.twosigma.beakerx.kernel.EvaluatorParameters)9 HashMap (java.util.HashMap)8 TryResult (com.twosigma.beakerx.TryResult)3 SimpleEvaluationObject (com.twosigma.beakerx.jvm.object.SimpleEvaluationObject)3 BeforeClass (org.junit.BeforeClass)3 Test (org.junit.Test)3 GroovyKernelMock (com.twosigma.beakerx.groovy.kernel.GroovyKernelMock)2 Before (org.junit.Before)2 KernelTest (com.twosigma.beakerx.KernelTest)1 BaseEvaluator (com.twosigma.beakerx.evaluator.BaseEvaluator)1 EvaluatorManager (com.twosigma.beakerx.evaluator.EvaluatorManager)1 GroovyEvaluator (com.twosigma.beakerx.groovy.evaluator.GroovyEvaluator)1 GroovyDefaultVariables (com.twosigma.beakerx.groovy.kernel.GroovyDefaultVariables)1 JavaEvaluator (com.twosigma.beakerx.javash.evaluator.JavaEvaluator)1 JavaDefaultVariables (com.twosigma.beakerx.javash.kernel.JavaDefaultVariables)1 MagicCommandOutput (com.twosigma.beakerx.kernel.magic.command.outcome.MagicCommandOutput)1 Binding (groovy.lang.Binding)1 HashedMap (org.apache.commons.collections.map.HashedMap)1