use of com.google.bigtable.v2.TableName in project java-bigtable by googleapis.
the class SampleRowKeysCallable method futureCall.
@Override
public ApiFuture<List<KeyOffset>> futureCall(String tableId, ApiCallContext context) {
String tableName = NameUtil.formatTableName(requestContext.getProjectId(), requestContext.getInstanceId(), tableId);
SampleRowKeysRequest request = SampleRowKeysRequest.newBuilder().setTableName(tableName).setAppProfileId(requestContext.getAppProfileId()).build();
ApiFuture<List<SampleRowKeysResponse>> rawResponse = inner.futureCall(request, context);
return ApiFutures.transform(rawResponse, new ApiFunction<List<SampleRowKeysResponse>, List<KeyOffset>>() {
@Override
public List<KeyOffset> apply(List<SampleRowKeysResponse> rawResponse) {
return convert(rawResponse);
}
}, MoreExecutors.directExecutor());
}
use of com.google.bigtable.v2.TableName in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method getTableExceptionTest.
@Test
public void getTableExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockBigtableTableAdmin.addException(exception);
try {
TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
client.getTable(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.bigtable.v2.TableName in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method snapshotTableTest2.
@Test
public void snapshotTableTest2() throws Exception {
Snapshot expectedResponse = Snapshot.newBuilder().setName(SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]").toString()).setSourceTable(Table.newBuilder().build()).setDataSizeBytes(-2110122398).setCreateTime(Timestamp.newBuilder().build()).setDeleteTime(Timestamp.newBuilder().build()).setDescription("description-1724546052").build();
Operation resultOperation = Operation.newBuilder().setName("snapshotTableTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
mockBigtableTableAdmin.addResponse(resultOperation);
TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
String cluster = "cluster872092154";
String snapshotId = "snapshotId-1113817601";
String description = "description-1724546052";
Snapshot actualResponse = client.snapshotTableAsync(name, cluster, snapshotId, description).get();
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
SnapshotTableRequest actualRequest = ((SnapshotTableRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertEquals(cluster, actualRequest.getCluster());
Assert.assertEquals(snapshotId, actualRequest.getSnapshotId());
Assert.assertEquals(description, actualRequest.getDescription());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.bigtable.v2.TableName in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method checkConsistencyExceptionTest.
@Test
public void checkConsistencyExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockBigtableTableAdmin.addException(exception);
try {
TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
String consistencyToken = "consistencyToken-1985152319";
client.checkConsistency(name, consistencyToken);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.bigtable.v2.TableName in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method generateConsistencyTokenExceptionTest.
@Test
public void generateConsistencyTokenExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockBigtableTableAdmin.addException(exception);
try {
TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
client.generateConsistencyToken(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations