Search in sources :

Example 41 with LocationName

use of com.google.logging.v2.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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ArrayList(java.util.ArrayList) DlpJob(com.google.privacy.dlp.v2.DlpJob) RiskAnalysisJobConfig(com.google.privacy.dlp.v2.RiskAnalysisJobConfig) CreateDlpJobRequest(com.google.privacy.dlp.v2.CreateDlpJobRequest) OrganizationLocationName(com.google.privacy.dlp.v2.OrganizationLocationName) LocationName(com.google.privacy.dlp.v2.LocationName) Test(org.junit.Test)

Example 42 with LocationName

use of com.google.logging.v2.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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ArrayList(java.util.ArrayList) Error(com.google.privacy.dlp.v2.Error) JobTrigger(com.google.privacy.dlp.v2.JobTrigger) OrganizationLocationName(com.google.privacy.dlp.v2.OrganizationLocationName) LocationName(com.google.privacy.dlp.v2.LocationName) CreateJobTriggerRequest(com.google.privacy.dlp.v2.CreateJobTriggerRequest) Test(org.junit.Test)

Example 43 with LocationName

use of com.google.logging.v2.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()));
}
Also used : ListDlpJobsPagedResponse(com.google.cloud.dlp.v2.DlpServiceClient.ListDlpJobsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ListDlpJobsRequest(com.google.privacy.dlp.v2.ListDlpJobsRequest) DlpJob(com.google.privacy.dlp.v2.DlpJob) ListDlpJobsResponse(com.google.privacy.dlp.v2.ListDlpJobsResponse) OrganizationLocationName(com.google.privacy.dlp.v2.OrganizationLocationName) LocationName(com.google.privacy.dlp.v2.LocationName) Test(org.junit.Test)

Example 44 with LocationName

use of com.google.logging.v2.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()));
}
Also used : ListBucketsResponse(com.google.logging.v2.ListBucketsResponse) ListBucketsPagedResponse(com.google.cloud.logging.v2.ConfigClient.ListBucketsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ListBucketsRequest(com.google.logging.v2.ListBucketsRequest) LogBucket(com.google.logging.v2.LogBucket) BillingAccountLocationName(com.google.logging.v2.BillingAccountLocationName) OrganizationLocationName(com.google.logging.v2.OrganizationLocationName) FolderLocationName(com.google.logging.v2.FolderLocationName) LocationName(com.google.logging.v2.LocationName) Test(org.junit.Test)

Example 45 with LocationName

use of com.google.logging.v2.LocationName in project java-cloudbuild by googleapis.

the class CloudBuildClientTest method createWorkerPoolTest.

@Test
public void createWorkerPoolTest() throws Exception {
    WorkerPool expectedResponse = WorkerPool.newBuilder().setName(WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString()).setDisplayName("displayName1714148973").setUid("uid115792").putAllAnnotations(new HashMap<String, String>()).setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).setDeleteTime(Timestamp.newBuilder().build()).setEtag("etag3123477").build();
    Operation resultOperation = Operation.newBuilder().setName("createWorkerPoolTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
    mockCloudBuild.addResponse(resultOperation);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    WorkerPool workerPool = WorkerPool.newBuilder().build();
    String workerPoolId = "workerPoolId-46320779";
    WorkerPool actualResponse = client.createWorkerPoolAsync(parent, workerPool, workerPoolId).get();
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockCloudBuild.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateWorkerPoolRequest actualRequest = ((CreateWorkerPoolRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertEquals(workerPool, actualRequest.getWorkerPool());
    Assert.assertEquals(workerPoolId, actualRequest.getWorkerPoolId());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : WorkerPool(com.google.cloudbuild.v1.WorkerPool) AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) Operation(com.google.longrunning.Operation) CreateWorkerPoolRequest(com.google.cloudbuild.v1.CreateWorkerPoolRequest) LocationName(com.google.cloudbuild.v1.LocationName) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)28 LocationName (com.google.privacy.dlp.v2.LocationName)22 OrganizationLocationName (com.google.privacy.dlp.v2.OrganizationLocationName)22 AutoMlClient (com.google.cloud.automl.v1.AutoMlClient)17 LocationName (com.google.cloud.automl.v1.LocationName)17 AbstractMessage (com.google.protobuf.AbstractMessage)14 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)13 LocationName (com.google.cloud.translate.v3.LocationName)13 TranslationServiceClient (com.google.cloud.translate.v3.TranslationServiceClient)13 StatusRuntimeException (io.grpc.StatusRuntimeException)13 OperationMetadata (com.google.cloud.automl.v1.OperationMetadata)12 AutoMlClient (com.google.cloud.automl.v1beta1.AutoMlClient)12 LocationName (com.google.cloud.automl.v1beta1.LocationName)12 LocationName (com.google.cloud.translate.v3beta1.LocationName)10 TranslationServiceClient (com.google.cloud.translate.v3beta1.TranslationServiceClient)10 Model (com.google.cloud.automl.v1.Model)8 Dataset (com.google.cloud.automl.v1.Dataset)7 Dataset (com.google.cloud.automl.v1beta1.Dataset)6 GcsSource (com.google.cloud.translate.v3.GcsSource)5 ArrayList (java.util.ArrayList)5