use of org.apache.cassandra.cql3.statements.ModificationStatement in project cassandra by apache.
the class UFIdentificationTest method testBatchStatementWithConditions.
@Test
public void testBatchStatementWithConditions() throws Throwable {
List<ModificationStatement> statements = new ArrayList<>();
statements.add(modificationStatement(cql("UPDATE %s SET i_val = %s WHERE key=0 AND i_cc=0 and t_cc='foo' IF l_val = %s", functionCall(iFunc, "0"), functionCall(lFunc, "[1]"))));
statements.add(modificationStatement(cql("UPDATE %s SET i_val = %s WHERE key=0 AND i_cc=1 and t_cc='foo' IF s_val = %s", functionCall(iFunc, "0"), functionCall(sFunc, "{1}"))));
BatchStatement batch = new BatchStatement(BatchStatement.Type.LOGGED, VariableSpecifications.empty(), statements, Attributes.none());
assertFunctions(batch, iFunc, lFunc, sFunc);
}
use of org.apache.cassandra.cql3.statements.ModificationStatement in project cassandra by apache.
the class UFAuthTest method testBatchStatement.
@Test
public void testBatchStatement() throws Throwable {
List<ModificationStatement> statements = new ArrayList<>();
List<String> functions = new ArrayList<>();
for (int i = 0; i < 3; i++) {
String functionName = createSimpleFunction();
ModificationStatement stmt = (ModificationStatement) getStatement(String.format("INSERT INTO %s (k, v1, v2) " + "VALUES (%s, %s, %s)", KEYSPACE + "." + currentTable(), i, i, functionCall(functionName)));
functions.add(functionName);
statements.add(stmt);
}
BatchStatement batch = new BatchStatement(BatchStatement.Type.LOGGED, VariableSpecifications.empty(), statements, Attributes.none());
assertUnauthorized(batch, functions);
grantExecuteOnFunction(functions.get(0));
assertUnauthorized(batch, functions.subList(1, functions.size()));
grantExecuteOnFunction(functions.get(1));
assertUnauthorized(batch, functions.subList(2, functions.size()));
grantExecuteOnFunction(functions.get(2));
batch.authorize(clientState);
}
Aggregations