Search in sources :

Example 21 with BlobValue

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(columns, 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)));
}
Also used : TextValue(com.scalar.db.io.TextValue) BooleanValue(com.scalar.db.io.BooleanValue) IntValue(com.scalar.db.io.IntValue) DoubleValue(com.scalar.db.io.DoubleValue) TextValue(com.scalar.db.io.TextValue) Value(com.scalar.db.io.Value) FloatValue(com.scalar.db.io.FloatValue) BigIntValue(com.scalar.db.io.BigIntValue) BlobValue(com.scalar.db.io.BlobValue) BooleanValue(com.scalar.db.io.BooleanValue) BlobValue(com.scalar.db.io.BlobValue) Test(org.junit.jupiter.api.Test)

Example 22 with BlobValue

use of com.scalar.db.io.BlobValue in project scalardb by scalar-labs.

the class StorageColumnValueIntegrationTestBase method put_WithNullValues_ShouldPutCorrectly.

@Test
public void put_WithNullValues_ShouldPutCorrectly() throws ExecutionException {
    // Arrange
    IntValue partitionKeyValue = new IntValue(PARTITION_KEY, 1);
    BooleanValue col1Value = new BooleanValue(COL_NAME1, false);
    IntValue col2Value = new IntValue(COL_NAME2, 0);
    BigIntValue col3Value = new BigIntValue(COL_NAME3, 0L);
    FloatValue col4Value = new FloatValue(COL_NAME4, 0.0f);
    DoubleValue col5Value = new DoubleValue(COL_NAME5, 0.0d);
    TextValue col6Value = new TextValue(COL_NAME6, (String) null);
    BlobValue col7Value = new BlobValue(COL_NAME7, (byte[]) null);
    Put put = new Put(new Key(partitionKeyValue)).withNullValue(COL_NAME1).withNullValue(COL_NAME2).withNullValue(COL_NAME3).withNullValue(COL_NAME4).withNullValue(COL_NAME5).withNullValue(COL_NAME6).withNullValue(COL_NAME7).forNamespace(namespace).forTable(TABLE);
    // Act
    storage.put(put);
    // Assert
    Optional<Result> actual = storage.get(new Get(new Key(partitionKeyValue)).forNamespace(namespace).forTable(TABLE));
    assertThat(actual).isPresent();
    assertThat(actual.get().getValue(PARTITION_KEY).isPresent()).isTrue();
    assertThat(actual.get().getValue(PARTITION_KEY).get()).isEqualTo(partitionKeyValue);
    assertThat(actual.get().getValue(COL_NAME1).isPresent()).isTrue();
    assertThat(actual.get().getValue(COL_NAME1).get()).isEqualTo(col1Value);
    assertThat(actual.get().getValue(COL_NAME2).isPresent()).isTrue();
    assertThat(actual.get().getValue(COL_NAME2).get()).isEqualTo(col2Value);
    assertThat(actual.get().getValue(COL_NAME3).isPresent()).isTrue();
    assertThat(actual.get().getValue(COL_NAME3).get()).isEqualTo(col3Value);
    assertThat(actual.get().getValue(COL_NAME4).isPresent()).isTrue();
    assertThat(actual.get().getValue(COL_NAME4).get()).isEqualTo(col4Value);
    assertThat(actual.get().getValue(COL_NAME5).isPresent()).isTrue();
    assertThat(actual.get().getValue(COL_NAME5).get()).isEqualTo(col5Value);
    assertThat(actual.get().getValue(COL_NAME6).isPresent()).isTrue();
    assertThat(actual.get().getValue(COL_NAME6).get()).isEqualTo(col6Value);
    assertThat(actual.get().getValue(COL_NAME7).isPresent()).isTrue();
    assertThat(actual.get().getValue(COL_NAME7).get()).isEqualTo(col7Value);
    assertThat(actual.get().getContainedColumnNames()).isEqualTo(new HashSet<>(Arrays.asList(PARTITION_KEY, COL_NAME1, COL_NAME2, COL_NAME3, COL_NAME4, COL_NAME5, COL_NAME6, COL_NAME7)));
    assertThat(actual.get().contains(PARTITION_KEY)).isTrue();
    assertThat(actual.get().isNull(PARTITION_KEY)).isFalse();
    assertThat(actual.get().getInt(PARTITION_KEY)).isEqualTo(partitionKeyValue.get());
    assertThat(actual.get().getAsObject(PARTITION_KEY)).isEqualTo(partitionKeyValue.get());
    assertThat(actual.get().contains(COL_NAME1)).isTrue();
    assertThat(actual.get().isNull(COL_NAME1)).isTrue();
    assertThat(actual.get().getBoolean(COL_NAME1)).isEqualTo(col1Value.get());
    assertThat(actual.get().getAsObject(COL_NAME1)).isNull();
    assertThat(actual.get().contains(COL_NAME2)).isTrue();
    assertThat(actual.get().isNull(COL_NAME2)).isTrue();
    assertThat(actual.get().getInt(COL_NAME2)).isEqualTo(col2Value.get());
    assertThat(actual.get().getAsObject(COL_NAME2)).isNull();
    assertThat(actual.get().contains(COL_NAME3)).isTrue();
    assertThat(actual.get().isNull(COL_NAME3)).isTrue();
    assertThat(actual.get().getBigInt(COL_NAME3)).isEqualTo(col3Value.get());
    assertThat(actual.get().getAsObject(COL_NAME3)).isNull();
    assertThat(actual.get().contains(COL_NAME4)).isTrue();
    assertThat(actual.get().isNull(COL_NAME4)).isTrue();
    assertThat(actual.get().getFloat(COL_NAME4)).isEqualTo(col4Value.get());
    assertThat(actual.get().getAsObject(COL_NAME4)).isNull();
    assertThat(actual.get().contains(COL_NAME5)).isTrue();
    assertThat(actual.get().isNull(COL_NAME5)).isTrue();
    assertThat(actual.get().getDouble(COL_NAME5)).isEqualTo(col5Value.get());
    assertThat(actual.get().getAsObject(COL_NAME5)).isNull();
    assertThat(actual.get().contains(COL_NAME6)).isTrue();
    assertThat(actual.get().isNull(COL_NAME6)).isTrue();
    assertThat(actual.get().getText(COL_NAME6)).isNull();
    assertThat(actual.get().getAsObject(COL_NAME6)).isNull();
    assertThat(actual.get().contains(COL_NAME7)).isTrue();
    assertThat(actual.get().isNull(COL_NAME7)).isTrue();
    assertThat(actual.get().getBlob(COL_NAME7)).isNull();
    assertThat(actual.get().getBlobAsByteBuffer(COL_NAME7)).isNull();
    assertThat(actual.get().getBlobAsBytes(COL_NAME7)).isNull();
    assertThat(actual.get().getAsObject(COL_NAME7)).isNull();
}
Also used : Put(com.scalar.db.api.Put) BlobValue(com.scalar.db.io.BlobValue) Result(com.scalar.db.api.Result) DoubleValue(com.scalar.db.io.DoubleValue) TextValue(com.scalar.db.io.TextValue) BooleanValue(com.scalar.db.io.BooleanValue) Get(com.scalar.db.api.Get) FloatValue(com.scalar.db.io.FloatValue) IntValue(com.scalar.db.io.IntValue) BigIntValue(com.scalar.db.io.BigIntValue) Key(com.scalar.db.io.Key) BigIntValue(com.scalar.db.io.BigIntValue) Test(org.junit.Test)

Example 23 with BlobValue

use of com.scalar.db.io.BlobValue in project scalardb by scalar-labs.

the class ConditionExpressionTest method constructor_ProperArgsGiven_ShouldConstructProperly.

@Test
public void constructor_ProperArgsGiven_ShouldConstructProperly() {
    // Arrange
    // Act
    ConditionalExpression expression1 = new ConditionalExpression("col1", new TextValue("aaa"), Operator.EQ);
    ConditionalExpression expression2 = new ConditionalExpression("col2", true, Operator.EQ);
    ConditionalExpression expression3 = new ConditionalExpression("col3", 123, Operator.NE);
    ConditionalExpression expression4 = new ConditionalExpression("col4", 456L, Operator.GT);
    ConditionalExpression expression5 = new ConditionalExpression("col5", 1.23F, Operator.GTE);
    ConditionalExpression expression6 = new ConditionalExpression("col6", 4.56D, Operator.LT);
    ConditionalExpression expression7 = new ConditionalExpression("col7", "text", Operator.LTE);
    ConditionalExpression expression8 = new ConditionalExpression("col8", "blob".getBytes(StandardCharsets.UTF_8), Operator.EQ);
    ConditionalExpression expression9 = new ConditionalExpression("col9", ByteBuffer.wrap("blob2".getBytes(StandardCharsets.UTF_8)), Operator.NE);
    // Assert
    assertThat(expression1.getColumnName()).isEqualTo("col1");
    assertThat(expression1.getValue()).isEqualTo(new TextValue("aaa"));
    assertThat(expression1.getTextValue()).isEqualTo("aaa");
    assertThat(expression1.getValueAsObject()).isEqualTo("aaa");
    assertThat(expression1.getOperator()).isEqualTo(Operator.EQ);
    assertThat(expression2.getColumnName()).isEqualTo("col2");
    assertThat(expression2.getValue()).isEqualTo(new BooleanValue(true));
    assertThat(expression2.getBooleanValue()).isTrue();
    assertThat(expression2.getValueAsObject()).isEqualTo(true);
    assertThat(expression2.getOperator()).isEqualTo(Operator.EQ);
    assertThat(expression3.getColumnName()).isEqualTo("col3");
    assertThat(expression3.getValue()).isEqualTo(new IntValue(123));
    assertThat(expression3.getIntValue()).isEqualTo(123);
    assertThat(expression3.getValueAsObject()).isEqualTo(123);
    assertThat(expression3.getOperator()).isEqualTo(Operator.NE);
    assertThat(expression4.getColumnName()).isEqualTo("col4");
    assertThat(expression4.getValue()).isEqualTo(new BigIntValue(456L));
    assertThat(expression4.getBigIntValue()).isEqualTo(456L);
    assertThat(expression4.getValueAsObject()).isEqualTo(456L);
    assertThat(expression4.getOperator()).isEqualTo(Operator.GT);
    assertThat(expression5.getColumnName()).isEqualTo("col5");
    assertThat(expression5.getValue()).isEqualTo(new FloatValue(1.23F));
    assertThat(expression5.getFloatValue()).isEqualTo(1.23F);
    assertThat(expression5.getValueAsObject()).isEqualTo(1.23F);
    assertThat(expression5.getOperator()).isEqualTo(Operator.GTE);
    assertThat(expression6.getColumnName()).isEqualTo("col6");
    assertThat(expression6.getValue()).isEqualTo(new DoubleValue(4.56D));
    assertThat(expression6.getDoubleValue()).isEqualTo(4.56D);
    assertThat(expression6.getValueAsObject()).isEqualTo(4.56D);
    assertThat(expression6.getOperator()).isEqualTo(Operator.LT);
    assertThat(expression7.getColumnName()).isEqualTo("col7");
    assertThat(expression7.getValue()).isEqualTo(new TextValue("text"));
    assertThat(expression7.getTextValue()).isEqualTo("text");
    assertThat(expression7.getValueAsObject()).isEqualTo("text");
    assertThat(expression7.getOperator()).isEqualTo(Operator.LTE);
    assertThat(expression8.getColumnName()).isEqualTo("col8");
    assertThat(expression8.getValue()).isEqualTo(new BlobValue("blob".getBytes(StandardCharsets.UTF_8)));
    assertThat(expression8.getBlobValue()).isEqualTo(ByteBuffer.wrap("blob".getBytes(StandardCharsets.UTF_8)));
    assertThat(expression8.getBlobValueAsByteBuffer()).isEqualTo(ByteBuffer.wrap("blob".getBytes(StandardCharsets.UTF_8)));
    assertThat(expression8.getBlobValueAsBytes()).isEqualTo("blob".getBytes(StandardCharsets.UTF_8));
    assertThat(expression8.getValueAsObject()).isEqualTo(ByteBuffer.wrap("blob".getBytes(StandardCharsets.UTF_8)));
    assertThat(expression8.getOperator()).isEqualTo(Operator.EQ);
    assertThat(expression9.getColumnName()).isEqualTo("col9");
    assertThat(expression9.getValue()).isEqualTo(new BlobValue("blob2".getBytes(StandardCharsets.UTF_8)));
    assertThat(expression9.getBlobValue()).isEqualTo(ByteBuffer.wrap("blob2".getBytes(StandardCharsets.UTF_8)));
    assertThat(expression9.getBlobValueAsByteBuffer()).isEqualTo(ByteBuffer.wrap("blob2".getBytes(StandardCharsets.UTF_8)));
    assertThat(expression9.getBlobValueAsBytes()).isEqualTo("blob2".getBytes(StandardCharsets.UTF_8));
    assertThat(expression9.getValueAsObject()).isEqualTo(ByteBuffer.wrap("blob2".getBytes(StandardCharsets.UTF_8)));
    assertThat(expression9.getOperator()).isEqualTo(Operator.NE);
}
Also used : DoubleValue(com.scalar.db.io.DoubleValue) TextValue(com.scalar.db.io.TextValue) BooleanValue(com.scalar.db.io.BooleanValue) FloatValue(com.scalar.db.io.FloatValue) IntValue(com.scalar.db.io.IntValue) BigIntValue(com.scalar.db.io.BigIntValue) BigIntValue(com.scalar.db.io.BigIntValue) BlobValue(com.scalar.db.io.BlobValue) Test(org.junit.Test)

Example 24 with BlobValue

use of com.scalar.db.io.BlobValue in project scalardb by scalar-labs.

the class ResultImplTest method getValue_ProperNullValuesGivenInConstructor_ShouldReturnWhatsSet.

@Test
public void getValue_ProperNullValuesGivenInConstructor_ShouldReturnWhatsSet() {
    // Arrange
    ResultImpl result = new ResultImpl(ImmutableMap.<String, Optional<Value<?>>>builder().put(ANY_NAME_1, Optional.of(new TextValue(ANY_NAME_1, ANY_TEXT_1))).put(ANY_NAME_2, Optional.of(new TextValue(ANY_NAME_2, ANY_TEXT_2))).put(ANY_COLUMN_NAME_1, Optional.empty()).put(ANY_COLUMN_NAME_2, Optional.empty()).put(ANY_COLUMN_NAME_3, Optional.empty()).put(ANY_COLUMN_NAME_4, Optional.empty()).put(ANY_COLUMN_NAME_5, Optional.empty()).put(ANY_COLUMN_NAME_6, Optional.empty()).put(ANY_COLUMN_NAME_7, Optional.empty()).build(), TABLE_METADATA);
    // Act Assert
    assertThat(result.getValue(ANY_NAME_1)).isEqualTo(Optional.of(new TextValue(ANY_NAME_1, ANY_TEXT_1)));
    assertThat(result.getValue(ANY_NAME_2)).isEqualTo(Optional.of(new TextValue(ANY_NAME_2, ANY_TEXT_2)));
    assertThat(result.getValue(ANY_COLUMN_NAME_1)).isEqualTo(Optional.of(new BooleanValue(ANY_COLUMN_NAME_1, false)));
    assertThat(result.getValue(ANY_COLUMN_NAME_2)).isEqualTo(Optional.of(new IntValue(ANY_COLUMN_NAME_2, 0)));
    assertThat(result.getValue(ANY_COLUMN_NAME_3)).isEqualTo(Optional.of(new BigIntValue(ANY_COLUMN_NAME_3, 0L)));
    assertThat(result.getValue(ANY_COLUMN_NAME_4)).isEqualTo(Optional.of(new FloatValue(ANY_COLUMN_NAME_4, 0.0F)));
    assertThat(result.getValue(ANY_COLUMN_NAME_5)).isEqualTo(Optional.of(new DoubleValue(ANY_COLUMN_NAME_5, 0.0D)));
    assertThat(result.getValue(ANY_COLUMN_NAME_6)).isEqualTo(Optional.of(new TextValue(ANY_COLUMN_NAME_6, (String) null)));
    assertThat(result.getValue(ANY_COLUMN_NAME_7)).isEqualTo(Optional.of(new BlobValue(ANY_COLUMN_NAME_7, (byte[]) null)));
    assertThat(result.getContainedColumnNames()).isEqualTo(new HashSet<>(Arrays.asList(ANY_NAME_1, ANY_NAME_2, ANY_COLUMN_NAME_1, ANY_COLUMN_NAME_2, ANY_COLUMN_NAME_3, ANY_COLUMN_NAME_4, ANY_COLUMN_NAME_5, ANY_COLUMN_NAME_6, ANY_COLUMN_NAME_7)));
    assertThat(result.contains(ANY_NAME_1)).isTrue();
    assertThat(result.isNull(ANY_NAME_1)).isFalse();
    assertThat(result.getText(ANY_NAME_1)).isEqualTo(ANY_TEXT_1);
    assertThat(result.getAsObject(ANY_NAME_1)).isEqualTo(ANY_TEXT_1);
    assertThat(result.contains(ANY_NAME_2)).isTrue();
    assertThat(result.isNull(ANY_NAME_2)).isFalse();
    assertThat(result.getText(ANY_NAME_2)).isEqualTo(ANY_TEXT_2);
    assertThat(result.getAsObject(ANY_NAME_2)).isEqualTo(ANY_TEXT_2);
    assertThat(result.contains(ANY_COLUMN_NAME_1)).isTrue();
    assertThat(result.isNull(ANY_COLUMN_NAME_1)).isTrue();
    assertThat(result.getBoolean(ANY_COLUMN_NAME_1)).isEqualTo(false);
    assertThat(result.getAsObject(ANY_COLUMN_NAME_1)).isNull();
    assertThat(result.contains(ANY_COLUMN_NAME_2)).isTrue();
    assertThat(result.isNull(ANY_COLUMN_NAME_2)).isTrue();
    assertThat(result.getInt(ANY_COLUMN_NAME_2)).isEqualTo(0);
    assertThat(result.getAsObject(ANY_COLUMN_NAME_2)).isNull();
    assertThat(result.contains(ANY_COLUMN_NAME_3)).isTrue();
    assertThat(result.isNull(ANY_COLUMN_NAME_3)).isTrue();
    assertThat(result.getBigInt(ANY_COLUMN_NAME_3)).isEqualTo(0L);
    assertThat(result.getAsObject(ANY_COLUMN_NAME_3)).isNull();
    assertThat(result.contains(ANY_COLUMN_NAME_4)).isTrue();
    assertThat(result.isNull(ANY_COLUMN_NAME_4)).isTrue();
    assertThat(result.getFloat(ANY_COLUMN_NAME_4)).isEqualTo(0.0F);
    assertThat(result.getAsObject(ANY_COLUMN_NAME_4)).isNull();
    assertThat(result.contains(ANY_COLUMN_NAME_5)).isTrue();
    assertThat(result.isNull(ANY_COLUMN_NAME_5)).isTrue();
    assertThat(result.getDouble(ANY_COLUMN_NAME_5)).isEqualTo(0.0D);
    assertThat(result.getAsObject(ANY_COLUMN_NAME_5)).isNull();
    assertThat(result.contains(ANY_COLUMN_NAME_6)).isTrue();
    assertThat(result.isNull(ANY_COLUMN_NAME_6)).isTrue();
    assertThat(result.getText(ANY_COLUMN_NAME_6)).isNull();
    assertThat(result.getAsObject(ANY_COLUMN_NAME_6)).isNull();
    assertThat(result.contains(ANY_COLUMN_NAME_7)).isTrue();
    assertThat(result.isNull(ANY_COLUMN_NAME_7)).isTrue();
    assertThat(result.getBlob(ANY_COLUMN_NAME_7)).isNull();
    assertThat(result.getBlobAsByteBuffer(ANY_COLUMN_NAME_7)).isNull();
    assertThat(result.getBlobAsBytes(ANY_COLUMN_NAME_7)).isNull();
    assertThat(result.getAsObject(ANY_COLUMN_NAME_7)).isNull();
}
Also used : DoubleValue(com.scalar.db.io.DoubleValue) TextValue(com.scalar.db.io.TextValue) BooleanValue(com.scalar.db.io.BooleanValue) IntValue(com.scalar.db.io.IntValue) DoubleValue(com.scalar.db.io.DoubleValue) TextValue(com.scalar.db.io.TextValue) Value(com.scalar.db.io.Value) BigIntValue(com.scalar.db.io.BigIntValue) FloatValue(com.scalar.db.io.FloatValue) BlobValue(com.scalar.db.io.BlobValue) BooleanValue(com.scalar.db.io.BooleanValue) FloatValue(com.scalar.db.io.FloatValue) IntValue(com.scalar.db.io.IntValue) BigIntValue(com.scalar.db.io.BigIntValue) BigIntValue(com.scalar.db.io.BigIntValue) BlobValue(com.scalar.db.io.BlobValue) Test(org.junit.Test)

Example 25 with BlobValue

use of com.scalar.db.io.BlobValue in project scalardb by scalar-labs.

the class ResultImplTest method getValue_ProperValuesWithNullTextValueAndNullBlobValueGivenInConstructor_ShouldReturnWhatsSet.

@Test
public void getValue_ProperValuesWithNullTextValueAndNullBlobValueGivenInConstructor_ShouldReturnWhatsSet() {
    // Arrange
    ResultImpl result = new ResultImpl(ImmutableMap.<String, Optional<Value<?>>>builder().put(ANY_NAME_1, Optional.of(new TextValue(ANY_NAME_1, ANY_TEXT_1))).put(ANY_NAME_2, Optional.of(new TextValue(ANY_NAME_2, ANY_TEXT_2))).put(ANY_COLUMN_NAME_1, Optional.of(new BooleanValue(ANY_COLUMN_NAME_1, true))).put(ANY_COLUMN_NAME_2, Optional.of(new IntValue(ANY_COLUMN_NAME_2, Integer.MAX_VALUE))).put(ANY_COLUMN_NAME_3, Optional.of(new BigIntValue(ANY_COLUMN_NAME_3, BigIntValue.MAX_VALUE))).put(ANY_COLUMN_NAME_4, Optional.of(new FloatValue(ANY_COLUMN_NAME_4, Float.MAX_VALUE))).put(ANY_COLUMN_NAME_5, Optional.of(new DoubleValue(ANY_COLUMN_NAME_5, Double.MAX_VALUE))).put(ANY_COLUMN_NAME_6, Optional.of(new TextValue(ANY_COLUMN_NAME_6, (String) null))).put(ANY_COLUMN_NAME_7, Optional.of(new BlobValue(ANY_COLUMN_NAME_7, (byte[]) null))).build(), TABLE_METADATA);
    // Act Assert
    assertThat(result.getValue(ANY_NAME_1)).isEqualTo(Optional.of(new TextValue(ANY_NAME_1, ANY_TEXT_1)));
    assertThat(result.getValue(ANY_NAME_2)).isEqualTo(Optional.of(new TextValue(ANY_NAME_2, ANY_TEXT_2)));
    assertThat(result.getValue(ANY_COLUMN_NAME_1)).isEqualTo(Optional.of(new BooleanValue(ANY_COLUMN_NAME_1, true)));
    assertThat(result.getValue(ANY_COLUMN_NAME_2)).isEqualTo(Optional.of(new IntValue(ANY_COLUMN_NAME_2, Integer.MAX_VALUE)));
    assertThat(result.getValue(ANY_COLUMN_NAME_3)).isEqualTo(Optional.of(new BigIntValue(ANY_COLUMN_NAME_3, BigIntValue.MAX_VALUE)));
    assertThat(result.getValue(ANY_COLUMN_NAME_4)).isEqualTo(Optional.of(new FloatValue(ANY_COLUMN_NAME_4, Float.MAX_VALUE)));
    assertThat(result.getValue(ANY_COLUMN_NAME_5)).isEqualTo(Optional.of(new DoubleValue(ANY_COLUMN_NAME_5, Double.MAX_VALUE)));
    assertThat(result.getValue(ANY_COLUMN_NAME_6)).isEqualTo(Optional.of(new TextValue(ANY_COLUMN_NAME_6, (String) null)));
    assertThat(result.getValue(ANY_COLUMN_NAME_7)).isEqualTo(Optional.of(new BlobValue(ANY_COLUMN_NAME_7, (byte[]) null)));
    assertThat(result.getContainedColumnNames()).isEqualTo(new HashSet<>(Arrays.asList(ANY_NAME_1, ANY_NAME_2, ANY_COLUMN_NAME_1, ANY_COLUMN_NAME_2, ANY_COLUMN_NAME_3, ANY_COLUMN_NAME_4, ANY_COLUMN_NAME_5, ANY_COLUMN_NAME_6, ANY_COLUMN_NAME_7)));
    assertThat(result.contains(ANY_NAME_1)).isTrue();
    assertThat(result.isNull(ANY_NAME_1)).isFalse();
    assertThat(result.getText(ANY_NAME_1)).isEqualTo(ANY_TEXT_1);
    assertThat(result.getAsObject(ANY_NAME_1)).isEqualTo(ANY_TEXT_1);
    assertThat(result.contains(ANY_NAME_2)).isTrue();
    assertThat(result.isNull(ANY_NAME_2)).isFalse();
    assertThat(result.getText(ANY_NAME_2)).isEqualTo(ANY_TEXT_2);
    assertThat(result.getAsObject(ANY_NAME_2)).isEqualTo(ANY_TEXT_2);
    assertThat(result.contains(ANY_COLUMN_NAME_1)).isTrue();
    assertThat(result.isNull(ANY_COLUMN_NAME_1)).isFalse();
    assertThat(result.getBoolean(ANY_COLUMN_NAME_1)).isEqualTo(true);
    assertThat(result.getAsObject(ANY_COLUMN_NAME_1)).isEqualTo(true);
    assertThat(result.contains(ANY_COLUMN_NAME_2)).isTrue();
    assertThat(result.isNull(ANY_COLUMN_NAME_2)).isFalse();
    assertThat(result.getInt(ANY_COLUMN_NAME_2)).isEqualTo(Integer.MAX_VALUE);
    assertThat(result.getAsObject(ANY_COLUMN_NAME_2)).isEqualTo(Integer.MAX_VALUE);
    assertThat(result.contains(ANY_COLUMN_NAME_3)).isTrue();
    assertThat(result.isNull(ANY_COLUMN_NAME_3)).isFalse();
    assertThat(result.getBigInt(ANY_COLUMN_NAME_3)).isEqualTo(BigIntValue.MAX_VALUE);
    assertThat(result.getAsObject(ANY_COLUMN_NAME_3)).isEqualTo(BigIntValue.MAX_VALUE);
    assertThat(result.contains(ANY_COLUMN_NAME_4)).isTrue();
    assertThat(result.isNull(ANY_COLUMN_NAME_4)).isFalse();
    assertThat(result.getFloat(ANY_COLUMN_NAME_4)).isEqualTo(Float.MAX_VALUE);
    assertThat(result.getAsObject(ANY_COLUMN_NAME_4)).isEqualTo(Float.MAX_VALUE);
    assertThat(result.contains(ANY_COLUMN_NAME_5)).isTrue();
    assertThat(result.isNull(ANY_COLUMN_NAME_5)).isFalse();
    assertThat(result.getDouble(ANY_COLUMN_NAME_5)).isEqualTo(Double.MAX_VALUE);
    assertThat(result.getAsObject(ANY_COLUMN_NAME_5)).isEqualTo(Double.MAX_VALUE);
    assertThat(result.contains(ANY_COLUMN_NAME_6)).isTrue();
    assertThat(result.isNull(ANY_COLUMN_NAME_6)).isTrue();
    assertThat(result.getText(ANY_COLUMN_NAME_6)).isNull();
    assertThat(result.getAsObject(ANY_COLUMN_NAME_6)).isNull();
    assertThat(result.contains(ANY_COLUMN_NAME_7)).isTrue();
    assertThat(result.isNull(ANY_COLUMN_NAME_7)).isTrue();
    assertThat(result.getBlob(ANY_COLUMN_NAME_7)).isNull();
    assertThat(result.getBlobAsByteBuffer(ANY_COLUMN_NAME_7)).isNull();
    assertThat(result.getBlobAsBytes(ANY_COLUMN_NAME_7)).isNull();
    assertThat(result.getAsObject(ANY_COLUMN_NAME_7)).isNull();
}
Also used : DoubleValue(com.scalar.db.io.DoubleValue) TextValue(com.scalar.db.io.TextValue) BooleanValue(com.scalar.db.io.BooleanValue) IntValue(com.scalar.db.io.IntValue) DoubleValue(com.scalar.db.io.DoubleValue) TextValue(com.scalar.db.io.TextValue) Value(com.scalar.db.io.Value) BigIntValue(com.scalar.db.io.BigIntValue) FloatValue(com.scalar.db.io.FloatValue) BlobValue(com.scalar.db.io.BlobValue) BooleanValue(com.scalar.db.io.BooleanValue) FloatValue(com.scalar.db.io.FloatValue) IntValue(com.scalar.db.io.IntValue) BigIntValue(com.scalar.db.io.BigIntValue) BigIntValue(com.scalar.db.io.BigIntValue) BlobValue(com.scalar.db.io.BlobValue) Test(org.junit.Test)

Aggregations

BlobValue (com.scalar.db.io.BlobValue)25 BigIntValue (com.scalar.db.io.BigIntValue)22 IntValue (com.scalar.db.io.IntValue)22 TextValue (com.scalar.db.io.TextValue)22 BooleanValue (com.scalar.db.io.BooleanValue)21 DoubleValue (com.scalar.db.io.DoubleValue)21 FloatValue (com.scalar.db.io.FloatValue)21 Test (org.junit.Test)14 Key (com.scalar.db.io.Key)12 Test (org.junit.jupiter.api.Test)10 Get (com.scalar.db.api.Get)6 Put (com.scalar.db.api.Put)6 Result (com.scalar.db.api.Result)6 Value (com.scalar.db.io.Value)6 BigIntColumn (com.scalar.db.io.BigIntColumn)2 BlobColumn (com.scalar.db.io.BlobColumn)2 BooleanColumn (com.scalar.db.io.BooleanColumn)2 Column (com.scalar.db.io.Column)2 DoubleColumn (com.scalar.db.io.DoubleColumn)2 FloatColumn (com.scalar.db.io.FloatColumn)2