Search in sources :

Example 6 with Code

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

the class MagicCommandResultOrderTest method classpathShouldBeLast.

@Test
public void classpathShouldBeLast() {
    // given
    String allCode = "" + "%classpath add jar " + DOC_CONTENTS_DEMO_RESOURCES_BEAKERX_TEST_LIBRARY_JAR + "\n" + "%classpath";
    Code code = CodeFactory.create(allCode, new Message(), kernel);
    // when
    code.execute(kernel, 1);
    // then
    List<Message> std = EvaluatorResultTestWatcher.getStdouts(kernel.getPublishedMessages());
    String text = (String) std.get(0).getContent().get("text");
    assertThat(text).contains(DEMO_JAR);
}
Also used : Message(com.twosigma.beakerx.message.Message) PlainCode(com.twosigma.beakerx.kernel.PlainCode) Code(com.twosigma.beakerx.kernel.Code) EvaluatorTest(com.twosigma.beakerx.evaluator.EvaluatorTest) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 7 with Code

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

the class MagicCommandResultOrderTest method codeResultShouldBeLast.

@Test
public void codeResultShouldBeLast() {
    // given
    String allCode = "" + "%classpath add jar " + DOC_CONTENTS_DEMO_RESOURCES_BEAKERX_TEST_LIBRARY_JAR + "\n" + "%classpath\n" + "code code code";
    // when
    Code code = CodeFactory.create(allCode, new Message(), kernel);
    code.execute(kernel, 1);
    // then
    PlainCode actual = (PlainCode) code.getCodeFrames().get(2);
    assertThat(actual.getPlainCode()).isEqualTo("code code code");
}
Also used : Message(com.twosigma.beakerx.message.Message) PlainCode(com.twosigma.beakerx.kernel.PlainCode) Code(com.twosigma.beakerx.kernel.Code) PlainCode(com.twosigma.beakerx.kernel.PlainCode) EvaluatorTest(com.twosigma.beakerx.evaluator.EvaluatorTest) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 8 with Code

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

the class TimeItLineModeMagicCommandTest method timeitLineMode.

@Test
public void timeitLineMode() {
    // given
    String allCode = "%timeit -r3 -n1 sleep(1)";
    Code code = CodeFactory.create(allCode, new Message(), kernel);
    // when
    code.execute(kernel, 1);
    // then
    List<Message> std = EvaluatorResultTestWatcher.getStdouts(kernel.getPublishedMessages());
    String text = (String) std.get(0).getContent().get("text");
    assertThat(text).contains("loop");
}
Also used : Message(com.twosigma.beakerx.message.Message) Code(com.twosigma.beakerx.kernel.Code) EvaluatorTest(com.twosigma.beakerx.evaluator.EvaluatorTest) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 9 with Code

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

the class ClasspathMagicCommandTest method handleClasspathAddJarWildcardMagicCommand.

@Test
public void handleClasspathAddJarWildcardMagicCommand() {
    // given
    String allCode = "" + CLASSPATH_ADD_JAR + " " + SRC_TEST_RESOURCES + "dirWithTwoJars/*";
    Code code = CodeFactory.create(allCode, new Message(), kernel);
    // when
    code.execute(kernel, 1);
    // then
    List<Message> std = EvaluatorResultTestWatcher.getStdouts(kernel.getPublishedMessages());
    String text = (String) std.get(0).getContent().get("text");
    assertThat(text).contains(FOO_JAR, "bar.jar");
    assertThat(evaluator.getResetEnvironmentCounter()).isEqualTo(0);
}
Also used : Message(com.twosigma.beakerx.message.Message) PlainCode(com.twosigma.beakerx.kernel.PlainCode) Code(com.twosigma.beakerx.kernel.Code) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest) EvaluatorTest(com.twosigma.beakerx.evaluator.EvaluatorTest)

Example 10 with Code

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

the class ClasspathMagicCommandTest method showClasspath.

@Test
public void showClasspath() {
    // given
    kernel.addJarsToClasspath(asList(new PathToJar(CLASSPATH_TO_JAR_PATH)));
    Code code = CodeFactory.create("%classpath", new Message(), kernel);
    // when
    code.execute(kernel, 1);
    // then
    List<Message> std = EvaluatorResultTestWatcher.getStdouts(kernel.getPublishedMessages());
    String text = (String) std.get(0).getContent().get("text");
    assertThat(text).contains(FOO_JAR);
}
Also used : Message(com.twosigma.beakerx.message.Message) PathToJar(com.twosigma.beakerx.kernel.PathToJar) PlainCode(com.twosigma.beakerx.kernel.PlainCode) Code(com.twosigma.beakerx.kernel.Code) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest) EvaluatorTest(com.twosigma.beakerx.evaluator.EvaluatorTest)

Aggregations

Code (com.twosigma.beakerx.kernel.Code)55 Message (com.twosigma.beakerx.message.Message)54 Test (org.junit.Test)47 KernelTest (com.twosigma.beakerx.KernelTest)33 EvaluatorTest (com.twosigma.beakerx.evaluator.EvaluatorTest)29 MessageFactoryTest.getExecuteRequestMessage (com.twosigma.beakerx.MessageFactoryTest.getExecuteRequestMessage)16 EvaluatorResultTestWatcher.waitForIdleMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForIdleMessage)16 PlainCode (com.twosigma.beakerx.kernel.PlainCode)14 MessageAssertions.verifyExecuteReplyMessage (com.twosigma.MessageAssertions.verifyExecuteReplyMessage)9 EvaluatorResultTestWatcher.waitForErrorMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForErrorMessage)9 EvaluatorResultTestWatcher.waitForSentMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForSentMessage)9 KernelExecutionTest (com.twosigma.beakerx.KernelExecutionTest)7 EvaluatorResultTestWatcher.waitForUpdateMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForUpdateMessage)7 ClasspathAddMvnMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.ClasspathAddMvnMagicCommand)4 ClasspathResetMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.ClasspathResetMagicCommand)4 ImportPath (com.twosigma.beakerx.kernel.ImportPath)3 PathToJar (com.twosigma.beakerx.kernel.PathToJar)2 MagicCommand (com.twosigma.beakerx.kernel.magic.command.MagicCommand)2 ClassPathAddMvnCellMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.ClassPathAddMvnCellMagicCommand)2 EvaluatorResultTestWatcher (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher)1