Search in sources :

Example 1 with BatchStatement

use of com.datastax.oss.driver.api.core.cql.BatchStatement 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);
}
Also used : BatchableStatement(com.datastax.oss.driver.api.core.cql.BatchableStatement) SimpleStatement(com.datastax.oss.driver.api.core.cql.SimpleStatement) BatchStatement(com.datastax.oss.driver.api.core.cql.BatchStatement) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

BatchStatement (com.datastax.oss.driver.api.core.cql.BatchStatement)1 BatchableStatement (com.datastax.oss.driver.api.core.cql.BatchableStatement)1 SimpleStatement (com.datastax.oss.driver.api.core.cql.SimpleStatement)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1