use of com.google.cloud.bigquery.datatransfer.v1.ProjectName in project java-webrisk by googleapis.
the class WebRiskServiceClientTest method createSubmissionExceptionTest.
@Test
public void createSubmissionExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockWebRiskService.addException(exception);
try {
ProjectName parent = ProjectName.of("[PROJECT]");
Submission submission = Submission.newBuilder().build();
client.createSubmission(parent, submission);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.cloud.bigquery.datatransfer.v1.ProjectName 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.ProjectName in project java-bigquerydatatransfer by googleapis.
the class CreateScheduledQuery method createScheduledQuery.
public static void createScheduledQuery(String projectId, TransferConfig transferConfig) throws IOException {
try (DataTransferServiceClient dataTransferServiceClient = DataTransferServiceClient.create()) {
ProjectName parent = ProjectName.of(projectId);
CreateTransferConfigRequest request = CreateTransferConfigRequest.newBuilder().setParent(parent.toString()).setTransferConfig(transferConfig).build();
TransferConfig config = dataTransferServiceClient.createTransferConfig(request);
System.out.println("\nScheduled query created successfully :" + config.getName());
} catch (ApiException ex) {
System.out.print("\nScheduled query was not created." + ex.toString());
}
}
use of com.google.cloud.bigquery.datatransfer.v1.ProjectName in project java-bigquerydatatransfer by googleapis.
the class CopyDataset method copyDataset.
public static void copyDataset(String projectId, TransferConfig transferConfig) throws IOException {
try (DataTransferServiceClient dataTransferServiceClient = DataTransferServiceClient.create()) {
ProjectName parent = ProjectName.of(projectId);
CreateTransferConfigRequest request = CreateTransferConfigRequest.newBuilder().setParent(parent.toString()).setTransferConfig(transferConfig).build();
TransferConfig config = dataTransferServiceClient.createTransferConfig(request);
System.out.println("Copy dataset created successfully :" + config.getName());
} catch (ApiException ex) {
System.out.print("Copy dataset was not created." + ex.toString());
}
}
use of com.google.cloud.bigquery.datatransfer.v1.ProjectName in project java-bigquerydatatransfer by googleapis.
the class CreateCampaignmanagerTransfer method createCampaignmanagerTransfer.
public static void createCampaignmanagerTransfer(String projectId, TransferConfig transferConfig) throws IOException {
try (DataTransferServiceClient client = DataTransferServiceClient.create()) {
ProjectName parent = ProjectName.of(projectId);
CreateTransferConfigRequest request = CreateTransferConfigRequest.newBuilder().setParent(parent.toString()).setTransferConfig(transferConfig).build();
TransferConfig config = client.createTransferConfig(request);
System.out.println("Campaignmanager transfer created successfully :" + config.getName());
} catch (ApiException ex) {
System.out.print("Campaignmanager transfer was not created." + ex.toString());
}
}
Aggregations