Search in sources :

Example 1 with ListEndpointsPagedResponse

use of com.google.cloud.aiplatform.v1.EndpointServiceClient.ListEndpointsPagedResponse in project java-aiplatform by googleapis.

the class EndpointServiceClientTest method listEndpointsTest.

@Test
public void listEndpointsTest() throws Exception {
    Endpoint responsesElement = Endpoint.newBuilder().build();
    ListEndpointsResponse expectedResponse = ListEndpointsResponse.newBuilder().setNextPageToken("").addAllEndpoints(Arrays.asList(responsesElement)).build();
    mockEndpointService.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    ListEndpointsPagedResponse pagedListResponse = client.listEndpoints(parent);
    List<Endpoint> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getEndpointsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockEndpointService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListEndpointsRequest actualRequest = ((ListEndpointsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListEndpointsPagedResponse(com.google.cloud.aiplatform.v1.EndpointServiceClient.ListEndpointsPagedResponse) Test(org.junit.Test)

Example 2 with ListEndpointsPagedResponse

use of com.google.cloud.aiplatform.v1.EndpointServiceClient.ListEndpointsPagedResponse in project java-aiplatform by googleapis.

the class EndpointServiceClientTest method listEndpointsTest.

@Test
public void listEndpointsTest() throws Exception {
    Endpoint responsesElement = Endpoint.newBuilder().build();
    ListEndpointsResponse expectedResponse = ListEndpointsResponse.newBuilder().setNextPageToken("").addAllEndpoints(Arrays.asList(responsesElement)).build();
    mockEndpointService.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    ListEndpointsPagedResponse pagedListResponse = client.listEndpoints(parent);
    List<Endpoint> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getEndpointsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockEndpointService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListEndpointsRequest actualRequest = ((ListEndpointsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListEndpointsPagedResponse(com.google.cloud.aiplatform.v1beta1.EndpointServiceClient.ListEndpointsPagedResponse) Test(org.junit.Test)

Example 3 with ListEndpointsPagedResponse

use of com.google.cloud.aiplatform.v1.EndpointServiceClient.ListEndpointsPagedResponse in project java-aiplatform by googleapis.

the class EndpointServiceClientTest method listEndpointsTest2.

@Test
public void listEndpointsTest2() throws Exception {
    Endpoint responsesElement = Endpoint.newBuilder().build();
    ListEndpointsResponse expectedResponse = ListEndpointsResponse.newBuilder().setNextPageToken("").addAllEndpoints(Arrays.asList(responsesElement)).build();
    mockEndpointService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListEndpointsPagedResponse pagedListResponse = client.listEndpoints(parent);
    List<Endpoint> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getEndpointsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockEndpointService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListEndpointsRequest actualRequest = ((ListEndpointsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListEndpointsPagedResponse(com.google.cloud.aiplatform.v1beta1.EndpointServiceClient.ListEndpointsPagedResponse) Test(org.junit.Test)

Example 4 with ListEndpointsPagedResponse

use of com.google.cloud.aiplatform.v1.EndpointServiceClient.ListEndpointsPagedResponse in project java-aiplatform by googleapis.

the class EndpointServiceClientTest method listEndpointsTest2.

@Test
public void listEndpointsTest2() throws Exception {
    Endpoint responsesElement = Endpoint.newBuilder().build();
    ListEndpointsResponse expectedResponse = ListEndpointsResponse.newBuilder().setNextPageToken("").addAllEndpoints(Arrays.asList(responsesElement)).build();
    mockEndpointService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListEndpointsPagedResponse pagedListResponse = client.listEndpoints(parent);
    List<Endpoint> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getEndpointsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockEndpointService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListEndpointsRequest actualRequest = ((ListEndpointsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListEndpointsPagedResponse(com.google.cloud.aiplatform.v1.EndpointServiceClient.ListEndpointsPagedResponse) Test(org.junit.Test)

Aggregations

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