use of com.scalar.db.api.Delete in project scalardb by scalar-labs.
the class DeleteStatementHandlerTest method prepareDeleteWithClusteringKey.
private Delete prepareDeleteWithClusteringKey() {
Key partitionKey = new Key(ANY_NAME_1, ANY_TEXT_1);
Key clusteringKey = new Key(ANY_NAME_2, ANY_TEXT_2);
return new Delete(partitionKey, clusteringKey).forNamespace(ANY_NAMESPACE_NAME).forTable(ANY_TABLE_NAME);
}
use of com.scalar.db.api.Delete in project scalardb by scalar-labs.
the class OperationCheckerTest method whenCheckingDeleteOperationWithAllValidArguments_shouldNotThrowAnyException.
@Test
public void whenCheckingDeleteOperationWithAllValidArguments_shouldNotThrowAnyException() {
// Arrange
Key partitionKey = new Key(PKEY1, 1, PKEY2, "val1");
Key clusteringKey = new Key(CKEY1, 2, CKEY2, "val1");
MutationCondition condition = new DeleteIf(new ConditionalExpression(COL1, new IntValue(1), ConditionalExpression.Operator.EQ));
Delete delete = new Delete(partitionKey, clusteringKey).withCondition(condition).forNamespace(NAMESPACE).forTable(TABLE_NAME);
// Act Assert
assertThatCode(() -> operationChecker.check(delete)).doesNotThrowAnyException();
}
use of com.scalar.db.api.Delete in project scalardb by scalar-labs.
the class OperationCheckerTest method whenCheckingDeleteOperationWithPutIfCondition_shouldThrowIllegalArgumentException.
@Test
public void whenCheckingDeleteOperationWithPutIfCondition_shouldThrowIllegalArgumentException() {
// Arrange
Key partitionKey = new Key(PKEY1, 1, PKEY2, "val1");
Key clusteringKey = new Key(CKEY1, 2, CKEY2, "val1");
MutationCondition condition = new PutIf();
Delete delete = new Delete(partitionKey, clusteringKey).withCondition(condition).forNamespace(NAMESPACE).forTable(TABLE_NAME);
// Act Assert
assertThatThrownBy(() -> operationChecker.check(delete)).isInstanceOf(IllegalArgumentException.class);
}
use of com.scalar.db.api.Delete in project scalardb by scalar-labs.
the class OperationCheckerTest method whenCheckingMutateOperationWithAllValidArguments_shouldNotThrowAnyException.
@Test
public void whenCheckingMutateOperationWithAllValidArguments_shouldNotThrowAnyException() {
// Arrange
Key partitionKey = new Key(PKEY1, 1, PKEY2, "val1");
Key clusteringKey = new Key(CKEY1, 2, CKEY2, "val1");
Put put = new Put(partitionKey, clusteringKey).withValue(COL1, 1).forNamespace(NAMESPACE).forTable(TABLE_NAME);
Delete delete = new Delete(partitionKey, clusteringKey).forNamespace(NAMESPACE).forTable(TABLE_NAME);
// Act Assert
assertThatCode(() -> operationChecker.check(Arrays.asList(put, delete))).doesNotThrowAnyException();
}
use of com.scalar.db.api.Delete in project scalardb by scalar-labs.
the class JdbcDatabaseTest method whenDeleteOperationExecuted_shouldCallJdbcService.
@Test
public void whenDeleteOperationExecuted_shouldCallJdbcService() throws Exception {
// Arrange
when(jdbcService.delete(any(), any())).thenReturn(true);
// Act
Delete delete = new Delete(new Key("p1", "val1")).forNamespace(NAMESPACE).forTable(TABLE);
jdbcDatabase.delete(delete);
// Assert
verify(jdbcService).delete(any(), any());
verify(connection).close();
}
Aggregations