use of com.google.cloud.dlp.v2.DlpServiceClient.ListDlpJobsPagedResponse 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()));
}
use of com.google.cloud.dlp.v2.DlpServiceClient.ListDlpJobsPagedResponse 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()));
}
use of com.google.cloud.dlp.v2.DlpServiceClient.ListDlpJobsPagedResponse 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()));
}
Aggregations