use of com.scalar.db.io.BooleanValue in project scalardb by scalar-labs.
the class DistributedStorageIntegrationTestBase method mutate_SinglePutGiven_ShouldStoreProperly.
@Test
public void mutate_SinglePutGiven_ShouldStoreProperly() throws ExecutionException {
// Arrange
int pKey = 0;
int cKey = 0;
List<Put> puts = preparePuts();
Key partitionKey = new Key(COL_NAME1, pKey);
Key clusteringKey = new Key(COL_NAME4, cKey);
Get get = new Get(partitionKey, clusteringKey);
// Act
storage.mutate(Collections.singletonList(puts.get(pKey * 2 + cKey)));
// Assert
Optional<Result> actual = storage.get(get);
assertThat(actual.isPresent()).isTrue();
assertThat(actual.get().getValue(COL_NAME1)).isEqualTo(Optional.of(new IntValue(COL_NAME1, pKey)));
assertThat(actual.get().getValue(COL_NAME2)).isEqualTo(Optional.of(new TextValue(COL_NAME2, Integer.toString(pKey + cKey))));
assertThat(actual.get().getValue(COL_NAME3)).isEqualTo(Optional.of(new IntValue(COL_NAME3, pKey + cKey)));
assertThat(actual.get().getValue(COL_NAME4)).isEqualTo(Optional.of(new IntValue(COL_NAME4, cKey)));
assertThat(actual.get().getValue(COL_NAME5)).isEqualTo(Optional.of(new BooleanValue(COL_NAME5, cKey % 2 == 0)));
}
use of com.scalar.db.io.BooleanValue 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.BooleanValue 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.BooleanValue 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.BooleanValue 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