@Test public void testCreateRuntimeWhenProviderExistsButRuntimeNameExitsts() { Provider provider = mock(Provider.class); ProviderTypeKey providerTypeKey = new ProviderTypeKey(PROVIDER_NAME, PROVIDER_VERSION); ProviderKey providerKey = new ProviderKey(providerTypeKey, PROVIDER_ID); List<RuntimeQueryResultItem> items = mock(List.class); when(providerService.getProvider(providerKey)).thenReturn(provider); when(runtimeProvisioningService.executeQuery(RuntimeQueryBuilder.newInstance() .withRuntimeName(RUNTIME_ID) .build())).thenReturn(items); when(items.isEmpty()).thenReturn(false); expectedException.expectMessage("A runtime with the given name already exists: " + RUNTIME_ID); service.createRuntime(providerKey, RUNTIME_ID, PIPELINE_KEY, mock(Map.class)); verify(pipelineService, never()).runPipeline(anyString(), any(Input.class), eq(true)); }
@Override public PipelineExecutionTraceKey createRuntime(final ProviderKey providerKey, final String runtimeName, final PipelineKey pipelineKey, final Map<String, String> params) { checkNotNull("providerKey", providerKey); checkNotNull("runtimeName", runtimeName); checkNotNull("pipelineKey", pipelineKey); validateForCreateRuntime(providerKey, runtimeName); try { final Input input = PipelineInputBuilder.newInstance() .withRuntimeName(runtimeName) .withProvider(providerKey) .withParams(params) .build(); return new PipelineExecutionTraceKey(pipelineService.runPipeline(pipelineKey.getId(), input, true)); } catch (Exception e) { logger.error("Runtime creation failed.", e); throw ExceptionUtilities.handleException(e); } }
RuntimeServiceImpl implements RuntimeService { @Override public PipelineExecutionTraceKey createRuntime(final ProviderKey providerKey, final String runtimeName, final PipelineKey pipelineKey, final Map<String, String> params) { checkNotNull("providerKey", providerKey); checkNotNull("runtimeName", runtimeName); checkNotNull("pipelineKey", pipelineKey); validateForCreateRuntime(providerKey, runtimeName); try { final Input input = PipelineInputBuilder.newInstance() .withRuntimeName(runtimeName) .withProvider(providerKey) .withParams(params) .build(); return new PipelineExecutionTraceKey(pipelineService.runPipeline(pipelineKey.getId(), input, true)); } catch (Exception e) { logger.error("Runtime creation failed.", e); throw ExceptionUtilities.handleException(e); } } }
RuntimeServiceImpl implements RuntimeService { @Override public PipelineExecutionTraceKey createRuntime(final ProviderKey providerKey, final String runtimeName, final PipelineKey pipelineKey, final Map<String, String> params) { checkNotNull("providerKey", providerKey); checkNotNull("runtimeName", runtimeName); checkNotNull("pipelineKey", pipelineKey); validateForCreateRuntime(providerKey, runtimeName); try { final Input input = PipelineInputBuilder.newInstance() .withRuntimeName(runtimeName) .withProvider(providerKey) .withParams(params) .build(); return new PipelineExecutionTraceKey(pipelineService.runPipeline(pipelineKey.getId(), input, true)); } catch (Exception e) { logger.error("Runtime creation failed.", e); throw ExceptionUtilities.handleException(e); } } RuntimeServiceImpl(); @Inject  RuntimeServiceImpl(final RuntimeProvisioningServiceBackend runtimeProvisioningService,
                              final PipelineServiceBackend pipelineService,
                              final ProviderService providerService,
                              final Event<RuntimeChangeEvent> runtimeChangeEvent,
                              final Event<PipelineExecutionChangeEvent> pipelineExecutionChangeEvent); }
RuntimeServiceImpl implements RuntimeService { @Override public PipelineExecutionTraceKey createRuntime(final ProviderKey providerKey, final String runtimeName, final PipelineKey pipelineKey, final Map<String, String> params) { checkNotNull("providerKey", providerKey); checkNotNull("runtimeName", runtimeName); checkNotNull("pipelineKey", pipelineKey); validateForCreateRuntime(providerKey, runtimeName); try { final Input input = PipelineInputBuilder.newInstance() .withRuntimeName(runtimeName) .withProvider(providerKey) .withParams(params) .build(); return new PipelineExecutionTraceKey(pipelineService.runPipeline(pipelineKey.getId(), input, true)); } catch (Exception e) { logger.error("Runtime creation failed.", e); throw ExceptionUtilities.handleException(e); } } RuntimeServiceImpl(); @Inject  RuntimeServiceImpl(final RuntimeProvisioningServiceBackend runtimeProvisioningService,
                              final PipelineServiceBackend pipelineService,
                              final ProviderService providerService,
                              final Event<RuntimeChangeEvent> runtimeChangeEvent,
                              final Event<PipelineExecutionChangeEvent> pipelineExecutionChangeEvent); @Override Collection<RuntimeListItem> getRuntimeItems(final ProviderKey providerKey); @Override RuntimeListItem getRuntimeItem(final PipelineExecutionTraceKey pipelineExecutionTraceKey); @Override RuntimeListItem getRuntimeItem(final RuntimeKey runtimeKey); @Override Collection<PipelineKey> getPipelines(final ProviderTypeKey providerTypeKey); @Override PipelineExecutionTraceKey createRuntime(final ProviderKey providerKey,
                                                   final String runtimeName,
                                                   final PipelineKey pipelineKey,
                                                   final Map<String, String> params); @Override void stopPipelineExecution(final PipelineExecutionTraceKey pipelineExecutionTraceKey); @Override void deletePipelineExecution(final PipelineExecutionTraceKey pipelineExecutionTraceKey); @Override void stopRuntime(final RuntimeKey runtimeKey); @Override void startRuntime(final RuntimeKey runtimeKey); @Override void deleteRuntime(final RuntimeKey runtimeKey,
                              final boolean forced); }
RuntimeServiceImpl implements RuntimeService { @Override public PipelineExecutionTraceKey createRuntime(final ProviderKey providerKey, final String runtimeName, final PipelineKey pipelineKey, final Map<String, String> params) { checkNotNull("providerKey", providerKey); checkNotNull("runtimeName", runtimeName); checkNotNull("pipelineKey", pipelineKey); validateForCreateRuntime(providerKey, runtimeName); try { final Input input = PipelineInputBuilder.newInstance() .withRuntimeName(runtimeName) .withProvider(providerKey) .withParams(params) .build(); return new PipelineExecutionTraceKey(pipelineService.runPipeline(pipelineKey.getId(), input, true)); } catch (Exception e) { logger.error("Runtime creation failed.", e); throw ExceptionUtilities.handleException(e); } } RuntimeServiceImpl(); @Inject  RuntimeServiceImpl(final RuntimeProvisioningServiceBackend runtimeProvisioningService,
                              final PipelineServiceBackend pipelineService,
                              final ProviderService providerService,
                              final Event<RuntimeChangeEvent> runtimeChangeEvent,
                              final Event<PipelineExecutionChangeEvent> pipelineExecutionChangeEvent); @Override Collection<RuntimeListItem> getRuntimeItems(final ProviderKey providerKey); @Override RuntimeListItem getRuntimeItem(final PipelineExecutionTraceKey pipelineExecutionTraceKey); @Override RuntimeListItem getRuntimeItem(final RuntimeKey runtimeKey); @Override Collection<PipelineKey> getPipelines(final ProviderTypeKey providerTypeKey); @Override PipelineExecutionTraceKey createRuntime(final ProviderKey providerKey,
                                                   final String runtimeName,
                                                   final PipelineKey pipelineKey,
                                                   final Map<String, String> params); @Override void stopPipelineExecution(final PipelineExecutionTraceKey pipelineExecutionTraceKey); @Override void deletePipelineExecution(final PipelineExecutionTraceKey pipelineExecutionTraceKey); @Override void stopRuntime(final RuntimeKey runtimeKey); @Override void startRuntime(final RuntimeKey runtimeKey); @Override void deleteRuntime(final RuntimeKey runtimeKey,
                              final boolean forced);  }