Search in sources :

Example 6 with TextColumn

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

the class PutTest method withValue_ProperValueGiven_ShouldReturnWhatsSet.

@Test
public void withValue_ProperValueGiven_ShouldReturnWhatsSet() {
    // Arrange
    Put put = preparePut();
    TextColumn column2 = TextColumn.of(ANY_NAME_2, ANY_TEXT_2);
    TextColumn column1 = TextColumn.of(ANY_NAME_1, ANY_TEXT_1);
    // Act
    put.withValue(column1).withValue(column2);
    // Assert
    assertThat(put.getValues()).isEqualTo(ImmutableMap.of(column1.getName(), ScalarDbUtils.toValue(column1), column2.getName(), ScalarDbUtils.toValue(column2)));
    assertThat(put.getColumns()).isEqualTo(ImmutableMap.of(column1.getName(), column1, column2.getName(), column2));
    assertThat(put.getContainedColumnNames()).isEqualTo(ImmutableSet.of(ANY_NAME_1, ANY_NAME_2));
    assertThat(put.containsColumn(ANY_NAME_1)).isTrue();
    assertThat(put.isNullValue(ANY_NAME_1)).isFalse();
    assertThat(put.getTextValue(ANY_NAME_1)).isEqualTo(ANY_TEXT_1);
    assertThat(put.getValueAsObject(ANY_NAME_1)).isEqualTo(ANY_TEXT_1);
    assertThat(put.containsColumn(ANY_NAME_2)).isTrue();
    assertThat(put.isNullValue(ANY_NAME_2)).isFalse();
    assertThat(put.getTextValue(ANY_NAME_2)).isEqualTo(ANY_TEXT_2);
    assertThat(put.getValueAsObject(ANY_NAME_2)).isEqualTo(ANY_TEXT_2);
}
Also used : TextColumn(com.scalar.db.io.TextColumn) Test(org.junit.jupiter.api.Test)

Aggregations

TextColumn (com.scalar.db.io.TextColumn)6 Test (org.junit.jupiter.api.Test)6 BigIntColumn (com.scalar.db.io.BigIntColumn)3 IntColumn (com.scalar.db.io.IntColumn)3 BlobColumn (com.scalar.db.io.BlobColumn)2 BooleanColumn (com.scalar.db.io.BooleanColumn)1 Column (com.scalar.db.io.Column)1 DoubleColumn (com.scalar.db.io.DoubleColumn)1 FloatColumn (com.scalar.db.io.FloatColumn)1