Search in sources :

Example 1 with TwoPhaseCommitTransaction

use of com.scalar.db.api.TwoPhaseCommitTransaction in project scalardb by scalar-labs.

the class TwoPhaseConsensusCommitSpecificIntegrationTestBase method scanAll_DeleteCalledBefore_ShouldReturnEmpty.

@Test
public void scanAll_DeleteCalledBefore_ShouldReturnEmpty() throws TransactionException {
    // Arrange
    TwoPhaseCommitTransaction transaction = manager.start();
    transaction.put(preparePut(0, 0, TABLE_1).withIntValue(BALANCE, 1));
    transaction.prepare();
    transaction.commit();
    // Act
    TwoPhaseCommitTransaction transaction1 = manager.start();
    ScanAll scanAll = prepareScanAll(TABLE_1);
    List<Result> resultBefore = transaction1.scan(scanAll);
    transaction1.delete(prepareDelete(0, 0, TABLE_1));
    List<Result> resultAfter = transaction1.scan(scanAll);
    assertThatCode(() -> {
        transaction1.prepare();
        transaction1.commit();
    }).doesNotThrowAnyException();
    // Assert
    assertThat(resultBefore.size()).isEqualTo(1);
    assertThat(resultAfter.size()).isEqualTo(0);
}
Also used : ScanAll(com.scalar.db.api.ScanAll) TwoPhaseCommitTransaction(com.scalar.db.api.TwoPhaseCommitTransaction) Result(com.scalar.db.api.Result) Test(org.junit.jupiter.api.Test)

Aggregations

Result (com.scalar.db.api.Result)1 ScanAll (com.scalar.db.api.ScanAll)1 TwoPhaseCommitTransaction (com.scalar.db.api.TwoPhaseCommitTransaction)1 Test (org.junit.jupiter.api.Test)1