Search in sources :

Example 76 with LocationName

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

the class DlpServiceClientTest method listJobTriggersTest.

@Test
public void listJobTriggersTest() throws Exception {
    JobTrigger responsesElement = JobTrigger.newBuilder().build();
    ListJobTriggersResponse expectedResponse = ListJobTriggersResponse.newBuilder().setNextPageToken("").addAllJobTriggers(Arrays.asList(responsesElement)).build();
    mockDlpService.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    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) ListJobTriggersRequest(com.google.privacy.dlp.v2.ListJobTriggersRequest) ListJobTriggersPagedResponse(com.google.cloud.dlp.v2.DlpServiceClient.ListJobTriggersPagedResponse) JobTrigger(com.google.privacy.dlp.v2.JobTrigger) OrganizationLocationName(com.google.privacy.dlp.v2.OrganizationLocationName) LocationName(com.google.privacy.dlp.v2.LocationName) Test(org.junit.Test)

Example 77 with LocationName

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

the class DlpServiceClientTest method listInspectTemplatesExceptionTest.

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

Example 78 with LocationName

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

the class DlpServiceClientTest method listDeidentifyTemplatesTest.

@Test
public void listDeidentifyTemplatesTest() throws Exception {
    DeidentifyTemplate responsesElement = DeidentifyTemplate.newBuilder().build();
    ListDeidentifyTemplatesResponse expectedResponse = ListDeidentifyTemplatesResponse.newBuilder().setNextPageToken("").addAllDeidentifyTemplates(Arrays.asList(responsesElement)).build();
    mockDlpService.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    ListDeidentifyTemplatesPagedResponse pagedListResponse = client.listDeidentifyTemplates(parent);
    List<DeidentifyTemplate> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getDeidentifyTemplatesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockDlpService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListDeidentifyTemplatesRequest actualRequest = ((ListDeidentifyTemplatesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListDeidentifyTemplatesRequest(com.google.privacy.dlp.v2.ListDeidentifyTemplatesRequest) AbstractMessage(com.google.protobuf.AbstractMessage) ListDeidentifyTemplatesResponse(com.google.privacy.dlp.v2.ListDeidentifyTemplatesResponse) ListDeidentifyTemplatesPagedResponse(com.google.cloud.dlp.v2.DlpServiceClient.ListDeidentifyTemplatesPagedResponse) DeidentifyTemplate(com.google.privacy.dlp.v2.DeidentifyTemplate) OrganizationLocationName(com.google.privacy.dlp.v2.OrganizationLocationName) LocationName(com.google.privacy.dlp.v2.LocationName) Test(org.junit.Test)

Example 79 with LocationName

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

the class DlpServiceClientTest method createDeidentifyTemplateExceptionTest.

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

Example 80 with LocationName

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

the class DlpServiceClientTest method createJobTriggerExceptionTest.

@Test
public void createJobTriggerExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockDlpService.addException(exception);
    try {
        LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
        JobTrigger jobTrigger = JobTrigger.newBuilder().build();
        client.createJobTrigger(parent, jobTrigger);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) JobTrigger(com.google.privacy.dlp.v2.JobTrigger) OrganizationLocationName(com.google.privacy.dlp.v2.OrganizationLocationName) LocationName(com.google.privacy.dlp.v2.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