Search in sources :

Example 1 with ListInstancesPagedResponse

use of com.google.cloud.notebooks.v1beta1.NotebookServiceClient.ListInstancesPagedResponse in project java-notebooks by googleapis.

the class NotebookServiceClientTest method listInstancesTest.

@Test
public void listInstancesTest() throws Exception {
    Instance responsesElement = Instance.newBuilder().build();
    ListInstancesResponse expectedResponse = ListInstancesResponse.newBuilder().setNextPageToken("").addAllInstances(Arrays.asList(responsesElement)).build();
    mockNotebookService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListInstancesPagedResponse pagedListResponse = client.listInstances(parent);
    List<Instance> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getInstancesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockNotebookService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListInstancesRequest actualRequest = ((ListInstancesRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListInstancesPagedResponse(com.google.cloud.notebooks.v1.NotebookServiceClient.ListInstancesPagedResponse) Test(org.junit.Test)

Example 2 with ListInstancesPagedResponse

use of com.google.cloud.notebooks.v1beta1.NotebookServiceClient.ListInstancesPagedResponse in project java-notebooks by googleapis.

the class NotebookServiceClientTest method listInstancesTest.

@Test
public void listInstancesTest() throws Exception {
    Instance responsesElement = Instance.newBuilder().build();
    ListInstancesResponse expectedResponse = ListInstancesResponse.newBuilder().setNextPageToken("").addAllInstances(Arrays.asList(responsesElement)).build();
    mockNotebookService.addResponse(expectedResponse);
    ListInstancesRequest request = ListInstancesRequest.newBuilder().setParent("parent-995424086").setPageSize(883849137).setPageToken("pageToken873572522").build();
    ListInstancesPagedResponse pagedListResponse = client.listInstances(request);
    List<Instance> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getInstancesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockNotebookService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListInstancesRequest actualRequest = ((ListInstancesRequest) actualRequests.get(0));
    Assert.assertEquals(request.getParent(), actualRequest.getParent());
    Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize());
    Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListInstancesPagedResponse(com.google.cloud.notebooks.v1beta1.NotebookServiceClient.ListInstancesPagedResponse) Test(org.junit.Test)

Aggregations

AbstractMessage (com.google.protobuf.AbstractMessage)2 Test (org.junit.Test)2 ListInstancesPagedResponse (com.google.cloud.notebooks.v1.NotebookServiceClient.ListInstancesPagedResponse)1 ListInstancesPagedResponse (com.google.cloud.notebooks.v1beta1.NotebookServiceClient.ListInstancesPagedResponse)1