use of com.twosigma.beakerx.kernel.msg.MessageHolder 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()));
}
use of com.twosigma.beakerx.kernel.msg.MessageHolder in project beakerx by twosigma.
the class MessageCreatorTest method createMessageWithNotNullResult_shouldReturnResult.
@Test
public void createMessageWithNotNullResult_shouldReturnResult() throws Exception {
// given
seo.finished("NotNullResult");
// when
List<MessageHolder> message = MessageCreator.createMessage(seo);
// then
Map data = TestWidgetUtils.getData(message.get(0).getMessage());
assertThat(data.get(MessageCreator.TEXT_PLAIN)).isEqualTo("NotNullResult");
}
use of com.twosigma.beakerx.kernel.msg.MessageHolder in project beakerx by twosigma.
the class MessageCreatorTest method createMessageForCollection.
// @Test
public void createMessageForCollection() throws Exception {
// given
seo.finished(asList("1", "2"));
// when
List<MessageHolder> message = MessageCreator.createMessage(seo);
// then
Map data = TestWidgetUtils.getData(message.get(0).getMessage());
assertThat(data.get(MessageCreator.TEXT_PLAIN)).isEqualTo("[\"1\",\"2\"]");
}
use of com.twosigma.beakerx.kernel.msg.MessageHolder in project beakerx by twosigma.
the class MessageCreatorTest method createMessageWithNullResult_shouldReturnNullStringForNull.
@Test
public void createMessageWithNullResult_shouldReturnNullStringForNull() throws Exception {
// given
seo.finished(null);
// when
List<MessageHolder> message = MessageCreator.createMessage(seo);
// then
Map data = TestWidgetUtils.getData(message.get(0).getMessage());
assertThat(data.get(MessageCreator.TEXT_PLAIN)).isEqualTo(NULL_RESULT);
}
use of com.twosigma.beakerx.kernel.msg.MessageHolder in project beakerx by twosigma.
the class ExecutionResultSender method update.
@Override
public synchronized void update(Observable o, Object arg) {
SimpleEvaluationObject seo = (SimpleEvaluationObject) o;
if (seo != null) {
List<MessageHolder> message = MessageCreator.createMessage(seo);
message.forEach(job -> {
if (SocketEnum.IOPUB_SOCKET.equals(job.getSocketType())) {
kernel.publish(singletonList(job.getMessage()));
} else if (SocketEnum.SHELL_SOCKET.equals(job.getSocketType())) {
kernel.send(job.getMessage());
}
});
}
}
Aggregations