Search in sources :

Example 1 with JobTriggerName

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

the class DlpServiceClientTest method getJobTriggerExceptionTest.

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

Example 2 with JobTriggerName

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

the class DlpServiceClientTest method deleteJobTriggerTest.

@Test
public void deleteJobTriggerTest() throws Exception {
    Empty expectedResponse = Empty.newBuilder().build();
    mockDlpService.addResponse(expectedResponse);
    JobTriggerName name = JobTriggerName.ofProjectJobTriggerName("[PROJECT]", "[JOB_TRIGGER]");
    client.deleteJobTrigger(name);
    List<AbstractMessage> actualRequests = mockDlpService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    DeleteJobTriggerRequest actualRequest = ((DeleteJobTriggerRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Empty(com.google.protobuf.Empty) AbstractMessage(com.google.protobuf.AbstractMessage) JobTriggerName(com.google.privacy.dlp.v2.JobTriggerName) DeleteJobTriggerRequest(com.google.privacy.dlp.v2.DeleteJobTriggerRequest) Test(org.junit.Test)

Example 3 with JobTriggerName

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

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

the class DlpServiceClientTest method updateJobTriggerExceptionTest.

@Test
public void updateJobTriggerExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockDlpService.addException(exception);
    try {
        JobTriggerName name = JobTriggerName.ofProjectJobTriggerName("[PROJECT]", "[JOB_TRIGGER]");
        JobTrigger jobTrigger = JobTrigger.newBuilder().build();
        FieldMask updateMask = FieldMask.newBuilder().build();
        client.updateJobTrigger(name, jobTrigger, updateMask);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) JobTriggerName(com.google.privacy.dlp.v2.JobTriggerName) JobTrigger(com.google.privacy.dlp.v2.JobTrigger) FieldMask(com.google.protobuf.FieldMask) Test(org.junit.Test)

Example 5 with JobTriggerName

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

the class DlpServiceClientTest method updateJobTriggerTest.

@Test
public void updateJobTriggerTest() 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 jobTrigger = JobTrigger.newBuilder().build();
    FieldMask updateMask = FieldMask.newBuilder().build();
    JobTrigger actualResponse = client.updateJobTrigger(name, jobTrigger, updateMask);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockDlpService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    UpdateJobTriggerRequest actualRequest = ((UpdateJobTriggerRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertEquals(jobTrigger, actualRequest.getJobTrigger());
    Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) UpdateJobTriggerRequest(com.google.privacy.dlp.v2.UpdateJobTriggerRequest) ArrayList(java.util.ArrayList) Error(com.google.privacy.dlp.v2.Error) JobTriggerName(com.google.privacy.dlp.v2.JobTriggerName) JobTrigger(com.google.privacy.dlp.v2.JobTrigger) FieldMask(com.google.protobuf.FieldMask) Test(org.junit.Test)

Aggregations

JobTriggerName (com.google.privacy.dlp.v2.JobTriggerName)8 Test (org.junit.Test)8 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)4 AbstractMessage (com.google.protobuf.AbstractMessage)4 StatusRuntimeException (io.grpc.StatusRuntimeException)4 JobTrigger (com.google.privacy.dlp.v2.JobTrigger)3 DeleteJobTriggerRequest (com.google.privacy.dlp.v2.DeleteJobTriggerRequest)2 Error (com.google.privacy.dlp.v2.Error)2 FieldMask (com.google.protobuf.FieldMask)2 ArrayList (java.util.ArrayList)2 GetJobTriggerRequest (com.google.privacy.dlp.v2.GetJobTriggerRequest)1 HybridInspectJobTriggerRequest (com.google.privacy.dlp.v2.HybridInspectJobTriggerRequest)1 HybridInspectResponse (com.google.privacy.dlp.v2.HybridInspectResponse)1 UpdateJobTriggerRequest (com.google.privacy.dlp.v2.UpdateJobTriggerRequest)1 Empty (com.google.protobuf.Empty)1