use of com.scalar.db.api.Get in project scalardb by scalar-labs.
the class ConsensusCommitIntegrationTestBase method get_GetGivenForDeletedWhenCoordinatorStateCommittedAndRolledForwardByAnother_ShouldRollforwardProperly.
@Test
public void get_GetGivenForDeletedWhenCoordinatorStateCommittedAndRolledForwardByAnother_ShouldRollforwardProperly() throws ExecutionException, CoordinatorException, CrudException {
Get get = prepareGet(0, 0, namespace1, TABLE_1);
selection_SelectionGivenForDeletedWhenCoordinatorStateCommittedAndRolledForwardByAnother_ShouldRollforwardProperly(get);
}
use of com.scalar.db.api.Get in project scalardb by scalar-labs.
the class ConsensusCommitIntegrationTestBase method get_GetGivenForDeletedWhenCoordinatorStateAbortedAndRolledBackByAnother_ShouldRollbackProperly.
@Test
public void get_GetGivenForDeletedWhenCoordinatorStateAbortedAndRolledBackByAnother_ShouldRollbackProperly() throws ExecutionException, CoordinatorException, CrudException {
Get get = prepareGet(0, 0, namespace1, TABLE_1);
selection_SelectionGivenForDeletedWhenCoordinatorStateAbortedAndRolledBackByAnother_ShouldRollbackProperly(get);
}
use of com.scalar.db.api.Get in project scalardb by scalar-labs.
the class JdbcTransactionIntegrationTest method get_GetGivenForCommittedRecord_ShouldReturnRecord.
@Test
public void get_GetGivenForCommittedRecord_ShouldReturnRecord() throws TransactionException {
// Arrange
populateRecords();
JdbcTransaction transaction = manager.start();
Get get = prepareGet(0, 0, NAMESPACE, TABLE);
// Act
Optional<Result> result = transaction.get(get);
transaction.commit();
// Assert
assertThat(result.isPresent()).isTrue();
}
use of com.scalar.db.api.Get in project scalardb by scalar-labs.
the class JdbcTransactionIntegrationTest method prepareTransfer.
private JdbcTransaction prepareTransfer(int fromId, int toId, int amount) throws TransactionException {
JdbcTransaction transaction = manager.start();
List<Get> gets = prepareGets(NAMESPACE, TABLE);
Optional<Result> fromResult = transaction.get(gets.get(fromId));
assertThat(fromResult.isPresent()).isTrue();
IntValue fromBalance = new IntValue(BALANCE, getBalance(fromResult.get()) - amount);
Optional<Result> toResult = transaction.get(gets.get(toId));
assertThat(toResult.isPresent()).isTrue();
IntValue toBalance = new IntValue(BALANCE, getBalance(toResult.get()) + amount);
List<Put> puts = preparePuts(NAMESPACE, TABLE);
puts.get(fromId).withValue(fromBalance);
puts.get(toId).withValue(toBalance);
transaction.put(puts.get(fromId));
transaction.put(puts.get(toId));
return transaction;
}
use of com.scalar.db.api.Get 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();
}
Aggregations