use of com.google.cloud.bigquery.connection.v1.ListConnectionsRequest in project java-bigqueryconnection by googleapis.
the class ITSystemTest method testListConnections.
@Test
public void testListConnections() {
int pageSize = 10;
ListConnectionsRequest request = ListConnectionsRequest.newBuilder().setParent(PARENT).setPageSize(pageSize).build();
for (Connection actualConnection : client.listConnections(request).iterateAll()) {
if (connection.getName().equals(actualConnection.getName())) {
assertEquals(connection, actualConnection);
}
}
}
use of com.google.cloud.bigquery.connection.v1.ListConnectionsRequest in project java-bigqueryconnection by googleapis.
the class ConnectionServiceClientTest method listConnectionsTest.
@Test
public void listConnectionsTest() throws Exception {
Connection responsesElement = Connection.newBuilder().build();
ListConnectionsResponse expectedResponse = ListConnectionsResponse.newBuilder().setNextPageToken("").addAllConnections(Arrays.asList(responsesElement)).build();
mockConnectionService.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListConnectionsPagedResponse pagedListResponse = client.listConnections(parent);
List<Connection> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getConnectionsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockConnectionService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListConnectionsRequest actualRequest = ((ListConnectionsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.bigquery.connection.v1.ListConnectionsRequest in project java-bigqueryconnection by googleapis.
the class ConnectionServiceClientTest method listConnectionsTest2.
@Test
public void listConnectionsTest2() throws Exception {
Connection responsesElement = Connection.newBuilder().build();
ListConnectionsResponse expectedResponse = ListConnectionsResponse.newBuilder().setNextPageToken("").addAllConnections(Arrays.asList(responsesElement)).build();
mockConnectionService.addResponse(expectedResponse);
String parent = "parent-995424086";
ListConnectionsPagedResponse pagedListResponse = client.listConnections(parent);
List<Connection> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getConnectionsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockConnectionService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListConnectionsRequest actualRequest = ((ListConnectionsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.bigquery.connection.v1.ListConnectionsRequest in project java-bigqueryconnection by googleapis.
the class ListConnections method listConnections.
public static void listConnections(String projectId, String location) throws IOException {
try (ConnectionServiceClient client = ConnectionServiceClient.create()) {
LocationName parent = LocationName.of(projectId, location);
int pageSize = 10;
ListConnectionsRequest request = ListConnectionsRequest.newBuilder().setParent(parent.toString()).setPageSize(pageSize).build();
client.listConnections(request).iterateAll().forEach(con -> System.out.println("Connection Id :" + con.getName()));
}
}
use of com.google.cloud.bigquery.connection.v1.ListConnectionsRequest in project java-bigqueryconnection by googleapis.
the class QuickstartSample method listConnections.
public static void listConnections(String projectId, String location) throws IOException {
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
LocationName parent = LocationName.of(projectId, location);
int pageSize = 10;
ListConnectionsRequest request = ListConnectionsRequest.newBuilder().setParent(parent.toString()).setPageSize(pageSize).build();
ConnectionServiceClient.ListConnectionsPagedResponse response = connectionServiceClient.listConnections(request);
// Print the results.
System.out.println("List of connections:");
response.iterateAll().forEach(connection -> System.out.println("Connection Name: " + connection.getName()));
}
}
Aggregations