Search in sources :

Example 1 with ListDlpJobsResponse

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

the class DlpServiceClientTest method listDlpJobsTest.

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

Example 2 with ListDlpJobsResponse

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

the class DlpServiceClientTest method listDlpJobsTest2.

@Test
public void listDlpJobsTest2() throws Exception {
    DlpJob responsesElement = DlpJob.newBuilder().build();
    ListDlpJobsResponse expectedResponse = ListDlpJobsResponse.newBuilder().setNextPageToken("").addAllJobs(Arrays.asList(responsesElement)).build();
    mockDlpService.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    ListDlpJobsPagedResponse pagedListResponse = client.listDlpJobs(parent);
    List<DlpJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getJobsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockDlpService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListDlpJobsRequest actualRequest = ((ListDlpJobsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListDlpJobsPagedResponse(com.google.cloud.dlp.v2.DlpServiceClient.ListDlpJobsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ListDlpJobsRequest(com.google.privacy.dlp.v2.ListDlpJobsRequest) ProjectName(com.google.privacy.dlp.v2.ProjectName) DlpJob(com.google.privacy.dlp.v2.DlpJob) ListDlpJobsResponse(com.google.privacy.dlp.v2.ListDlpJobsResponse) Test(org.junit.Test)

Example 3 with ListDlpJobsResponse

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

the class DlpServiceClientTest method listDlpJobsTest3.

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

Aggregations

ListDlpJobsPagedResponse (com.google.cloud.dlp.v2.DlpServiceClient.ListDlpJobsPagedResponse)3 DlpJob (com.google.privacy.dlp.v2.DlpJob)3 ListDlpJobsRequest (com.google.privacy.dlp.v2.ListDlpJobsRequest)3 ListDlpJobsResponse (com.google.privacy.dlp.v2.ListDlpJobsResponse)3 AbstractMessage (com.google.protobuf.AbstractMessage)3 Test (org.junit.Test)3 LocationName (com.google.privacy.dlp.v2.LocationName)1 OrganizationLocationName (com.google.privacy.dlp.v2.OrganizationLocationName)1 ProjectName (com.google.privacy.dlp.v2.ProjectName)1 ByteString (com.google.protobuf.ByteString)1