use of com.google.cloud.bigquery.connection.v1.ConnectionName in project java-bigqueryconnection by googleapis.
the class ConnectionServiceClientTest method updateConnectionExceptionTest.
@Test
public void updateConnectionExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockConnectionService.addException(exception);
try {
ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
Connection connection = Connection.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
client.updateConnection(name, connection, updateMask);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.cloud.bigquery.connection.v1.ConnectionName in project java-bigqueryconnection by googleapis.
the class ConnectionServiceClientTest method deleteConnectionExceptionTest.
@Test
public void deleteConnectionExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockConnectionService.addException(exception);
try {
ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
client.deleteConnection(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.cloud.bigquery.connection.v1.ConnectionName in project java-bigqueryconnection by googleapis.
the class ConnectionServiceClientTest method deleteConnectionTest.
@Test
public void deleteConnectionTest() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockConnectionService.addResponse(expectedResponse);
ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
client.deleteConnection(name);
List<AbstractMessage> actualRequests = mockConnectionService.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteConnectionRequest actualRequest = ((DeleteConnectionRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.bigquery.connection.v1.ConnectionName in project java-bigqueryconnection by googleapis.
the class DeleteConnection method deleteConnection.
public static void deleteConnection(String projectId, String location, String connectionName) throws IOException {
try (ConnectionServiceClient client = ConnectionServiceClient.create()) {
ConnectionName name = ConnectionName.of(projectId, location, connectionName);
DeleteConnectionRequest request = DeleteConnectionRequest.newBuilder().setName(name.toString()).build();
client.deleteConnection(request);
System.out.println("Connection deleted successfully");
}
}
use of com.google.cloud.bigquery.connection.v1.ConnectionName in project java-bigqueryconnection by googleapis.
the class GetConnection method getConnection.
public static void getConnection(String projectId, String location, String connectionId) throws IOException {
try (ConnectionServiceClient client = ConnectionServiceClient.create()) {
ConnectionName name = ConnectionName.of(projectId, location, connectionId);
GetConnectionRequest request = GetConnectionRequest.newBuilder().setName(name.toString()).build();
Connection response = client.getConnection(request);
System.out.println("Connection info retrieved successfully :" + response.getName());
}
}
Aggregations