Search in sources :

Example 1 with ListInstancesResponse

use of com.google.api.services.notebooks.v1.model.ListInstancesResponse in project terra-cloud-resource-lib by DataBiosphere.

the class AIPlatformNotebooksCowTest method createGetListDeleteNotebookInstance.

@Test
public void createGetListDeleteNotebookInstance() throws Exception {
    InstanceName instanceName = defaultInstanceName().build();
    createInstance(instanceName);
    Instance retrievedInstance = notebooks.instances().get(instanceName).execute();
    assertEquals(instanceName.formatName(), retrievedInstance.getName());
    ListInstancesResponse listResponse = notebooks.instances().list(instanceName.formatParent()).execute();
    // There may be other notebook instances from other tests.
    assertThat(listResponse.getInstances().size(), Matchers.greaterThan(0));
    assertThat(listResponse.getInstances().stream().map(Instance::getName).collect(Collectors.toList()), Matchers.hasItem(instanceName.formatName()));
    OperationCow<Operation> deleteOperation = notebooks.operations().operationCow(notebooks.instances().delete(instanceName).execute());
    OperationTestUtils.pollAndAssertSuccess(deleteOperation, Duration.ofSeconds(30), Duration.ofMinutes(5));
    GoogleJsonResponseException e = assertThrows(GoogleJsonResponseException.class, () -> notebooks.instances().get(instanceName).execute());
    assertEquals(404, e.getStatusCode());
}
Also used : ListInstancesResponse(com.google.api.services.notebooks.v1.model.ListInstancesResponse) GoogleJsonResponseException(com.google.api.client.googleapis.json.GoogleJsonResponseException) Instance(com.google.api.services.notebooks.v1.model.Instance) Operation(com.google.api.services.notebooks.v1.model.Operation) Test(org.junit.jupiter.api.Test)

Aggregations

GoogleJsonResponseException (com.google.api.client.googleapis.json.GoogleJsonResponseException)1 Instance (com.google.api.services.notebooks.v1.model.Instance)1 ListInstancesResponse (com.google.api.services.notebooks.v1.model.ListInstancesResponse)1 Operation (com.google.api.services.notebooks.v1.model.Operation)1 Test (org.junit.jupiter.api.Test)1