Search in sources :

Example 11 with OrganizationLocationName

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

the class DlpServiceClientTest method listInspectTemplatesTest2.

@Test
public void listInspectTemplatesTest2() throws Exception {
    InspectTemplate responsesElement = InspectTemplate.newBuilder().build();
    ListInspectTemplatesResponse expectedResponse = ListInspectTemplatesResponse.newBuilder().setNextPageToken("").addAllInspectTemplates(Arrays.asList(responsesElement)).build();
    mockDlpService.addResponse(expectedResponse);
    OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]");
    ListInspectTemplatesPagedResponse pagedListResponse = client.listInspectTemplates(parent);
    List<InspectTemplate> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getInspectTemplatesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockDlpService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListInspectTemplatesRequest actualRequest = ((ListInspectTemplatesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListInspectTemplatesResponse(com.google.privacy.dlp.v2.ListInspectTemplatesResponse) OrganizationLocationName(com.google.privacy.dlp.v2.OrganizationLocationName) AbstractMessage(com.google.protobuf.AbstractMessage) InspectTemplate(com.google.privacy.dlp.v2.InspectTemplate) ListInspectTemplatesRequest(com.google.privacy.dlp.v2.ListInspectTemplatesRequest) ListInspectTemplatesPagedResponse(com.google.cloud.dlp.v2.DlpServiceClient.ListInspectTemplatesPagedResponse) Test(org.junit.Test)

Example 12 with OrganizationLocationName

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

the class DlpServiceClientTest method createDeidentifyTemplateTest2.

@Test
public void createDeidentifyTemplateTest2() 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);
    OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]");
    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 : OrganizationLocationName(com.google.privacy.dlp.v2.OrganizationLocationName) AbstractMessage(com.google.protobuf.AbstractMessage) CreateDeidentifyTemplateRequest(com.google.privacy.dlp.v2.CreateDeidentifyTemplateRequest) DeidentifyTemplate(com.google.privacy.dlp.v2.DeidentifyTemplate) Test(org.junit.Test)

Example 13 with OrganizationLocationName

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

the class DlpServiceClientTest method createStoredInfoTypeTest2.

@Test
public void createStoredInfoTypeTest2() throws Exception {
    StoredInfoType expectedResponse = StoredInfoType.newBuilder().setName(StoredInfoTypeName.ofOrganizationStoredInfoTypeName("[ORGANIZATION]", "[STORED_INFO_TYPE]").toString()).setCurrentVersion(StoredInfoTypeVersion.newBuilder().build()).addAllPendingVersions(new ArrayList<StoredInfoTypeVersion>()).build();
    mockDlpService.addResponse(expectedResponse);
    OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]");
    StoredInfoTypeConfig config = StoredInfoTypeConfig.newBuilder().build();
    StoredInfoType actualResponse = client.createStoredInfoType(parent, config);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockDlpService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateStoredInfoTypeRequest actualRequest = ((CreateStoredInfoTypeRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertEquals(config, actualRequest.getConfig());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : OrganizationLocationName(com.google.privacy.dlp.v2.OrganizationLocationName) AbstractMessage(com.google.protobuf.AbstractMessage) CreateStoredInfoTypeRequest(com.google.privacy.dlp.v2.CreateStoredInfoTypeRequest) ArrayList(java.util.ArrayList) StoredInfoType(com.google.privacy.dlp.v2.StoredInfoType) StoredInfoTypeConfig(com.google.privacy.dlp.v2.StoredInfoTypeConfig) Test(org.junit.Test)

Example 14 with OrganizationLocationName

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

the class DlpServiceClientTest method listInspectTemplatesExceptionTest2.

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

Aggregations

Test (org.junit.Test)14 OrganizationLocationName (com.google.privacy.dlp.v2.OrganizationLocationName)12 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)7 AbstractMessage (com.google.protobuf.AbstractMessage)7 StatusRuntimeException (io.grpc.StatusRuntimeException)7 DeidentifyTemplate (com.google.privacy.dlp.v2.DeidentifyTemplate)3 InspectTemplate (com.google.privacy.dlp.v2.InspectTemplate)3 OrganizationLocationName (com.google.logging.v2.OrganizationLocationName)2 StoredInfoType (com.google.privacy.dlp.v2.StoredInfoType)2 StoredInfoTypeConfig (com.google.privacy.dlp.v2.StoredInfoTypeConfig)2 ListDeidentifyTemplatesPagedResponse (com.google.cloud.dlp.v2.DlpServiceClient.ListDeidentifyTemplatesPagedResponse)1 ListInspectTemplatesPagedResponse (com.google.cloud.dlp.v2.DlpServiceClient.ListInspectTemplatesPagedResponse)1 ListStoredInfoTypesPagedResponse (com.google.cloud.dlp.v2.DlpServiceClient.ListStoredInfoTypesPagedResponse)1 ListBucketsPagedResponse (com.google.cloud.logging.v2.ConfigClient.ListBucketsPagedResponse)1 ListBucketsRequest (com.google.logging.v2.ListBucketsRequest)1 ListBucketsResponse (com.google.logging.v2.ListBucketsResponse)1 LogBucket (com.google.logging.v2.LogBucket)1 CreateDeidentifyTemplateRequest (com.google.privacy.dlp.v2.CreateDeidentifyTemplateRequest)1 CreateInspectTemplateRequest (com.google.privacy.dlp.v2.CreateInspectTemplateRequest)1 CreateStoredInfoTypeRequest (com.google.privacy.dlp.v2.CreateStoredInfoTypeRequest)1