use of com.scalar.db.api.MutationCondition in project scalardb by scalar-labs.
the class OperationCheckerTest method whenCheckingPutOperationWithInvalidPartitionKey_shouldThrowIllegalArgumentException.
@Test
public void whenCheckingPutOperationWithInvalidPartitionKey_shouldThrowIllegalArgumentException() {
// Arrange
Key partitionKey = new Key(PKEY1, 1, "c3", "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 = 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 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();
}
use of com.scalar.db.api.MutationCondition in project scalardb by scalar-labs.
the class OperationCheckerTest method whenCheckingPutOperationWithInvalidPutIfCondition_shouldThrowIllegalArgumentException.
@Test
public void whenCheckingPutOperationWithInvalidPutIfCondition_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(COL3, true));
MutationCondition condition = new PutIf(new ConditionalExpression(COL1, new TextValue("1"), ConditionalExpression.Operator.EQ));
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 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);
}
use of com.scalar.db.api.MutationCondition in project scalardb by scalar-labs.
the class OperationCheckerTest method whenCheckingPutOperationWithInvalidValueType_shouldThrowIllegalArgumentException.
@Test
public void whenCheckingPutOperationWithInvalidValueType_shouldThrowIllegalArgumentException() {
// Arrange
Key partitionKey = new Key(PKEY1, 1, PKEY2, "val1");
Key clusteringKey = new Key(CKEY1, 2, CKEY2, "val1");
List<Value<?>> values = Arrays.asList(new TextValue(COL1, "1"), new DoubleValue(COL2, 0.1), new BooleanValue(COL3, true));
MutationCondition condition = new PutIfNotExists();
Put put = new Put(partitionKey, clusteringKey).withValues(values).withCondition(condition).forNamespace(NAMESPACE).forTable(TABLE_NAME);
// Act Assert
assertThatThrownBy(() -> operationChecker.check(put)).isInstanceOf(IllegalArgumentException.class);
}
Aggregations