use of com.google.api.services.storagetransfer.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();
}
use of com.google.api.services.storagetransfer.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));
}
use of com.google.api.services.storagetransfer.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);
}
use of com.google.api.services.storagetransfer.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);
}
}
use of com.google.api.services.storagetransfer.v1.model.Operation in project terra-workspace-manager by DataBiosphere.
the class CompleteTransferOperationStep method getLatestOperationName.
// First, we poll the transfer jobs endpoint until an operation has started so that we can get
// its server-generated name. Returns the most recently started operation's name.
private String getLatestOperationName(Storagetransfer storageTransferService, String transferJobName, String projectId) throws InterruptedException, IOException {
String operationName = null;
for (int numAttempts = 0; numAttempts < MAX_ATTEMPTS; ++numAttempts) {
final TransferJob getResponse = storageTransferService.transferJobs().get(transferJobName, projectId).execute();
operationName = getResponse.getLatestOperationName();
if (null != operationName) {
break;
} else {
TimeUnit.MILLISECONDS.sleep(JOBS_POLL_INTERVAL.toMillis());
}
}
if (null == operationName) {
throw new StorageTransferServiceTimeoutException("Exceeded max attempts to get transfer operation name");
}
logger.debug("Latest transfer operation name is {}", operationName);
return operationName;
}
Aggregations