Search in sources :

Example 1 with ListEndpointsPagedResponse

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

Example 2 with ListEndpointsPagedResponse

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

Example 3 with ListEndpointsPagedResponse

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

Example 4 with ListEndpointsPagedResponse

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

Aggregations

AbstractMessage (com.google.protobuf.AbstractMessage)4 Test (org.junit.Test)4 ListEndpointsPagedResponse (com.google.cloud.servicedirectory.v1.RegistrationServiceClient.ListEndpointsPagedResponse)2 ListEndpointsPagedResponse (com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient.ListEndpointsPagedResponse)2 ByteString (com.google.protobuf.ByteString)2