use of com.google.bigtable.admin.v2.RestoreTableRequest in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method restoreTableTest.
@Test
public void restoreTableTest() throws Exception {
Table expectedResponse = Table.newBuilder().setName(TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]").toString()).putAllClusterStates(new HashMap<String, Table.ClusterState>()).putAllColumnFamilies(new HashMap<String, ColumnFamily>()).setRestoreInfo(RestoreInfo.newBuilder().build()).build();
Operation resultOperation = Operation.newBuilder().setName("restoreTableTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
mockBigtableTableAdmin.addResponse(resultOperation);
RestoreTableRequest request = RestoreTableRequest.newBuilder().setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString()).setTableId("tableId-1552905847").build();
Table actualResponse = client.restoreTableAsync(request).get();
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
RestoreTableRequest actualRequest = ((RestoreTableRequest) actualRequests.get(0));
Assert.assertEquals(request.getParent(), actualRequest.getParent());
Assert.assertEquals(request.getTableId(), actualRequest.getTableId());
Assert.assertEquals(request.getBackup(), actualRequest.getBackup());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.bigtable.admin.v2.RestoreTableRequest in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method restoreTableExceptionTest.
@Test
public void restoreTableExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockBigtableTableAdmin.addException(exception);
try {
RestoreTableRequest request = RestoreTableRequest.newBuilder().setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString()).setTableId("tableId-1552905847").build();
client.restoreTableAsync(request).get();
Assert.fail("No exception raised");
} catch (ExecutionException e) {
Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
}
}
Aggregations