use of com.scalar.db.api.Get in project scalardb by scalar-labs.
the class StorageWithReservedKeywordIntegrationTestBase method get_GetWithReservedKeywordAndPartitionKeyAndClusteringKeyGiven_ShouldRetrieveSingleResult.
@Test
public void get_GetWithReservedKeywordAndPartitionKeyAndClusteringKeyGiven_ShouldRetrieveSingleResult() throws ExecutionException {
// Arrange
populateRecords();
int pKey = 0;
// Act
Get get = prepareGet(pKey, 0);
Optional<Result> actual = storage.get(get);
// Assert
assertThat(actual.isPresent()).isTrue();
assertThat(actual.get().getValue(columnName1)).isEqualTo(Optional.of(new IntValue(columnName1, pKey)));
assertThat(actual.get().getValue(columnName4)).isEqualTo(Optional.of(new IntValue(columnName4, 0)));
}
use of com.scalar.db.api.Get in project scalardb by scalar-labs.
the class ConsensusCommitIntegrationTestBase method get_DeleteCalledBefore_ShouldReturnEmpty.
@Test
public void get_DeleteCalledBefore_ShouldReturnEmpty() throws CommitException, UnknownTransactionStatusException, CrudException {
// Arrange
ConsensusCommit transaction = manager.start();
transaction.put(preparePut(0, 0, namespace1, TABLE_1).withValue(BALANCE, 1));
transaction.commit();
// Act
ConsensusCommit transaction1 = manager.start();
Get get = prepareGet(0, 0, namespace1, TABLE_1);
Optional<Result> resultBefore = transaction1.get(get);
transaction1.delete(prepareDelete(0, 0, namespace1, TABLE_1));
Optional<Result> resultAfter = transaction1.get(get);
assertThatCode(transaction1::commit).doesNotThrowAnyException();
// Assert
assertThat(resultBefore.isPresent()).isTrue();
assertThat(resultAfter.isPresent()).isFalse();
}
use of com.scalar.db.api.Get in project scalardb by scalar-labs.
the class ConsensusCommitIntegrationTestBase method commit_DeleteGivenForNonExisting_ShouldThrowIllegalArgumentException.
@Test
public void commit_DeleteGivenForNonExisting_ShouldThrowIllegalArgumentException() throws CrudException {
// Arrange
Get get = prepareGet(0, 0, namespace1, TABLE_1);
Delete delete = prepareDelete(0, 0, namespace1, TABLE_1);
ConsensusCommit transaction = manager.start();
// Act Assert
transaction.get(get);
transaction.delete(delete);
assertThatCode(transaction::commit).isInstanceOf(CommitException.class).hasCauseInstanceOf(IllegalArgumentException.class);
}
use of com.scalar.db.api.Get in project scalardb by scalar-labs.
the class ConsensusCommitIntegrationTestBase method delete_PutCalledBefore_ShouldDelete.
@Test
public void delete_PutCalledBefore_ShouldDelete() throws CommitException, UnknownTransactionStatusException, CrudException {
// Arrange
ConsensusCommit transaction = manager.start();
transaction.put(preparePut(0, 0, namespace1, TABLE_1).withValue(BALANCE, 1));
transaction.commit();
// Act
ConsensusCommit transaction1 = manager.start();
Get get = prepareGet(0, 0, namespace1, TABLE_1);
Optional<Result> resultBefore = transaction1.get(get);
transaction1.put(preparePut(0, 0, namespace1, TABLE_1).withValue(BALANCE, 2));
transaction1.delete(prepareDelete(0, 0, namespace1, TABLE_1));
assertThatCode(transaction1::commit).doesNotThrowAnyException();
// Assert
ConsensusCommit transaction2 = manager.start();
Optional<Result> resultAfter = transaction2.get(get);
transaction2.commit();
assertThat(resultBefore.isPresent()).isTrue();
assertThat(resultAfter.isPresent()).isFalse();
}
use of com.scalar.db.api.Get in project scalardb by scalar-labs.
the class ConsensusCommitIntegrationTestBase method commit_DeleteGivenForExistingAfterRead_ShouldDeleteRecord.
@Test
public void commit_DeleteGivenForExistingAfterRead_ShouldDeleteRecord() throws CommitException, UnknownTransactionStatusException, CrudException {
// Arrange
populateRecords(namespace1, TABLE_1);
Get get = prepareGet(0, 0, namespace1, TABLE_1);
Delete delete = prepareDelete(0, 0, namespace1, TABLE_1);
ConsensusCommit transaction = manager.start();
// Act
Optional<Result> result = transaction.get(get);
transaction.delete(delete);
transaction.commit();
// Assert
assertThat(result.isPresent()).isTrue();
ConsensusCommit another = manager.start();
assertThat(another.get(get).isPresent()).isFalse();
}
Aggregations