use of com.google.cloud.bigquery.datatransfer.v1.ListTransferConfigsRequest in project java-bigquerydatatransfer by googleapis.
the class ListTransferConfigs method listTransferConfigs.
public static void listTransferConfigs(String projectId) throws IOException {
try (DataTransferServiceClient dataTransferServiceClient = DataTransferServiceClient.create()) {
ProjectName parent = ProjectName.of(projectId);
ListTransferConfigsRequest request = ListTransferConfigsRequest.newBuilder().setParent(parent.toString()).build();
dataTransferServiceClient.listTransferConfigs(request).iterateAll().forEach(config -> System.out.print("Success! Config ID :" + config.getName() + "\n"));
} catch (ApiException ex) {
System.out.println("Config list not found due to error." + ex.toString());
}
}
use of com.google.cloud.bigquery.datatransfer.v1.ListTransferConfigsRequest in project java-bigquerydatatransfer by googleapis.
the class DataTransferServiceClientTest method listTransferConfigsTest3.
@Test
public void listTransferConfigsTest3() throws Exception {
TransferConfig responsesElement = TransferConfig.newBuilder().build();
ListTransferConfigsResponse expectedResponse = ListTransferConfigsResponse.newBuilder().setNextPageToken("").addAllTransferConfigs(Arrays.asList(responsesElement)).build();
mockDataTransferService.addResponse(expectedResponse);
String parent = "parent-995424086";
ListTransferConfigsPagedResponse pagedListResponse = client.listTransferConfigs(parent);
List<TransferConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getTransferConfigsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockDataTransferService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListTransferConfigsRequest actualRequest = ((ListTransferConfigsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.bigquery.datatransfer.v1.ListTransferConfigsRequest in project java-bigquerydatatransfer by googleapis.
the class DataTransferServiceClientTest method listTransferConfigsTest2.
@Test
public void listTransferConfigsTest2() throws Exception {
TransferConfig responsesElement = TransferConfig.newBuilder().build();
ListTransferConfigsResponse expectedResponse = ListTransferConfigsResponse.newBuilder().setNextPageToken("").addAllTransferConfigs(Arrays.asList(responsesElement)).build();
mockDataTransferService.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
ListTransferConfigsPagedResponse pagedListResponse = client.listTransferConfigs(parent);
List<TransferConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getTransferConfigsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockDataTransferService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListTransferConfigsRequest actualRequest = ((ListTransferConfigsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.bigquery.datatransfer.v1.ListTransferConfigsRequest in project java-bigquerydatatransfer by googleapis.
the class DataTransferServiceClientTest method listTransferConfigsTest.
@Test
public void listTransferConfigsTest() throws Exception {
TransferConfig responsesElement = TransferConfig.newBuilder().build();
ListTransferConfigsResponse expectedResponse = ListTransferConfigsResponse.newBuilder().setNextPageToken("").addAllTransferConfigs(Arrays.asList(responsesElement)).build();
mockDataTransferService.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListTransferConfigsPagedResponse pagedListResponse = client.listTransferConfigs(parent);
List<TransferConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getTransferConfigsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockDataTransferService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListTransferConfigsRequest actualRequest = ((ListTransferConfigsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations