use of com.google.cloud.bigtable.core.IBigtableTableAdminClient in project java-bigtable-hbase by googleapis.
the class SimpleIT method testConnection.
@Test
public void testConnection() throws Exception {
String projectId = "fake-project";
String instanceId = "fake-instance";
String tableId = "myTable";
String family = "cf";
String key = "key";
String value = "value";
BigtableOptions opts = new BigtableOptions.Builder().setUserAgent("fake").setProjectId(projectId).setInstanceId(instanceId).build();
try (BigtableSession session = new BigtableSession(opts)) {
IBigtableTableAdminClient tableAdminClient = session.getTableAdminClientWrapper();
tableAdminClient.createTable(CreateTableRequest.of(tableId).addFamily(family));
IBigtableDataClient dataClient = session.getDataClientWrapper();
dataClient.mutateRow(RowMutation.create(tableId, key).setCell(family, "", value));
List<Row> results = dataClient.readRowsAsync(Query.create(tableId).rowKey(key)).get();
Assert.assertEquals(ByteString.copyFromUtf8(value), results.get(0).getCells().get(0).getValue());
}
}
Aggregations