Search in sources :

Example 41 with Error

use of com.google.privacy.dlp.v2.Error 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 42 with Error

use of com.google.privacy.dlp.v2.Error 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 43 with Error

use of com.google.privacy.dlp.v2.Error in project java-dlp by googleapis.

the class DlpServiceClientTest method createJobTriggerTest3.

@Test
public void createJobTriggerTest3() 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);
    String parent = "parent-995424086";
    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, 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) ByteString(com.google.protobuf.ByteString) JobTrigger(com.google.privacy.dlp.v2.JobTrigger) CreateJobTriggerRequest(com.google.privacy.dlp.v2.CreateJobTriggerRequest) Test(org.junit.Test)

Example 44 with Error

use of com.google.privacy.dlp.v2.Error in project java-dlp by googleapis.

the class DlpServiceClientTest method getJobTriggerTest.

@Test
public void getJobTriggerTest() 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);
    JobTriggerName name = JobTriggerName.ofProjectJobTriggerName("[PROJECT]", "[JOB_TRIGGER]");
    JobTrigger actualResponse = client.getJobTrigger(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockDlpService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetJobTriggerRequest actualRequest = ((GetJobTriggerRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    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) GetJobTriggerRequest(com.google.privacy.dlp.v2.GetJobTriggerRequest) JobTriggerName(com.google.privacy.dlp.v2.JobTriggerName) JobTrigger(com.google.privacy.dlp.v2.JobTrigger) Test(org.junit.Test)

Example 45 with Error

use of com.google.privacy.dlp.v2.Error in project java-dlp by googleapis.

the class DlpServiceClientTest method createDlpJobTest6.

@Test
public void createDlpJobTest6() 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);
    String parent = "parent-995424086";
    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, 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) ByteString(com.google.protobuf.ByteString) CreateDlpJobRequest(com.google.privacy.dlp.v2.CreateDlpJobRequest) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)28 DlpServiceClient (com.google.cloud.dlp.v2.DlpServiceClient)23 Test (org.junit.Test)23 ParseException (org.apache.commons.cli.ParseException)18 AbstractMessage (com.google.protobuf.AbstractMessage)16 DlpJob (com.google.privacy.dlp.v2.DlpJob)15 InfoType (com.google.privacy.dlp.v2.InfoType)13 CreateDlpJobRequest (com.google.privacy.dlp.v2.CreateDlpJobRequest)12 ByteString (com.google.protobuf.ByteString)12 Error (dev.hawala.xns.level2.Error)12 Error (org.ovirt.engine.sdk4.Error)12 InspectConfig (com.google.privacy.dlp.v2.InspectConfig)11 Error (org.eclipse.bpmn2.Error)11 ContentItem (com.google.privacy.dlp.v2.ContentItem)10 ProjectName (com.google.privacy.dlp.v2.ProjectName)9 Iterator (java.util.Iterator)9 JobTrigger (com.google.privacy.dlp.v2.JobTrigger)8 RootElement (org.eclipse.bpmn2.RootElement)8 Error (com.google.privacy.dlp.v2.Error)7 ServiceOptions (com.google.cloud.ServiceOptions)6