use of com.google.cloud.bigtable.data.v2.models.Row in project java-bigtable by googleapis.
the class BigtableDataClientTest method readRowTest.
@Test
public void readRowTest() {
Mockito.when(mockStub.readRowCallable()).thenReturn(mockReadRowCallable);
Row expectedRow = Row.create(ByteString.copyFromUtf8("fake-row-key"), ImmutableList.<RowCell>of());
Mockito.when(mockReadRowCallable.futureCall(Query.create("fake-table").rowKey("fake-row-key"))).thenReturn(ApiFutures.immediateFuture(expectedRow));
Row actualRow = bigtableDataClient.readRow("fake-table", ByteString.copyFromUtf8("fake-row-key"));
assertThat(actualRow).isEqualTo(expectedRow);
}
use of com.google.cloud.bigtable.data.v2.models.Row in project java-bigtable by googleapis.
the class BigtableDataClientTest method readRowStrFilterTest.
@Test
public void readRowStrFilterTest() {
Mockito.when(mockStub.readRowCallable()).thenReturn(mockReadRowCallable);
// Build the filter expression
Filter filter = FILTERS.chain().filter(FILTERS.qualifier().regex("prefix.*")).filter(FILTERS.limit().cellsPerRow(10));
Row expectedRow = Row.create(ByteString.copyFromUtf8("fake-row-key"), ImmutableList.<RowCell>of());
Mockito.when(mockReadRowCallable.futureCall(Query.create("fake-table").rowKey("fake-row-key").filter(filter))).thenReturn(ApiFutures.immediateFuture(expectedRow));
Row actualRow = bigtableDataClient.readRow("fake-table", "fake-row-key", filter);
assertThat(actualRow).isEqualTo(expectedRow);
}
use of com.google.cloud.bigtable.data.v2.models.Row in project java-bigtable by googleapis.
the class BigtableDataClientTest method readRowFilterAsyncTest.
@Test
public void readRowFilterAsyncTest() {
Mockito.when(mockStub.readRowCallable()).thenReturn(mockReadRowCallable);
// Build the filter expression
Filter filter = FILTERS.chain().filter(FILTERS.qualifier().regex("prefix.*")).filter(FILTERS.limit().cellsPerRow(10));
bigtableDataClient.readRowAsync("fake-table", ByteString.copyFromUtf8("fake-row-key"), filter);
Mockito.verify(mockReadRowCallable).futureCall(Query.create("fake-table").rowKey("fake-row-key").filter(filter));
}
use of com.google.cloud.bigtable.data.v2.models.Row in project java-bigtable by googleapis.
the class BigtableDataClientTest method readModifyWriteRowTest.
@Test
public void readModifyWriteRowTest() {
Mockito.when(mockStub.readModifyWriteRowCallable()).thenReturn(mockReadModifyWriteRowCallable);
Mockito.when(mockReadModifyWriteRowCallable.futureCall(ArgumentMatchers.any(ReadModifyWriteRow.class))).thenReturn(ApiFutures.immediateFuture(Row.create(ByteString.copyFromUtf8("fake-row-key"), Collections.<RowCell>emptyList())));
ReadModifyWriteRow request = ReadModifyWriteRow.create("fake-table", "some-key").append("fake-family", "fake-qualifier", "suffix");
bigtableDataClient.readModifyWriteRow(request);
Mockito.verify(mockReadModifyWriteRowCallable).futureCall(request);
}
use of com.google.cloud.bigtable.data.v2.models.Row in project java-bigtable by googleapis.
the class BigtableDataClientTest method proxyNewBulkReadRowsTest.
@Test
public void proxyNewBulkReadRowsTest() {
Mockito.when(mockStub.newBulkReadRowsBatcher(Mockito.any(Query.class), Mockito.any())).thenReturn(mockBulkReadRowsBatcher);
ApiFuture<Row> expectedResponse = ApiFutures.immediateFuture(Row.create(ByteString.copyFromUtf8("fake-row-key"), Collections.<RowCell>emptyList()));
ByteString request = ByteString.copyFromUtf8("fake-row-key");
Batcher<ByteString, Row> batcher = bigtableDataClient.newBulkReadRowsBatcher("fake-table");
Mockito.when(mockBulkReadRowsBatcher.add(request)).thenReturn(expectedResponse);
ApiFuture<Row> actualResponse = batcher.add(request);
assertThat(actualResponse).isSameInstanceAs(expectedResponse);
Mockito.verify(mockStub).newBulkReadRowsBatcher(Mockito.any(Query.class), Mockito.any());
}
Aggregations