Search in sources :

Example 51 with Value

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

the class SnapshotTest method get_KeyGivenContainedInWriteSetAndReadSet_ShouldReturnMergedResult.

@Test
public void get_KeyGivenContainedInWriteSetAndReadSet_ShouldReturnMergedResult() throws CrudException {
    // Arrange
    snapshot = prepareSnapshot(Isolation.SNAPSHOT);
    Key partitionKey = new Key(ANY_NAME_1, ANY_TEXT_1);
    Key clusteringKey = new Key(ANY_NAME_2, ANY_TEXT_2);
    Put put = new Put(partitionKey, clusteringKey).withConsistency(Consistency.LINEARIZABLE).forNamespace(ANY_NAMESPACE_NAME).forTable(ANY_TABLE_NAME).withValue(ANY_NAME_3, ANY_TEXT_5).withTextValue(ANY_NAME_4, null);
    Snapshot.Key key = new Snapshot.Key(prepareGet());
    TransactionResult result = prepareResult(ANY_ID);
    snapshot.put(key, Optional.of(result));
    snapshot.put(key, put);
    // Act
    Optional<TransactionResult> actual = snapshot.get(key);
    // Assert
    assertThat(actual).isPresent();
    assertThat(actual.get().getValues()).isEqualTo(ImmutableMap.<String, Value<?>>builder().put(ANY_NAME_1, new TextValue(ANY_NAME_1, ANY_TEXT_1)).put(ANY_NAME_2, new TextValue(ANY_NAME_2, ANY_TEXT_2)).put(ANY_NAME_3, new TextValue(ANY_NAME_3, ANY_TEXT_5)).put(ANY_NAME_4, new TextValue(ANY_NAME_4, (String) null)).put(Attribute.ID, Attribute.toIdValue(ANY_ID)).put(Attribute.VERSION, Attribute.toVersionValue(ANY_VERSION)).build());
    assertThat(actual.get().getValue(ANY_NAME_1).isPresent()).isTrue();
    assertThat(actual.get().getValue(ANY_NAME_1).get()).isEqualTo(new TextValue(ANY_NAME_1, ANY_TEXT_1));
    assertThat(actual.get().getValue(ANY_NAME_2).isPresent()).isTrue();
    assertThat(actual.get().getValue(ANY_NAME_2).get()).isEqualTo(new TextValue(ANY_NAME_2, ANY_TEXT_2));
    assertThat(actual.get().getValue(ANY_NAME_3).isPresent()).isTrue();
    assertThat(actual.get().getValue(ANY_NAME_3).get()).isEqualTo(new TextValue(ANY_NAME_3, ANY_TEXT_5));
    assertThat(actual.get().getValue(ANY_NAME_4).isPresent()).isTrue();
    assertThat(actual.get().getValue(ANY_NAME_4).get()).isEqualTo(new TextValue(ANY_NAME_4, (String) null));
    assertThat(actual.get().getValue(Attribute.ID).isPresent()).isTrue();
    assertThat(actual.get().getValue(Attribute.ID).get()).isEqualTo(Attribute.toIdValue(ANY_ID));
    assertThat(actual.get().getValue(Attribute.VERSION).isPresent()).isTrue();
    assertThat(actual.get().getValue(Attribute.VERSION).get()).isEqualTo(Attribute.toVersionValue(ANY_VERSION));
    assertThat(actual.get().getContainedColumnNames()).isEqualTo(new HashSet<>(Arrays.asList(ANY_NAME_1, ANY_NAME_2, ANY_NAME_3, ANY_NAME_4, Attribute.ID, Attribute.VERSION)));
    assertThat(actual.get().contains(ANY_NAME_1)).isTrue();
    assertThat(actual.get().isNull(ANY_NAME_1)).isFalse();
    assertThat(actual.get().getText(ANY_NAME_1)).isEqualTo(ANY_TEXT_1);
    assertThat(actual.get().getAsObject(ANY_NAME_1)).isEqualTo(ANY_TEXT_1);
    assertThat(actual.get().contains(ANY_NAME_2)).isTrue();
    assertThat(actual.get().isNull(ANY_NAME_2)).isFalse();
    assertThat(actual.get().getText(ANY_NAME_2)).isEqualTo(ANY_TEXT_2);
    assertThat(actual.get().getAsObject(ANY_NAME_2)).isEqualTo(ANY_TEXT_2);
    assertThat(actual.get().contains(ANY_NAME_3)).isTrue();
    assertThat(actual.get().isNull(ANY_NAME_3)).isFalse();
    assertThat(actual.get().getText(ANY_NAME_3)).isEqualTo(ANY_TEXT_5);
    assertThat(actual.get().getAsObject(ANY_NAME_3)).isEqualTo(ANY_TEXT_5);
    assertThat(actual.get().contains(ANY_NAME_4)).isTrue();
    assertThat(actual.get().isNull(ANY_NAME_4)).isTrue();
    assertThat(actual.get().getText(ANY_NAME_4)).isNull();
    assertThat(actual.get().getAsObject(ANY_NAME_4)).isNull();
    assertThat(actual.get().contains(Attribute.ID)).isTrue();
    assertThat(actual.get().isNull(Attribute.ID)).isFalse();
    assertThat(actual.get().getText(Attribute.ID)).isEqualTo(ANY_ID);
    assertThat(actual.get().getAsObject(Attribute.ID)).isEqualTo(ANY_ID);
    assertThat(actual.get().contains(Attribute.VERSION)).isTrue();
    assertThat(actual.get().isNull(Attribute.VERSION)).isFalse();
    assertThat(actual.get().getInt(Attribute.VERSION)).isEqualTo(ANY_VERSION);
    assertThat(actual.get().getAsObject(Attribute.VERSION)).isEqualTo(ANY_VERSION);
}
Also used : TextValue(com.scalar.db.io.TextValue) TextValue(com.scalar.db.io.TextValue) Value(com.scalar.db.io.Value) Key(com.scalar.db.io.Key) Put(com.scalar.db.api.Put) Test(org.junit.jupiter.api.Test)

Example 52 with Value

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

the class MergedResultTest method getValues_OnlyPutGiven_ShouldReturnMergedValues.

@Test
public void getValues_OnlyPutGiven_ShouldReturnMergedValues() {
    // Arrange
    Put put = new Put(new Key(ANY_NAME_1, ANY_TEXT_1), new Key(ANY_NAME_2, ANY_TEXT_2)).withValue(ANY_NAME_3, ANY_INT_3);
    MergedResult mergedResult = new MergedResult(Optional.empty(), put, TABLE_METADATA);
    // Act
    Map<String, Value<?>> values = mergedResult.getValues();
    // Assert
    assertThat(values.get(ANY_NAME_1)).isEqualTo(new TextValue(ANY_NAME_1, ANY_TEXT_1));
    assertThat(values.get(ANY_NAME_2)).isEqualTo(new TextValue(ANY_NAME_2, ANY_TEXT_2));
    assertThat(values.get(ANY_NAME_3)).isEqualTo(new IntValue(ANY_NAME_3, ANY_INT_3));
    assertThat(values.get(ANY_NAME_4)).isEqualTo(new TextValue(ANY_NAME_4, (String) null));
    assertThat(values.get(Attribute.ID)).isEqualTo(Attribute.toIdValue(null));
    assertThat(values.get(Attribute.PREPARED_AT)).isEqualTo(Attribute.toPreparedAtValue(0L));
    assertThat(values.get(Attribute.COMMITTED_AT)).isEqualTo(Attribute.toCommittedAtValue(0L));
    assertThat(values.get(Attribute.STATE)).isEqualTo(new IntValue(Attribute.STATE, 0));
    assertThat(values.get(Attribute.VERSION)).isEqualTo(Attribute.toVersionValue(0));
    assertThat(values.get(Attribute.BEFORE_PREFIX + ANY_NAME_3)).isEqualTo(new IntValue(Attribute.BEFORE_PREFIX + ANY_NAME_3, 0));
    assertThat(values.get(Attribute.BEFORE_ID)).isEqualTo(Attribute.toBeforeIdValue(null));
    assertThat(values.get(Attribute.BEFORE_PREPARED_AT)).isEqualTo(Attribute.toBeforePreparedAtValue(0L));
    assertThat(values.get(Attribute.BEFORE_COMMITTED_AT)).isEqualTo(Attribute.toBeforeCommittedAtValue(0L));
    assertThat(values.get(Attribute.BEFORE_STATE)).isEqualTo(new IntValue(Attribute.BEFORE_STATE, 0));
    assertThat(values.get(Attribute.BEFORE_VERSION)).isEqualTo(Attribute.toBeforeVersionValue(0));
}
Also used : TextValue(com.scalar.db.io.TextValue) IntValue(com.scalar.db.io.IntValue) TextValue(com.scalar.db.io.TextValue) Value(com.scalar.db.io.Value) IntValue(com.scalar.db.io.IntValue) Put(com.scalar.db.api.Put) Key(com.scalar.db.io.Key) Test(org.junit.jupiter.api.Test)

Example 53 with Value

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

the class MergedResultTest method getValues_ResultAndPutWithNullValueGiven_ShouldReturnMergedValues.

@Test
public void getValues_ResultAndPutWithNullValueGiven_ShouldReturnMergedValues() {
    // Arrange
    Put put = new Put(new Key(ANY_NAME_1, ANY_TEXT_1), new Key(ANY_NAME_2, ANY_TEXT_2)).withValue(ANY_NAME_3, ANY_INT_3).withTextValue(ANY_NAME_4, null);
    MergedResult mergedResult = new MergedResult(Optional.of(result), put, TABLE_METADATA);
    // Act
    Map<String, Value<?>> values = mergedResult.getValues();
    // Assert
    assertThat(values.get(ANY_NAME_1)).isEqualTo(new TextValue(ANY_NAME_1, ANY_TEXT_1));
    assertThat(values.get(ANY_NAME_2)).isEqualTo(new TextValue(ANY_NAME_2, ANY_TEXT_2));
    assertThat(values.get(ANY_NAME_3)).isEqualTo(new IntValue(ANY_NAME_3, ANY_INT_3));
    assertThat(values.get(ANY_NAME_4)).isEqualTo(new TextValue(ANY_NAME_4, (String) null));
    assertThat(values.get(Attribute.ID)).isEqualTo(Attribute.toIdValue(ANY_ID_2));
    assertThat(values.get(Attribute.PREPARED_AT)).isEqualTo(Attribute.toPreparedAtValue(ANY_TIME_3));
    assertThat(values.get(Attribute.COMMITTED_AT)).isEqualTo(Attribute.toCommittedAtValue(ANY_TIME_4));
    assertThat(values.get(Attribute.STATE)).isEqualTo(Attribute.toStateValue(TransactionState.COMMITTED));
    assertThat(values.get(Attribute.VERSION)).isEqualTo(Attribute.toVersionValue(ANY_VERSION_2));
    assertThat(values.get(Attribute.BEFORE_PREFIX + ANY_NAME_3)).isEqualTo(new IntValue(Attribute.BEFORE_PREFIX + ANY_NAME_3, ANY_INT_1));
    assertThat(values.get(Attribute.BEFORE_ID)).isEqualTo(Attribute.toBeforeIdValue(ANY_ID_1));
    assertThat(values.get(Attribute.BEFORE_PREPARED_AT)).isEqualTo(Attribute.toBeforePreparedAtValue(ANY_TIME_1));
    assertThat(values.get(Attribute.BEFORE_COMMITTED_AT)).isEqualTo(Attribute.toBeforeCommittedAtValue(ANY_TIME_2));
    assertThat(values.get(Attribute.BEFORE_STATE)).isEqualTo(Attribute.toBeforeStateValue(TransactionState.COMMITTED));
    assertThat(values.get(Attribute.BEFORE_VERSION)).isEqualTo(Attribute.toBeforeVersionValue(ANY_VERSION_1));
}
Also used : TextValue(com.scalar.db.io.TextValue) IntValue(com.scalar.db.io.IntValue) TextValue(com.scalar.db.io.TextValue) Value(com.scalar.db.io.Value) IntValue(com.scalar.db.io.IntValue) Put(com.scalar.db.api.Put) Key(com.scalar.db.io.Key) Test(org.junit.jupiter.api.Test)

Example 54 with Value

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

the class ResultInterpreterTest method interpret_ShouldReturnWhatsSetWithNullValues.

@Test
public void interpret_ShouldReturnWhatsSetWithNullValues() {
    // Arrange
    Record record = new Record();
    record.setId(ANY_ID_1);
    record.setConcatenatedPartitionKey(ANY_TEXT_1);
    record.setPartitionKey(ImmutableMap.of(ANY_NAME_1, ANY_TEXT_1));
    record.setClusteringKey(ImmutableMap.of(ANY_NAME_2, ANY_TEXT_2));
    Map<String, Object> v = new HashMap<>();
    v.put(ANY_COLUMN_NAME_1, null);
    v.put(ANY_COLUMN_NAME_2, null);
    v.put(ANY_COLUMN_NAME_3, null);
    v.put(ANY_COLUMN_NAME_4, null);
    v.put(ANY_COLUMN_NAME_5, null);
    v.put(ANY_COLUMN_NAME_6, null);
    v.put(ANY_COLUMN_NAME_7, null);
    record.setValues(v);
    List<String> projections = Collections.emptyList();
    ResultInterpreter spy = spy(new ResultInterpreter(projections, TABLE_METADATA));
    // Act
    Result result = spy.interpret(record);
    // Assert
    assertThat(result.getValue(ANY_NAME_1).isPresent()).isTrue();
    assertThat(result.getValue(ANY_NAME_1).get().getAsString().isPresent()).isTrue();
    assertThat(result.getValue(ANY_NAME_1).get().getAsString().get()).isEqualTo(ANY_TEXT_1);
    assertThat(result.getValue(ANY_NAME_2).isPresent()).isTrue();
    assertThat(result.getValue(ANY_NAME_2).get().getAsString().isPresent()).isTrue();
    assertThat(result.getValue(ANY_NAME_2).get().getAsString().get()).isEqualTo(ANY_TEXT_2);
    assertThat(result.getValue(ANY_COLUMN_NAME_1).isPresent()).isTrue();
    assertThat(result.getValue(ANY_COLUMN_NAME_1).get().getAsBoolean()).isFalse();
    assertThat(result.getValue(ANY_COLUMN_NAME_2).isPresent()).isTrue();
    assertThat(result.getValue(ANY_COLUMN_NAME_2).get().getAsInt()).isEqualTo(0);
    assertThat(result.getValue(ANY_COLUMN_NAME_3).isPresent()).isTrue();
    assertThat(result.getValue(ANY_COLUMN_NAME_3).get().getAsLong()).isEqualTo(0L);
    assertThat(result.getValue(ANY_COLUMN_NAME_4).isPresent()).isTrue();
    assertThat(result.getValue(ANY_COLUMN_NAME_4).get().getAsFloat()).isEqualTo(0.0F);
    assertThat(result.getValue(ANY_COLUMN_NAME_5).isPresent()).isTrue();
    assertThat(result.getValue(ANY_COLUMN_NAME_5).get().getAsDouble()).isEqualTo(0.0D);
    assertThat(result.getValue(ANY_COLUMN_NAME_6).isPresent()).isTrue();
    assertThat(result.getValue(ANY_COLUMN_NAME_6).get().getAsString()).isNotPresent();
    assertThat(result.getValue(ANY_COLUMN_NAME_7).isPresent()).isTrue();
    assertThat(result.getValue(ANY_COLUMN_NAME_7).get().getAsBytes()).isNotPresent();
    Map<String, Value<?>> values = result.getValues();
    assertThat(values.containsKey(ANY_NAME_1)).isTrue();
    assertThat(values.get(ANY_NAME_1).getAsString().isPresent()).isTrue();
    assertThat(values.get(ANY_NAME_1).getAsString().get()).isEqualTo(ANY_TEXT_1);
    assertThat(values.containsKey(ANY_NAME_2)).isTrue();
    assertThat(values.get(ANY_NAME_2).getAsString().isPresent()).isTrue();
    assertThat(values.get(ANY_NAME_2).getAsString().get()).isEqualTo(ANY_TEXT_2);
    assertThat(values.containsKey(ANY_COLUMN_NAME_1)).isTrue();
    assertThat(values.get(ANY_COLUMN_NAME_1).getAsBoolean()).isFalse();
    assertThat(values.containsKey(ANY_COLUMN_NAME_2)).isTrue();
    assertThat(values.get(ANY_COLUMN_NAME_2).getAsInt()).isEqualTo(0);
    assertThat(values.containsKey(ANY_COLUMN_NAME_3)).isTrue();
    assertThat(values.get(ANY_COLUMN_NAME_3).getAsLong()).isEqualTo(0L);
    assertThat(values.containsKey(ANY_COLUMN_NAME_4)).isTrue();
    assertThat(values.get(ANY_COLUMN_NAME_4).getAsFloat()).isEqualTo(0.0F);
    assertThat(values.containsKey(ANY_COLUMN_NAME_5)).isTrue();
    assertThat(values.get(ANY_COLUMN_NAME_5).getAsDouble()).isEqualTo(0.0D);
    assertThat(values.containsKey(ANY_COLUMN_NAME_6)).isTrue();
    assertThat(values.get(ANY_COLUMN_NAME_6).getAsString()).isNotPresent();
    assertThat(values.containsKey(ANY_COLUMN_NAME_7)).isTrue();
    assertThat(values.get(ANY_COLUMN_NAME_7).getAsBytes()).isNotPresent();
    assertThat(result.isNull(ANY_NAME_1)).isFalse();
    assertThat(result.getText(ANY_NAME_1)).isEqualTo(ANY_TEXT_1);
    assertThat(result.isNull(ANY_NAME_2)).isFalse();
    assertThat(result.getText(ANY_NAME_2)).isEqualTo(ANY_TEXT_2);
    assertThat(result.isNull(ANY_COLUMN_NAME_1)).isTrue();
    assertThat(result.getBoolean(ANY_COLUMN_NAME_1)).isFalse();
    assertThat(result.isNull(ANY_COLUMN_NAME_2)).isTrue();
    assertThat(result.getInt(ANY_COLUMN_NAME_2)).isEqualTo(0);
    assertThat(result.isNull(ANY_COLUMN_NAME_3)).isTrue();
    assertThat(result.getBigInt(ANY_COLUMN_NAME_3)).isEqualTo(0L);
    assertThat(result.isNull(ANY_COLUMN_NAME_4)).isTrue();
    assertThat(result.getFloat(ANY_COLUMN_NAME_4)).isEqualTo(0.0F);
    assertThat(result.isNull(ANY_COLUMN_NAME_5)).isTrue();
    assertThat(result.getDouble(ANY_COLUMN_NAME_5)).isEqualTo(0.0D);
    assertThat(result.isNull(ANY_COLUMN_NAME_6)).isTrue();
    assertThat(result.getText(ANY_COLUMN_NAME_6)).isNull();
    assertThat(result.isNull(ANY_COLUMN_NAME_7)).isTrue();
    assertThat(result.getBlob(ANY_COLUMN_NAME_7)).isNull();
    assertThat(result.getBlobAsBytes(ANY_COLUMN_NAME_7)).isNull();
}
Also used : HashMap(java.util.HashMap) Value(com.scalar.db.io.Value) BigIntValue(com.scalar.db.io.BigIntValue) Result(com.scalar.db.api.Result) Test(org.junit.jupiter.api.Test)

Example 55 with Value

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

the class ResultInterpreterTest method interpret_ShouldReturnWhatsSet.

@Test
public void interpret_ShouldReturnWhatsSet() {
    // Arrange
    Record record = new Record();
    record.setId(ANY_ID_1);
    record.setConcatenatedPartitionKey(ANY_TEXT_1);
    record.setPartitionKey(ImmutableMap.of(ANY_NAME_1, ANY_TEXT_1));
    record.setClusteringKey(ImmutableMap.of(ANY_NAME_2, ANY_TEXT_2));
    record.setValues(ImmutableMap.<String, Object>builder().put(ANY_COLUMN_NAME_1, true).put(ANY_COLUMN_NAME_2, Integer.MAX_VALUE).put(ANY_COLUMN_NAME_3, BigIntValue.MAX_VALUE).put(ANY_COLUMN_NAME_4, Float.MAX_VALUE).put(ANY_COLUMN_NAME_5, Double.MAX_VALUE).put(ANY_COLUMN_NAME_6, "string").put(ANY_COLUMN_NAME_7, Base64.getEncoder().encodeToString("bytes".getBytes(StandardCharsets.UTF_8))).build());
    List<String> projections = Collections.emptyList();
    ResultInterpreter spy = spy(new ResultInterpreter(projections, TABLE_METADATA));
    // Act
    Result result = spy.interpret(record);
    // Assert
    assertThat(result.getValue(ANY_NAME_1).isPresent()).isTrue();
    assertThat(result.getValue(ANY_NAME_1).get().getAsString().isPresent()).isTrue();
    assertThat(result.getValue(ANY_NAME_1).get().getAsString().get()).isEqualTo(ANY_TEXT_1);
    assertThat(result.getValue(ANY_NAME_2).isPresent()).isTrue();
    assertThat(result.getValue(ANY_NAME_2).get().getAsString().isPresent()).isTrue();
    assertThat(result.getValue(ANY_NAME_2).get().getAsString().get()).isEqualTo(ANY_TEXT_2);
    assertThat(result.getValue(ANY_COLUMN_NAME_1).isPresent()).isTrue();
    assertThat(result.getValue(ANY_COLUMN_NAME_1).get().getAsBoolean()).isTrue();
    assertThat(result.getValue(ANY_COLUMN_NAME_2).isPresent()).isTrue();
    assertThat(result.getValue(ANY_COLUMN_NAME_2).get().getAsInt()).isEqualTo(Integer.MAX_VALUE);
    assertThat(result.getValue(ANY_COLUMN_NAME_3).isPresent()).isTrue();
    assertThat(result.getValue(ANY_COLUMN_NAME_3).get().getAsLong()).isEqualTo(BigIntValue.MAX_VALUE);
    assertThat(result.getValue(ANY_COLUMN_NAME_4).isPresent()).isTrue();
    assertThat(result.getValue(ANY_COLUMN_NAME_4).get().getAsFloat()).isEqualTo(Float.MAX_VALUE);
    assertThat(result.getValue(ANY_COLUMN_NAME_5).isPresent()).isTrue();
    assertThat(result.getValue(ANY_COLUMN_NAME_5).get().getAsDouble()).isEqualTo(Double.MAX_VALUE);
    assertThat(result.getValue(ANY_COLUMN_NAME_6).isPresent()).isTrue();
    assertThat(result.getValue(ANY_COLUMN_NAME_6).get().getAsString().isPresent()).isTrue();
    assertThat(result.getValue(ANY_COLUMN_NAME_6).get().getAsString().get()).isEqualTo("string");
    assertThat(result.getValue(ANY_COLUMN_NAME_7).isPresent()).isTrue();
    assertThat(result.getValue(ANY_COLUMN_NAME_7).get().getAsBytes().isPresent()).isTrue();
    assertThat(result.getValue(ANY_COLUMN_NAME_7).get().getAsBytes().get()).isEqualTo("bytes".getBytes(StandardCharsets.UTF_8));
    Map<String, Value<?>> values = result.getValues();
    assertThat(values.containsKey(ANY_NAME_1)).isTrue();
    assertThat(values.get(ANY_NAME_1).getAsString().isPresent()).isTrue();
    assertThat(values.get(ANY_NAME_1).getAsString().get()).isEqualTo(ANY_TEXT_1);
    assertThat(values.containsKey(ANY_NAME_2)).isTrue();
    assertThat(values.get(ANY_NAME_2).getAsString().isPresent()).isTrue();
    assertThat(values.get(ANY_NAME_2).getAsString().get()).isEqualTo(ANY_TEXT_2);
    assertThat(values.containsKey(ANY_COLUMN_NAME_1)).isTrue();
    assertThat(values.get(ANY_COLUMN_NAME_1).getAsBoolean()).isTrue();
    assertThat(values.containsKey(ANY_COLUMN_NAME_2)).isTrue();
    assertThat(values.get(ANY_COLUMN_NAME_2).getAsInt()).isEqualTo(Integer.MAX_VALUE);
    assertThat(values.containsKey(ANY_COLUMN_NAME_3)).isTrue();
    assertThat(values.get(ANY_COLUMN_NAME_3).getAsLong()).isEqualTo(BigIntValue.MAX_VALUE);
    assertThat(values.containsKey(ANY_COLUMN_NAME_4)).isTrue();
    assertThat(values.get(ANY_COLUMN_NAME_4).getAsFloat()).isEqualTo(Float.MAX_VALUE);
    assertThat(values.containsKey(ANY_COLUMN_NAME_5)).isTrue();
    assertThat(values.get(ANY_COLUMN_NAME_5).getAsDouble()).isEqualTo(Double.MAX_VALUE);
    assertThat(values.containsKey(ANY_COLUMN_NAME_6)).isTrue();
    assertThat(values.get(ANY_COLUMN_NAME_6).getAsString().isPresent()).isTrue();
    assertThat(values.get(ANY_COLUMN_NAME_6).getAsString().get()).isEqualTo("string");
    assertThat(values.containsKey(ANY_COLUMN_NAME_7)).isTrue();
    assertThat(values.get(ANY_COLUMN_NAME_7).getAsBytes().isPresent()).isTrue();
    assertThat(values.get(ANY_COLUMN_NAME_7).getAsBytes().get()).isEqualTo("bytes".getBytes(StandardCharsets.UTF_8));
    assertThat(result.isNull(ANY_NAME_1)).isFalse();
    assertThat(result.getText(ANY_NAME_1)).isEqualTo(ANY_TEXT_1);
    assertThat(result.isNull(ANY_NAME_2)).isFalse();
    assertThat(result.getText(ANY_NAME_2)).isEqualTo(ANY_TEXT_2);
    assertThat(result.isNull(ANY_COLUMN_NAME_1)).isFalse();
    assertThat(result.getBoolean(ANY_COLUMN_NAME_1)).isTrue();
    assertThat(result.isNull(ANY_COLUMN_NAME_2)).isFalse();
    assertThat(result.getInt(ANY_COLUMN_NAME_2)).isEqualTo(Integer.MAX_VALUE);
    assertThat(result.isNull(ANY_COLUMN_NAME_3)).isFalse();
    assertThat(result.getBigInt(ANY_COLUMN_NAME_3)).isEqualTo(BigIntValue.MAX_VALUE);
    assertThat(result.isNull(ANY_COLUMN_NAME_4)).isFalse();
    assertThat(result.getFloat(ANY_COLUMN_NAME_4)).isEqualTo(Float.MAX_VALUE);
    assertThat(result.isNull(ANY_COLUMN_NAME_5)).isFalse();
    assertThat(result.getDouble(ANY_COLUMN_NAME_5)).isEqualTo(Double.MAX_VALUE);
    assertThat(result.isNull(ANY_COLUMN_NAME_6)).isFalse();
    assertThat(result.getText(ANY_COLUMN_NAME_6)).isEqualTo("string");
    assertThat(result.isNull(ANY_COLUMN_NAME_7)).isFalse();
    assertThat(result.getBlob(ANY_COLUMN_NAME_7)).isEqualTo(ByteBuffer.wrap("bytes".getBytes(StandardCharsets.UTF_8)));
    assertThat(result.getBlobAsBytes(ANY_COLUMN_NAME_7)).isEqualTo("bytes".getBytes(StandardCharsets.UTF_8));
}
Also used : Value(com.scalar.db.io.Value) BigIntValue(com.scalar.db.io.BigIntValue) Result(com.scalar.db.api.Result) Test(org.junit.jupiter.api.Test)

Aggregations

Value (com.scalar.db.io.Value)85 Test (org.junit.jupiter.api.Test)50 TextValue (com.scalar.db.io.TextValue)36 IntValue (com.scalar.db.io.IntValue)34 Put (com.scalar.db.api.Put)31 BooleanValue (com.scalar.db.io.BooleanValue)30 DoubleValue (com.scalar.db.io.DoubleValue)30 Key (com.scalar.db.io.Key)30 Result (com.scalar.db.api.Result)19 BigIntValue (com.scalar.db.io.BigIntValue)18 DataType (com.scalar.db.io.DataType)18 Order (com.scalar.db.api.Scan.Ordering.Order)16 Test (org.junit.Test)14 MutationCondition (com.scalar.db.api.MutationCondition)12 ArrayList (java.util.ArrayList)12 BlobValue (com.scalar.db.io.BlobValue)10 FloatValue (com.scalar.db.io.FloatValue)10 Scan (com.scalar.db.api.Scan)8 ExecutionException (com.scalar.db.exception.storage.ExecutionException)8 HashSet (java.util.HashSet)8