BigtableDataClientWrapper implements IBigtableDataClient { @Override public Row readModifyWriteRow(ReadModifyWriteRow readModifyWriteRow) { ReadModifyWriteRowResponse response = delegate.readModifyWriteRow(readModifyWriteRow.toProto(requestContext)); return new DefaultRowAdapter().createRowFromProto(response.getRow()); } BigtableDataClientWrapper(
      BigtableDataClient bigtableDataClient, RequestContext requestContext); @Override void mutateRow(RowMutation rowMutation); @Override ApiFuture<Void> mutateRowAsync(RowMutation rowMutation); @Override Row readModifyWriteRow(ReadModifyWriteRow readModifyWriteRow); @Override ApiFuture<Row> readModifyWriteRowAsync(ReadModifyWriteRow readModifyWriteRow); @Override IBulkMutation createBulkMutationBatcher(String tableId); @Override ApiFuture<Boolean> checkAndMutateRowAsync(ConditionalRowMutation conditionalRowMutation); @Override Boolean checkAndMutateRow(ConditionalRowMutation conditionalRowMutation); @Override List<KeyOffset> sampleRowKeys(String tableId); @Override ApiFuture<List<KeyOffset>> sampleRowKeysAsync(String tableId); @Override ResultScanner<Row> readRows(Query request); @Override ApiFuture<List<Row>> readRowsAsync(Query request); @Override List<FlatRow> readFlatRowsList(Query request); @Override ResultScanner<FlatRow> readFlatRows(Query request); @Override ApiFuture<List<FlatRow>> readFlatRowsAsync(Query request); @Override void readFlatRowsAsync(Query request, StreamObserver<FlatRow> observer);  }
@Test public void testReadModifyWriteWithOneCell() { ReadModifyWriteRow readModify = ReadModifyWriteRow.create(TABLE_ID, "test-key"); ReadModifyWriteRowRequest request = readModify.toProto(REQUEST_CONTEXT); Row expectedRow = buildRow(); ReadModifyWriteRowResponse response = ReadModifyWriteRowResponse.newBuilder().setRow(expectedRow).build(); RowCell rowCell = RowCell.create("firstFamily", QUALIFIER_1, TIMESTAMP, LABEL_LIST, VALUE); com.google.cloud.bigtable.data.v2.models.Row modelRow = com.google.cloud.bigtable.data.v2.models.Row.create( ROW_KEY, Collections.singletonList(rowCell)); when(client.readModifyWriteRow(request)).thenReturn(response); com.google.cloud.bigtable.data.v2.models.Row actualRow = clientWrapper.readModifyWriteRow(readModify); assertEquals(modelRow, actualRow); verify(client).readModifyWriteRow(request); }
@Test public void testReadModifyWriteWithMultipleCell() { Row row = Row.newBuilder() .setKey(ROW_KEY) .addFamilies( Family.newBuilder() .setName("firstFamily") .addColumns( Column.newBuilder() .setQualifier(QUALIFIER_1) .addCells( Cell.newBuilder() .setValue(VALUE) .setTimestampMicros(TIMESTAMP) .addLabels(LABEL) .build()) .build()) .addColumns( Column.newBuilder() .setQualifier(QUALIFIER_2) .addCells( Cell.newBuilder() .setValue(VALUE) .setTimestampMicros(TIMESTAMP) .addLabels(LABEL) .build()) .addCells( Cell.newBuilder() .setValue(VALUE) .setTimestampMicros(54321) .addLabels(LABEL) .build()) .build()) .build()) .addFamilies( Family.newBuilder() .setName("secondFamily") .addColumns( Column.newBuilder() .setQualifier(QUALIFIER_1) .addCells( Cell.newBuilder() .setValue(VALUE) .setTimestampMicros(TIMESTAMP) .addLabels(LABEL) .build()) .build())) .build(); ReadModifyWriteRowResponse response = ReadModifyWriteRowResponse.newBuilder().setRow(row).build(); ReadModifyWriteRow readModify = ReadModifyWriteRow.create(TABLE_ID, "test-key"); ReadModifyWriteRowRequest request = readModify.toProto(REQUEST_CONTEXT); ImmutableList.Builder<RowCell> rowCells = ImmutableList.builder(); rowCells.add(RowCell.create("firstFamily", QUALIFIER_1, TIMESTAMP, LABEL_LIST, VALUE)); rowCells.add(RowCell.create("firstFamily", QUALIFIER_2, TIMESTAMP, LABEL_LIST, VALUE)); rowCells.add(RowCell.create("firstFamily", QUALIFIER_2, 54321, LABEL_LIST, VALUE)); rowCells.add(RowCell.create("secondFamily", QUALIFIER_1, TIMESTAMP, LABEL_LIST, VALUE)); com.google.cloud.bigtable.data.v2.models.Row expectedModelRow = com.google.cloud.bigtable.data.v2.models.Row.create(ROW_KEY, rowCells.build()); when(client.readModifyWriteRow(request)).thenReturn(response); com.google.cloud.bigtable.data.v2.models.Row actualRow = clientWrapper.readModifyWriteRow(readModify); assertEquals(expectedModelRow, actualRow); verify(client).readModifyWriteRow(request); }