Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,64 @@ public void onSuccess(Row result) {
assertThat(found.get()).isTrue();
}

@Test
public void readSingleRowWithReadRow() throws Exception {
String rowKey = prefix + "-readSingleRowWithReadRow";
TableId tableId = testEnvRule.env().getTableId();
Row expectedRow = writeTestRowAndBuildExpected(tableId, rowKey);

Row row = testEnvRule.env().getDataClient().readRow(tableId, rowKey);
assertThat(row).isEqualTo(expectedRow);
}

@Test
public void readSingleRowWithRowKeyQuery() throws Exception {
String rowKey = prefix + "-readSingleRowWithRowKeyQuery";
TableId tableId = testEnvRule.env().getTableId();
Row expectedRow = writeTestRowAndBuildExpected(tableId, rowKey);

List<Row> rows =
Lists.newArrayList(
testEnvRule.env().getDataClient().readRows(Query.create(tableId).rowKey(rowKey)));
assertThat(rows).containsExactly(expectedRow);
}

@Test
public void readSingleRowWithRowRangeQuery() throws Exception {
String rowKey = prefix + "-readSingleRowWithRowRangeQuery";
TableId tableId = testEnvRule.env().getTableId();
Row expectedRow = writeTestRowAndBuildExpected(tableId, rowKey);

List<Row> rows =
Lists.newArrayList(
testEnvRule
.env()
.getDataClient()
.readRows(
Query.create(tableId)
.range(ByteStringRange.unbounded().startClosed(rowKey).endClosed(rowKey))));
assertThat(rows).containsExactly(expectedRow);
}
Comment thread
mutianf marked this conversation as resolved.

private Row writeTestRowAndBuildExpected(TableId tableId, String rowKey) {
String familyId = testEnvRule.env().getFamilyId();
long timestampMicros = System.currentTimeMillis() * 1_000;
testEnvRule
.env()
.getDataClient()
.mutateRow(
RowMutation.create(tableId, rowKey).setCell(familyId, "q", timestampMicros, "value"));
return Row.create(
ByteString.copyFromUtf8(rowKey),
ImmutableList.of(
RowCell.create(
familyId,
ByteString.copyFromUtf8("q"),
timestampMicros,
ImmutableList.of(),
ByteString.copyFromUtf8("value"))));
}

static class AccumulatingObserver implements ResponseObserver<Row> {

final List<Row> responses = Lists.newArrayList();
Expand Down
Loading