use of com.google.cloud.bigtable.data.v2.models.RowCell 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.RowCell 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.RowCell 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());
}
use of com.google.cloud.bigtable.data.v2.models.RowCell in project testcontainers-java by testcontainers.
the class BigtableEmulatorContainerTest method testSimple.
// }
@Test
public // testWithEmulatorContainer {
void testSimple() throws IOException, InterruptedException, ExecutionException {
ManagedChannel channel = ManagedChannelBuilder.forTarget(emulator.getEmulatorEndpoint()).usePlaintext().build();
TransportChannelProvider channelProvider = FixedTransportChannelProvider.create(GrpcTransportChannel.create(channel));
NoCredentialsProvider credentialsProvider = NoCredentialsProvider.create();
try {
createTable(channelProvider, credentialsProvider, "test-table");
BigtableDataClient client = BigtableDataClient.create(BigtableDataSettings.newBuilderForEmulator(emulator.getHost(), emulator.getEmulatorPort()).setProjectId(PROJECT_ID).setInstanceId(INSTANCE_ID).build());
client.mutateRow(RowMutation.create("test-table", "1").setCell("name", "firstName", "Ray"));
Row row = client.readRow("test-table", "1");
List<RowCell> cells = row.getCells("name", "firstName");
assertThat(cells).isNotNull().hasSize(1);
assertThat(cells.get(0).getValue().toStringUtf8()).isEqualTo("Ray");
} finally {
channel.shutdown();
}
}
use of com.google.cloud.bigtable.data.v2.models.RowCell in project java-bigtable-hbase by googleapis.
the class TestRowResultAdapter method testWithSingleCellRow.
@Test
public void testWithSingleCellRow() {
RowAdapter.RowBuilder<Result> rowBuilder = underTest.createRowBuilder();
rowBuilder.startRow(ROW_KEY);
rowBuilder.startCell(COL_FAMILY, QUAL_ONE, 10000L, Collections.<String>emptyList(), VALUE.size());
rowBuilder.cellValue(VALUE);
rowBuilder.finishCell();
rowBuilder.startCell(COL_FAMILY, QUAL_TWO, 20000L, LABELS, -1);
rowBuilder.cellValue(VALUE);
rowBuilder.finishCell();
Result expected = Result.create(ImmutableList.<Cell>of(new RowCell(ROW_KEY.toByteArray(), COL_FAMILY.getBytes(), QUAL_ONE.toByteArray(), 10L, VALUE.toByteArray()), new RowCell(ROW_KEY.toByteArray(), COL_FAMILY.getBytes(), QUAL_TWO.toByteArray(), 20L, VALUE.toByteArray(), LABELS)));
assertResult(expected, rowBuilder.finishRow());
assertEquals(ROW_KEY, underTest.getKey(expected));
}
Aggregations