use of com.scalar.db.api.Delete in project scalardb by scalar-labs.
the class ConsensusCommitIntegrationTestBase method commit_DeleteGivenWithoutRead_ShouldThrowIllegalArgumentException.
@Test
public void commit_DeleteGivenWithoutRead_ShouldThrowIllegalArgumentException() {
// Arrange
Delete delete = prepareDelete(0, 0, namespace1, TABLE_1);
ConsensusCommit transaction = manager.start();
// Act Assert
transaction.delete(delete);
assertThatCode(transaction::commit).isInstanceOf(CommitException.class).hasCauseInstanceOf(IllegalArgumentException.class);
}
use of com.scalar.db.api.Delete in project scalardb by scalar-labs.
the class JdbcTransactionIntegrationTest method prepareDelete.
private Delete prepareDelete(int id, int type, String namespace, String table) {
Key partitionKey = new Key(ACCOUNT_ID, id);
Key clusteringKey = new Key(ACCOUNT_TYPE, type);
return new Delete(partitionKey, clusteringKey).forNamespace(namespace).forTable(table).withConsistency(Consistency.LINEARIZABLE);
}
use of com.scalar.db.api.Delete in project scalardb by scalar-labs.
the class JdbcTransactionIntegrationTest method commit_DeleteGivenForExistingAfterRead_ShouldDeleteRecord.
@Test
public void commit_DeleteGivenForExistingAfterRead_ShouldDeleteRecord() throws TransactionException {
// Arrange
populateRecords();
Get get = prepareGet(0, 0, NAMESPACE, TABLE);
Delete delete = prepareDelete(0, 0, NAMESPACE, TABLE);
JdbcTransaction transaction = manager.start();
// Act
Optional<Result> result = transaction.get(get);
transaction.delete(delete);
transaction.commit();
// Assert
assertThat(result.isPresent()).isTrue();
JdbcTransaction another = manager.start();
Optional<Result> result1 = another.get(get);
another.commit();
assertThat(result1.isPresent()).isFalse();
}
use of com.scalar.db.api.Delete in project scalardb by scalar-labs.
the class DistributedTransactionServiceWithJdbcTransactionIntegrationTest method commit_DeleteGivenForExistingAfterRead_ShouldDeleteRecord.
@Test
public void commit_DeleteGivenForExistingAfterRead_ShouldDeleteRecord() throws TransactionException {
// Arrange
populateRecords();
Get get = prepareGet(0, 0, NAMESPACE, TABLE);
Delete delete = prepareDelete(0, 0, NAMESPACE, TABLE);
GrpcTransaction transaction = manager.start();
// Act
Optional<Result> result = transaction.get(get);
transaction.delete(delete);
transaction.commit();
// Assert
assertThat(result.isPresent()).isTrue();
GrpcTransaction another = manager.start();
Optional<Result> result1 = another.get(get);
another.commit();
assertThat(result1.isPresent()).isFalse();
}
use of com.scalar.db.api.Delete in project scalardb by scalar-labs.
the class DistributedTransactionServiceWithJdbcTransactionIntegrationTest method prepareDelete.
private Delete prepareDelete(int id, int type, String namespace, String table) {
Key partitionKey = new Key(ACCOUNT_ID, id);
Key clusteringKey = new Key(ACCOUNT_TYPE, type);
return new Delete(partitionKey, clusteringKey).forNamespace(namespace).forTable(table).withConsistency(Consistency.LINEARIZABLE);
}
Aggregations