use of com.scalar.db.api.MutationCondition in project scalardb by scalar-labs.
the class OperationCheckerTest method whenCheckingDeleteOperationWithPutIfNotExistsCondition_shouldThrowIllegalArgumentException.
@Test
public void whenCheckingDeleteOperationWithPutIfNotExistsCondition_shouldThrowIllegalArgumentException() {
// Arrange
Key partitionKey = new Key(PKEY1, 1, PKEY2, "val1");
Key clusteringKey = new Key(CKEY1, 2, CKEY2, "val1");
MutationCondition condition = new PutIfNotExists();
Delete delete = new Delete(partitionKey, clusteringKey).withCondition(condition).forNamespace(NAMESPACE).forTable(TABLE_NAME);
// Act Assert
assertThatThrownBy(() -> operationChecker.check(delete)).isInstanceOf(IllegalArgumentException.class);
}
use of com.scalar.db.api.MutationCondition in project scalardb by scalar-labs.
the class OperationCheckerTest method whenCheckingPutOperationWithoutAnyCondition_shouldNotThrowAnyException.
@Test
public void whenCheckingPutOperationWithoutAnyCondition_shouldNotThrowAnyException() {
// Arrange
Key partitionKey = new Key(PKEY1, 1, PKEY2, "val1");
Key clusteringKey = new Key(CKEY1, 2, CKEY2, "val1");
List<Value<?>> values = Arrays.asList(new IntValue(COL1, 1), new DoubleValue(COL2, 0.1), new BooleanValue(COL3, true));
MutationCondition condition = null;
Put put = new Put(partitionKey, clusteringKey).withValues(values).withCondition(condition).forNamespace(NAMESPACE).forTable(TABLE_NAME);
// Act Assert
assertThatCode(() -> operationChecker.check(put)).doesNotThrowAnyException();
}
use of com.scalar.db.api.MutationCondition in project scalardb by scalar-labs.
the class OperationCheckerTest method whenCheckingDeleteOperationWithInvalidPartitionKey_shouldThrowIllegalArgumentException.
@Test
public void whenCheckingDeleteOperationWithInvalidPartitionKey_shouldThrowIllegalArgumentException() {
// Arrange
Key partitionKey = new Key(PKEY1, 1, "p3", "val1");
Key clusteringKey = new Key(CKEY1, 2, CKEY2, "val1");
MutationCondition condition = new DeleteIfExists();
Delete delete = new Delete(partitionKey, clusteringKey).withCondition(condition).forNamespace(NAMESPACE).forTable(TABLE_NAME);
// Act Assert
assertThatThrownBy(() -> operationChecker.check(delete)).isInstanceOf(IllegalArgumentException.class);
}
use of com.scalar.db.api.MutationCondition in project scalardb by scalar-labs.
the class OperationCheckerTest method whenCheckingDeleteOperationWithoutAnyCondition_shouldNotThrowAnyException.
@Test
public void whenCheckingDeleteOperationWithoutAnyCondition_shouldNotThrowAnyException() {
// Arrange
Key partitionKey = new Key(PKEY1, 1, PKEY2, "val1");
Key clusteringKey = new Key(CKEY1, 2, CKEY2, "val1");
MutationCondition condition = null;
Delete delete = new Delete(partitionKey, clusteringKey).withCondition(condition).forNamespace(NAMESPACE).forTable(TABLE_NAME);
// Act Assert
assertThatCode(() -> operationChecker.check(delete)).doesNotThrowAnyException();
}
use of com.scalar.db.api.MutationCondition in project scalardb by scalar-labs.
the class OperationCheckerTest method whenCheckingDeleteOperationWithoutAnyClusteringKey_shouldThrowIllegalArgumentException.
@Test
public void whenCheckingDeleteOperationWithoutAnyClusteringKey_shouldThrowIllegalArgumentException() {
// Arrange
Key partitionKey = new Key(PKEY1, 1, PKEY2, "val1");
Key clusteringKey = null;
MutationCondition condition = new DeleteIfExists();
Delete delete = new Delete(partitionKey, clusteringKey).withCondition(condition).forNamespace(NAMESPACE).forTable(TABLE_NAME);
// Act Assert
assertThatThrownBy(() -> operationChecker.check(delete)).isInstanceOf(IllegalArgumentException.class);
}
Aggregations