Search in sources :

Example 1 with ActivateJobTriggerRequest

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

the class DlpServiceClientTest method activateJobTriggerTest.

@Test
public void activateJobTriggerTest() 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);
    ActivateJobTriggerRequest request = ActivateJobTriggerRequest.newBuilder().setName(JobTriggerName.ofProjectJobTriggerName("[PROJECT]", "[JOB_TRIGGER]").toString()).build();
    DlpJob actualResponse = client.activateJobTrigger(request);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockDlpService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ActivateJobTriggerRequest actualRequest = ((ActivateJobTriggerRequest) actualRequests.get(0));
    Assert.assertEquals(request.getName(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ArrayList(java.util.ArrayList) ActivateJobTriggerRequest(com.google.privacy.dlp.v2.ActivateJobTriggerRequest) DlpJob(com.google.privacy.dlp.v2.DlpJob) Test(org.junit.Test)

Example 2 with ActivateJobTriggerRequest

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

the class DlpServiceClientTest method activateJobTriggerExceptionTest.

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

Aggregations

ActivateJobTriggerRequest (com.google.privacy.dlp.v2.ActivateJobTriggerRequest)2 Test (org.junit.Test)2 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)1 DlpJob (com.google.privacy.dlp.v2.DlpJob)1 AbstractMessage (com.google.protobuf.AbstractMessage)1 StatusRuntimeException (io.grpc.StatusRuntimeException)1 ArrayList (java.util.ArrayList)1