Search in sources :

Example 46 with Message

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

the class CommOpenHandlerTest method handleMessage_sentMessageHasTargetName.

@Test
public void handleMessage_sentMessageHasTargetName() throws Exception {
    // given
    String expectedTargetName = (String) message.getContent().get(TARGET_NAME);
    // when
    commOpenHandler.handle(message);
    // then
    Assertions.assertThat(kernel.getSentMessages()).isNotEmpty();
    Message sendMessage = kernel.getSentMessages().get(0);
    Assertions.assertThat(sendMessage.getContent().get(TARGET_NAME)).isEqualTo(expectedTargetName);
}
Also used : Message(com.twosigma.beakerx.message.Message) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 47 with Message

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

the class CommOpenHandlerTest method handleMessage_sentMessageHasCommId.

@Test
public void handleMessage_sentMessageHasCommId() throws Exception {
    // given
    String expectedCommId = (String) message.getContent().get(COMM_ID);
    // when
    commOpenHandler.handle(message);
    // then
    Assertions.assertThat(kernel.getSentMessages()).isNotEmpty();
    Message sendMessage = kernel.getSentMessages().get(0);
    Assertions.assertThat(sendMessage.getContent().get(COMM_ID)).isEqualTo(expectedCommId);
}
Also used : Message(com.twosigma.beakerx.message.Message) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 48 with Message

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

the class CommOpenHandlerTest method setUp.

@Before
public void setUp() {
    kernel = new KernelTest();
    commOpenHandler = new CommOpenHandler(kernel) {

        @Override
        public Handler<Message>[] getKernelControlChanelHandlers(String targetName) {
            return (Handler<Message>[]) new Handler<?>[0];
        }
    };
    message = JupyterHandlerTest.initOpenMessage();
}
Also used : Message(com.twosigma.beakerx.message.Message) KernelTest(com.twosigma.beakerx.KernelTest) CommOpenHandler(com.twosigma.beakerx.kernel.handler.CommOpenHandler) Handler(com.twosigma.beakerx.handler.Handler) CommOpenHandler(com.twosigma.beakerx.kernel.handler.CommOpenHandler) Before(org.junit.Before)

Example 49 with Message

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

the class ExecuteRequestHandlerTest method setUpClass.

@BeforeClass
public static void setUpClass() {
    evaluatorTest = new EvaluatorTest();
    kernel = new KernelTest("sid", evaluatorTest) {

        @Override
        public void publish(List<Message> message) {
            super.publish(message.stream().map(ExecuteRequestHandlerTest::copyMessage).collect(Collectors.toList()));
        }
    };
}
Also used : EvaluatorResultTestWatcher.waitForIdleMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForIdleMessage) Message(com.twosigma.beakerx.message.Message) EvaluatorResultTestWatcher.waitForErrorMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForErrorMessage) KernelTest(com.twosigma.beakerx.KernelTest) EvaluatorTest(com.twosigma.beakerx.evaluator.EvaluatorTest) BeforeClass(org.junit.BeforeClass)

Example 50 with Message

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

the class ExecuteRequestHandlerTest method handleMessage_secondSentMessageHasContentExecutionCount.

@Test
public void handleMessage_secondSentMessageHasContentExecutionCount() throws Exception {
    // when
    executeRequestHandler.handle(message);
    waitForIdleMessage(kernel);
    // then
    assertThat(kernel.getPublishedMessages()).isNotEmpty();
    Message publishMessage = kernel.getPublishedMessages().get(1);
    assertThat(publishMessage.getContent().get("execution_count")).isNotNull();
}
Also used : EvaluatorResultTestWatcher.waitForIdleMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForIdleMessage) Message(com.twosigma.beakerx.message.Message) EvaluatorResultTestWatcher.waitForErrorMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForErrorMessage) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest) EvaluatorTest(com.twosigma.beakerx.evaluator.EvaluatorTest)

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