use of com.google.storage.v2.ProjectName in project java-bigquerydatatransfer by googleapis.
the class DeleteTransferConfigIT method setUp.
@Before
public void setUp() throws IOException {
bout = new ByteArrayOutputStream();
out = new PrintStream(bout);
originalPrintStream = System.out;
System.setOut(out);
displayName = "MY_SCHEDULE_NAME_TEST_" + UUID.randomUUID().toString().substring(0, 8);
datasetName = "MY_DATASET_NAME_TEST_" + UUID.randomUUID().toString().substring(0, 8);
// create a temporary dataset
bigquery = BigQueryOptions.getDefaultInstance().getService();
bigquery.create(DatasetInfo.of(datasetName));
// create a scheduled query
String query = "SELECT CURRENT_TIMESTAMP() as current_time, @run_time as intended_run_time, " + "@run_date as intended_run_date, 17 as some_integer";
String destinationTableName = "MY_DESTINATION_TABLE_" + UUID.randomUUID().toString().substring(0, 8) + "_{run_date}";
Map<String, Value> params = new HashMap<>();
params.put("query", Value.newBuilder().setStringValue(query).build());
params.put("destination_table_name_template", Value.newBuilder().setStringValue(destinationTableName).build());
params.put("write_disposition", Value.newBuilder().setStringValue("WRITE_TRUNCATE").build());
params.put("partitioning_field", Value.newBuilder().setStringValue("").build());
TransferConfig transferConfig = TransferConfig.newBuilder().setDestinationDatasetId(datasetName).setDisplayName(displayName).setDataSourceId("scheduled_query").setParams(Struct.newBuilder().putAllFields(params).build()).setSchedule("every 24 hours").build();
try (DataTransferServiceClient dataTransferServiceClient = DataTransferServiceClient.create()) {
ProjectName parent = ProjectName.of(PROJECT_ID);
CreateTransferConfigRequest request = CreateTransferConfigRequest.newBuilder().setParent(parent.toString()).setTransferConfig(transferConfig).build();
name = dataTransferServiceClient.createTransferConfig(request).getName();
System.out.println("Transfer config created successfully :" + name);
}
}
use of com.google.storage.v2.ProjectName in project java-webrisk by googleapis.
the class WebRiskServiceClientTest method createSubmissionTest.
@Test
public void createSubmissionTest() throws Exception {
Submission expectedResponse = Submission.newBuilder().setUri("uri116076").build();
mockWebRiskService.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
Submission submission = Submission.newBuilder().build();
Submission actualResponse = client.createSubmission(parent, submission);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockWebRiskService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateSubmissionRequest actualRequest = ((CreateSubmissionRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(submission, actualRequest.getSubmission());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.storage.v2.ProjectName in project java-containeranalysis by googleapis.
the class ContainerAnalysisV1Beta1ClientTest method listScanConfigsExceptionTest.
@Test
@SuppressWarnings("all")
public void listScanConfigsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockContainerAnalysisV1Beta1.addException(exception);
try {
ProjectName parent = ProjectName.of("[PROJECT]");
String filter = "filter-1274492040";
client.listScanConfigs(parent, filter);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception
}
}
use of com.google.storage.v2.ProjectName in project java-containeranalysis by googleapis.
the class GrafeasV1Beta1ClientTest method createOccurrenceExceptionTest.
@Test
@SuppressWarnings("all")
public void createOccurrenceExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockGrafeasV1Beta1.addException(exception);
try {
ProjectName parent = ProjectName.of("[PROJECT]");
Occurrence occurrence = Occurrence.newBuilder().build();
client.createOccurrence(parent, occurrence);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception
}
}
use of com.google.storage.v2.ProjectName in project java-containeranalysis by googleapis.
the class GrafeasV1Beta1ClientTest method batchCreateOccurrencesExceptionTest.
@Test
@SuppressWarnings("all")
public void batchCreateOccurrencesExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockGrafeasV1Beta1.addException(exception);
try {
ProjectName parent = ProjectName.of("[PROJECT]");
List<Occurrence> occurrences = new ArrayList<>();
client.batchCreateOccurrences(parent, occurrences);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception
}
}
Aggregations