Search in sources :

Example 51 with Message

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

the class ExecuteRequestHandlerTest method handleMessage_secondSentMessageHasContentCode.

@Test
public void handleMessage_secondSentMessageHasContentCode() throws Exception {
    // given
    String expectedCode = (String) message.getContent().get("code");
    // when
    executeRequestHandler.handle(message);
    waitForIdleMessage(kernel);
    // then
    assertThat(kernel.getPublishedMessages()).isNotEmpty();
    Message publishMessage = kernel.getPublishedMessages().get(1);
    assertThat(publishMessage.getContent().get("code")).isEqualTo(expectedCode);
}
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)

Example 52 with Message

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

the class ExecuteRequestHandlerTest method handleMessage_firstSentMessageHasParentHeader.

@Test
public void handleMessage_firstSentMessageHasParentHeader() throws Exception {
    // given
    String expectedHeader = message.getHeader().asJson();
    // when
    executeRequestHandler.handle(message);
    waitForIdleMessage(kernel);
    // then
    assertThat(kernel.getPublishedMessages()).isNotEmpty();
    Message publishMessage = kernel.getPublishedMessages().get(0);
    assertThat(publishMessage.getParentHeader().asJson()).isEqualTo(expectedHeader);
}
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)

Example 53 with Message

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

the class ExecuteRequestHandlerTest method handleMessage_secondSendMessageHasTypeIsExecutionInput.

@Test
public void handleMessage_secondSendMessageHasTypeIsExecutionInput() throws Exception {
    // when
    executeRequestHandler.handle(message);
    waitForIdleMessage(kernel);
    // then
    assertThat(kernel.getPublishedMessages()).isNotEmpty();
    Message publishMessage = kernel.getPublishedMessages().get(1);
    assertThat(publishMessage.getHeader().getType()).isEqualTo(JupyterMessages.EXECUTE_INPUT.getName());
}
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)

Example 54 with Message

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

the class ExecuteRequestHandlerTest method handleMessage_firstSentMessageHasSessionId.

@Test
public void handleMessage_firstSentMessageHasSessionId() throws Exception {
    // given
    String expectedSessionId = message.getHeader().getSession();
    // when
    executeRequestHandler.handle(message);
    waitForIdleMessage(kernel);
    // then
    assertThat(kernel.getPublishedMessages()).isNotEmpty();
    Message publishMessage = kernel.getPublishedMessages().get(0);
    assertThat(publishMessage.getHeader().getSession()).isEqualTo(expectedSessionId);
}
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)

Example 55 with Message

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

the class ExecuteRequestHandlerTest method handleMessage_firstSentMessageHasExecutionStateIsBusy.

@Test
public void handleMessage_firstSentMessageHasExecutionStateIsBusy() throws Exception {
    // when
    executeRequestHandler.handle(message);
    waitForIdleMessage(kernel);
    // then
    assertThat(kernel.getPublishedMessages()).isNotEmpty();
    Message publishMessage = kernel.getPublishedMessages().get(0);
    assertThat(publishMessage.getContent().get("execution_state")).isEqualTo("busy");
}
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