use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.
the class CassandraInterpreterTest method should_bind_null_value.
@Test
public void should_bind_null_value() throws Exception {
//Given
String queries = "@prepare[bind_null]=INSERT INTO zeppelin.users(login,firstname,lastname) VALUES(?,?,?)\n" + "@bind[bind_null]='bind_null',null,'NULL'\n" + "SELECT firstname,lastname FROM zeppelin.users WHERE login='bind_null';";
//When
final InterpreterResult actual = interpreter.interpret(queries, intrContext);
//Then
assertThat(actual.code()).isEqualTo(Code.SUCCESS);
assertThat(actual.message().get(0).getData()).isEqualTo("firstname\tlastname\n" + "null\tNULL\n");
}
use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.
the class CassandraInterpreterTest method should_display_statistics_for_non_select_statement.
@Test
public void should_display_statistics_for_non_select_statement() throws Exception {
//Given
String query = "USE zeppelin;\nCREATE TABLE IF NOT EXISTS no_select(id int PRIMARY KEY);";
final String rawResult = reformatHtml(readTestResource("/scalate/NoResultWithExecutionInfo.html"));
//When
final InterpreterResult actual = interpreter.interpret(query, intrContext);
final Cluster cluster = session.getCluster();
final int port = cluster.getConfiguration().getProtocolOptions().getPort();
final String address = cluster.getMetadata().getAllHosts().iterator().next().getAddress().getHostAddress().replaceAll("/", "").replaceAll("\\[", "").replaceAll("\\]", "");
//Then
final String expected = rawResult.replaceAll("TRIED_HOSTS", address + ":" + port).replaceAll("QUERIED_HOSTS", address + ":" + port);
assertThat(actual.code()).isEqualTo(Code.SUCCESS);
assertThat(reformatHtml(actual.message().get(0).getData())).isEqualTo(expected);
}
use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.
the class CassandraInterpreterTest method should_execute_prepared_and_bound_statements.
@Test
public void should_execute_prepared_and_bound_statements() throws Exception {
//Given
String queries = "@prepare[ps]=INSERT INTO zeppelin.prepared(key,val) VALUES(?,?)\n" + "@prepare[select]=SELECT * FROM zeppelin.prepared WHERE key=:key\n" + "@bind[ps]='myKey','myValue'\n" + "@bind[select]='myKey'";
//When
final InterpreterResult actual = interpreter.interpret(queries, intrContext);
//Then
assertThat(actual.code()).isEqualTo(Code.SUCCESS);
assertThat(actual.message().get(0).getData()).isEqualTo("key\tval\n" + "myKey\tmyValue\n");
}
use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.
the class CassandraInterpreterTest method should_error_and_display_stack_trace.
@Test
public void should_error_and_display_stack_trace() throws Exception {
//Given
String query = "@consistency=THREE\n" + "SELECT * FROM zeppelin.users LIMIT 3;";
//When
final InterpreterResult actual = interpreter.interpret(query, intrContext);
//Then
assertThat(actual.code()).isEqualTo(Code.ERROR);
assertThat(actual.message().get(0).getData()).contains("All host(s) tried for query failed");
}
use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.
the class AlluxioInterpreterTest method mkdirComplexPathTest.
@Test
public void mkdirComplexPathTest() throws IOException, AlluxioException {
InterpreterResult output = alluxioInterpreter.interpret("mkdir /Complex!@#$%^&*()-_=+[]{};\"'<>,.?/File", null);
boolean existsDir = fs.exists(new AlluxioURI("/Complex!@#$%^&*()-_=+[]{};\"'<>,.?/File"));
Assert.assertEquals("Successfully created directory /Complex!@#$%^&*()-_=+[]{};\"'<>,.?/File\n\n", output.message().get(0).getData());
Assert.assertTrue(existsDir);
}
Aggregations