Search in sources :

Example 31 with Message

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

the class ClojureKernelTest method evaluateFibSeq.

@Test
public void evaluateFibSeq() throws Exception {
    // given
    String code = "" + "(def fib-seq-lazy \n" + "  ((fn rfib [a b] \n" + "     (lazy-seq (cons a (rfib b (+ a b)))))\n" + "   0 1))\n" + "(take 20 fib-seq-lazy)";
    Message message = getExecuteRequestMessage(code);
    // when
    kernelSocketsService.handleMsg(message);
    // then
    Optional<Message> idleMessage = waitForIdleMessage(kernelSocketsService.getKernelSockets());
    assertThat(idleMessage).isPresent();
    Optional<Message> result = waitForResult(kernelSocketsService.getKernelSockets());
    checkResultForErrors(result, code);
    verifyResult(result.get());
    verifyPublishedMsgs(kernelSocketsService);
    waitForSentMessage(kernelSocketsService.getKernelSockets());
    verifySentMsgs(kernelSocketsService);
}
Also used : MessageAssertions.verifyExecuteReplyMessage(com.twosigma.MessageAssertions.verifyExecuteReplyMessage) MessageFactoryTest.getExecuteRequestMessage(com.twosigma.beakerx.MessageFactoryTest.getExecuteRequestMessage) EvaluatorResultTestWatcher.waitForIdleMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForIdleMessage) Message(com.twosigma.beakerx.message.Message) EvaluatorResultTestWatcher.waitForSentMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForSentMessage) KernelExecutionTest(com.twosigma.beakerx.KernelExecutionTest) KernelSocketsServiceTest(com.twosigma.beakerx.KernelSocketsServiceTest) Test(org.junit.Test)

Example 32 with Message

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

the class GroovyKernelInfoHandlerTest method handle_messageContentHasGroovyLabel.

@Test
public void handle_messageContentHasGroovyLabel() throws Exception {
    // when
    handler.handle(message);
    // then
    Message sentMessage = kernel.getSentMessages().get(0);
    Map<String, Serializable> map = sentMessage.getContent();
    Assertions.assertThat(map).isNotNull();
    Assertions.assertThat(map.get("implementation")).isEqualTo("groovy");
}
Also used : Serializable(java.io.Serializable) Message(com.twosigma.beakerx.message.Message) Test(org.junit.Test) MessageTest(com.twosigma.beakerx.message.MessageTest)

Example 33 with Message

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

the class ClojureKernelInfoHandlerTest method handle_sentMessageHasLanguageInfo.

@Test
public void handle_sentMessageHasLanguageInfo() throws Exception {
    // when
    handler.handle(message);
    // then
    Message sentMessage = kernel.getSentMessages().get(0);
    Map<String, Serializable> map = sentMessage.getContent();
    Assertions.assertThat(map).isNotNull();
    Assertions.assertThat(map.get("language_info")).isNotNull();
}
Also used : Serializable(java.io.Serializable) Message(com.twosigma.beakerx.message.Message) MessageTest(com.twosigma.beakerx.message.MessageTest) Test(org.junit.Test)

Example 34 with Message

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

the class ClojureKernelInfoHandlerTest method handle_sentMessageHasContent.

@Test
public void handle_sentMessageHasContent() throws Exception {
    // when
    handler.handle(message);
    // then
    Message sentMessage = kernel.getSentMessages().get(0);
    Assertions.assertThat(sentMessage.getContent()).isNotEmpty();
}
Also used : Message(com.twosigma.beakerx.message.Message) MessageTest(com.twosigma.beakerx.message.MessageTest) Test(org.junit.Test)

Example 35 with Message

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

the class GroovyOutputContainerTest method verifyPlot.

private void verifyPlot(List<Message> messages) {
    Message tableDisplay = messages.get(0);
    verifyInternalOpenCommMsg(tableDisplay, BeakerxPlot.MODEL_NAME_VALUE, BeakerxPlot.VIEW_NAME_VALUE);
// Message model = messages.get(1);
// assertThat(getValueForProperty(model, "model", Map.class)).isNotEmpty();
// verifyDisplayMsg(messages);
}
Also used : Message(com.twosigma.beakerx.message.Message)

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