Search in sources :

Example 46 with ScanAll

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

the class ConsensusCommitSpecificIntegrationTestBase method scanAll_ScanAllGivenForPreparedWhenCoordinatorStateNotExistAndNotExpired_ShouldNotAbortTransaction.

@Test
public void scanAll_ScanAllGivenForPreparedWhenCoordinatorStateNotExistAndNotExpired_ShouldNotAbortTransaction() throws ExecutionException, CoordinatorException {
    ScanAll scanAll = prepareScanAll(namespace1, TABLE_1);
    selection_SelectionGivenForPreparedWhenCoordinatorStateNotExistAndNotExpired_ShouldNotAbortTransaction(scanAll);
}
Also used : ScanAll(com.scalar.db.api.ScanAll) Test(org.junit.jupiter.api.Test)

Example 47 with ScanAll

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

the class ConsensusCommitSpecificIntegrationTestBase method scanAll_ScanAllGivenForPreparedWhenCoordinatorStateCommitted_ShouldRollforward.

@Test
public void scanAll_ScanAllGivenForPreparedWhenCoordinatorStateCommitted_ShouldRollforward() throws ExecutionException, CoordinatorException, CrudException {
    ScanAll scanAll = prepareScanAll(namespace1, TABLE_1);
    selection_SelectionGivenForPreparedWhenCoordinatorStateCommitted_ShouldRollforward(scanAll);
}
Also used : ScanAll(com.scalar.db.api.ScanAll) Test(org.junit.jupiter.api.Test)

Example 48 with ScanAll

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

the class ConsensusCommitSpecificIntegrationTestBase method scanAll_ScanAllGivenForNonExisting_ShouldReturnEmpty.

@Test
public void scanAll_ScanAllGivenForNonExisting_ShouldReturnEmpty() throws CrudException, CommitException, UnknownTransactionStatusException {
    // Arrange
    ConsensusCommit putTransaction = manager.start();
    putTransaction.put(preparePut(0, 0, namespace1, TABLE_1));
    putTransaction.commit();
    ConsensusCommit transaction = manager.start();
    ScanAll scanAll = prepareScanAll(namespace2, TABLE_2);
    // Act
    List<Result> results = transaction.scan(scanAll);
    // Assert
    assertThat(results.size()).isEqualTo(0);
}
Also used : ScanAll(com.scalar.db.api.ScanAll) Result(com.scalar.db.api.Result) Test(org.junit.jupiter.api.Test)

Example 49 with ScanAll

use of com.scalar.db.api.ScanAll 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)

Example 50 with ScanAll

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

the class TwoPhaseConsensusCommitSpecificIntegrationTestBase method scanAll_DeleteGivenBefore_ShouldScanAll.

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

Aggregations

ScanAll (com.scalar.db.api.ScanAll)52 Test (org.junit.jupiter.api.Test)43 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)10 Result (com.scalar.db.api.Result)9 CosmosQueryRequestOptions (com.azure.cosmos.models.CosmosQueryRequestOptions)8 Put (com.scalar.db.api.Put)4 HashMap (java.util.HashMap)4 Scan (com.scalar.db.api.Scan)3 TableMetadata (com.scalar.db.api.TableMetadata)3 Key (com.scalar.db.io.Key)3 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)3 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)3 ScanRequest (software.amazon.awssdk.services.dynamodb.model.ScanRequest)3 SelectQuery (com.scalar.db.storage.jdbc.query.SelectQuery)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 List (java.util.List)2 Nonnull (javax.annotation.Nonnull)2 ResultSet (com.datastax.driver.core.ResultSet)1 Select (com.datastax.driver.core.querybuilder.Select)1