Search in sources :

Example 86 with Message

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

the class GroovyKernelTest method shouldImportStaticMethodDemoClassByMagicCommand.

@Test
public void shouldImportStaticMethodDemoClassByMagicCommand() throws Exception {
    // given
    addDemoJar();
    String path = pathToDemoClassFromAddedDemoJar() + ".staticTest";
    // when
    Code code = CodeFactory.create(ADD_STATIC_IMPORT + " " + path, new Message(), getKernel());
    code.execute(kernel, 1);
    // then
    verifyStaticImportedDemoClassByMagicCommand(pathToDemoClassFromAddedDemoJar() + ".staticTest()");
}
Also used : MessageFactoryTest.getExecuteRequestMessage(com.twosigma.beakerx.MessageFactoryTest.getExecuteRequestMessage) EvaluatorResultTestWatcher.waitForIdleMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForIdleMessage) Message(com.twosigma.beakerx.message.Message) EvaluatorResultTestWatcher.waitForUpdateMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForUpdateMessage) Code(com.twosigma.beakerx.kernel.Code) KernelExecutionTest(com.twosigma.beakerx.KernelExecutionTest) Test(org.junit.Test)

Example 87 with Message

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

the class GroovyKernelTest method verifyStaticImportedDemoClassByMagicCommand.

protected void verifyStaticImportedDemoClassByMagicCommand(String path) throws InterruptedException {
    Message message = getExecuteRequestMessage(path);
    getKernelSocketsService().handleMsg(message);
    Optional<Message> idleMessage = waitForIdleMessage(getKernelSocketsService().getKernelSockets());
    assertThat(idleMessage).isPresent();
    Optional<Message> result = waitForResult(getKernelSocketsService().getKernelSockets());
    Map actual = ((Map) result.get().getContent().get(Comm.DATA));
    String value = (String) actual.get("text/plain");
    assertThat(value).isEqualTo("Demo_static_test_123");
}
Also used : MessageFactoryTest.getExecuteRequestMessage(com.twosigma.beakerx.MessageFactoryTest.getExecuteRequestMessage) EvaluatorResultTestWatcher.waitForIdleMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForIdleMessage) Message(com.twosigma.beakerx.message.Message) EvaluatorResultTestWatcher.waitForUpdateMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForUpdateMessage) HashMap(java.util.HashMap) Map(java.util.Map)

Example 88 with Message

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

the class GroovyKernelTest method shouldImportStaticFieldDemoClassByMagicCommand.

@Test
public void shouldImportStaticFieldDemoClassByMagicCommand() throws Exception {
    // given
    addDemoJar();
    String path = pathToDemoClassFromAddedDemoJar() + ".STATIC_TEST_123";
    // when
    Code code = CodeFactory.create(ADD_STATIC_IMPORT + " " + path, new Message(), getKernel());
    code.execute(kernel, 1);
    // then
    verifyStaticImportedDemoClassByMagicCommand(pathToDemoClassFromAddedDemoJar() + ".STATIC_TEST_123");
}
Also used : MessageFactoryTest.getExecuteRequestMessage(com.twosigma.beakerx.MessageFactoryTest.getExecuteRequestMessage) EvaluatorResultTestWatcher.waitForIdleMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForIdleMessage) Message(com.twosigma.beakerx.message.Message) EvaluatorResultTestWatcher.waitForUpdateMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForUpdateMessage) Code(com.twosigma.beakerx.kernel.Code) KernelExecutionTest(com.twosigma.beakerx.KernelExecutionTest) Test(org.junit.Test)

Example 89 with Message

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

the class GroovyKernelTest method shouldImportStaticWildcardDemoClassByMagicCommand.

@Test
public void shouldImportStaticWildcardDemoClassByMagicCommand() throws Exception {
    // given
    addDemoJar();
    String path = pathToDemoClassFromAddedDemoJar() + ".*";
    // when
    Code code = CodeFactory.create(ADD_STATIC_IMPORT + " " + path, new Message(), getKernel());
    code.execute(kernel, 1);
    // then
    verifyStaticImportedDemoClassByMagicCommand(pathToDemoClassFromAddedDemoJar() + ".staticTest()");
    verifyStaticImportedDemoClassByMagicCommand(pathToDemoClassFromAddedDemoJar() + ".STATIC_TEST_123");
}
Also used : MessageFactoryTest.getExecuteRequestMessage(com.twosigma.beakerx.MessageFactoryTest.getExecuteRequestMessage) EvaluatorResultTestWatcher.waitForIdleMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForIdleMessage) Message(com.twosigma.beakerx.message.Message) EvaluatorResultTestWatcher.waitForUpdateMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForUpdateMessage) Code(com.twosigma.beakerx.kernel.Code) KernelExecutionTest(com.twosigma.beakerx.KernelExecutionTest) Test(org.junit.Test)

Example 90 with Message

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

the class GroovyKernelTest method addOutputWidget.

private void addOutputWidget(String outputCommId) throws InterruptedException {
    Utils.setFixedCommUUID(outputCommId);
    String addWidget = "" + "import com.twosigma.beakerx.widget.Output\n" + "out2 = new Output()\n" + "OutputManager.setOutput(out2)\n" + "out2";
    Message addWidgetMessage = getExecuteRequestMessage(addWidget);
    kernelSocketsService.handleMsg(addWidgetMessage);
    Optional<Message> idleAddWidget = waitForIdleMessage(kernelSocketsService.getKernelSockets());
    assertThat(idleAddWidget).isPresent();
    kernelSocketsService.clear();
    Utils.setDefaultCommUUID();
}
Also used : MessageFactoryTest.getExecuteRequestMessage(com.twosigma.beakerx.MessageFactoryTest.getExecuteRequestMessage) EvaluatorResultTestWatcher.waitForIdleMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForIdleMessage) Message(com.twosigma.beakerx.message.Message) EvaluatorResultTestWatcher.waitForUpdateMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForUpdateMessage)

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