Search in sources :

Example 31 with Delete

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

the class DeleteStatementHandlerTest method prepareDeleteWithClusteringKey.

private Delete prepareDeleteWithClusteringKey() {
    Key partitionKey = new Key(ANY_NAME_1, ANY_TEXT_1);
    Key clusteringKey = new Key(ANY_NAME_2, ANY_TEXT_2);
    return new Delete(partitionKey, clusteringKey).forNamespace(ANY_NAMESPACE_NAME).forTable(ANY_TABLE_NAME);
}
Also used : Delete(com.scalar.db.api.Delete) Key(com.scalar.db.io.Key)

Example 32 with Delete

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

the class OperationCheckerTest method whenCheckingDeleteOperationWithAllValidArguments_shouldNotThrowAnyException.

@Test
public void whenCheckingDeleteOperationWithAllValidArguments_shouldNotThrowAnyException() {
    // Arrange
    Key partitionKey = new Key(PKEY1, 1, PKEY2, "val1");
    Key clusteringKey = new Key(CKEY1, 2, CKEY2, "val1");
    MutationCondition condition = new DeleteIf(new ConditionalExpression(COL1, new IntValue(1), ConditionalExpression.Operator.EQ));
    Delete delete = new Delete(partitionKey, clusteringKey).withCondition(condition).forNamespace(NAMESPACE).forTable(TABLE_NAME);
    // Act Assert
    assertThatCode(() -> operationChecker.check(delete)).doesNotThrowAnyException();
}
Also used : Delete(com.scalar.db.api.Delete) MutationCondition(com.scalar.db.api.MutationCondition) ConditionalExpression(com.scalar.db.api.ConditionalExpression) IntValue(com.scalar.db.io.IntValue) Key(com.scalar.db.io.Key) DeleteIf(com.scalar.db.api.DeleteIf) Test(org.junit.jupiter.api.Test)

Example 33 with Delete

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

the class OperationCheckerTest method whenCheckingDeleteOperationWithPutIfCondition_shouldThrowIllegalArgumentException.

@Test
public void whenCheckingDeleteOperationWithPutIfCondition_shouldThrowIllegalArgumentException() {
    // Arrange
    Key partitionKey = new Key(PKEY1, 1, PKEY2, "val1");
    Key clusteringKey = new Key(CKEY1, 2, CKEY2, "val1");
    MutationCondition condition = new PutIf();
    Delete delete = new Delete(partitionKey, clusteringKey).withCondition(condition).forNamespace(NAMESPACE).forTable(TABLE_NAME);
    // Act Assert
    assertThatThrownBy(() -> operationChecker.check(delete)).isInstanceOf(IllegalArgumentException.class);
}
Also used : Delete(com.scalar.db.api.Delete) PutIf(com.scalar.db.api.PutIf) MutationCondition(com.scalar.db.api.MutationCondition) Key(com.scalar.db.io.Key) Test(org.junit.jupiter.api.Test)

Example 34 with Delete

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

the class OperationCheckerTest method whenCheckingMutateOperationWithAllValidArguments_shouldNotThrowAnyException.

@Test
public void whenCheckingMutateOperationWithAllValidArguments_shouldNotThrowAnyException() {
    // Arrange
    Key partitionKey = new Key(PKEY1, 1, PKEY2, "val1");
    Key clusteringKey = new Key(CKEY1, 2, CKEY2, "val1");
    Put put = new Put(partitionKey, clusteringKey).withValue(COL1, 1).forNamespace(NAMESPACE).forTable(TABLE_NAME);
    Delete delete = new Delete(partitionKey, clusteringKey).forNamespace(NAMESPACE).forTable(TABLE_NAME);
    // Act Assert
    assertThatCode(() -> operationChecker.check(Arrays.asList(put, delete))).doesNotThrowAnyException();
}
Also used : Delete(com.scalar.db.api.Delete) Key(com.scalar.db.io.Key) Put(com.scalar.db.api.Put) Test(org.junit.jupiter.api.Test)

Example 35 with Delete

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

the class JdbcDatabaseTest method whenDeleteOperationExecuted_shouldCallJdbcService.

@Test
public void whenDeleteOperationExecuted_shouldCallJdbcService() throws Exception {
    // Arrange
    when(jdbcService.delete(any(), any())).thenReturn(true);
    // Act
    Delete delete = new Delete(new Key("p1", "val1")).forNamespace(NAMESPACE).forTable(TABLE);
    jdbcDatabase.delete(delete);
    // Assert
    verify(jdbcService).delete(any(), any());
    verify(connection).close();
}
Also used : Delete(com.scalar.db.api.Delete) Key(com.scalar.db.io.Key) Test(org.junit.jupiter.api.Test)

Aggregations

Delete (com.scalar.db.api.Delete)174 Key (com.scalar.db.io.Key)112 Test (org.junit.jupiter.api.Test)111 Put (com.scalar.db.api.Put)59 Get (com.scalar.db.api.Get)29 Result (com.scalar.db.api.Result)29 Test (org.junit.Test)25 DeleteIfExists (com.scalar.db.api.DeleteIfExists)24 ConditionalExpression (com.scalar.db.api.ConditionalExpression)16 DeleteIf (com.scalar.db.api.DeleteIf)15 Mutation (com.scalar.db.api.Mutation)14 MutationCondition (com.scalar.db.api.MutationCondition)11 Scan (com.scalar.db.api.Scan)11 PutIfNotExists (com.scalar.db.api.PutIfNotExists)10 TextValue (com.scalar.db.io.TextValue)10 ExecutionException (com.scalar.db.exception.storage.ExecutionException)8 CosmosStoredProcedureRequestOptions (com.azure.cosmos.models.CosmosStoredProcedureRequestOptions)6 GrpcTransaction (com.scalar.db.transaction.rpc.GrpcTransaction)6 DeleteItemRequest (software.amazon.awssdk.services.dynamodb.model.DeleteItemRequest)6 PartitionKey (com.azure.cosmos.models.PartitionKey)5