use of com.twosigma.beakerx.kernel.Code in project beakerx by twosigma.
the class GroovyKernelTest method shouldImportStaticFieldDemoClassByMagicCommand.
@Test
public void shouldImportStaticFieldDemoClassByMagicCommand() throws Exception {
// given
addDemoJar();
String path = pathToDemoClassFromAddedDemoJar() + ".STATIC_TEST_123";
// when
Code code = CodeFactory.create(ADD_STATIC_IMPORT + " " + path, new Message(), getKernel());
code.execute(kernel, 1);
// then
verifyStaticImportedDemoClassByMagicCommand(pathToDemoClassFromAddedDemoJar() + ".STATIC_TEST_123");
}
use of com.twosigma.beakerx.kernel.Code in project beakerx by twosigma.
the class GroovyKernelTest method shouldImportStaticWildcardDemoClassByMagicCommand.
@Test
public void shouldImportStaticWildcardDemoClassByMagicCommand() throws Exception {
// given
addDemoJar();
String path = pathToDemoClassFromAddedDemoJar() + ".*";
// when
Code code = CodeFactory.create(ADD_STATIC_IMPORT + " " + path, new Message(), getKernel());
code.execute(kernel, 1);
// then
verifyStaticImportedDemoClassByMagicCommand(pathToDemoClassFromAddedDemoJar() + ".staticTest()");
verifyStaticImportedDemoClassByMagicCommand(pathToDemoClassFromAddedDemoJar() + ".STATIC_TEST_123");
}
use of com.twosigma.beakerx.kernel.Code in project beakerx by twosigma.
the class SQLMagicCommandTest method handleDefaultDatasourceMagicCommand.
@Test
public void handleDefaultDatasourceMagicCommand() throws Exception {
// given
String codeAsString = DEFAULT_DATASOURCE + " jdbc:h2:mem:db1";
MagicCommand command = new MagicCommand(new DefaultDataSourcesMagicCommand(kernel), codeAsString);
Code code = Code.createCode(codeAsString, singletonList(command), NO_ERRORS, new Message());
// when
code.execute(kernel, 1);
// then
assertThat(getDefaultDatasource().get()).isEqualTo("jdbc:h2:mem:db1");
}
use of com.twosigma.beakerx.kernel.Code in project beakerx by twosigma.
the class SQLMagicCommandTest method handleDatasourceMagicCommand.
@Test
public void handleDatasourceMagicCommand() throws Exception {
// given
String codeAsString = DATASOURCES + " jdbc:h2:mem:db2";
MagicCommand command = new MagicCommand(new DataSourcesMagicCommand(kernel), codeAsString);
Code code = Code.createCode(codeAsString, singletonList(command), NO_ERRORS, new Message());
// when
code.execute(kernel, 1);
// then
assertThat(getDatasource().get()).isEqualTo("jdbc:h2:mem:db2");
}
use of com.twosigma.beakerx.kernel.Code in project beakerx by twosigma.
the class ClasspathAddMvnDepsCellMagicCommandTest method handleUnresolvedDep.
@Test
public void handleUnresolvedDep() throws Exception {
String allCode = "%%classpath add mvn\n" + "com.google.code.XXXX:gson:2.6.2";
// given
MagicCommand command = new MagicCommand(new ClassPathAddMvnCellMagicCommand(kernel.mavenResolverParam, kernel), allCode);
Code code = Code.createCode(allCode, Collections.singletonList(command), NO_ERRORS, new Message());
// when
code.execute(kernel, 1);
// then
List<Message> stderr = EvaluatorResultTestWatcher.getStderr(kernel.getPublishedMessages());
String text = (String) stderr.get(0).getContent().get("text");
Assertions.assertThat(text).contains("Could not resolve dependencies for:");
Assertions.assertThat(text).contains("com.google.code.XXXX : gson : 2.6.2");
}
Aggregations