Search in sources :

Example 1 with TextColumn

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

the class ValueBinderTest method visit_AcceptCalledMultipleTimes_ShouldCallSetWithIncremented.

@Test
public void visit_AcceptCalledMultipleTimes_ShouldCallSetWithIncremented() {
    // Arrange
    TextColumn column1 = TextColumn.of(ANY_NAME, ANY_STRING);
    IntColumn column2 = IntColumn.of(ANY_NAME, ANY_INT);
    ValueBinder binder = new ValueBinder(bound);
    // Act
    column1.accept(binder);
    column2.accept(binder);
    // Assert
    verify(bound).setString(0, ANY_STRING);
    verify(bound).setInt(1, ANY_INT);
}
Also used : IntColumn(com.scalar.db.io.IntColumn) BigIntColumn(com.scalar.db.io.BigIntColumn) TextColumn(com.scalar.db.io.TextColumn) Test(org.junit.jupiter.api.Test)

Example 2 with TextColumn

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

the class ValueBinderTest method visit_AcceptCalledMultipleTimesWithNullValue_ShouldSetProperly.

@Test
public void visit_AcceptCalledMultipleTimesWithNullValue_ShouldSetProperly() {
    // Arrange
    IntColumn column1 = IntColumn.of(ANY_NAME, ANY_INT);
    BlobColumn column2 = BlobColumn.ofNull(ANY_NAME);
    TextColumn column3 = TextColumn.ofNull(ANY_NAME);
    IntColumn column4 = IntColumn.of(ANY_NAME, ANY_INT);
    ValueBinder binder = new ValueBinder(bound);
    // Act
    column1.accept(binder);
    column2.accept(binder);
    column3.accept(binder);
    column4.accept(binder);
    // Assert
    verify(bound).setInt(0, ANY_INT);
    verify(bound).setToNull(1);
    verify(bound).setToNull(2);
    verify(bound).setInt(3, ANY_INT);
}
Also used : BlobColumn(com.scalar.db.io.BlobColumn) IntColumn(com.scalar.db.io.IntColumn) BigIntColumn(com.scalar.db.io.BigIntColumn) TextColumn(com.scalar.db.io.TextColumn) Test(org.junit.jupiter.api.Test)

Example 3 with TextColumn

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

the class ValueBinderTest method visit_TextColumnAcceptCalled_ShouldCallSetString.

@Test
public void visit_TextColumnAcceptCalled_ShouldCallSetString() {
    // Arrange
    TextColumn column = TextColumn.of(ANY_NAME, ANY_STRING);
    ValueBinder binder = new ValueBinder(bound);
    // Act
    column.accept(binder);
    // Assert
    verify(bound).setString(0, ANY_STRING);
}
Also used : TextColumn(com.scalar.db.io.TextColumn) Test(org.junit.jupiter.api.Test)

Example 4 with TextColumn

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

the class PutTest method getColumns_TryToModifyReturned_ShouldThrowException.

@Test
public void getColumns_TryToModifyReturned_ShouldThrowException() {
    // Arrange
    Put put = preparePut();
    TextColumn column1 = TextColumn.of(ANY_NAME_1, ANY_TEXT_1);
    TextColumn column2 = TextColumn.of(ANY_NAME_2, ANY_TEXT_2);
    put.withValue(column1).withValue(column2);
    // Act Assert
    Map<String, Column<?>> values = put.getColumns();
    assertThatThrownBy(() -> values.put(ANY_NAME_3, TextColumn.of(ANY_NAME_3, ANY_TEXT_3))).isInstanceOf(UnsupportedOperationException.class);
}
Also used : IntColumn(com.scalar.db.io.IntColumn) BooleanColumn(com.scalar.db.io.BooleanColumn) TextColumn(com.scalar.db.io.TextColumn) DoubleColumn(com.scalar.db.io.DoubleColumn) BigIntColumn(com.scalar.db.io.BigIntColumn) FloatColumn(com.scalar.db.io.FloatColumn) Column(com.scalar.db.io.Column) BlobColumn(com.scalar.db.io.BlobColumn) TextColumn(com.scalar.db.io.TextColumn) Test(org.junit.jupiter.api.Test)

Example 5 with TextColumn

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

the class ValueBinderTest method visit_TextColumnWithNullValueAcceptCalled_ShouldCallSetToNull.

@Test
public void visit_TextColumnWithNullValueAcceptCalled_ShouldCallSetToNull() {
    // Arrange
    TextColumn column = TextColumn.ofNull(ANY_NAME);
    ValueBinder binder = new ValueBinder(bound);
    // Act
    column.accept(binder);
    // Assert
    verify(bound).setToNull(0);
}
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