Search in sources :

Example 6 with ListInstancesRequest

use of com.google.cloud.notebooks.v1beta1.ListInstancesRequest in project java-spanner by googleapis.

the class InstanceAdminClientTest method listInstancesTest.

@Test
public void listInstancesTest() throws Exception {
    Instance responsesElement = Instance.newBuilder().build();
    ListInstancesResponse expectedResponse = ListInstancesResponse.newBuilder().setNextPageToken("").addAllInstances(Arrays.asList(responsesElement)).build();
    mockInstanceAdmin.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    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 = mockInstanceAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListInstancesRequest actualRequest = ((ListInstancesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListInstancesResponse(com.google.spanner.admin.instance.v1.ListInstancesResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Instance(com.google.spanner.admin.instance.v1.Instance) ProjectName(com.google.spanner.admin.instance.v1.ProjectName) ListInstancesRequest(com.google.spanner.admin.instance.v1.ListInstancesRequest) ListInstancesPagedResponse(com.google.cloud.spanner.admin.instance.v1.InstanceAdminClient.ListInstancesPagedResponse) Test(org.junit.Test)

Example 7 with ListInstancesRequest

use of com.google.cloud.notebooks.v1beta1.ListInstancesRequest 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)

Example 8 with ListInstancesRequest

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

the class ITNotebookServiceClientTest method testListInstances.

@Test
public void testListInstances() {
    ListInstancesRequest request = ListInstancesRequest.newBuilder().setParent(PARENT).build();
    for (Instance element : client.listInstances(request).iterateAll()) {
        if (element.getName().equals(NOTEBOOK_INSTANCE_ID)) {
            assertEquals(expectedNotebookInstance.getContainerImage(), element.getContainerImage());
            assertEquals(expectedNotebookInstance.getName(), element.getName());
            assertEquals(expectedNotebookInstance.getMachineType(), element.getMachineType());
            assertEquals(expectedNotebookInstance.getNetwork(), element.getNetwork());
            assertEquals(expectedNotebookInstance.getSubnet(), element.getSubnet());
        }
    }
}
Also used : Instance(com.google.cloud.notebooks.v1beta1.Instance) ListInstancesRequest(com.google.cloud.notebooks.v1beta1.ListInstancesRequest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)7 AbstractMessage (com.google.protobuf.AbstractMessage)6 ListInstancesRequest (com.google.spanner.admin.instance.v1.ListInstancesRequest)4 ListInstancesResponse (com.google.spanner.admin.instance.v1.ListInstancesResponse)4 ByteString (com.google.protobuf.ByteString)3 ArrayList (java.util.ArrayList)3 ListInstancesRequest (com.google.bigtable.admin.v2.ListInstancesRequest)2 ListInstancesResponse (com.google.bigtable.admin.v2.ListInstancesResponse)2 ListInstancesPagedResponse (com.google.cloud.spanner.admin.instance.v1.InstanceAdminClient.ListInstancesPagedResponse)2 Instance (com.google.spanner.admin.instance.v1.Instance)2 ProjectName (com.google.spanner.admin.instance.v1.ProjectName)2 GrpcCallContext (com.google.api.gax.grpc.GrpcCallContext)1 ProjectName (com.google.bigtable.admin.v2.ProjectName)1 Instance (com.google.cloud.notebooks.v1beta1.Instance)1 ListInstancesRequest (com.google.cloud.notebooks.v1beta1.ListInstancesRequest)1 ListInstancesPagedResponse (com.google.cloud.notebooks.v1beta1.NotebookServiceClient.ListInstancesPagedResponse)1 StatusRuntimeException (io.grpc.StatusRuntimeException)1 IOException (java.io.IOException)1 ExecutionException (java.util.concurrent.ExecutionException)1 ExpectedException (org.junit.rules.ExpectedException)1