Search in sources :

Example 71 with Message

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

the class ClasspathAddRepoMagicCommandTest method addMvnLocal.

public void addMvnLocal() {
    // given
    String allCode = CLASSPATH_CONFIG_RESOLVER + " " + MVN_LOCAL;
    Code code = CodeFactory.create(allCode, new Message(), kernel);
    // when
    code.execute(kernel, 1);
    // then
    List<Message> std = EvaluatorResultTestWatcher.getStdouts(kernel.getPublishedMessages());
    String text = (String) std.get(0).getContent().get("text");
    assertThat(text).contains(ADDED_NEW_REPO + MVN_LOCAL);
}
Also used : Message(com.twosigma.beakerx.message.Message) Code(com.twosigma.beakerx.kernel.Code)

Example 72 with Message

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

the class ClasspathAddRepoMagicCommandTest method addExternalRepo.

@Test
public void addExternalRepo() {
    // given
    String allCode = CLASSPATH_CONFIG_RESOLVER + " " + "externalRepo http://someExternalRepo";
    Code code = CodeFactory.create(allCode, new Message(), kernel);
    // when
    code.execute(kernel, 1);
    // then
    List<Message> std = EvaluatorResultTestWatcher.getStdouts(kernel.getPublishedMessages());
    String text = (String) std.get(0).getContent().get("text");
    assertThat(text).contains(ADDED_NEW_REPO + "externalRepo");
}
Also used : Message(com.twosigma.beakerx.message.Message) Code(com.twosigma.beakerx.kernel.Code) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest) EvaluatorTest(com.twosigma.beakerx.evaluator.EvaluatorTest)

Example 73 with Message

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

the class TimeCellModeMagicCommandTest method timeInCellMode.

@Test
public void timeInCellMode() {
    // given
    String allCode = "" + "%%time \n" + "a = [10,20,30,40,50]; \n" + "a= a.sum(); \n" + "a*10;";
    Code code = CodeFactory.create(allCode, new Message(), kernel);
    // when
    code.execute(kernel, 1);
    // then
    List<Message> std = EvaluatorResultTestWatcher.getStdouts(kernel.getPublishedMessages());
    String text = (String) std.get(0).getContent().get("text");
    assertThat(text).contains("CPU times:");
}
Also used : Message(com.twosigma.beakerx.message.Message) Code(com.twosigma.beakerx.kernel.Code) EvaluatorTest(com.twosigma.beakerx.evaluator.EvaluatorTest) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 74 with Message

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

the class KernelExecutionTest method shouldImportDemoClassByMagicCommand.

@Test
public void shouldImportDemoClassByMagicCommand() throws Exception {
    // given
    addDemoJar();
    String path = pathToDemoClassFromAddedDemoJar();
    // when
    Code code = CodeFactory.create(IMPORT + " " + path, new Message(), getKernel());
    code.execute(kernel, 1);
    // then
    verifyImportedDemoClassByMagicCommand();
}
Also used : MessageAssertions.verifyExecuteReplyMessage(com.twosigma.MessageAssertions.verifyExecuteReplyMessage) EvaluatorResultTestWatcher.waitForIdleMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForIdleMessage) Message(com.twosigma.beakerx.message.Message) MessageFactoryTest.getExecuteRequestMessage(com.twosigma.beakerx.MessageFactoryTest.getExecuteRequestMessage) EvaluatorResultTestWatcher.waitForErrorMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForErrorMessage) EvaluatorResultTestWatcher.waitForSentMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForSentMessage) Code(com.twosigma.beakerx.kernel.Code) Test(org.junit.Test)

Example 75 with Message

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

the class KernelExecutionTest method verifyImportedDemoClassByMagicCommand.

private void verifyImportedDemoClassByMagicCommand() throws InterruptedException {
    String allCode = getObjectTestMethodFromAddedDemoJar();
    Message message = getExecuteRequestMessage(allCode);
    getKernelSocketsService().handleMsg(message);
    Optional<Message> idleMessage = waitForIdleMessage(getKernelSocketsService().getKernelSockets());
    assertThat(idleMessage).isPresent();
    Optional<Message> result = waitForResult(getKernelSocketsService().getKernelSockets());
    checkResultForErrors(result, allCode);
    assertThat(result).isPresent();
    Map actual = ((Map) result.get().getContent().get(Comm.DATA));
    String value = (String) actual.get("text/plain");
    assertThat(value).isEqualTo("Demo_test_123");
}
Also used : MessageAssertions.verifyExecuteReplyMessage(com.twosigma.MessageAssertions.verifyExecuteReplyMessage) EvaluatorResultTestWatcher.waitForIdleMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForIdleMessage) Message(com.twosigma.beakerx.message.Message) MessageFactoryTest.getExecuteRequestMessage(com.twosigma.beakerx.MessageFactoryTest.getExecuteRequestMessage) EvaluatorResultTestWatcher.waitForErrorMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForErrorMessage) EvaluatorResultTestWatcher.waitForSentMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForSentMessage) Map(java.util.Map)

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