use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.
the class KernelSocketsZMQ method readMessage.
private Message readMessage(ZMQ.Socket socket) {
ZMsg zmsg = null;
Message message = new Message();
try {
zmsg = ZMsg.recvMsg(socket);
ZFrame[] parts = new ZFrame[zmsg.size()];
zmsg.toArray(parts);
byte[] uuid = parts[MessageParts.UUID].getData();
byte[] header = parts[MessageParts.HEADER].getData();
byte[] parent = parts[MessageParts.PARENT].getData();
byte[] metadata = parts[MessageParts.METADATA].getData();
byte[] content = parts[MessageParts.CONTENT].getData();
byte[] expectedSig = parts[MessageParts.HMAC].getData();
verifyDelim(parts[MessageParts.DELIM]);
verifySignatures(expectedSig, header, parent, metadata, content);
if (uuid != null) {
message.getIdentities().add(uuid);
}
message.setHeader(parse(header, Header.class));
message.setParentHeader(parse(parent, Header.class));
message.setMetadata(parse(metadata, LinkedHashMap.class));
message.setContent(parse(content, LinkedHashMap.class));
} finally {
if (zmsg != null) {
zmsg.destroy();
}
}
return message;
}
use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.
the class PasswordTest method verifyPasswordField.
public static void verifyPasswordField(List<Message> messages, String modelNameValue, String modelModuleValue, String viewNameValue, String viewModuleValue) {
Message widget = SearchMessages.getListWidgetsByViewName(messages, viewNameValue).get(0);
Message layout = SearchMessages.getLayoutForWidget(messages, widget);
verifyTypeMsg(widget, COMM_OPEN);
Map data = getState(widget);
assertThat(data.get(LAYOUT)).isEqualTo(IPY_MODEL + layout.getContent().get(Comm.COMM_ID));
assertThat(data.get(MODEL_NAME)).isEqualTo(modelNameValue);
assertThat(data.get(MODEL_MODULE)).isEqualTo(modelModuleValue);
assertThat(data.get(VIEW_NAME)).isEqualTo(viewNameValue);
assertThat(data.get(VIEW_MODULE)).isEqualTo(viewModuleValue);
}
use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.
the class BeakerxWidgetTest method verifyOpenCommMsgBeakerxWidget.
private void verifyOpenCommMsgBeakerxWidget(List<Message> messages, String modelNameValue, String viewNameValue) {
assertThat(messages.size()).isEqualTo(1);
Message widget = messages.get(0);
assertThat(widget.getHeader().getType()).isEqualTo(COMM_OPEN.getName());
Map data = TestWidgetUtils.getData(widget);
assertThat(data.get(Widget.MODEL_MODULE)).isEqualTo(BeakerxWidget.MODEL_MODULE_VALUE);
assertThat(data.get(Widget.VIEW_MODULE)).isEqualTo(BeakerxWidget.VIEW_MODULE_VALUE);
assertThat(data.get(Widget.MODEL_NAME)).isEqualTo(modelNameValue);
assertThat(data.get(Widget.VIEW_NAME)).isEqualTo(viewNameValue);
}
use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.
the class ImageTest method shouldSendCommMsgWhenValueChange.
@Test
public void shouldSendCommMsgWhenValueChange() throws Exception {
// given
Image widget = image();
// when
widget.setValue("picture".getBytes());
// then
Message message = groovyKernel.getPublishedMessages().get(0);
Map data = getData(message);
List<List<String>> o = (List) data.get(Comm.BUFFER_PATHS);
Assertions.assertThat(o.get(0).get(0)).isEqualTo("value");
}
use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.
the class OutputWidgetTest method submitCodeToExecution.
private Message submitCodeToExecution() {
SimpleEvaluationObject value = new SimpleEvaluationObject("output");
Message jupyterMessage = new Message();
value.setJupyterMessage(jupyterMessage);
InternalVariable.setValue(value);
return jupyterMessage;
}
Aggregations