Search in sources :

Example 1 with ListServicesPagedResponse

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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListServicesPagedResponse(com.google.cloud.servicedirectory.v1.RegistrationServiceClient.ListServicesPagedResponse) MockGrpcService(com.google.api.gax.grpc.testing.MockGrpcService) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 2 with ListServicesPagedResponse

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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListServicesPagedResponse(com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient.ListServicesPagedResponse) MockGrpcService(com.google.api.gax.grpc.testing.MockGrpcService) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 3 with ListServicesPagedResponse

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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListServicesPagedResponse(com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient.ListServicesPagedResponse) MockGrpcService(com.google.api.gax.grpc.testing.MockGrpcService) Test(org.junit.Test)

Example 4 with ListServicesPagedResponse

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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListServicesPagedResponse(com.google.cloud.servicedirectory.v1.RegistrationServiceClient.ListServicesPagedResponse) MockGrpcService(com.google.api.gax.grpc.testing.MockGrpcService) Test(org.junit.Test)

Aggregations

MockGrpcService (com.google.api.gax.grpc.testing.MockGrpcService)4 AbstractMessage (com.google.protobuf.AbstractMessage)4 Test (org.junit.Test)4 ListServicesPagedResponse (com.google.cloud.servicedirectory.v1.RegistrationServiceClient.ListServicesPagedResponse)2 ListServicesPagedResponse (com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient.ListServicesPagedResponse)2 ByteString (com.google.protobuf.ByteString)2