Search in sources :

Example 1 with ListEnvironmentsRequest

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

the class ITNotebookServiceClientTest method testListEnvironment.

@Test
public void testListEnvironment() {
    ListEnvironmentsRequest request = ListEnvironmentsRequest.newBuilder().setParent(PARENT).build();
    for (Environment element : client.listEnvironments(request).iterateAll()) {
        if (element.getName().equals(ENVIRONMENT_ID)) {
            assertEquals(expectedEnvironmentResponse.getName(), element.getName());
            assertEquals(expectedEnvironmentResponse.getContainerImage(), element.getContainerImage());
        }
    }
}
Also used : ListEnvironmentsRequest(com.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest) Environment(com.google.cloud.notebooks.v1beta1.Environment) Test(org.junit.Test)

Example 2 with ListEnvironmentsRequest

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

the class NotebookServiceClientTest method listEnvironmentsTest.

@Test
public void listEnvironmentsTest() throws Exception {
    Environment responsesElement = Environment.newBuilder().build();
    ListEnvironmentsResponse expectedResponse = ListEnvironmentsResponse.newBuilder().setNextPageToken("").addAllEnvironments(Arrays.asList(responsesElement)).build();
    mockNotebookService.addResponse(expectedResponse);
    ListEnvironmentsRequest request = ListEnvironmentsRequest.newBuilder().setParent("parent-995424086").setPageSize(883849137).setPageToken("pageToken873572522").build();
    ListEnvironmentsPagedResponse pagedListResponse = client.listEnvironments(request);
    List<Environment> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getEnvironmentsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockNotebookService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListEnvironmentsRequest actualRequest = ((ListEnvironmentsRequest) 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) ListEnvironmentsPagedResponse(com.google.cloud.notebooks.v1beta1.NotebookServiceClient.ListEnvironmentsPagedResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 Environment (com.google.cloud.notebooks.v1beta1.Environment)1 ListEnvironmentsRequest (com.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest)1 ListEnvironmentsPagedResponse (com.google.cloud.notebooks.v1beta1.NotebookServiceClient.ListEnvironmentsPagedResponse)1 AbstractMessage (com.google.protobuf.AbstractMessage)1