use of com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient.ListEndpointsPagedResponse in project java-servicedirectory by googleapis.
the class RegistrationServiceClientTest method listEndpointsTest.
@Test
public void listEndpointsTest() throws Exception {
Endpoint responsesElement = Endpoint.newBuilder().build();
ListEndpointsResponse expectedResponse = ListEndpointsResponse.newBuilder().setNextPageToken("").addAllEndpoints(Arrays.asList(responsesElement)).build();
mockRegistrationService.addResponse(expectedResponse);
ServiceName parent = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]");
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 = mockRegistrationService.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()));
}
use of com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient.ListEndpointsPagedResponse in project java-servicedirectory by googleapis.
the class RegistrationServiceClientTest method listEndpointsTest.
@Test
public void listEndpointsTest() throws Exception {
Endpoint responsesElement = Endpoint.newBuilder().build();
ListEndpointsResponse expectedResponse = ListEndpointsResponse.newBuilder().setNextPageToken("").addAllEndpoints(Arrays.asList(responsesElement)).build();
mockRegistrationService.addResponse(expectedResponse);
ServiceName parent = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]");
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 = mockRegistrationService.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()));
}
use of com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient.ListEndpointsPagedResponse in project java-servicedirectory by googleapis.
the class RegistrationServiceClientTest method listEndpointsTest2.
@Test
public void listEndpointsTest2() throws Exception {
Endpoint responsesElement = Endpoint.newBuilder().build();
ListEndpointsResponse expectedResponse = ListEndpointsResponse.newBuilder().setNextPageToken("").addAllEndpoints(Arrays.asList(responsesElement)).build();
mockRegistrationService.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 = mockRegistrationService.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()));
}
use of com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient.ListEndpointsPagedResponse in project java-servicedirectory by googleapis.
the class RegistrationServiceClientTest method listEndpointsTest2.
@Test
public void listEndpointsTest2() throws Exception {
Endpoint responsesElement = Endpoint.newBuilder().build();
ListEndpointsResponse expectedResponse = ListEndpointsResponse.newBuilder().setNextPageToken("").addAllEndpoints(Arrays.asList(responsesElement)).build();
mockRegistrationService.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 = mockRegistrationService.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()));
}
Aggregations