use of com.scalar.db.api.MutationCondition in project scalardb by scalar-labs.
the class OperationCheckerTest method whenCheckingPutOperationWithNullValue_shouldNotThrowAnyException.
@Test
public void whenCheckingPutOperationWithNullValue_shouldNotThrowAnyException() {
// Arrange
Key partitionKey = new Key(PKEY1, 1, PKEY2, "val1");
Key clusteringKey = new Key(CKEY1, 2, CKEY2, "val1");
MutationCondition condition = new PutIfNotExists();
Put put = new Put(partitionKey, clusteringKey).withValue(COL1, 1).withValue(COL2, 0.1D).withBooleanValue(COL3, null).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 whenCheckingPutOperationWithInvalidValues_shouldThrowIllegalArgumentException.
@Test
public void whenCheckingPutOperationWithInvalidValues_shouldThrowIllegalArgumentException() {
// 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("v4", true));
MutationCondition condition = new PutIfExists();
Put put = new Put(partitionKey, clusteringKey).withValues(values).withCondition(condition).forNamespace(NAMESPACE).forTable(TABLE_NAME);
// Act Assert
assertThatThrownBy(() -> operationChecker.check(put)).isInstanceOf(IllegalArgumentException.class);
}
use of com.scalar.db.api.MutationCondition in project scalardb by scalar-labs.
the class OperationCheckerTest method whenCheckingDeleteOperationWithInvalidDeleteIfConditionWithIsNotNull_shouldThrowIllegalArgumentException.
@Test
public void whenCheckingDeleteOperationWithInvalidDeleteIfConditionWithIsNotNull_shouldThrowIllegalArgumentException() {
// Arrange
Key partitionKey = new Key(PKEY1, 1, PKEY2, "val1");
Key clusteringKey = new Key(CKEY1, 2, CKEY2, "val1");
MutationCondition condition = ConditionBuilder.deleteIf(ConditionBuilder.buildConditionalExpression(IntColumn.of(COL1, 1), Operator.IS_NOT_NULL)).build();
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 whenCheckingDeleteOperationWithInvalidDeleteIfConditionWithIsNull_shouldThrowIllegalArgumentException.
@Test
public void whenCheckingDeleteOperationWithInvalidDeleteIfConditionWithIsNull_shouldThrowIllegalArgumentException() {
// Arrange
Key partitionKey = new Key(PKEY1, 1, PKEY2, "val1");
Key clusteringKey = new Key(CKEY1, 2, CKEY2, "val1");
MutationCondition condition = ConditionBuilder.deleteIf(ConditionBuilder.buildConditionalExpression(IntColumn.of(COL1, 1), Operator.IS_NULL)).build();
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 whenCheckingDeleteOperationWithInvalidClusteringKey_shouldThrowIllegalArgumentException.
@Test
public void whenCheckingDeleteOperationWithInvalidClusteringKey_shouldThrowIllegalArgumentException() {
// Arrange
Key partitionKey = new Key(PKEY1, 1, PKEY2, "val1");
Key clusteringKey = new Key(CKEY1, 2, "c3", "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);
}
Aggregations