Search in sources :

Example 71 with IntValue

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

the class CoordinatorTest method getState_WithCoordinatorNamespaceChanged_ShouldGetWithChangedNamespace.

@Test
public void getState_WithCoordinatorNamespaceChanged_ShouldGetWithChangedNamespace() throws ExecutionException, CoordinatorException {
    // Arrange
    when(config.getCoordinatorNamespace()).thenReturn(Optional.of("changed_coordinator"));
    coordinator = new Coordinator(storage, config);
    Result result = mock(Result.class);
    when(result.getValue(Attribute.ID)).thenReturn(Optional.of(new TextValue(Attribute.ID, ANY_ID_1)));
    when(result.getValue(Attribute.STATE)).thenReturn(Optional.of(new IntValue(Attribute.STATE, TransactionState.COMMITTED.get())));
    when(result.getValue(Attribute.CREATED_AT)).thenReturn(Optional.of(new BigIntValue(Attribute.CREATED_AT, ANY_TIME_1)));
    when(storage.get(any(Get.class))).thenReturn(Optional.of(result));
    // Act
    Optional<Coordinator.State> state = coordinator.getState(ANY_ID_1);
    // Assert
    ArgumentCaptor<Get> captor = ArgumentCaptor.forClass(Get.class);
    verify(storage).get(captor.capture());
    assertThat(captor.getValue().forNamespace().get()).isEqualTo("changed_coordinator");
    assertThat(captor.getValue().forTable().get()).isEqualTo(Coordinator.TABLE);
    assertThat(state.get().getId()).isEqualTo(ANY_ID_1);
    Assertions.assertThat(state.get().getState()).isEqualTo(TransactionState.COMMITTED);
    assertThat(state.get().getCreatedAt()).isEqualTo(ANY_TIME_1);
}
Also used : TextValue(com.scalar.db.io.TextValue) TransactionState(com.scalar.db.api.TransactionState) Get(com.scalar.db.api.Get) IntValue(com.scalar.db.io.IntValue) BigIntValue(com.scalar.db.io.BigIntValue) Result(com.scalar.db.api.Result) BigIntValue(com.scalar.db.io.BigIntValue) Test(org.junit.jupiter.api.Test)

Example 72 with IntValue

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

the class MergedResultTest method getValue_ResultAndPutGiven_ShouldReturnMergedValue.

@Test
public void getValue_ResultAndPutGiven_ShouldReturnMergedValue() {
    // 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.of(result), put, TABLE_METADATA);
    // Act Assert
    assertThat(mergedResult.getValue(ANY_NAME_1)).isEqualTo(Optional.of(new TextValue(ANY_NAME_1, ANY_TEXT_1)));
    assertThat(mergedResult.getValue(ANY_NAME_2)).isEqualTo(Optional.of(new TextValue(ANY_NAME_2, ANY_TEXT_2)));
    assertThat(mergedResult.getValue(ANY_NAME_3)).isEqualTo(Optional.of(new IntValue(ANY_NAME_3, ANY_INT_3)));
    assertThat(mergedResult.getValue(ANY_NAME_4)).isEqualTo(Optional.of(new TextValue(ANY_NAME_4, ANY_TEXT_3)));
    assertThat(mergedResult.getValue(Attribute.ID)).isEqualTo(Optional.of(Attribute.toIdValue(ANY_ID_2)));
    assertThat(mergedResult.getValue(Attribute.PREPARED_AT)).isEqualTo(Optional.of(Attribute.toPreparedAtValue(ANY_TIME_3)));
    assertThat(mergedResult.getValue(Attribute.COMMITTED_AT)).isEqualTo(Optional.of(Attribute.toCommittedAtValue(ANY_TIME_4)));
    assertThat(mergedResult.getValue(Attribute.STATE)).isEqualTo(Optional.of(Attribute.toStateValue(TransactionState.COMMITTED)));
    assertThat(mergedResult.getValue(Attribute.VERSION)).isEqualTo(Optional.of(Attribute.toVersionValue(ANY_VERSION_2)));
    assertThat(mergedResult.getValue(Attribute.BEFORE_PREFIX + ANY_NAME_3)).isEqualTo(Optional.of(new IntValue(Attribute.BEFORE_PREFIX + ANY_NAME_3, ANY_INT_1)));
    assertThat(mergedResult.getValue(Attribute.BEFORE_ID)).isEqualTo(Optional.of(Attribute.toBeforeIdValue(ANY_ID_1)));
    assertThat(mergedResult.getValue(Attribute.BEFORE_PREPARED_AT)).isEqualTo(Optional.of(Attribute.toBeforePreparedAtValue(ANY_TIME_1)));
    assertThat(mergedResult.getValue(Attribute.BEFORE_COMMITTED_AT)).isEqualTo(Optional.of(Attribute.toBeforeCommittedAtValue(ANY_TIME_2)));
    assertThat(mergedResult.getValue(Attribute.BEFORE_STATE)).isEqualTo(Optional.of(Attribute.toBeforeStateValue(TransactionState.COMMITTED)));
    assertThat(mergedResult.getValue(Attribute.BEFORE_VERSION)).isEqualTo(Optional.of(Attribute.toBeforeVersionValue(ANY_VERSION_1)));
    assertThat(mergedResult.getContainedColumnNames()).isEqualTo(new HashSet<>(Arrays.asList(ANY_NAME_1, ANY_NAME_2, ANY_NAME_3, ANY_NAME_4, Attribute.ID, Attribute.PREPARED_AT, Attribute.COMMITTED_AT, Attribute.STATE, Attribute.VERSION, Attribute.BEFORE_PREFIX + ANY_NAME_3, Attribute.BEFORE_PREFIX + ANY_NAME_4, Attribute.BEFORE_ID, Attribute.BEFORE_PREPARED_AT, Attribute.BEFORE_COMMITTED_AT, Attribute.BEFORE_STATE, Attribute.BEFORE_VERSION)));
    assertThat(mergedResult.contains(ANY_NAME_1)).isTrue();
    assertThat(mergedResult.isNull(ANY_NAME_1)).isFalse();
    assertThat(mergedResult.getText(ANY_NAME_1)).isEqualTo(ANY_TEXT_1);
    assertThat(mergedResult.getAsObject(ANY_NAME_1)).isEqualTo(ANY_TEXT_1);
    assertThat(mergedResult.contains(ANY_NAME_2)).isTrue();
    assertThat(mergedResult.isNull(ANY_NAME_2)).isFalse();
    assertThat(mergedResult.getText(ANY_NAME_2)).isEqualTo(ANY_TEXT_2);
    assertThat(mergedResult.getAsObject(ANY_NAME_2)).isEqualTo(ANY_TEXT_2);
    assertThat(mergedResult.contains(ANY_NAME_3)).isTrue();
    assertThat(mergedResult.isNull(ANY_NAME_3)).isFalse();
    assertThat(mergedResult.getInt(ANY_NAME_3)).isEqualTo(ANY_INT_3);
    assertThat(mergedResult.getAsObject(ANY_NAME_3)).isEqualTo(ANY_INT_3);
    assertThat(mergedResult.contains(ANY_NAME_4)).isTrue();
    assertThat(mergedResult.isNull(ANY_NAME_4)).isFalse();
    assertThat(mergedResult.getText(ANY_NAME_4)).isEqualTo(ANY_TEXT_3);
    assertThat(mergedResult.getAsObject(ANY_NAME_4)).isEqualTo(ANY_TEXT_3);
    assertThat(mergedResult.contains(Attribute.ID)).isTrue();
    assertThat(mergedResult.isNull(Attribute.ID)).isFalse();
    assertThat(mergedResult.getText(Attribute.ID)).isEqualTo(ANY_ID_2);
    assertThat(mergedResult.getAsObject(Attribute.ID)).isEqualTo(ANY_ID_2);
    assertThat(mergedResult.contains(Attribute.PREPARED_AT)).isTrue();
    assertThat(mergedResult.isNull(Attribute.PREPARED_AT)).isFalse();
    assertThat(mergedResult.getBigInt(Attribute.PREPARED_AT)).isEqualTo(ANY_TIME_3);
    assertThat(mergedResult.getAsObject(Attribute.PREPARED_AT)).isEqualTo(ANY_TIME_3);
    assertThat(mergedResult.contains(Attribute.COMMITTED_AT)).isTrue();
    assertThat(mergedResult.isNull(Attribute.COMMITTED_AT)).isFalse();
    assertThat(mergedResult.getBigInt(Attribute.COMMITTED_AT)).isEqualTo(ANY_TIME_4);
    assertThat(mergedResult.getAsObject(Attribute.COMMITTED_AT)).isEqualTo(ANY_TIME_4);
    assertThat(mergedResult.contains(Attribute.STATE)).isTrue();
    assertThat(mergedResult.isNull(Attribute.STATE)).isFalse();
    assertThat(mergedResult.getInt(Attribute.STATE)).isEqualTo(TransactionState.COMMITTED.get());
    assertThat(mergedResult.getAsObject(Attribute.STATE)).isEqualTo(TransactionState.COMMITTED.get());
    assertThat(mergedResult.contains(Attribute.VERSION)).isTrue();
    assertThat(mergedResult.isNull(Attribute.VERSION)).isFalse();
    assertThat(mergedResult.getInt(Attribute.VERSION)).isEqualTo(ANY_VERSION_2);
    assertThat(mergedResult.getAsObject(Attribute.VERSION)).isEqualTo(ANY_VERSION_2);
    assertThat(mergedResult.contains(Attribute.BEFORE_PREFIX + ANY_NAME_3)).isTrue();
    assertThat(mergedResult.isNull(Attribute.BEFORE_PREFIX + ANY_NAME_3)).isFalse();
    assertThat(mergedResult.getInt(Attribute.BEFORE_PREFIX + ANY_NAME_3)).isEqualTo(ANY_INT_1);
    assertThat(mergedResult.getAsObject(Attribute.BEFORE_PREFIX + ANY_NAME_3)).isEqualTo(ANY_INT_1);
    assertThat(mergedResult.contains(Attribute.BEFORE_PREFIX + ANY_NAME_4)).isTrue();
    assertThat(mergedResult.isNull(Attribute.BEFORE_PREFIX + ANY_NAME_4)).isFalse();
    assertThat(mergedResult.getText(Attribute.BEFORE_PREFIX + ANY_NAME_4)).isEqualTo(ANY_TEXT_4);
    assertThat(mergedResult.getAsObject(Attribute.BEFORE_PREFIX + ANY_NAME_4)).isEqualTo(ANY_TEXT_4);
    assertThat(mergedResult.contains(Attribute.BEFORE_ID)).isTrue();
    assertThat(mergedResult.isNull(Attribute.BEFORE_ID)).isFalse();
    assertThat(mergedResult.getText(Attribute.BEFORE_ID)).isEqualTo(ANY_ID_1);
    assertThat(mergedResult.getAsObject(Attribute.BEFORE_ID)).isEqualTo(ANY_ID_1);
    assertThat(mergedResult.contains(Attribute.BEFORE_PREPARED_AT)).isTrue();
    assertThat(mergedResult.isNull(Attribute.BEFORE_PREPARED_AT)).isFalse();
    assertThat(mergedResult.getBigInt(Attribute.BEFORE_PREPARED_AT)).isEqualTo(ANY_TIME_1);
    assertThat(mergedResult.getAsObject(Attribute.BEFORE_PREPARED_AT)).isEqualTo(ANY_TIME_1);
    assertThat(mergedResult.contains(Attribute.BEFORE_COMMITTED_AT)).isTrue();
    assertThat(mergedResult.isNull(Attribute.BEFORE_COMMITTED_AT)).isFalse();
    assertThat(mergedResult.getBigInt(Attribute.BEFORE_COMMITTED_AT)).isEqualTo(ANY_TIME_2);
    assertThat(mergedResult.getAsObject(Attribute.BEFORE_COMMITTED_AT)).isEqualTo(ANY_TIME_2);
    assertThat(mergedResult.contains(Attribute.BEFORE_STATE)).isTrue();
    assertThat(mergedResult.isNull(Attribute.BEFORE_STATE)).isFalse();
    assertThat(mergedResult.getInt(Attribute.BEFORE_STATE)).isEqualTo(TransactionState.COMMITTED.get());
    assertThat(mergedResult.getAsObject(Attribute.BEFORE_STATE)).isEqualTo(TransactionState.COMMITTED.get());
    assertThat(mergedResult.contains(Attribute.BEFORE_VERSION)).isTrue();
    assertThat(mergedResult.isNull(Attribute.BEFORE_VERSION)).isFalse();
    assertThat(mergedResult.getInt(Attribute.BEFORE_VERSION)).isEqualTo(ANY_VERSION_1);
    assertThat(mergedResult.getAsObject(Attribute.BEFORE_VERSION)).isEqualTo(ANY_VERSION_1);
}
Also used : TextValue(com.scalar.db.io.TextValue) 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 73 with IntValue

use of com.scalar.db.io.IntValue 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 74 with IntValue

use of com.scalar.db.io.IntValue 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 75 with IntValue

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

the class MergedResultTest method getValue_ResultAndPutWithNullValueGiven_ShouldReturnMergedValue.

@Test
public void getValue_ResultAndPutWithNullValueGiven_ShouldReturnMergedValue() {
    // 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 Assert
    assertThat(mergedResult.getValue(ANY_NAME_1)).isEqualTo(Optional.of(new TextValue(ANY_NAME_1, ANY_TEXT_1)));
    assertThat(mergedResult.getValue(ANY_NAME_2)).isEqualTo(Optional.of(new TextValue(ANY_NAME_2, ANY_TEXT_2)));
    assertThat(mergedResult.getValue(ANY_NAME_3)).isEqualTo(Optional.of(new IntValue(ANY_NAME_3, ANY_INT_3)));
    assertThat(mergedResult.getValue(ANY_NAME_4)).isEqualTo(Optional.of(new TextValue(ANY_NAME_4, (String) null)));
    assertThat(mergedResult.getValue(Attribute.ID)).isEqualTo(Optional.of(Attribute.toIdValue(ANY_ID_2)));
    assertThat(mergedResult.getValue(Attribute.PREPARED_AT)).isEqualTo(Optional.of(Attribute.toPreparedAtValue(ANY_TIME_3)));
    assertThat(mergedResult.getValue(Attribute.COMMITTED_AT)).isEqualTo(Optional.of(Attribute.toCommittedAtValue(ANY_TIME_4)));
    assertThat(mergedResult.getValue(Attribute.STATE)).isEqualTo(Optional.of(Attribute.toStateValue(TransactionState.COMMITTED)));
    assertThat(mergedResult.getValue(Attribute.VERSION)).isEqualTo(Optional.of(Attribute.toVersionValue(ANY_VERSION_2)));
    assertThat(mergedResult.getValue(Attribute.BEFORE_PREFIX + ANY_NAME_3)).isEqualTo(Optional.of(new IntValue(Attribute.BEFORE_PREFIX + ANY_NAME_3, ANY_INT_1)));
    assertThat(mergedResult.getValue(Attribute.BEFORE_ID)).isEqualTo(Optional.of(Attribute.toBeforeIdValue(ANY_ID_1)));
    assertThat(mergedResult.getValue(Attribute.BEFORE_PREPARED_AT)).isEqualTo(Optional.of(Attribute.toBeforePreparedAtValue(ANY_TIME_1)));
    assertThat(mergedResult.getValue(Attribute.BEFORE_COMMITTED_AT)).isEqualTo(Optional.of(Attribute.toBeforeCommittedAtValue(ANY_TIME_2)));
    assertThat(mergedResult.getValue(Attribute.BEFORE_STATE)).isEqualTo(Optional.of(Attribute.toBeforeStateValue(TransactionState.COMMITTED)));
    assertThat(mergedResult.getValue(Attribute.BEFORE_VERSION)).isEqualTo(Optional.of(Attribute.toBeforeVersionValue(ANY_VERSION_1)));
    assertThat(mergedResult.getContainedColumnNames()).isEqualTo(new HashSet<>(Arrays.asList(ANY_NAME_1, ANY_NAME_2, ANY_NAME_3, ANY_NAME_4, Attribute.ID, Attribute.PREPARED_AT, Attribute.COMMITTED_AT, Attribute.STATE, Attribute.VERSION, Attribute.BEFORE_PREFIX + ANY_NAME_3, Attribute.BEFORE_PREFIX + ANY_NAME_4, Attribute.BEFORE_ID, Attribute.BEFORE_PREPARED_AT, Attribute.BEFORE_COMMITTED_AT, Attribute.BEFORE_STATE, Attribute.BEFORE_VERSION)));
    assertThat(mergedResult.contains(ANY_NAME_1)).isTrue();
    assertThat(mergedResult.isNull(ANY_NAME_1)).isFalse();
    assertThat(mergedResult.getText(ANY_NAME_1)).isEqualTo(ANY_TEXT_1);
    assertThat(mergedResult.getAsObject(ANY_NAME_1)).isEqualTo(ANY_TEXT_1);
    assertThat(mergedResult.contains(ANY_NAME_2)).isTrue();
    assertThat(mergedResult.isNull(ANY_NAME_2)).isFalse();
    assertThat(mergedResult.getText(ANY_NAME_2)).isEqualTo(ANY_TEXT_2);
    assertThat(mergedResult.getAsObject(ANY_NAME_2)).isEqualTo(ANY_TEXT_2);
    assertThat(mergedResult.contains(ANY_NAME_3)).isTrue();
    assertThat(mergedResult.isNull(ANY_NAME_3)).isFalse();
    assertThat(mergedResult.getInt(ANY_NAME_3)).isEqualTo(ANY_INT_3);
    assertThat(mergedResult.getAsObject(ANY_NAME_3)).isEqualTo(ANY_INT_3);
    assertThat(mergedResult.contains(ANY_NAME_4)).isTrue();
    assertThat(mergedResult.isNull(ANY_NAME_4)).isTrue();
    assertThat(mergedResult.getText(ANY_NAME_4)).isNull();
    assertThat(mergedResult.getAsObject(ANY_NAME_4)).isNull();
    assertThat(mergedResult.contains(Attribute.ID)).isTrue();
    assertThat(mergedResult.isNull(Attribute.ID)).isFalse();
    assertThat(mergedResult.getText(Attribute.ID)).isEqualTo(ANY_ID_2);
    assertThat(mergedResult.getAsObject(Attribute.ID)).isEqualTo(ANY_ID_2);
    assertThat(mergedResult.contains(Attribute.PREPARED_AT)).isTrue();
    assertThat(mergedResult.isNull(Attribute.PREPARED_AT)).isFalse();
    assertThat(mergedResult.getBigInt(Attribute.PREPARED_AT)).isEqualTo(ANY_TIME_3);
    assertThat(mergedResult.getAsObject(Attribute.PREPARED_AT)).isEqualTo(ANY_TIME_3);
    assertThat(mergedResult.contains(Attribute.COMMITTED_AT)).isTrue();
    assertThat(mergedResult.isNull(Attribute.COMMITTED_AT)).isFalse();
    assertThat(mergedResult.getBigInt(Attribute.COMMITTED_AT)).isEqualTo(ANY_TIME_4);
    assertThat(mergedResult.getAsObject(Attribute.COMMITTED_AT)).isEqualTo(ANY_TIME_4);
    assertThat(mergedResult.contains(Attribute.STATE)).isTrue();
    assertThat(mergedResult.isNull(Attribute.STATE)).isFalse();
    assertThat(mergedResult.getInt(Attribute.STATE)).isEqualTo(TransactionState.COMMITTED.get());
    assertThat(mergedResult.getAsObject(Attribute.STATE)).isEqualTo(TransactionState.COMMITTED.get());
    assertThat(mergedResult.contains(Attribute.VERSION)).isTrue();
    assertThat(mergedResult.isNull(Attribute.VERSION)).isFalse();
    assertThat(mergedResult.getInt(Attribute.VERSION)).isEqualTo(ANY_VERSION_2);
    assertThat(mergedResult.getAsObject(Attribute.VERSION)).isEqualTo(ANY_VERSION_2);
    assertThat(mergedResult.contains(Attribute.BEFORE_PREFIX + ANY_NAME_3)).isTrue();
    assertThat(mergedResult.isNull(Attribute.BEFORE_PREFIX + ANY_NAME_3)).isFalse();
    assertThat(mergedResult.getInt(Attribute.BEFORE_PREFIX + ANY_NAME_3)).isEqualTo(ANY_INT_1);
    assertThat(mergedResult.getAsObject(Attribute.BEFORE_PREFIX + ANY_NAME_3)).isEqualTo(ANY_INT_1);
    assertThat(mergedResult.contains(Attribute.BEFORE_PREFIX + ANY_NAME_4)).isTrue();
    assertThat(mergedResult.isNull(Attribute.BEFORE_PREFIX + ANY_NAME_4)).isFalse();
    assertThat(mergedResult.getText(Attribute.BEFORE_PREFIX + ANY_NAME_4)).isEqualTo(ANY_TEXT_4);
    assertThat(mergedResult.getAsObject(Attribute.BEFORE_PREFIX + ANY_NAME_4)).isEqualTo(ANY_TEXT_4);
    assertThat(mergedResult.contains(Attribute.BEFORE_ID)).isTrue();
    assertThat(mergedResult.isNull(Attribute.BEFORE_ID)).isFalse();
    assertThat(mergedResult.getText(Attribute.BEFORE_ID)).isEqualTo(ANY_ID_1);
    assertThat(mergedResult.getAsObject(Attribute.BEFORE_ID)).isEqualTo(ANY_ID_1);
    assertThat(mergedResult.contains(Attribute.BEFORE_PREPARED_AT)).isTrue();
    assertThat(mergedResult.isNull(Attribute.BEFORE_PREPARED_AT)).isFalse();
    assertThat(mergedResult.getBigInt(Attribute.BEFORE_PREPARED_AT)).isEqualTo(ANY_TIME_1);
    assertThat(mergedResult.getAsObject(Attribute.BEFORE_PREPARED_AT)).isEqualTo(ANY_TIME_1);
    assertThat(mergedResult.contains(Attribute.BEFORE_COMMITTED_AT)).isTrue();
    assertThat(mergedResult.isNull(Attribute.BEFORE_COMMITTED_AT)).isFalse();
    assertThat(mergedResult.getBigInt(Attribute.BEFORE_COMMITTED_AT)).isEqualTo(ANY_TIME_2);
    assertThat(mergedResult.getAsObject(Attribute.BEFORE_COMMITTED_AT)).isEqualTo(ANY_TIME_2);
    assertThat(mergedResult.contains(Attribute.BEFORE_STATE)).isTrue();
    assertThat(mergedResult.isNull(Attribute.BEFORE_STATE)).isFalse();
    assertThat(mergedResult.getInt(Attribute.BEFORE_STATE)).isEqualTo(TransactionState.COMMITTED.get());
    assertThat(mergedResult.getAsObject(Attribute.BEFORE_STATE)).isEqualTo(TransactionState.COMMITTED.get());
    assertThat(mergedResult.contains(Attribute.BEFORE_VERSION)).isTrue();
    assertThat(mergedResult.isNull(Attribute.BEFORE_VERSION)).isFalse();
    assertThat(mergedResult.getInt(Attribute.BEFORE_VERSION)).isEqualTo(ANY_VERSION_1);
    assertThat(mergedResult.getAsObject(Attribute.BEFORE_VERSION)).isEqualTo(ANY_VERSION_1);
}
Also used : TextValue(com.scalar.db.io.TextValue) IntValue(com.scalar.db.io.IntValue) Put(com.scalar.db.api.Put) Key(com.scalar.db.io.Key) Test(org.junit.jupiter.api.Test)

Aggregations

IntValue (com.scalar.db.io.IntValue)108 Test (org.junit.jupiter.api.Test)65 TextValue (com.scalar.db.io.TextValue)63 Key (com.scalar.db.io.Key)62 Put (com.scalar.db.api.Put)55 BooleanValue (com.scalar.db.io.BooleanValue)48 DoubleValue (com.scalar.db.io.DoubleValue)38 Result (com.scalar.db.api.Result)35 Test (org.junit.Test)33 Get (com.scalar.db.api.Get)29 Value (com.scalar.db.io.Value)26 BigIntValue (com.scalar.db.io.BigIntValue)23 BlobValue (com.scalar.db.io.BlobValue)20 FloatValue (com.scalar.db.io.FloatValue)19 ExpectedResult (com.scalar.db.util.TestUtils.ExpectedResult)15 ConditionalExpression (com.scalar.db.api.ConditionalExpression)13 MutationCondition (com.scalar.db.api.MutationCondition)12 PutIf (com.scalar.db.api.PutIf)8 TransactionState (com.scalar.db.api.TransactionState)8 DeleteIf (com.scalar.db.api.DeleteIf)6