use of com.scalar.db.common.ResultImpl in project scalardb by scalar-labs.
the class TransactionResultTest method equals_ResultImplWithDifferentValuesGiven_ShouldReturnFalse.
@Test
public void equals_ResultImplWithDifferentValuesGiven_ShouldReturnFalse() {
// Arrange
Result r1 = new ResultImpl(ImmutableMap.<String, Column<?>>builder().put(ANY_NAME_1, TextColumn.of(ANY_NAME_1, ANY_TEXT_1)).put(ANY_NAME_2, TextColumn.of(ANY_NAME_2, ANY_TEXT_2)).put(ANY_NAME_3, IntColumn.of(ANY_NAME_3, ANY_INT_2)).put(Attribute.ID, ScalarDbUtils.toColumn(Attribute.toIdValue(ANY_ID_2))).put(Attribute.PREPARED_AT, ScalarDbUtils.toColumn(Attribute.toPreparedAtValue(ANY_TIME_3))).put(Attribute.COMMITTED_AT, ScalarDbUtils.toColumn(Attribute.toCommittedAtValue(ANY_TIME_4))).put(Attribute.STATE, ScalarDbUtils.toColumn(Attribute.toStateValue(TransactionState.COMMITTED))).put(Attribute.VERSION, ScalarDbUtils.toColumn(Attribute.toVersionValue(ANY_VERSION_2))).put(Attribute.BEFORE_PREFIX + ANY_NAME_3, IntColumn.of(Attribute.BEFORE_PREFIX + ANY_NAME_3, ANY_INT_1)).put(Attribute.BEFORE_ID, ScalarDbUtils.toColumn(Attribute.toBeforeIdValue(ANY_ID_1))).put(Attribute.BEFORE_PREPARED_AT, ScalarDbUtils.toColumn(Attribute.toBeforePreparedAtValue(ANY_TIME_1))).put(Attribute.BEFORE_COMMITTED_AT, ScalarDbUtils.toColumn(Attribute.toBeforeCommittedAtValue(ANY_TIME_2))).put(Attribute.BEFORE_STATE, ScalarDbUtils.toColumn(Attribute.toBeforeStateValue(TransactionState.COMMITTED))).put(Attribute.BEFORE_VERSION, ScalarDbUtils.toColumn(Attribute.toBeforeVersionValue(ANY_VERSION_1))).build(), TABLE_METADATA);
Map<String, Column<?>> emptyValues = Collections.emptyMap();
Result r2 = new TransactionResult(new ResultImpl(emptyValues, TABLE_METADATA));
// Act Assert
assertThat(r1.equals(r2)).isFalse();
}
use of com.scalar.db.common.ResultImpl in project scalardb by scalar-labs.
the class TransactionResultTest method equals_ResultImplWithSameValuesGiven_ShouldReturnTrue.
@Test
public void equals_ResultImplWithSameValuesGiven_ShouldReturnTrue() {
// Arrange
Result r1 = new ResultImpl(ImmutableMap.<String, Column<?>>builder().put(ANY_NAME_1, TextColumn.of(ANY_NAME_1, ANY_TEXT_1)).put(ANY_NAME_2, TextColumn.of(ANY_NAME_2, ANY_TEXT_2)).put(ANY_NAME_3, IntColumn.of(ANY_NAME_3, ANY_INT_2)).put(Attribute.ID, ScalarDbUtils.toColumn(Attribute.toIdValue(ANY_ID_2))).put(Attribute.PREPARED_AT, ScalarDbUtils.toColumn(Attribute.toPreparedAtValue(ANY_TIME_3))).put(Attribute.COMMITTED_AT, ScalarDbUtils.toColumn(Attribute.toCommittedAtValue(ANY_TIME_4))).put(Attribute.STATE, ScalarDbUtils.toColumn(Attribute.toStateValue(TransactionState.COMMITTED))).put(Attribute.VERSION, ScalarDbUtils.toColumn(Attribute.toVersionValue(ANY_VERSION_2))).put(Attribute.BEFORE_PREFIX + ANY_NAME_3, IntColumn.of(Attribute.BEFORE_PREFIX + ANY_NAME_3, ANY_INT_1)).put(Attribute.BEFORE_ID, ScalarDbUtils.toColumn(Attribute.toBeforeIdValue(ANY_ID_1))).put(Attribute.BEFORE_PREPARED_AT, ScalarDbUtils.toColumn(Attribute.toBeforePreparedAtValue(ANY_TIME_1))).put(Attribute.BEFORE_COMMITTED_AT, ScalarDbUtils.toColumn(Attribute.toBeforeCommittedAtValue(ANY_TIME_2))).put(Attribute.BEFORE_STATE, ScalarDbUtils.toColumn(Attribute.toBeforeStateValue(TransactionState.COMMITTED))).put(Attribute.BEFORE_VERSION, ScalarDbUtils.toColumn(Attribute.toBeforeVersionValue(ANY_VERSION_1))).build(), TABLE_METADATA);
Result r2 = new TransactionResult(r1);
// Act Assert
assertThat(r1.equals(r2)).isTrue();
}
use of com.scalar.db.common.ResultImpl in project scalardb by scalar-labs.
the class FilteredResultTest method equals_ResultImplWithSameValuesGiven_WithoutProjections_ShouldReturnTrue.
@Test
public void equals_ResultImplWithSameValuesGiven_WithoutProjections_ShouldReturnTrue() {
// Arrange
Result filteredResult = new FilteredResult(result, Collections.emptyList(), TABLE_METADATA);
Result anotherResult = new ResultImpl(ImmutableMap.of(ACCOUNT_ID, ScalarDbUtils.toColumn(ACCOUNT_ID_VALUE), ACCOUNT_TYPE, ScalarDbUtils.toColumn(ACCOUNT_TYPE_VALUE), BALANCE, ScalarDbUtils.toColumn(BALANCE_VALUE)), TABLE_METADATA);
// Act
boolean isEqual = filteredResult.equals(anotherResult);
// Assert
assertThat(isEqual).isTrue();
}
use of com.scalar.db.common.ResultImpl in project scalardb by scalar-labs.
the class MergedResultTest method equals_ResultImplWithSamePutAndResultGiven_ShouldReturnTrue.
@Test
public void equals_ResultImplWithSamePutAndResultGiven_ShouldReturnTrue() {
// 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);
Result another = new ResultImpl(ImmutableMap.<String, Column<?>>builder().put(ANY_NAME_1, TextColumn.of(ANY_NAME_1, ANY_TEXT_1)).put(ANY_NAME_2, TextColumn.of(ANY_NAME_2, ANY_TEXT_2)).put(ANY_NAME_3, IntColumn.of(ANY_NAME_3, ANY_INT_3)).put(ANY_NAME_4, TextColumn.of(ANY_NAME_4, ANY_TEXT_3)).put(Attribute.ID, ScalarDbUtils.toColumn(Attribute.toIdValue(ANY_ID_2))).put(Attribute.PREPARED_AT, ScalarDbUtils.toColumn(Attribute.toPreparedAtValue(ANY_TIME_3))).put(Attribute.COMMITTED_AT, ScalarDbUtils.toColumn(Attribute.toCommittedAtValue(ANY_TIME_4))).put(Attribute.STATE, ScalarDbUtils.toColumn(Attribute.toStateValue(TransactionState.COMMITTED))).put(Attribute.VERSION, ScalarDbUtils.toColumn(Attribute.toVersionValue(ANY_VERSION_2))).put(Attribute.BEFORE_PREFIX + ANY_NAME_3, IntColumn.of(Attribute.BEFORE_PREFIX + ANY_NAME_3, ANY_INT_1)).put(Attribute.BEFORE_PREFIX + ANY_NAME_4, TextColumn.of(Attribute.BEFORE_PREFIX + ANY_NAME_4, ANY_TEXT_4)).put(Attribute.BEFORE_ID, ScalarDbUtils.toColumn(Attribute.toBeforeIdValue(ANY_ID_1))).put(Attribute.BEFORE_PREPARED_AT, ScalarDbUtils.toColumn(Attribute.toBeforePreparedAtValue(ANY_TIME_1))).put(Attribute.BEFORE_COMMITTED_AT, ScalarDbUtils.toColumn(Attribute.toBeforeCommittedAtValue(ANY_TIME_2))).put(Attribute.BEFORE_STATE, ScalarDbUtils.toColumn(Attribute.toBeforeStateValue(TransactionState.COMMITTED))).put(Attribute.BEFORE_VERSION, ScalarDbUtils.toColumn(Attribute.toBeforeVersionValue(ANY_VERSION_1))).build(), TABLE_METADATA);
// Act Assert
assertThat(mergedResult.equals(another)).isTrue();
}
use of com.scalar.db.common.ResultImpl in project scalardb by scalar-labs.
the class MergedResultTest method equals_ResultImplWithDifferentPutAndResultGiven_ShouldReturnFalse.
@Test
public void equals_ResultImplWithDifferentPutAndResultGiven_ShouldReturnFalse() {
// 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);
Result another = new ResultImpl(Collections.emptyMap(), TABLE_METADATA);
// Act Assert
assertThat(mergedResult.equals(another)).isFalse();
}
Aggregations