use of com.google.cloud.bigtable.data.v2.models.Row in project java-bigtable by googleapis.
the class BigtableDataClientTests 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 BigtableDataClientTests method existsTest.
@Test
public void existsTest() {
Mockito.when(mockStub.readRowCallable()).thenReturn(mockReadRowCallable);
Query expectedQuery = Query.create("fake-table").rowKey("fake-row-key").filter(FILTERS.chain().filter(FILTERS.limit().cellsPerRow(1)).filter(FILTERS.value().strip()));
Row row = Row.create(ByteString.copyFromUtf8("fake-row-key"), ImmutableList.<RowCell>of());
Mockito.when(mockReadRowCallable.futureCall(expectedQuery)).thenReturn(ApiFutures.immediateFuture(row)).thenReturn(ApiFutures.<Row>immediateFuture(null));
boolean result = bigtableDataClient.exists("fake-table", "fake-row-key");
boolean anotherResult = bigtableDataClient.exists("fake-table", ByteString.copyFromUtf8("fake-row-key"));
assertThat(result).isTrue();
assertThat(anotherResult).isFalse();
Mockito.verify(mockReadRowCallable, Mockito.times(2)).futureCall(expectedQuery);
}
use of com.google.cloud.bigtable.data.v2.models.Row in project java-bigtable by googleapis.
the class BigtableDataClientTests 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 BigtableDataClientTests method readRowFilterTest.
@Test
public void readRowFilterTest() {
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", ByteString.copyFromUtf8("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 BigtableDataClientTests method proxyNewBulkReadRowsWithFilterTest.
@Test
public void proxyNewBulkReadRowsWithFilterTest() {
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", FILTERS.key().regex("fake-row"));
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