use of com.datastax.oss.driver.api.core.cql.BatchableStatement in project zeppelin by apache.
the class InterpreterLogicTest method should_generate_batch_statement.
@Test
public void should_generate_batch_statement() {
// Given
SimpleStatement st1 = SimpleStatement.newInstance("SELECT * FROM users LIMIT 10;");
SimpleStatement st2 = SimpleStatement.newInstance("INSERT INTO users(id) VALUES(10);");
SimpleStatement st3 = SimpleStatement.newInstance("UPDATE users SET name = 'John DOE' WHERE id=10;");
CassandraQueryOptions options = new CassandraQueryOptions(Option.apply(QUORUM), Option.empty(), Option.empty(), Option.empty(), Option.empty());
// When
BatchStatement actual = helper.generateBatchStatement(UNLOGGED, options, toScalaList(asList(st1, st2, st3)));
// Then
assertThat(actual).isNotNull();
List<BatchableStatement> statements = new ArrayList<>();
for (BatchableStatement b : actual) {
statements.add(b);
}
assertThat(statements).hasSize(3);
assertThat(statements.get(0)).isSameAs(st1);
assertThat(statements.get(1)).isSameAs(st2);
assertThat(statements.get(2)).isSameAs(st3);
assertThat(actual.getConsistencyLevel()).isSameAs(QUORUM);
}
Aggregations