Search in sources :

Example 36 with Message

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

the class Display method displayMIMEContainers.

private static void displayMIMEContainers(List<MIMEContainer> result) {
    HashMap<String, Serializable> content = new HashMap<>();
    HashMap<String, Object> data = new HashMap<>();
    result.forEach(x -> data.put(x.getMime().asString(), x.getData()));
    content.put(DATA, data);
    content.put(METADATA, new HashMap<>());
    Message message = Comm.messageMessage(DISPLAY_DATA, Comm.Buffer.EMPTY, content, getParentHeader());
    KernelManager.get().publish(singletonList(message));
}
Also used : Serializable(java.io.Serializable) Message(com.twosigma.beakerx.message.Message) HashMap(java.util.HashMap)

Example 37 with Message

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

the class KernelInfoHandler method handleMsg.

private void handleMsg(Message message) {
    logger.debug("Processing kernel info request");
    Message reply = new Message();
    reply.setContent(content());
    reply.setHeader(new Header(KERNEL_INFO_REPLY, message.getHeader().getSession()));
    reply.setParentHeader(message.getHeader());
    reply.setIdentities(message.getIdentities());
    send(reply);
}
Also used : Message(com.twosigma.beakerx.message.Message) Header(com.twosigma.beakerx.message.Header)

Example 38 with Message

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

the class ClasspathAddMagicCommandTest method errorWhenIncompleteMagicCommand.

@Test
public void errorWhenIncompleteMagicCommand() {
    // given
    String allCode = ClasspathAddJarMagicCommand.CLASSPATH + " add garbage";
    Code code = CodeFactory.create(allCode, new Message(), kernel);
    // when
    code.execute(kernel, 1);
    // then
    List<Message> std = EvaluatorResultTestWatcher.getStderr(kernel.getPublishedMessages());
    String text = (String) std.get(0).getContent().get("text");
    assertThat(text).contains(" not found");
}
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 39 with Message

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

the class TableDisplayActionsTest method actionDetailsMessage.

private Message actionDetailsMessage() {
    Message message = new Message();
    message.setHeader(initHeader(JupyterMessages.COMM_MSG));
    Map<String, Serializable> content = new LinkedHashMap<>();
    content.put(COMM_ID, tableDisplay.getComm().getCommId());
    Map<String, Serializable> dataContent = new LinkedHashMap<>();
    dataContent.put("event", CommActions.ACTIONDETAILS.getAction());
    Map<String, Serializable> params = new LinkedHashMap<>();
    params.put("actionType", CONTEXT_MENU_CLICK.getAction());
    params.put("row", 1);
    params.put("col", 1);
    params.put("contextMenuItem", "run print cell");
    Map<String, Serializable> data = new LinkedHashMap<>();
    content.put("data", (Serializable) data);
    data.put("content", (Serializable) dataContent);
    dataContent.put("params", (Serializable) params);
    message.setContent(content);
    return message;
}
Also used : Serializable(java.io.Serializable) Message(com.twosigma.beakerx.message.Message) LinkedHashMap(java.util.LinkedHashMap)

Example 40 with Message

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

the class TableDisplayActionsTest method contextMenuActionShouldHaveDetails.

@Test
public void contextMenuActionShouldHaveDetails() throws Exception {
    // given
    Message message = contextMenuMessage();
    // when
    commMsgHandler.handle(message);
    // then
    assertThat(tableDisplay.getDetails()).isNotNull();
}
Also used : Message(com.twosigma.beakerx.message.Message) 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