@Test public void testCreateRuntimeSuccessful() { Provider provider = mock(Provider.class); ProviderTypeKey providerTypeKey = new ProviderTypeKey(PROVIDER_NAME, PROVIDER_VERSION); ProviderKey providerKey = new ProviderKey(providerTypeKey, PROVIDER_ID); Map<String, String> params = PipelineInputBuilderTest.mockParams(PARAMS_COUNT); 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(true); Input expectedInput = PipelineInputBuilder.newInstance() .withProvider(providerKey) .withRuntimeName(RUNTIME_ID) .withParams(params).build(); service.createRuntime(providerKey, RUNTIME_ID, PIPELINE_KEY, params); verify(pipelineService, times(1)).runPipeline(PIPELINE, expectedInput, true); }
@Test public void testCreateRuntimeSuccessful() { Provider provider = mock(Provider.class); ProviderTypeKey providerTypeKey = new ProviderTypeKey(PROVIDER_NAME, PROVIDER_VERSION); ProviderKey providerKey = new ProviderKey(providerTypeKey, PROVIDER_ID); Map<String, String> params = PipelineInputBuilderTest.mockParams(PARAMS_COUNT); 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(true); Input expectedInput = PipelineInputBuilder.newInstance() .withProvider(providerKey) .withRuntimeName(RUNTIME_ID) .withParams(params).build(); service.createRuntime(providerKey, RUNTIME_ID, PIPELINE_KEY, params); verify(pipelineService, times(1)).runPipeline(PIPELINE, expectedInput, 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); } }
@Test public void testBuild() { Input result = PipelineInputBuilder.newInstance() .withProvider(providerKey) .withParams(params) .withRuntimeName(RUNTIME).build(); assertNotNull(result); assertEquals(RUNTIME, result.get(RuntimeConfig.RUNTIME_NAME)); assertEquals(PROVIDER, result.get(ProviderConfig.PROVIDER_NAME)); params.forEach((name, value) -> assertEquals(value, result.get(name))); }
@Test public void testBuild() { Input result = PipelineInputBuilder.newInstance() .withProvider(providerKey) .withParams(params) .withRuntimeName(RUNTIME).build(); assertNotNull(result); assertEquals(RUNTIME, result.get(RuntimeConfig.RUNTIME_NAME)); assertEquals(PROVIDER, result.get(ProviderConfig.PROVIDER_NAME)); params.forEach((name, value) -> assertEquals(value, result.get(name))); }