use of com.scalar.db.io.BlobValue in project scalardb by scalar-labs.
the class ResultImplTest method getValues_ProperValuesGivenInConstructor_ShouldReturnWhatsSet.
@Test
public void getValues_ProperValuesGivenInConstructor_ShouldReturnWhatsSet() {
// Arrange
ResultImpl result = new ResultImpl(values, TABLE_METADATA);
// Act
Map<String, Value<?>> actual = result.getValues();
// Assert
assertThat(actual.get(ANY_NAME_1)).isEqualTo(new TextValue(ANY_NAME_1, ANY_TEXT_1));
assertThat(actual.get(ANY_NAME_2)).isEqualTo(new TextValue(ANY_NAME_2, ANY_TEXT_2));
assertThat(actual.get(ANY_COLUMN_NAME_1)).isEqualTo(new BooleanValue(ANY_COLUMN_NAME_1, true));
assertThat(actual.get(ANY_COLUMN_NAME_7)).isEqualTo(new BlobValue(ANY_COLUMN_NAME_7, "bytes".getBytes(StandardCharsets.UTF_8)));
}
use of com.scalar.db.io.BlobValue in project scalardb by scalar-labs.
the class ValueBinderTest method visit_AcceptCalledMultipleTimesWithNullValue_ShouldSkipNull.
@Test
public void visit_AcceptCalledMultipleTimesWithNullValue_ShouldSkipNull() {
// Arrange
IntValue value1 = new IntValue(ANY_NAME, ANY_INT);
BlobValue value2 = new BlobValue(ANY_NAME, (byte[]) null);
TextValue value3 = new TextValue(ANY_NAME, (String) null);
IntValue value4 = new IntValue(ANY_NAME, ANY_INT);
ValueBinder binder = new ValueBinder(bound);
// Act
value1.accept(binder);
value2.accept(binder);
value3.accept(binder);
value4.accept(binder);
// Assert
verify(bound).setInt(0, ANY_INT);
verify(bound, never()).setBytes(anyInt(), any(ByteBuffer.class));
verify(bound, never()).setString(anyInt(), anyString());
verify(bound).setInt(3, ANY_INT);
}
use of com.scalar.db.io.BlobValue in project scalardb by scalar-labs.
the class ValueBinderTest method visit_BlobValueAcceptCalled_ShouldCallSetString.
@Test
public void visit_BlobValueAcceptCalled_ShouldCallSetString() {
// Arrange
BlobValue value = new BlobValue(ANY_NAME, ANY_STRING.getBytes(StandardCharsets.UTF_8));
ValueBinder binder = new ValueBinder(bound);
// Act
value.accept(binder);
// Assert
verify(bound).setBytes(0, (ByteBuffer) ByteBuffer.allocate(ANY_STRING.length()).put(ANY_STRING.getBytes(StandardCharsets.UTF_8)).flip());
}
use of com.scalar.db.io.BlobValue in project scalardb by scalar-labs.
the class ValueBinderTest method visit_BlobValueWithNullValueAcceptCalled_ShouldCallSetToNull.
@Test
public void visit_BlobValueWithNullValueAcceptCalled_ShouldCallSetToNull() {
// Arrange
BlobValue value = new BlobValue(ANY_NAME, (byte[]) null);
ValueBinder binder = new ValueBinder(bound);
// Act
value.accept(binder);
// Assert
verify(bound).setToNull(0);
}
use of com.scalar.db.io.BlobValue in project scalardb by scalar-labs.
the class MapVisitorTest method visit_BlobValueWithNullValueAcceptCalled_ShouldGetMap.
@Test
public void visit_BlobValueWithNullValueAcceptCalled_ShouldGetMap() {
// Act
new BlobValue("any_blob", (byte[]) null).accept(visitor);
// Assert
assertThat(visitor.get().containsKey("any_blob")).isTrue();
assertThat(visitor.get().get("any_blob")).isNull();
}
Aggregations