Search in sources :

Example 1 with ClasspathResetMagicCommand

use of com.twosigma.beakerx.kernel.magic.command.functionality.ClasspathResetMagicCommand in project beakerx by twosigma.

the class ClasspathAddMvnDepsMagicCommandTest method handleClasspathReset.

@Test
public void handleClasspathReset() throws Exception {
    // given
    String allCode = CLASSPATH_ADD_MVN + " com.google.code.gson:gson:2.6.2";
    handleClasspathAddMvnDep(allCode, "gson-2.6.2.jar");
    kernel.clearMessages();
    ClasspathAddMvnMagicCommand mvnMagicCommand = MagicCommandTypesFactory.getClasspathAddMvnMagicCommand(kernel);
    mvnMagicCommand.addRepo("jcenter", "jcenter");
    // when
    String resetCode = CLASSPATH_RESET;
    ClasspathResetMagicCommand resetMagicCommand = MagicCommandTypesFactory.getClasspathResetMagicCommand(kernel);
    MagicCommand command = new MagicCommand(resetMagicCommand, resetCode);
    Code code = Code.createCode(resetCode, singletonList(command), NO_ERRORS, new Message());
    code.execute(kernel, 1);
    // then
    List<Message> stderr = EvaluatorResultTestWatcher.getStdouts(kernel.getPublishedMessages());
    String text = (String) stderr.get(0).getContent().get("text");
    assertThat(text).contains("Reset done");
    boolean cache = Files.exists(Paths.get(mvnMagicCommand.getCommandParams().getPathToCache()));
    Assert.assertFalse(cache);
    boolean jars = Files.exists(Paths.get(mvnMagicCommand.getCommandParams().getPathToNotebookJars()));
    Assert.assertFalse(jars);
    Assert.assertTrue(mvnMagicCommand.getRepos().get().isEmpty());
}
Also used : ClasspathAddMvnMagicCommand(com.twosigma.beakerx.kernel.magic.command.functionality.ClasspathAddMvnMagicCommand) Message(com.twosigma.beakerx.message.Message) ClasspathResetMagicCommand(com.twosigma.beakerx.kernel.magic.command.functionality.ClasspathResetMagicCommand) ClasspathResetMagicCommand(com.twosigma.beakerx.kernel.magic.command.functionality.ClasspathResetMagicCommand) ClasspathAddMvnMagicCommand(com.twosigma.beakerx.kernel.magic.command.functionality.ClasspathAddMvnMagicCommand) Code(com.twosigma.beakerx.kernel.Code) EvaluatorTest(com.twosigma.beakerx.evaluator.EvaluatorTest) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Aggregations

KernelTest (com.twosigma.beakerx.KernelTest)1 EvaluatorTest (com.twosigma.beakerx.evaluator.EvaluatorTest)1 Code (com.twosigma.beakerx.kernel.Code)1 ClasspathAddMvnMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.ClasspathAddMvnMagicCommand)1 ClasspathResetMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.ClasspathResetMagicCommand)1 Message (com.twosigma.beakerx.message.Message)1 Test (org.junit.Test)1