Search in sources :

Example 91 with ProjectName

use of com.google.recaptchaenterprise.v1beta1.ProjectName in project java-dlp by googleapis.

the class DlpServiceClientTest method listStoredInfoTypesTest4.

@Test
public void listStoredInfoTypesTest4() throws Exception {
    StoredInfoType responsesElement = StoredInfoType.newBuilder().build();
    ListStoredInfoTypesResponse expectedResponse = ListStoredInfoTypesResponse.newBuilder().setNextPageToken("").addAllStoredInfoTypes(Arrays.asList(responsesElement)).build();
    mockDlpService.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    ListStoredInfoTypesPagedResponse pagedListResponse = client.listStoredInfoTypes(parent);
    List<StoredInfoType> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getStoredInfoTypesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockDlpService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListStoredInfoTypesRequest actualRequest = ((ListStoredInfoTypesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListStoredInfoTypesPagedResponse(com.google.cloud.dlp.v2.DlpServiceClient.ListStoredInfoTypesPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ProjectName(com.google.privacy.dlp.v2.ProjectName) ListStoredInfoTypesRequest(com.google.privacy.dlp.v2.ListStoredInfoTypesRequest) ListStoredInfoTypesResponse(com.google.privacy.dlp.v2.ListStoredInfoTypesResponse) StoredInfoType(com.google.privacy.dlp.v2.StoredInfoType) Test(org.junit.Test)

Example 92 with ProjectName

use of com.google.recaptchaenterprise.v1beta1.ProjectName in project java-dlp by googleapis.

the class DlpServiceClientTest method listInspectTemplatesExceptionTest4.

@Test
public void listInspectTemplatesExceptionTest4() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockDlpService.addException(exception);
    try {
        ProjectName parent = ProjectName.of("[PROJECT]");
        client.listInspectTemplates(parent);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) ProjectName(com.google.privacy.dlp.v2.ProjectName) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Example 93 with ProjectName

use of com.google.recaptchaenterprise.v1beta1.ProjectName in project java-dlp by googleapis.

the class DlpServiceClientTest method createDlpJobTest4.

@Test
public void createDlpJobTest4() 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);
    ProjectName parent = ProjectName.of("[PROJECT]");
    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) ProjectName(com.google.privacy.dlp.v2.ProjectName) 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) Test(org.junit.Test)

Example 94 with ProjectName

use of com.google.recaptchaenterprise.v1beta1.ProjectName in project java-dlp by googleapis.

the class DlpServiceClientTest method listJobTriggersTest2.

@Test
public void listJobTriggersTest2() throws Exception {
    JobTrigger responsesElement = JobTrigger.newBuilder().build();
    ListJobTriggersResponse expectedResponse = ListJobTriggersResponse.newBuilder().setNextPageToken("").addAllJobTriggers(Arrays.asList(responsesElement)).build();
    mockDlpService.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    ListJobTriggersPagedResponse pagedListResponse = client.listJobTriggers(parent);
    List<JobTrigger> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getJobTriggersList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockDlpService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListJobTriggersRequest actualRequest = ((ListJobTriggersRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListJobTriggersResponse(com.google.privacy.dlp.v2.ListJobTriggersResponse) ProjectName(com.google.privacy.dlp.v2.ProjectName) ListJobTriggersRequest(com.google.privacy.dlp.v2.ListJobTriggersRequest) ListJobTriggersPagedResponse(com.google.cloud.dlp.v2.DlpServiceClient.ListJobTriggersPagedResponse) JobTrigger(com.google.privacy.dlp.v2.JobTrigger) Test(org.junit.Test)

Example 95 with ProjectName

use of com.google.recaptchaenterprise.v1beta1.ProjectName in project java-dlp by googleapis.

the class DlpServiceClientTest method createDeidentifyTemplateTest4.

@Test
public void createDeidentifyTemplateTest4() throws Exception {
    DeidentifyTemplate expectedResponse = DeidentifyTemplate.newBuilder().setName(DeidentifyTemplateName.ofOrganizationDeidentifyTemplateName("[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]").toString()).setDisplayName("displayName1714148973").setDescription("description-1724546052").setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).setDeidentifyConfig(DeidentifyConfig.newBuilder().build()).build();
    mockDlpService.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    DeidentifyTemplate deidentifyTemplate = DeidentifyTemplate.newBuilder().build();
    DeidentifyTemplate actualResponse = client.createDeidentifyTemplate(parent, deidentifyTemplate);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockDlpService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateDeidentifyTemplateRequest actualRequest = ((CreateDeidentifyTemplateRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertEquals(deidentifyTemplate, actualRequest.getDeidentifyTemplate());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) CreateDeidentifyTemplateRequest(com.google.privacy.dlp.v2.CreateDeidentifyTemplateRequest) ProjectName(com.google.privacy.dlp.v2.ProjectName) DeidentifyTemplate(com.google.privacy.dlp.v2.DeidentifyTemplate) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)178 StatusRuntimeException (io.grpc.StatusRuntimeException)89 AbstractMessage (com.google.protobuf.AbstractMessage)76 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)74 ProjectName (com.google.monitoring.v3.ProjectName)62 ProjectName (com.google.pubsub.v1.ProjectName)44 ProjectName (com.google.logging.v2.ProjectName)31 ArrayList (java.util.ArrayList)31 ProjectName (com.google.privacy.dlp.v2.ProjectName)22 ByteString (com.google.protobuf.ByteString)20 DataTransferServiceClient (com.google.cloud.bigquery.datatransfer.v1.DataTransferServiceClient)17 ProjectName (com.google.cloud.bigquery.datatransfer.v1.ProjectName)17 IOException (java.io.IOException)17 CreateTransferConfigRequest (com.google.cloud.bigquery.datatransfer.v1.CreateTransferConfigRequest)16 TransferConfig (com.google.cloud.bigquery.datatransfer.v1.TransferConfig)16 ProjectName (com.google.cloud.secretmanager.v1.ProjectName)16 ProjectName (com.google.containeranalysis.v1beta1.ProjectName)16 ApiException (com.google.api.gax.rpc.ApiException)15 MetricServiceClient (com.google.cloud.monitoring.v3.MetricServiceClient)15 TimeSeries (com.google.monitoring.v3.TimeSeries)15