use of com.scalar.db.api.Delete in project scalardb by scalar-labs.
the class DeleteStatementHandlerTest method handle_DynamoDbExceptionWithConditionalCheckFailed_ShouldThrowNoMutationException.
@Test
public void handle_DynamoDbExceptionWithConditionalCheckFailed_ShouldThrowNoMutationException() {
// Arrange
when(metadata.getClusteringKeyNames()).thenReturn(new LinkedHashSet<>(Collections.singletonList(ANY_NAME_2)));
when(client.deleteItem(any(DeleteItemRequest.class))).thenReturn(response);
ConditionalCheckFailedException toThrow = mock(ConditionalCheckFailedException.class);
doThrow(toThrow).when(client).deleteItem(any(DeleteItemRequest.class));
Delete delete = prepareDelete().withCondition(new DeleteIfExists());
// Act Assert
assertThatThrownBy(() -> handler.handle(delete)).isInstanceOf(NoMutationException.class);
}
use of com.scalar.db.api.Delete in project scalardb by scalar-labs.
the class GrpcStorageTest method mutate_StubThrowInternalError_ShouldThrowExecutionException.
@Test
public void mutate_StubThrowInternalError_ShouldThrowExecutionException() {
// Arrange
Key partitionKey = new Key("col1", 1);
List<Mutation> mutations = Arrays.asList(new Put(partitionKey), new Delete(partitionKey));
when(blockingStub.mutate(any())).thenThrow(Status.INTERNAL.asRuntimeException());
// Act
assertThatThrownBy(() -> storage.mutate(mutations)).isInstanceOf(ExecutionException.class);
}
use of com.scalar.db.api.Delete in project scalardb by scalar-labs.
the class GrpcStorageTest method mutate_isCalledWithProperArguments_StubShouldBeCalledProperly.
@Test
public void mutate_isCalledWithProperArguments_StubShouldBeCalledProperly() throws ExecutionException {
// Arrange
Key partitionKey = new Key("col1", 1);
List<Mutation> mutations = Arrays.asList(new Put(partitionKey), new Delete(partitionKey));
// Act
storage.mutate(mutations);
// Assert
verify(blockingStub).mutate(any());
}
use of com.scalar.db.api.Delete in project scalardb by scalar-labs.
the class GrpcStorageTest method deletes_StubThrowInvalidArgumentError_ShouldThrowIllegalArgumentException.
@Test
public void deletes_StubThrowInvalidArgumentError_ShouldThrowIllegalArgumentException() {
// Arrange
Key partitionKey1 = new Key("col1", 1);
Key partitionKey2 = new Key("col1", 2);
List<Delete> deletes = Arrays.asList(new Delete(partitionKey2), new Delete(partitionKey1));
when(blockingStub.mutate(any())).thenThrow(Status.INVALID_ARGUMENT.asRuntimeException());
// Act Assert
assertThatThrownBy(() -> storage.delete(deletes)).isInstanceOf(IllegalArgumentException.class);
}
use of com.scalar.db.api.Delete in project scalardb by scalar-labs.
the class GrpcStorageTest method delete_StubThrowInternalError_ShouldThrowExecutionException.
@Test
public void delete_StubThrowInternalError_ShouldThrowExecutionException() {
// Arrange
Key partitionKey = new Key("col1", 1);
Delete delete = new Delete(partitionKey);
when(blockingStub.mutate(any())).thenThrow(Status.INTERNAL.asRuntimeException());
// Act
assertThatThrownBy(() -> storage.delete(delete)).isInstanceOf(ExecutionException.class);
}
Aggregations