use of com.scalar.db.transaction.rpc.GrpcTransaction in project scalardb by scalar-labs.
the class DistributedTransactionServiceWithJdbcTransactionIntegrationTest method scan_ScanGivenForCommittedRecord_ShouldReturnRecord.
@Test
public void scan_ScanGivenForCommittedRecord_ShouldReturnRecord() throws TransactionException {
// Arrange
populateRecords();
GrpcTransaction transaction = manager.start();
Scan scan = prepareScan(0, 0, 0, NAMESPACE, TABLE);
// Act
List<Result> results = transaction.scan(scan);
transaction.commit();
// Assert
assertThat(results.size()).isEqualTo(1);
}
use of com.scalar.db.transaction.rpc.GrpcTransaction in project scalardb by scalar-labs.
the class DistributedTransactionServiceWithJdbcTransactionIntegrationTest method putAndCommit_PutGivenForNonExisting_ShouldCreateRecord.
@Test
public void putAndCommit_PutGivenForNonExisting_ShouldCreateRecord() throws TransactionException {
// Arrange
int expected = INITIAL_BALANCE;
Put put = preparePut(0, 0, NAMESPACE, TABLE).withValue(BALANCE, expected);
GrpcTransaction transaction = manager.start();
// Act
transaction.put(put);
transaction.commit();
// Assert
Get get = prepareGet(0, 0, NAMESPACE, TABLE);
GrpcTransaction another = manager.start();
Optional<Result> result = another.get(get);
assertThat(result).isPresent();
another.commit();
assertThat(getBalance(result.get())).isEqualTo(expected);
}
Aggregations