Search in sources :

Example 56 with Message

use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.

the class ExecuteRequestHandlerTest method handleMessage_firstSentMessageHasIdentities.

@Test
public void handleMessage_firstSentMessageHasIdentities() throws Exception {
    // given
    String expectedIdentities = new String(message.getIdentities().get(0));
    // when
    executeRequestHandler.handle(message);
    waitForIdleMessage(kernel);
    // then
    assertThat(kernel.getPublishedMessages()).isNotEmpty();
    Message publishMessage = kernel.getPublishedMessages().get(0);
    assertThat(new String(publishMessage.getIdentities().get(0))).isEqualTo(expectedIdentities);
}
Also used : EvaluatorResultTestWatcher.waitForIdleMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForIdleMessage) Message(com.twosigma.beakerx.message.Message) EvaluatorResultTestWatcher.waitForErrorMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForErrorMessage) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest) EvaluatorTest(com.twosigma.beakerx.evaluator.EvaluatorTest)

Example 57 with Message

use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.

the class MessageCreatorNoResultTest method noResult.

@Test
public void noResult() throws Exception {
    // given
    SimpleEvaluationObject seo = new SimpleEvaluationObject("code");
    seo.setJupyterMessage(new Message());
    seo.finished(OutputCell.HIDDEN);
    // when
    List<MessageHolder> messages = MessageCreator.createMessage(seo);
    // then
    messages.forEach(m -> assertThat(JupyterMessages.EXECUTE_RESULT).isNotEqualTo(m.getMessage().type()));
}
Also used : MessageHolder(com.twosigma.beakerx.kernel.msg.MessageHolder) Message(com.twosigma.beakerx.message.Message) SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 58 with Message

use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.

the class CodeFactoryTest method shouldBuildCodeWithCombinationOfCodeAndMagic.

@Test
public void shouldBuildCodeWithCombinationOfCodeAndMagic() {
    // given
    String codeAsString = "" + "println(1)\n" + "%time 1+1\n" + "println(2)\n" + "%time 1+2\n";
    // when
    Code code = CodeFactory.create(codeAsString, new Message(), kernel);
    // then
    assertThat(code.getCodeFrames().size()).isEqualTo(4);
}
Also used : Message(com.twosigma.beakerx.message.Message) Code(com.twosigma.beakerx.kernel.Code) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 59 with Message

use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.

the class CodeFactoryTest method shouldNotModifyCode.

@Test
public void shouldNotModifyCode() {
    String codeAsString = "%time println(\"x  y\")";
    // when
    Code code = CodeFactory.create(codeAsString, new Message(), kernel);
    // then
    assertThat(((MagicCommand) code.getCodeFrames().get(0)).getCommand()).isEqualTo(codeAsString);
}
Also used : Message(com.twosigma.beakerx.message.Message) Code(com.twosigma.beakerx.kernel.Code) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 60 with Message

use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.

the class MagicCommandResultOrderTest method classpathAddJarShouldBeLast.

@Test
public void classpathAddJarShouldBeLast() {
    // given
    String allCode = "" + "%classpath\n" + "%classpath add jar " + DOC_CONTENTS_DEMO_RESOURCES_BEAKERX_TEST_LIBRARY_JAR + "\n";
    Code code = CodeFactory.create(allCode, new Message(), kernel);
    // when
    code.execute(kernel, 1);
    // then
    MagicCommand actual = (MagicCommand) code.getCodeFrames().get(1);
    assertThat(actual.getCommand()).contains("%classpath add 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)

Aggregations

Message (com.twosigma.beakerx.message.Message)270 Test (org.junit.Test)170 KernelTest (com.twosigma.beakerx.KernelTest)121 EvaluatorResultTestWatcher.waitForIdleMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForIdleMessage)64 EvaluatorTest (com.twosigma.beakerx.evaluator.EvaluatorTest)57 Code (com.twosigma.beakerx.kernel.Code)55 Serializable (java.io.Serializable)36 MessageFactoryTest.getExecuteRequestMessage (com.twosigma.beakerx.MessageFactoryTest.getExecuteRequestMessage)35 EvaluatorResultTestWatcher.waitForErrorMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForErrorMessage)28 MessageTest (com.twosigma.beakerx.message.MessageTest)27 Map (java.util.Map)26 HashMap (java.util.HashMap)24 Header (com.twosigma.beakerx.message.Header)23 MessageAssertions.verifyExecuteReplyMessage (com.twosigma.MessageAssertions.verifyExecuteReplyMessage)19 EvaluatorResultTestWatcher.waitForSentMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForSentMessage)19 PlainCode (com.twosigma.beakerx.kernel.PlainCode)14 KernelExecutionTest (com.twosigma.beakerx.KernelExecutionTest)13 EvaluatorResultTestWatcher.waitForUpdateMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForUpdateMessage)13 LinkedHashMap (java.util.LinkedHashMap)12 SimpleEvaluationObject (com.twosigma.beakerx.jvm.object.SimpleEvaluationObject)11