use of com.scalar.db.io.IntValue 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.io.IntValue in project scalardb by scalar-labs.
the class OperationCheckerTest method whenCheckingPutOperationWithPartitionKeyWithEmptyTextValue_shouldThrowIllegalArgumentException.
@Test
public void whenCheckingPutOperationWithPartitionKeyWithEmptyTextValue_shouldThrowIllegalArgumentException() {
// Arrange
Key partitionKey = new Key(PKEY1, 1, PKEY2, "");
Key clusteringKey = new Key(CKEY1, 2, CKEY2, "val2");
List<Value<?>> values = Arrays.asList(new IntValue(COL1, 1), new DoubleValue(COL2, 0.1), new BooleanValue(COL3, true));
Put put = new Put(partitionKey, clusteringKey).withValues(values).forNamespace(NAMESPACE).forTable(TABLE_NAME);
// Act Assert
assertThatThrownBy(() -> operationChecker.check(put)).isInstanceOf(IllegalArgumentException.class);
}
use of com.scalar.db.io.IntValue in project scalardb by scalar-labs.
the class OperationCheckerTest method whenCheckingPutOperationWithPartitionKeyWithEmptyBlobValue_shouldThrowIllegalArgumentException.
@Test
public void whenCheckingPutOperationWithPartitionKeyWithEmptyBlobValue_shouldThrowIllegalArgumentException() throws ExecutionException {
// Arrange
when(metadataManager.getTableMetadata(any())).thenReturn(TableMetadata.newBuilder().addColumn(PKEY1, DataType.BLOB).addColumn(CKEY1, DataType.BLOB).addColumn(COL1, DataType.INT).addPartitionKey(PKEY1).addClusteringKey(CKEY1).build());
operationChecker = new OperationChecker(metadataManager);
Key partitionKey = new Key(PKEY1, new byte[0]);
Key clusteringKey = new Key(CKEY1, new byte[] { 1, 1, 1 });
List<Value<?>> values = Collections.singletonList(new IntValue(COL1, 1));
Put put = new Put(partitionKey, clusteringKey).withValues(values).forNamespace(NAMESPACE).forTable(TABLE_NAME);
// Act Assert
assertThatThrownBy(() -> operationChecker.check(put)).isInstanceOf(IllegalArgumentException.class);
}
use of com.scalar.db.io.IntValue in project scalardb by scalar-labs.
the class OperationCheckerTest method whenCheckingPutOperationWithPartitionKeyWithNullTextValue_shouldThrowIllegalArgumentException.
@Test
public void whenCheckingPutOperationWithPartitionKeyWithNullTextValue_shouldThrowIllegalArgumentException() {
// Arrange
Key partitionKey = Key.newBuilder().addInt(PKEY1, 1).addText(PKEY2, null).build();
Key clusteringKey = new Key(CKEY1, 2, CKEY2, "val2");
List<Value<?>> values = Arrays.asList(new IntValue(COL1, 1), new DoubleValue(COL2, 0.1), new BooleanValue(COL3, true));
Put put = new Put(partitionKey, clusteringKey).withValues(values).forNamespace(NAMESPACE).forTable(TABLE_NAME);
// Act Assert
assertThatThrownBy(() -> operationChecker.check(put)).isInstanceOf(IllegalArgumentException.class);
}
use of com.scalar.db.io.IntValue in project scalardb by scalar-labs.
the class OperationCheckerTest method whenCheckingPutOperationWithDeleteIfExistsCondition_shouldThrowIllegalArgumentException.
@Test
public void whenCheckingPutOperationWithDeleteIfExistsCondition_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 DeleteIfExists();
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