use of com.google.cloud.bigquery.storage.v1beta2.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.cloud.bigquery.storage.v1beta2.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.
}
}
use of com.google.cloud.bigquery.storage.v1beta2.TableName in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method modifyColumnFamiliesTest.
@Test
public void modifyColumnFamiliesTest() 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();
mockBigtableTableAdmin.addResponse(expectedResponse);
TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
List<ModifyColumnFamiliesRequest.Modification> modifications = new ArrayList<>();
Table actualResponse = client.modifyColumnFamilies(name, modifications);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
ModifyColumnFamiliesRequest actualRequest = ((ModifyColumnFamiliesRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertEquals(modifications, actualRequest.getModificationsList());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.bigquery.storage.v1beta2.TableName in project java-bigtable by googleapis.
the class BigtableTableAdminClientTests method testAwaitReplication.
@Test
public void testAwaitReplication() {
// Setup
Mockito.when(mockStub.awaitReplicationCallable()).thenReturn(mockAwaitReplicationCallable);
TableName expectedRequest = TableName.parse(TABLE_NAME);
final AtomicBoolean wasCalled = new AtomicBoolean(false);
Mockito.when(mockAwaitReplicationCallable.futureCall(expectedRequest)).thenAnswer((Answer<ApiFuture<Void>>) invocationOnMock -> {
wasCalled.set(true);
return ApiFutures.immediateFuture(null);
});
// Execute
adminClient.awaitReplication(TABLE_ID);
// Verify
assertThat(wasCalled.get()).isTrue();
}
use of com.google.cloud.bigquery.storage.v1beta2.TableName in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method snapshotTableTest.
@Test
public void snapshotTableTest() 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]");
ClusterName cluster = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
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.toString(), actualRequest.getCluster());
Assert.assertEquals(snapshotId, actualRequest.getSnapshotId());
Assert.assertEquals(description, actualRequest.getDescription());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations