private void prepareRuntimesInfo() { ProviderTypeKey providerTypeKey = mockProviderTypeKey("1"); providerKey = mockProviderKey(providerTypeKey, "1"); ProviderConfiguration configuration = mock(ProviderConfiguration.class); provider = new Provider(providerKey, configuration); runtimesInfo = mock(RuntimesInfo.class); when(runtimesInfo.getProvider()).thenReturn(provider); when(runtimesInfo.getRuntimeItems()).thenReturn(runtimeItems); when(providerService.getProvider(providerKey)).thenReturn(provider); when(provisioningScreensService.getRuntimesInfo(providerKey)).thenReturn(runtimesInfo); when(handlerRegistry.isProviderInstalled(providerTypeKey)).thenReturn(true); when(handlerRegistry.getProviderHandler(providerTypeKey)).thenReturn(handler); when(handler.getFormResolver()).thenReturn(formResolver); when(formResolver.newProviderConfigurationForm()).thenReturn(configurationForm); when(configurationForm.getView()).thenReturn(configurationFormView); }
private void prepareRuntimesInfo() { ProviderTypeKey providerTypeKey = mockProviderTypeKey("1"); providerKey = mockProviderKey(providerTypeKey, "1"); ProviderConfiguration configuration = mock(ProviderConfiguration.class); provider = new Provider(providerKey, configuration); runtimesInfo = mock(RuntimesInfo.class); when(runtimesInfo.getProvider()).thenReturn(provider); when(runtimesInfo.getRuntimeItems()).thenReturn(runtimeItems); when(providerService.getProvider(providerKey)).thenReturn(provider); when(provisioningScreensService.getRuntimesInfo(providerKey)).thenReturn(runtimesInfo); when(handlerRegistry.isProviderInstalled(providerTypeKey)).thenReturn(true); when(handlerRegistry.getProviderHandler(providerTypeKey)).thenReturn(handler); when(handler.getFormResolver()).thenReturn(formResolver); when(formResolver.newProviderConfigurationForm()).thenReturn(configurationForm); when(configurationForm.getView()).thenReturn(configurationFormView); }
@Test public void testAddNewRuntime() { Provider provider = new Provider(mockProviderKey(mockProviderTypeKey(""), ""), mock(ProviderConfiguration.class)); @SuppressWarnings("unchecked") List<PipelineKey> pipelines = mock(List.class); when(runtimeService.getPipelines(provider.getKey().getProviderTypeKey())).thenReturn(pipelines); perspective.onAddNewRuntime(new AddNewRuntimeEvent(provider)); verify(newDeployWizard, times(1)).start(provider, pipelines); } }
@Test public void testAddNewRuntime() { Provider provider = new Provider(mockProviderKey(mockProviderTypeKey(""), ""), mock(ProviderConfiguration.class)); @SuppressWarnings("unchecked") List<PipelineKey> pipelines = mock(List.class); when(runtimeService.getPipelines(provider.getKey().getProviderTypeKey())).thenReturn(pipelines); perspective.onAddNewRuntime(new AddNewRuntimeEvent(provider)); verify(newDeployWizard, times(1)).start(provider, pipelines); } }
/** * @param provider A provider representation in the guvnor-ala core domain. * @return the converted version of the provider in the format managed by the UI related modules. */ @Override public Provider toModel(org.guvnor.ala.runtime.providers.Provider provider) { Provider result = null; if (provider != null) { ProviderTypeKey providerTypeKey = new ProviderTypeKey(provider.getProviderType().getProviderTypeName(), provider.getProviderType().getVersion()); ProviderKey providerKey = new ProviderKey(providerTypeKey, provider.getId()); final BackendProviderHandler handler = handlerRegistry.ensureHandler(providerTypeKey); @SuppressWarnings("unchecked") final ProviderConfiguration providerConfiguration = (ProviderConfiguration) handler.getProviderConfigConverter().toModel(provider.getConfig()); result = new Provider(providerKey, providerConfiguration); } return result; } }