use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.
the class ClasspathMagicCommandTest method handleClasspathAddJarMagicCommand.
@Test
public void handleClasspathAddJarMagicCommand() {
// given
String allCode = "" + CLASSPATH_ADD_JAR + " " + CLASSPATH_TO_JAR_PATH + "\n" + "code code code";
Code code = CodeFactory.create(allCode, new Message(), kernel);
// when
code.execute(kernel, 1);
// then
PlainCode actual = (PlainCode) code.getCodeFrames().get(1);
Assertions.assertThat(actual.getPlainCode()).isEqualTo("code code code");
assertThat(kernel.getClasspath().get(0)).contains(FOO_JAR);
}
use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.
the class ClasspathMagicCommandTest method shouldCreateMsgWithWrongMagic.
@Test
public void shouldCreateMsgWithWrongMagic() {
// given
String jar = SRC_TEST_RESOURCES + "BeakerXClasspathTest.jar";
Code code = CodeFactory.create("%classpath2 add jar" + " " + jar, 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("Inline magic %classpath2 add jar ./src/test/resources/BeakerXClasspathTest.jar not found\n");
assertThat(kernel.getClasspath().size()).isEqualTo(0);
}
use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.
the class ImportMagicCommandTest method addImport.
@Test
public void addImport() {
// given
String allCode = "%import com.twosigma.beakerx.widget.IntSlider\n" + "w = new IntSlider()";
Code code = CodeFactory.create(allCode, new Message(), kernel);
// when
code.execute(kernel, 1);
// then
PlainCode actual = (PlainCode) code.getCodeFrames().get(1);
assertThat(actual.getPlainCode()).isEqualTo("w = new IntSlider()");
assertThat(kernel.getImports().getImportPaths()).contains(new ImportPath("com.twosigma.beakerx.widget.IntSlider"));
}
use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.
the class ImportMagicCommandTest method wrongImportFormat.
@Test
public void wrongImportFormat() {
String allCode = "%import ";
Code wrongFormatImport = CodeFactory.create(allCode, new Message(), kernel);
wrongFormatImport.execute(kernel, 1);
List<Message> std = EvaluatorResultTestWatcher.getStderr(kernel.getPublishedMessages());
String text = (String) std.get(0).getContent().get("text");
assertThat(text).contains("Wrong format.");
}
use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.
the class ClasspathAddDynamicMagicCommandTest method runCode.
private void runCode(String code) throws InterruptedException {
Message message = JupyterHandlerTest.createExecuteRequestMessage(code);
kernelSocketsService.handleMsg(message);
Optional<Message> idleMessage = waitForIdleMessage(kernelSocketsService.getKernelSockets());
assertThat(idleMessage).isPresent();
kernelSocketsService.clear();
}
Aggregations