Search in sources :

Example 31 with Operation

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

the class ProjectUtils method executeCreateProject.

/**
 * Creates a new Google Project in GCP for testing.
 */
public static Project executeCreateProject() throws Exception {
    Project project = new Project().setProjectId(randomProjectId()).setParent(PARENT_RESOURCE);
    Operation operation = getManagerCow().projects().create(project).execute();
    OperationCow<Operation> operationCow = managerCow.operations().operationCow(operation);
    OperationTestUtils.pollAndAssertSuccess(operationCow, Duration.ofSeconds(5), Duration.ofSeconds(60));
    return managerCow.projects().get(project.getProjectId()).execute();
}
Also used : Project(com.google.api.services.cloudresourcemanager.v3.model.Project) Operation(com.google.api.services.cloudresourcemanager.v3.model.Operation)

Example 32 with Operation

use of com.google.api.services.notebooks.v1.model.Operation in project platinum by hartwigmedical.

the class KubernetesEngineTest method shouldCreateAndReturnInstanceWhenNoneExists.

@Test
public void shouldCreateAndReturnInstanceWhenNoneExists() throws IOException {
    Get foundOperation = mock(Get.class);
    Create created = mock(Create.class);
    Operation executedCreate = mock(Operation.class);
    when(clusters.get(anyString())).thenReturn(foundOperation);
    when(foundOperation.execute()).thenThrow(GoogleJsonResponseException.class);
    when(clusters.create(eq(format("projects/%s/locations/%s", PROJECT, REGION)), any())).thenReturn(created);
    when(created.execute()).thenReturn(executedCreate);
    when(executedCreate.getName()).thenReturn("created");
    mockForClusterCreation();
    victim.findOrCreate(RUN_NAME, Collections.emptyList(), JSON_KEY, BUCKET, SERVICE_ACCOUNT);
    verify(created).execute();
}
Also used : Create(com.google.api.services.container.v1beta1.Container.Projects.Locations.Clusters.Create) Get(com.google.api.services.container.v1beta1.Container.Projects.Locations.Clusters.Get) Operation(com.google.api.services.container.v1beta1.model.Operation) Test(org.junit.Test)

Example 33 with Operation

use of com.google.api.services.notebooks.v1.model.Operation in project FAAAST-Service by FraunhoferIOSB.

the class RequestHandlerManagerTest method testInvokeOperationSyncRequest.

@Test
public void testInvokeOperationSyncRequest() {
    CoreConfig coreConfig = CoreConfig.builder().build();
    Persistence persistence = mock(Persistence.class);
    MessageBus messageBus = mock(MessageBus.class);
    AssetConnectionManager assetConnectionManager = mock(AssetConnectionManager.class);
    when(assetConnectionManager.hasOperationProvider(any())).thenReturn(true);
    when(assetConnectionManager.getOperationProvider(any())).thenReturn(new CustomAssetOperationProvider());
    RequestHandlerManager manager = new RequestHandlerManager(coreConfig, persistence, messageBus, assetConnectionManager);
    Operation operation = getTestOperation();
    InvokeOperationSyncRequest invokeOperationSyncRequest = new InvokeOperationSyncRequest.Builder().requestId("1").inoutputArguments(operation.getInoutputVariables()).inputArguments(operation.getInputVariables()).id(new DefaultIdentifier.Builder().idType(IdentifierType.IRI).identifier("http://example.org").build()).build();
    InvokeOperationSyncResponse actual = manager.execute(invokeOperationSyncRequest);
    InvokeOperationSyncResponse expected = new InvokeOperationSyncResponse.Builder().statusCode(StatusCode.SUCCESS).payload(new OperationResult.Builder().requestId("1").inoutputArguments(List.of(new DefaultOperationVariable.Builder().value(new DefaultProperty.Builder().idShort("TestProp").value("TestOutput").build()).build())).outputArguments(operation.getInputVariables()).executionState(ExecutionState.COMPLETED).build()).build();
    Assert.assertTrue(ResponseHelper.equalsIgnoringTime(expected, actual));
}
Also used : CoreConfig(de.fraunhofer.iosb.ilt.faaast.service.config.CoreConfig) InvokeOperationSyncRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.InvokeOperationSyncRequest) OperationResult(de.fraunhofer.iosb.ilt.faaast.service.model.api.operation.OperationResult) Operation(io.adminshell.aas.v3.model.Operation) DefaultOperation(io.adminshell.aas.v3.model.impl.DefaultOperation) DefaultOperationVariable(io.adminshell.aas.v3.model.impl.DefaultOperationVariable) Persistence(de.fraunhofer.iosb.ilt.faaast.service.persistence.Persistence) MessageBus(de.fraunhofer.iosb.ilt.faaast.service.messagebus.MessageBus) AssetConnectionManager(de.fraunhofer.iosb.ilt.faaast.service.assetconnection.AssetConnectionManager) RequestHandlerManager(de.fraunhofer.iosb.ilt.faaast.service.request.RequestHandlerManager) DefaultIdentifier(io.adminshell.aas.v3.model.impl.DefaultIdentifier) InvokeOperationSyncResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.InvokeOperationSyncResponse) Test(org.junit.Test)

Example 34 with Operation

use of com.google.api.services.notebooks.v1.model.Operation in project FAAAST-Service by FraunhoferIOSB.

the class RequestHandlerManagerTest method testInvokeOperationAsyncRequest.

@Test
public void testInvokeOperationAsyncRequest() {
    CoreConfig coreConfig = CoreConfig.builder().build();
    Persistence persistence = mock(Persistence.class);
    MessageBus messageBus = mock(MessageBus.class);
    AssetConnectionManager assetConnectionManager = mock(AssetConnectionManager.class);
    AssetOperationProvider assetOperationProvider = mock(AssetOperationProvider.class);
    RequestHandlerManager manager = new RequestHandlerManager(coreConfig, persistence, messageBus, assetConnectionManager);
    Operation operation = getTestOperation();
    OperationHandle expectedOperationHandle = new OperationHandle.Builder().handleId("1").requestId("1").build();
    when(persistence.putOperationContext(any(), any(), any())).thenReturn(expectedOperationHandle);
    when(persistence.getOperationResult(any())).thenReturn(new OperationResult.Builder().requestId("1").build());
    when(assetConnectionManager.hasOperationProvider(any())).thenReturn(true);
    when(assetConnectionManager.getOperationProvider(any())).thenReturn(assetOperationProvider);
    InvokeOperationAsyncRequest invokeOperationAsyncRequest = new InvokeOperationAsyncRequest.Builder().requestId("1").id(new DefaultIdentifier.Builder().idType(IdentifierType.IRI).identifier("http://example.org").build()).inoutputArguments(operation.getInoutputVariables()).inputArguments(operation.getInputVariables()).build();
    InvokeOperationAsyncResponse response = manager.execute(invokeOperationAsyncRequest);
    OperationHandle actualOperationHandle = response.getPayload();
    Assert.assertEquals(expectedOperationHandle, actualOperationHandle);
}
Also used : CoreConfig(de.fraunhofer.iosb.ilt.faaast.service.config.CoreConfig) OperationResult(de.fraunhofer.iosb.ilt.faaast.service.model.api.operation.OperationResult) Operation(io.adminshell.aas.v3.model.Operation) DefaultOperation(io.adminshell.aas.v3.model.impl.DefaultOperation) OperationHandle(de.fraunhofer.iosb.ilt.faaast.service.model.api.operation.OperationHandle) Persistence(de.fraunhofer.iosb.ilt.faaast.service.persistence.Persistence) MessageBus(de.fraunhofer.iosb.ilt.faaast.service.messagebus.MessageBus) AssetConnectionManager(de.fraunhofer.iosb.ilt.faaast.service.assetconnection.AssetConnectionManager) RequestHandlerManager(de.fraunhofer.iosb.ilt.faaast.service.request.RequestHandlerManager) InvokeOperationAsyncRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.InvokeOperationAsyncRequest) AssetOperationProvider(de.fraunhofer.iosb.ilt.faaast.service.assetconnection.AssetOperationProvider) DefaultIdentifier(io.adminshell.aas.v3.model.impl.DefaultIdentifier) InvokeOperationAsyncResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.InvokeOperationAsyncResponse) Test(org.junit.Test)

Example 35 with Operation

use of com.google.api.services.notebooks.v1.model.Operation in project terra-cli by DataBiosphere.

the class GoogleNotebooks method start.

public void start(InstanceName instanceName) {
    try {
        Operation startOperation = notebooks.instances().start(instanceName).execute();
        pollForSuccess(startOperation, "Error starting notebook instance: ");
    } catch (InterruptedException | IOException e) {
        checkFor409BadState(e);
        throw new SystemException("Error starting notebook instance", e);
    }
}
Also used : SystemException(bio.terra.cli.exception.SystemException) Operation(com.google.api.services.notebooks.v1.model.Operation) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)14 Test (org.junit.Test)9 Operation (io.adminshell.aas.v3.model.Operation)7 GoogleJsonResponseException (com.google.api.client.googleapis.json.GoogleJsonResponseException)6 CloudHealthcare (com.google.api.services.healthcare.v1.CloudHealthcare)6 Operation (com.google.api.services.healthcare.v1.model.Operation)6 StepResult (bio.terra.stairway.StepResult)5 Operation (com.google.api.services.notebooks.v1.model.Operation)5 MessageBus (de.fraunhofer.iosb.ilt.faaast.service.messagebus.MessageBus)5 Operation (com.google.api.services.appengine.v1.model.Operation)4 Create (com.google.api.services.container.v1beta1.Container.Projects.Locations.Clusters.Create)4 Operation (com.google.api.services.container.v1beta1.model.Operation)4 AIPlatformNotebooksCow (bio.terra.cloudres.google.notebooks.AIPlatformNotebooksCow)3 InstanceName (bio.terra.cloudres.google.notebooks.InstanceName)3 GcpCloudContext (bio.terra.workspace.service.workspace.model.GcpCloudContext)3 Status (com.google.api.services.appengine.v1.model.Status)3 Get (com.google.api.services.container.v1beta1.Container.Projects.Locations.Clusters.Get)3 Operation (com.google.api.services.serviceusage.v1beta1.model.Operation)3 AssetConnectionManager (de.fraunhofer.iosb.ilt.faaast.service.assetconnection.AssetConnectionManager)3 CoreConfig (de.fraunhofer.iosb.ilt.faaast.service.config.CoreConfig)3