Search in sources :

Example 21 with PutIfExists

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

the class StorageIntegrationTestBase method put_PutWithIfExistsGivenWhenNoSuchRecord_ShouldThrowNoMutationException.

@Test
public void put_PutWithIfExistsGivenWhenNoSuchRecord_ShouldThrowNoMutationException() throws ExecutionException {
    // Arrange
    int pKey = 0;
    int cKey = 0;
    List<Put> puts = preparePuts();
    puts.get(0).withCondition(new PutIfExists());
    Get get = prepareGet(pKey, cKey);
    // Act Assert
    assertThatThrownBy(() -> storage.put(puts.get(0))).isInstanceOf(NoMutationException.class);
    // Assert
    Optional<Result> actual = storage.get(get);
    assertThat(actual.isPresent()).isFalse();
}
Also used : Get(com.scalar.db.api.Get) Put(com.scalar.db.api.Put) PutIfExists(com.scalar.db.api.PutIfExists) Result(com.scalar.db.api.Result) Test(org.junit.Test)

Aggregations

PutIfExists (com.scalar.db.api.PutIfExists)21 Test (org.junit.jupiter.api.Test)18 Put (com.scalar.db.api.Put)15 Key (com.scalar.db.io.Key)6 MutationCondition (com.scalar.db.api.MutationCondition)5 IntValue (com.scalar.db.io.IntValue)4 CosmosStoredProcedureRequestOptions (com.azure.cosmos.models.CosmosStoredProcedureRequestOptions)3 BooleanValue (com.scalar.db.io.BooleanValue)3 DoubleValue (com.scalar.db.io.DoubleValue)3 TextValue (com.scalar.db.io.TextValue)3 Value (com.scalar.db.io.Value)3 CosmosException (com.azure.cosmos.CosmosException)2 Get (com.scalar.db.api.Get)2 Result (com.scalar.db.api.Result)2 Test (org.junit.Test)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 AttributeValue (software.amazon.awssdk.services.dynamodb.model.AttributeValue)2 UpdateItemRequest (software.amazon.awssdk.services.dynamodb.model.UpdateItemRequest)2 BatchStatement (com.datastax.driver.core.BatchStatement)1 BoundStatement (com.datastax.driver.core.BoundStatement)1