use of com.scalar.db.api.Delete in project scalardb by scalar-labs.
the class StorageIntegrationTestBase method delete_DeleteWithIfExistsGivenWhenNoSuchRecord_ShouldThrowNoMutationException.
@Test
public void delete_DeleteWithIfExistsGivenWhenNoSuchRecord_ShouldThrowNoMutationException() {
// Arrange
populateRecords();
int pKey = 0;
// Act Assert
Delete delete = prepareDelete(pKey, Integer.MAX_VALUE);
delete.withCondition(new DeleteIfExists());
assertThatThrownBy(() -> storage.delete(delete)).isInstanceOf(NoMutationException.class);
}
use of com.scalar.db.api.Delete in project scalardb by scalar-labs.
the class StorageIntegrationTestBase method prepareDeletes.
private List<Delete> prepareDeletes() {
List<Delete> deletes = new ArrayList<>();
IntStream.range(0, 5).forEach(i -> IntStream.range(0, 3).forEach(j -> {
Key partitionKey = new Key(COL_NAME1, i);
Key clusteringKey = new Key(COL_NAME4, j);
Delete delete = new Delete(partitionKey, clusteringKey);
deletes.add(delete);
}));
return deletes;
}
use of com.scalar.db.api.Delete in project scalardb by scalar-labs.
the class StorageIntegrationTestBase method prepareDelete.
private Delete prepareDelete(int pKey, int cKey) {
Key partitionKey = new Key(COL_NAME1, pKey);
Key clusteringKey = new Key(COL_NAME4, cKey);
return new Delete(partitionKey, clusteringKey);
}
use of com.scalar.db.api.Delete in project scalardb by scalar-labs.
the class StorageIntegrationTestBase method delete_DeleteWithIfExistsGivenWhenSuchRecordExists_ShouldDeleteProperly.
@Test
public void delete_DeleteWithIfExistsGivenWhenSuchRecordExists_ShouldDeleteProperly() throws ExecutionException {
// Arrange
populateRecords();
int pKey = 0;
int cKey = 0;
Key partitionKey = new Key(COL_NAME1, pKey);
Key clusteringKey = new Key(COL_NAME4, cKey);
// Act
Delete delete = prepareDelete(pKey, cKey);
delete.withCondition(new DeleteIfExists());
assertThatCode(() -> storage.delete(delete)).doesNotThrowAnyException();
// Assert
Optional<Result> actual = storage.get(new Get(partitionKey, clusteringKey));
assertThat(actual.isPresent()).isFalse();
}
use of com.scalar.db.api.Delete in project scalardb by scalar-labs.
the class PrepareMutationComposerTest method delete_DeleteAndNullResultGiven_ShouldThrowIllegalArgumentException.
@Test
public void delete_DeleteAndNullResultGiven_ShouldThrowIllegalArgumentException() {
// Arrange
Delete delete = prepareDelete();
// Act Assert
assertThatThrownBy(() -> composer.add(delete, null)).isInstanceOf(IllegalArgumentException.class);
}
Aggregations