use of com.google.cloud.speech.v1p1beta1.LocationName in project java-dlp by googleapis.
the class DlpServiceClientTest method createDlpJobTest2.
@Test
public void createDlpJobTest2() throws Exception {
DlpJob expectedResponse = DlpJob.newBuilder().setName(DlpJobName.ofProjectDlpJobName("[PROJECT]", "[DLP_JOB]").toString()).setType(DlpJobType.forNumber(0)).setCreateTime(Timestamp.newBuilder().build()).setStartTime(Timestamp.newBuilder().build()).setEndTime(Timestamp.newBuilder().build()).setJobTriggerName("jobTriggerName494333030").addAllErrors(new ArrayList<Error>()).build();
mockDlpService.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
RiskAnalysisJobConfig riskJob = RiskAnalysisJobConfig.newBuilder().build();
DlpJob actualResponse = client.createDlpJob(parent, riskJob);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockDlpService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateDlpJobRequest actualRequest = ((CreateDlpJobRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(riskJob, actualRequest.getRiskJob());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.speech.v1p1beta1.LocationName in project java-dlp by googleapis.
the class DlpServiceClientTest method createJobTriggerTest.
@Test
public void createJobTriggerTest() throws Exception {
JobTrigger expectedResponse = JobTrigger.newBuilder().setName(JobTriggerName.ofProjectJobTriggerName("[PROJECT]", "[JOB_TRIGGER]").toString()).setDisplayName("displayName1714148973").setDescription("description-1724546052").addAllTriggers(new ArrayList<JobTrigger.Trigger>()).addAllErrors(new ArrayList<Error>()).setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).setLastRunTime(Timestamp.newBuilder().build()).build();
mockDlpService.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
JobTrigger jobTrigger = JobTrigger.newBuilder().build();
JobTrigger actualResponse = client.createJobTrigger(parent, jobTrigger);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockDlpService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateJobTriggerRequest actualRequest = ((CreateJobTriggerRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(jobTrigger, actualRequest.getJobTrigger());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.speech.v1p1beta1.LocationName in project java-dlp by googleapis.
the class DlpServiceClientTest method listDlpJobsTest.
@Test
public void listDlpJobsTest() throws Exception {
DlpJob responsesElement = DlpJob.newBuilder().build();
ListDlpJobsResponse expectedResponse = ListDlpJobsResponse.newBuilder().setNextPageToken("").addAllJobs(Arrays.asList(responsesElement)).build();
mockDlpService.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListDlpJobsPagedResponse pagedListResponse = client.listDlpJobs(parent);
List<DlpJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getJobsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockDlpService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListDlpJobsRequest actualRequest = ((ListDlpJobsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.speech.v1p1beta1.LocationName in project java-logging by googleapis.
the class ConfigClientTest method listBucketsTest3.
@Test
public void listBucketsTest3() throws Exception {
LogBucket responsesElement = LogBucket.newBuilder().build();
ListBucketsResponse expectedResponse = ListBucketsResponse.newBuilder().setNextPageToken("").addAllBuckets(Arrays.asList(responsesElement)).build();
mockConfigServiceV2.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListBucketsPagedResponse pagedListResponse = client.listBuckets(parent);
List<LogBucket> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getBucketsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListBucketsRequest actualRequest = ((ListBucketsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.speech.v1p1beta1.LocationName in project java-servicedirectory by googleapis.
the class Quickstart method quickstart.
public static void quickstart(String projectId, String locationId) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (RegistrationServiceClient client = RegistrationServiceClient.create()) {
// The project and location that hold the namespace to list.
LocationName parent = LocationName.of(projectId, locationId);
// Call the API.
ListNamespacesPagedResponse response = client.listNamespaces(parent);
// Iterate over each namespace and print its name.
System.out.println("Namespaces:");
for (Namespace namespace : response.iterateAll()) {
System.out.println(namespace.getName());
}
}
}
Aggregations