use of com.scalar.db.api.Get in project scalardb by scalar-labs.
the class ConsensusCommitIntegrationTestBase method get_GetGivenForPreparedWhenCoordinatorStateNotExistAndNotExpired_ShouldNotAbortTransaction.
@Test
public void get_GetGivenForPreparedWhenCoordinatorStateNotExistAndNotExpired_ShouldNotAbortTransaction() throws ExecutionException, CoordinatorException {
Get get = prepareGet(0, 0, namespace1, TABLE_1);
selection_SelectionGivenForPreparedWhenCoordinatorStateNotExistAndNotExpired_ShouldNotAbortTransaction(get);
}
use of com.scalar.db.api.Get in project scalardb by scalar-labs.
the class ConsensusCommitIntegrationTestBase method get_CalledTwiceAndAnotherTransactionCommitsInBetween_ShouldReturnFromSnapshotInSecondTime.
@Test
public void get_CalledTwiceAndAnotherTransactionCommitsInBetween_ShouldReturnFromSnapshotInSecondTime() throws CrudException, ExecutionException, CommitException, UnknownTransactionStatusException {
// Arrange
ConsensusCommit transaction = manager.start();
Get get = prepareGet(0, 0, namespace1, TABLE_1);
// Act
Optional<Result> result1 = transaction.get(get);
populateRecords(namespace1, TABLE_1);
Optional<Result> result2 = transaction.get(get);
// Assert
verify(storage).get(any(Get.class));
assertThat(result1).isEqualTo(result2);
}
use of com.scalar.db.api.Get in project scalardb by scalar-labs.
the class TwoPhaseConsensusCommitIntegrationTest method put_DeleteCalledBefore_ShouldThrowIllegalArgumentException.
@Test
public void put_DeleteCalledBefore_ShouldThrowIllegalArgumentException() throws TransactionException {
// Arrange
TwoPhaseConsensusCommit transaction = manager.start();
transaction.put(preparePut(0, 0, TABLE_1).withValue(BALANCE, 1));
transaction.prepare();
transaction.commit();
// Act
TwoPhaseConsensusCommit transaction1 = manager.start();
Get get = prepareGet(0, 0, TABLE_1);
transaction1.get(get);
transaction1.delete(prepareDelete(0, 0, TABLE_1));
Throwable thrown = catchThrowable(() -> transaction1.put(preparePut(0, 0, TABLE_1).withValue(BALANCE, 2)));
transaction1.rollback();
// Assert
assertThat(thrown).isInstanceOf(IllegalArgumentException.class);
}
use of com.scalar.db.api.Get in project scalardb by scalar-labs.
the class TwoPhaseConsensusCommitIntegrationTest method get_PutCalledBefore_ShouldGet.
@Test
public void get_PutCalledBefore_ShouldGet() throws CrudException {
// Arrange
TwoPhaseConsensusCommit transaction = manager.start();
// Act
transaction.put(preparePut(0, 0, TABLE_1).withValue(BALANCE, 1));
Get get = prepareGet(0, 0, TABLE_1);
Optional<Result> result = transaction.get(get);
assertThatCode(() -> {
transaction.prepare();
transaction.commit();
}).doesNotThrowAnyException();
// Assert
assertThat(result).isPresent();
assertThat(getBalance(result.get())).isEqualTo(1);
}
use of com.scalar.db.api.Get in project scalardb by scalar-labs.
the class JdbcTransactionIntegrationTest method prepareGet.
private Get prepareGet(int id, int type, String namespace, String table) {
Key partitionKey = new Key(ACCOUNT_ID, id);
Key clusteringKey = new Key(ACCOUNT_TYPE, type);
return new Get(partitionKey, clusteringKey).forNamespace(namespace).forTable(table).withConsistency(Consistency.LINEARIZABLE);
}
Aggregations