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());
}
Aggregations