use of com.google.cloud.aiplatform.v1beta1.JobServiceClient.ListCustomJobsPagedResponse in project java-aiplatform by googleapis.
the class JobServiceClientTest method listCustomJobsTest.
@Test
public void listCustomJobsTest() throws Exception {
CustomJob responsesElement = CustomJob.newBuilder().build();
ListCustomJobsResponse expectedResponse = ListCustomJobsResponse.newBuilder().setNextPageToken("").addAllCustomJobs(Arrays.asList(responsesElement)).build();
mockJobService.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListCustomJobsPagedResponse pagedListResponse = client.listCustomJobs(parent);
List<CustomJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getCustomJobsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockJobService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListCustomJobsRequest actualRequest = ((ListCustomJobsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.aiplatform.v1beta1.JobServiceClient.ListCustomJobsPagedResponse in project java-aiplatform by googleapis.
the class JobServiceClientTest method listCustomJobsTest.
@Test
public void listCustomJobsTest() throws Exception {
CustomJob responsesElement = CustomJob.newBuilder().build();
ListCustomJobsResponse expectedResponse = ListCustomJobsResponse.newBuilder().setNextPageToken("").addAllCustomJobs(Arrays.asList(responsesElement)).build();
mockJobService.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListCustomJobsPagedResponse pagedListResponse = client.listCustomJobs(parent);
List<CustomJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getCustomJobsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockJobService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListCustomJobsRequest actualRequest = ((ListCustomJobsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.aiplatform.v1beta1.JobServiceClient.ListCustomJobsPagedResponse in project java-aiplatform by googleapis.
the class JobServiceClientTest method listCustomJobsTest2.
@Test
public void listCustomJobsTest2() throws Exception {
CustomJob responsesElement = CustomJob.newBuilder().build();
ListCustomJobsResponse expectedResponse = ListCustomJobsResponse.newBuilder().setNextPageToken("").addAllCustomJobs(Arrays.asList(responsesElement)).build();
mockJobService.addResponse(expectedResponse);
String parent = "parent-995424086";
ListCustomJobsPagedResponse pagedListResponse = client.listCustomJobs(parent);
List<CustomJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getCustomJobsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockJobService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListCustomJobsRequest actualRequest = ((ListCustomJobsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.aiplatform.v1beta1.JobServiceClient.ListCustomJobsPagedResponse in project java-aiplatform by googleapis.
the class JobServiceClientTest method listCustomJobsTest2.
@Test
public void listCustomJobsTest2() throws Exception {
CustomJob responsesElement = CustomJob.newBuilder().build();
ListCustomJobsResponse expectedResponse = ListCustomJobsResponse.newBuilder().setNextPageToken("").addAllCustomJobs(Arrays.asList(responsesElement)).build();
mockJobService.addResponse(expectedResponse);
String parent = "parent-995424086";
ListCustomJobsPagedResponse pagedListResponse = client.listCustomJobs(parent);
List<CustomJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getCustomJobsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockJobService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListCustomJobsRequest actualRequest = ((ListCustomJobsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations