Search in sources :

Example 1 with ListCustomJobsPagedResponse

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()));
}
Also used : ListCustomJobsPagedResponse(com.google.cloud.aiplatform.v1beta1.JobServiceClient.ListCustomJobsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Example 2 with ListCustomJobsPagedResponse

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()));
}
Also used : ListCustomJobsPagedResponse(com.google.cloud.aiplatform.v1.JobServiceClient.ListCustomJobsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Example 3 with ListCustomJobsPagedResponse

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()));
}
Also used : ListCustomJobsPagedResponse(com.google.cloud.aiplatform.v1.JobServiceClient.ListCustomJobsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Example 4 with ListCustomJobsPagedResponse

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()));
}
Also used : ListCustomJobsPagedResponse(com.google.cloud.aiplatform.v1beta1.JobServiceClient.ListCustomJobsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Aggregations

AbstractMessage (com.google.protobuf.AbstractMessage)4 Test (org.junit.Test)4 ListCustomJobsPagedResponse (com.google.cloud.aiplatform.v1.JobServiceClient.ListCustomJobsPagedResponse)2 ListCustomJobsPagedResponse (com.google.cloud.aiplatform.v1beta1.JobServiceClient.ListCustomJobsPagedResponse)2