Search in sources :

Example 11 with StoredInfoType

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

the class DlpServiceClientTest method listStoredInfoTypesTest3.

@Test
public void listStoredInfoTypesTest3() throws Exception {
    StoredInfoType responsesElement = StoredInfoType.newBuilder().build();
    ListStoredInfoTypesResponse expectedResponse = ListStoredInfoTypesResponse.newBuilder().setNextPageToken("").addAllStoredInfoTypes(Arrays.asList(responsesElement)).build();
    mockDlpService.addResponse(expectedResponse);
    OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
    ListStoredInfoTypesPagedResponse pagedListResponse = client.listStoredInfoTypes(parent);
    List<StoredInfoType> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getStoredInfoTypesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockDlpService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListStoredInfoTypesRequest actualRequest = ((ListStoredInfoTypesRequest) 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) ListStoredInfoTypesPagedResponse(com.google.cloud.dlp.v2.DlpServiceClient.ListStoredInfoTypesPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ListStoredInfoTypesRequest(com.google.privacy.dlp.v2.ListStoredInfoTypesRequest) ListStoredInfoTypesResponse(com.google.privacy.dlp.v2.ListStoredInfoTypesResponse) StoredInfoType(com.google.privacy.dlp.v2.StoredInfoType) Test(org.junit.Test)

Example 12 with StoredInfoType

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

the class DlpServiceClientTest method listStoredInfoTypesTest5.

@Test
public void listStoredInfoTypesTest5() throws Exception {
    StoredInfoType responsesElement = StoredInfoType.newBuilder().build();
    ListStoredInfoTypesResponse expectedResponse = ListStoredInfoTypesResponse.newBuilder().setNextPageToken("").addAllStoredInfoTypes(Arrays.asList(responsesElement)).build();
    mockDlpService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListStoredInfoTypesPagedResponse pagedListResponse = client.listStoredInfoTypes(parent);
    List<StoredInfoType> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getStoredInfoTypesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockDlpService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListStoredInfoTypesRequest actualRequest = ((ListStoredInfoTypesRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListStoredInfoTypesPagedResponse(com.google.cloud.dlp.v2.DlpServiceClient.ListStoredInfoTypesPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ListStoredInfoTypesRequest(com.google.privacy.dlp.v2.ListStoredInfoTypesRequest) ListStoredInfoTypesResponse(com.google.privacy.dlp.v2.ListStoredInfoTypesResponse) StoredInfoType(com.google.privacy.dlp.v2.StoredInfoType) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 13 with StoredInfoType

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

the class DlpServiceClientTest method createStoredInfoTypeTest5.

@Test
public void createStoredInfoTypeTest5() 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);
    String parent = "parent-995424086";
    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, actualRequest.getParent());
    Assert.assertEquals(config, actualRequest.getConfig());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) CreateStoredInfoTypeRequest(com.google.privacy.dlp.v2.CreateStoredInfoTypeRequest) ArrayList(java.util.ArrayList) StoredInfoType(com.google.privacy.dlp.v2.StoredInfoType) ByteString(com.google.protobuf.ByteString) StoredInfoTypeConfig(com.google.privacy.dlp.v2.StoredInfoTypeConfig) Test(org.junit.Test)

Example 14 with StoredInfoType

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

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

the class DlpServiceClientTest method createStoredInfoTypeTest4.

@Test
public void createStoredInfoTypeTest4() 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);
    ProjectName parent = ProjectName.of("[PROJECT]");
    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 : AbstractMessage(com.google.protobuf.AbstractMessage) CreateStoredInfoTypeRequest(com.google.privacy.dlp.v2.CreateStoredInfoTypeRequest) ProjectName(com.google.privacy.dlp.v2.ProjectName) ArrayList(java.util.ArrayList) StoredInfoType(com.google.privacy.dlp.v2.StoredInfoType) StoredInfoTypeConfig(com.google.privacy.dlp.v2.StoredInfoTypeConfig) Test(org.junit.Test)

Aggregations

StoredInfoType (com.google.privacy.dlp.v2.StoredInfoType)14 AbstractMessage (com.google.protobuf.AbstractMessage)14 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)9 StoredInfoTypeConfig (com.google.privacy.dlp.v2.StoredInfoTypeConfig)7 ListStoredInfoTypesPagedResponse (com.google.cloud.dlp.v2.DlpServiceClient.ListStoredInfoTypesPagedResponse)5 CreateStoredInfoTypeRequest (com.google.privacy.dlp.v2.CreateStoredInfoTypeRequest)5 ListStoredInfoTypesRequest (com.google.privacy.dlp.v2.ListStoredInfoTypesRequest)5 ListStoredInfoTypesResponse (com.google.privacy.dlp.v2.ListStoredInfoTypesResponse)5 OrganizationLocationName (com.google.privacy.dlp.v2.OrganizationLocationName)4 ByteString (com.google.protobuf.ByteString)4 DeleteStoredInfoTypeRequest (com.google.privacy.dlp.v2.DeleteStoredInfoTypeRequest)2 GetStoredInfoTypeRequest (com.google.privacy.dlp.v2.GetStoredInfoTypeRequest)2 LocationName (com.google.privacy.dlp.v2.LocationName)2 OrganizationName (com.google.privacy.dlp.v2.OrganizationName)2 ProjectName (com.google.privacy.dlp.v2.ProjectName)2 StoredInfoTypeName (com.google.privacy.dlp.v2.StoredInfoTypeName)2 UpdateStoredInfoTypeRequest (com.google.privacy.dlp.v2.UpdateStoredInfoTypeRequest)2 FieldMask (com.google.protobuf.FieldMask)2