use of com.google.api.services.serviceusage.v1beta1.model.Operation 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());
}
use of com.google.api.services.serviceusage.v1beta1.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();
}
use of com.google.api.services.serviceusage.v1beta1.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();
}
use of com.google.api.services.serviceusage.v1beta1.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));
}
use of com.google.api.services.serviceusage.v1beta1.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);
}
Aggregations