Search in sources :

Example 1 with OrganizationName

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

the class DlpServiceClientTest method createInspectTemplateTest3.

@Test
public void createInspectTemplateTest3() throws Exception {
    InspectTemplate expectedResponse = InspectTemplate.newBuilder().setName(InspectTemplateName.ofOrganizationInspectTemplateName("[ORGANIZATION]", "[INSPECT_TEMPLATE]").toString()).setDisplayName("displayName1714148973").setDescription("description-1724546052").setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).setInspectConfig(InspectConfig.newBuilder().build()).build();
    mockDlpService.addResponse(expectedResponse);
    OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
    InspectTemplate inspectTemplate = InspectTemplate.newBuilder().build();
    InspectTemplate actualResponse = client.createInspectTemplate(parent, inspectTemplate);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockDlpService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateInspectTemplateRequest actualRequest = ((CreateInspectTemplateRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertEquals(inspectTemplate, actualRequest.getInspectTemplate());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : OrganizationName(com.google.privacy.dlp.v2.OrganizationName) AbstractMessage(com.google.protobuf.AbstractMessage) InspectTemplate(com.google.privacy.dlp.v2.InspectTemplate) CreateInspectTemplateRequest(com.google.privacy.dlp.v2.CreateInspectTemplateRequest) Test(org.junit.Test)

Example 2 with OrganizationName

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

the class DlpServiceClientTest method createStoredInfoTypeTest3.

@Test
public void createStoredInfoTypeTest3() 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);
    OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
    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 : OrganizationName(com.google.privacy.dlp.v2.OrganizationName) 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 3 with OrganizationName

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

the class DlpServiceClientTest method createStoredInfoTypeExceptionTest3.

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

Example 4 with OrganizationName

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

the class DlpServiceClientTest method listStoredInfoTypesExceptionTest3.

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

Example 5 with OrganizationName

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

the class DlpServiceClientTest method listInspectTemplatesTest3.

@Test
public void listInspectTemplatesTest3() throws Exception {
    InspectTemplate responsesElement = InspectTemplate.newBuilder().build();
    ListInspectTemplatesResponse expectedResponse = ListInspectTemplatesResponse.newBuilder().setNextPageToken("").addAllInspectTemplates(Arrays.asList(responsesElement)).build();
    mockDlpService.addResponse(expectedResponse);
    OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
    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 : OrganizationName(com.google.privacy.dlp.v2.OrganizationName) ListInspectTemplatesResponse(com.google.privacy.dlp.v2.ListInspectTemplatesResponse) 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)

Aggregations

Test (org.junit.Test)22 OrganizationName (com.google.privacy.dlp.v2.OrganizationName)12 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)11 AbstractMessage (com.google.protobuf.AbstractMessage)11 StatusRuntimeException (io.grpc.StatusRuntimeException)11 OrganizationName (com.google.logging.v2.OrganizationName)10 LogExclusion (com.google.logging.v2.LogExclusion)3 LogSink (com.google.logging.v2.LogSink)3 DeidentifyTemplate (com.google.privacy.dlp.v2.DeidentifyTemplate)3 InspectTemplate (com.google.privacy.dlp.v2.InspectTemplate)3 StoredInfoType (com.google.privacy.dlp.v2.StoredInfoType)2 StoredInfoTypeConfig (com.google.privacy.dlp.v2.StoredInfoTypeConfig)2 ArrayList (java.util.ArrayList)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 ListExclusionsPagedResponse (com.google.cloud.logging.v2.ConfigClient.ListExclusionsPagedResponse)1 ListSinksPagedResponse (com.google.cloud.logging.v2.ConfigClient.ListSinksPagedResponse)1 ListLogsPagedResponse (com.google.cloud.logging.v2.LoggingClient.ListLogsPagedResponse)1 NotificationConfig (com.google.cloud.securitycenter.v1.NotificationConfig)1