use of com.scalar.db.io.IntValue in project scalardb by scalar-labs.
the class OperationCheckerTest method whenCheckingPutOperationWithClusteringKeyWithEmptyBlobValue_shouldThrowIllegalArgumentException.
@Test
public void whenCheckingPutOperationWithClusteringKeyWithEmptyBlobValue_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[] { 1, 1, 1 });
Key clusteringKey = new Key(CKEY1, new byte[0]);
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 DeleteStatementHandlerTest method setConsistency_DeleteOperationWithIfGiven_ShouldPrepareWithQuorumAndSerial.
@Test
public void setConsistency_DeleteOperationWithIfGiven_ShouldPrepareWithQuorumAndSerial() {
// Arrange
configureBehavior(null);
del = prepareDeleteWithClusteringKey();
del.withCondition(new DeleteIf(new ConditionalExpression(ANY_NAME_3, new IntValue(ANY_INT_1), Operator.EQ), new ConditionalExpression(ANY_NAME_4, new TextValue(ANY_TEXT_3), Operator.EQ))).withConsistency(Consistency.EVENTUAL);
// Act
handler.setConsistency(bound, del);
// Assert
verify(bound).setConsistencyLevel(ConsistencyLevel.QUORUM);
verify(bound).setSerialConsistencyLevel(ConsistencyLevel.SERIAL);
}
use of com.scalar.db.io.IntValue in project scalardb by scalar-labs.
the class UpdateStatementHandlerTest method prepare_PutOperationWithIfGiven_ShouldCallAccept.
@Test
public void prepare_PutOperationWithIfGiven_ShouldCallAccept() {
// Arrange
configureBehavior(null);
put = preparePutWithClusteringKey();
PutIf putIf = Mockito.spy(new PutIf(new ConditionalExpression(ANY_NAME_4, new IntValue(ANY_INT_2), Operator.EQ)));
put.withCondition(putIf);
// Act
handler.prepare(put);
// Assert
verify(putIf).accept(any(ConditionSetter.class));
}
use of com.scalar.db.io.IntValue in project scalardb by scalar-labs.
the class UpdateStatementHandlerTest method bind_PutOperationWithIfGiven_ShouldBindProperly.
@Test
public void bind_PutOperationWithIfGiven_ShouldBindProperly() {
// Arrange
configureBehavior(null);
put = preparePutWithClusteringKey();
put.withCondition(new PutIf(new ConditionalExpression(ANY_NAME_4, new IntValue(ANY_INT_2), Operator.EQ), new ConditionalExpression(ANY_NAME_5, new TextValue(ANY_TEXT_3), Operator.EQ)));
// Act
handler.bind(prepared, put);
// Assert
verify(bound).setInt(0, ANY_INT_1);
verify(bound).setString(1, ANY_TEXT_1);
verify(bound).setString(2, ANY_TEXT_2);
verify(bound).setInt(3, ANY_INT_2);
verify(bound).setString(4, ANY_TEXT_3);
}
use of com.scalar.db.io.IntValue in project scalardb by scalar-labs.
the class OperationCheckerTest method whenCheckingPutOperationWithAllValidArguments_shouldNotThrowAnyException.
@Test
public void whenCheckingPutOperationWithAllValidArguments_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 = new PutIfNotExists();
Put put = new Put(partitionKey, clusteringKey).withValues(values).withCondition(condition).forNamespace(NAMESPACE).forTable(TABLE_NAME);
// Act Assert
assertThatCode(() -> operationChecker.check(put)).doesNotThrowAnyException();
}
Aggregations