use of com.google.cloud.servicedirectory.v1.RegistrationServiceClient.ListServicesPagedResponse in project java-servicedirectory by googleapis.
the class RegistrationServiceClientTest method listServicesTest2.
@Test
public void listServicesTest2() throws Exception {
Service responsesElement = Service.newBuilder().build();
ListServicesResponse expectedResponse = ListServicesResponse.newBuilder().setNextPageToken("").addAllServices(Arrays.asList(responsesElement)).build();
mockRegistrationService.addResponse(expectedResponse);
String parent = "parent-995424086";
ListServicesPagedResponse pagedListResponse = client.listServices(parent);
List<Service> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getServicesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockRegistrationService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListServicesRequest actualRequest = ((ListServicesRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.servicedirectory.v1.RegistrationServiceClient.ListServicesPagedResponse in project java-servicedirectory by googleapis.
the class RegistrationServiceClientTest method listServicesTest2.
@Test
public void listServicesTest2() throws Exception {
Service responsesElement = Service.newBuilder().build();
ListServicesResponse expectedResponse = ListServicesResponse.newBuilder().setNextPageToken("").addAllServices(Arrays.asList(responsesElement)).build();
mockRegistrationService.addResponse(expectedResponse);
String parent = "parent-995424086";
ListServicesPagedResponse pagedListResponse = client.listServices(parent);
List<Service> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getServicesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockRegistrationService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListServicesRequest actualRequest = ((ListServicesRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.servicedirectory.v1.RegistrationServiceClient.ListServicesPagedResponse in project java-servicedirectory by googleapis.
the class RegistrationServiceClientTest method listServicesTest.
@Test
public void listServicesTest() throws Exception {
Service responsesElement = Service.newBuilder().build();
ListServicesResponse expectedResponse = ListServicesResponse.newBuilder().setNextPageToken("").addAllServices(Arrays.asList(responsesElement)).build();
mockRegistrationService.addResponse(expectedResponse);
NamespaceName parent = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]");
ListServicesPagedResponse pagedListResponse = client.listServices(parent);
List<Service> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getServicesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockRegistrationService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListServicesRequest actualRequest = ((ListServicesRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.servicedirectory.v1.RegistrationServiceClient.ListServicesPagedResponse in project java-servicedirectory by googleapis.
the class RegistrationServiceClientTest method listServicesTest.
@Test
public void listServicesTest() throws Exception {
Service responsesElement = Service.newBuilder().build();
ListServicesResponse expectedResponse = ListServicesResponse.newBuilder().setNextPageToken("").addAllServices(Arrays.asList(responsesElement)).build();
mockRegistrationService.addResponse(expectedResponse);
NamespaceName parent = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]");
ListServicesPagedResponse pagedListResponse = client.listServices(parent);
List<Service> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getServicesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockRegistrationService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListServicesRequest actualRequest = ((ListServicesRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations