use of com.palantir.atlasdb.transaction.impl.AbstractTransaction in project atlasdb by palantir.
the class AbstractSchemaApiTest method testRowRangeSecondColumnFirstTwoResults.
@Test
public void testRowRangeSecondColumnFirstTwoResults() {
AbstractTransaction transaction = mock(AbstractTransaction.class);
Cell expectedCell = getCell(TEST_ROW_KEY, SECOND_COL_SHORT_NAME);
Cell anotherExpectedCell = getCell(TEST_ROW_KEY2, SECOND_COL_SHORT_NAME);
Cell cellToBeDroppedFromResults = getCell(TEST_ROW_KEY3, SECOND_COL_SHORT_NAME);
RangeRequest expectedRange = RangeRequest.builder().startRowInclusive(TEST_ROW_KEY.getBytes()).endRowExclusive(RANGE_END_ROW_KEY.getBytes()).retainColumns(SECOND_COLUMN_SELECTION).batchHint(2).build();
when(transaction.getRange(tableRef, expectedRange)).thenReturn(BatchingVisitableFromIterable.create(Arrays.asList(RowResult.of(expectedCell, STRING_VALUE_PERSISTER.persistToBytes(TEST_VALUE_STRING)), RowResult.of(anotherExpectedCell, STRING_VALUE_PERSISTER.persistToBytes(TEST_VALUE_STRING2)), RowResult.of(cellToBeDroppedFromResults, STRING_VALUE_PERSISTER.persistToBytes(TEST_VALUE_STRING3)))));
Map<String, StringValue> result = getRangeSecondColumnOnlyFirstTwoResults(transaction, TEST_ROW_KEY, RANGE_END_ROW_KEY);
assertThat(result).isEqualTo(ImmutableMap.of(TEST_ROW_KEY, TEST_VALUE_STRING, TEST_ROW_KEY2, TEST_VALUE_STRING2));
verify(transaction, times(1)).getRange(tableRef, expectedRange);
}
use of com.palantir.atlasdb.transaction.impl.AbstractTransaction in project atlasdb by palantir.
the class AbstractSchemaApiTest method testDeleteFirstColumn.
@Test
public void testDeleteFirstColumn() {
AbstractTransaction transaction = mock(AbstractTransaction.class);
deleteFirstColumn(transaction, TEST_ROW_KEY);
Cell expectedDeletedCell = getCell(TEST_ROW_KEY, FIRST_COL_SHORT_NAME);
verify(transaction, times(1)).delete(tableRef, ImmutableSet.of(expectedDeletedCell));
}
use of com.palantir.atlasdb.transaction.impl.AbstractTransaction in project atlasdb by palantir.
the class SchemaApiTestV2Impl method testUpdateEntryIfEntryExists.
@Test
public void testUpdateEntryIfEntryExists() {
AbstractTransaction transaction = mock(AbstractTransaction.class);
SchemaApiTestV2Table table = spy(tableFactory.getSchemaApiTestV2Table(transaction));
doReturn(Optional.of(TEST_VALUE_LONG)).when(table).getColumn1(TEST_ROW_KEY);
table.updateColumn1(TEST_ROW_KEY, entry -> entry + 1);
verify(table, times(1)).putColumn1(TEST_ROW_KEY, TEST_VALUE_LONG + 1);
}
use of com.palantir.atlasdb.transaction.impl.AbstractTransaction in project atlasdb by palantir.
the class SchemaApiTestV2Impl method testUpdateEntryIfEntryDoesNotExist.
@Test
public void testUpdateEntryIfEntryDoesNotExist() {
AbstractTransaction transaction = mock(AbstractTransaction.class);
SchemaApiTestV2Table table = spy(tableFactory.getSchemaApiTestV2Table(transaction));
doReturn(Optional.empty()).when(table).getColumn1(TEST_ROW_KEY);
table.updateColumn1(TEST_ROW_KEY, entry -> entry + 1);
verify(table, never()).putColumn1(any(), anyLong());
}
Aggregations