Search in sources :

Example 1 with Environment

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

the class ITNotebookServiceClientTest method testGetEnvironment.

@Test
public void testGetEnvironment() {
    GetEnvironmentRequest environmentRequest = GetEnvironmentRequest.newBuilder().setName(ENVIRONMENT_NAME).build();
    Environment expectedEnvironmentResponse = client.getEnvironment(environmentRequest);
    assertEquals(expectedEnvironmentResponse.getName(), expectedEnvironmentResponse.getName());
    assertEquals(expectedEnvironmentResponse.getContainerImage(), expectedEnvironmentResponse.getContainerImage());
}
Also used : Environment(com.google.cloud.notebooks.v1beta1.Environment) GetEnvironmentRequest(com.google.cloud.notebooks.v1beta1.GetEnvironmentRequest) Test(org.junit.Test)

Example 2 with Environment

use of com.google.cloud.notebooks.v1beta1.Environment 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 3 with Environment

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

the class ITNotebookServiceClientTest method setUp.

@BeforeClass
public static void setUp() throws IOException, ExecutionException, InterruptedException {
    // Create Test Notebook Instance
    client = NotebookServiceClient.create();
    ContainerImage containerImage = ContainerImage.newBuilder().setRepository(FieldBehavior.OPTIONAL.name()).build();
    Environment environment = Environment.newBuilder().setName(ENVIRONMENT_NAME).setContainerImage(containerImage).build();
    CreateEnvironmentRequest environmentRequest = CreateEnvironmentRequest.newBuilder().setParent(PARENT).setEnvironmentId(ENVIRONMENT_ID).setEnvironment(environment).build();
    expectedEnvironmentResponse = client.createEnvironmentAsync(environmentRequest).get();
    Instance notebookInstance = Instance.newBuilder().setContainerImage(containerImage).setMachineType(MACHINE_TYPE_A).build();
    CreateInstanceRequest instanceRequest = CreateInstanceRequest.newBuilder().setParent(PARENT).setInstanceId(NOTEBOOK_INSTANCE_ID).setInstance(notebookInstance).build();
    expectedNotebookInstance = client.createInstanceAsync(instanceRequest).get();
}
Also used : CreateEnvironmentRequest(com.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest) Instance(com.google.cloud.notebooks.v1beta1.Instance) ContainerImage(com.google.cloud.notebooks.v1beta1.ContainerImage) Environment(com.google.cloud.notebooks.v1beta1.Environment) CreateInstanceRequest(com.google.cloud.notebooks.v1beta1.CreateInstanceRequest) BeforeClass(org.junit.BeforeClass)

Example 4 with Environment

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

the class ITNotebookServiceClientTest method tearDown.

@AfterClass
public static void tearDown() throws ExecutionException, InterruptedException {
    // Delete Test Environment Instance
    DeleteEnvironmentRequest deleteEnvironmentRequest = DeleteEnvironmentRequest.newBuilder().setName(ENVIRONMENT_NAME).build();
    client.deleteEnvironmentAsync(deleteEnvironmentRequest).get();
    // Delete Test Notebook Instance
    DeleteInstanceRequest deleteInstanceRequest = DeleteInstanceRequest.newBuilder().setName(INSTANCE_NAME).build();
    client.deleteInstanceAsync(deleteInstanceRequest).get();
    client.close();
}
Also used : DeleteEnvironmentRequest(com.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest) DeleteInstanceRequest(com.google.cloud.notebooks.v1beta1.DeleteInstanceRequest) AfterClass(org.junit.AfterClass)

Example 5 with Environment

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

Environment (com.google.cloud.notebooks.v1beta1.Environment)3 Test (org.junit.Test)3 ContainerImage (com.google.cloud.notebooks.v1beta1.ContainerImage)1 CreateEnvironmentRequest (com.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest)1 CreateInstanceRequest (com.google.cloud.notebooks.v1beta1.CreateInstanceRequest)1 DeleteEnvironmentRequest (com.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest)1 DeleteInstanceRequest (com.google.cloud.notebooks.v1beta1.DeleteInstanceRequest)1 GetEnvironmentRequest (com.google.cloud.notebooks.v1beta1.GetEnvironmentRequest)1 Instance (com.google.cloud.notebooks.v1beta1.Instance)1 ListEnvironmentsRequest (com.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest)1 ListEnvironmentsPagedResponse (com.google.cloud.notebooks.v1beta1.NotebookServiceClient.ListEnvironmentsPagedResponse)1 AbstractMessage (com.google.protobuf.AbstractMessage)1 AfterClass (org.junit.AfterClass)1 BeforeClass (org.junit.BeforeClass)1