public void refresh() { load(provider.getKey()); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } AddNewRuntimeEvent that = (AddNewRuntimeEvent) o; return provider != null ? provider.equals(that.provider) : that.provider == null; }
@Override public int hashCode() { int result = provider != null ? provider.hashCode() : 0; result = ~~result; return result; } }
@Override public void load(final Provider provider) { clear(); view.setProviderName(provider.getKey().getId()); view.setMasterURL(getStringValue(provider.getConfiguration().getValues(), MASTER_URL)); view.setUsername(getStringValue(provider.getConfiguration().getValues(), USER)); view.setPassword(getStringValue(provider.getConfiguration().getValues(), PASSWORD)); }
@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); } }
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 testLoad() { Map<String, Object> values = new HashMap<>(); values.put(MASTER_URL, MASTER_URL_VALUE); values.put(USER, USER_VALUE); values.put(PASSWORD, PASSWORD_VALUE); Provider provider = mock(Provider.class); ProviderKey providerKey = mock(ProviderKey.class); ProviderConfiguration configuration = mock(ProviderConfiguration.class); when(provider.getKey()).thenReturn(providerKey); when(providerKey.getId()).thenReturn(PROVIDER_NAME_VALUE); when(provider.getConfiguration()).thenReturn(configuration); when(configuration.getValues()).thenReturn(values); presenter.load(provider); verify(view, times(1)).clear(); verify(view, times(1)).setProviderName(PROVIDER_NAME_VALUE); verify(view, times(1)).setMasterURL(MASTER_URL_VALUE); verify(view, times(1)).setUsername(USER_VALUE); verify(view, times(1)).setPassword(PASSWORD_VALUE); }
@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); } }
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); }
public void refresh() { load(provider.getKey()); }
@Test public void testToModelWhenHandlerIsConfigured() { when(handlerRegistry.ensureHandler(providerTypeKey)).thenReturn(providerHandler); when(providerHandler.getProviderConfigConverter()).thenReturn(providerConfigConverter); when(providerConfigConverter.toModel(providerConfig)).thenReturn(providerConfiguration); Provider result = converter.toModel(provider); assertNotNull(result); assertEquals(PROVIDER_ID, result.getKey().getId()); assertEquals(PROVIDER_TYPE_NAME, result.getKey().getProviderTypeKey().getId()); assertEquals(PROVIDER_VERSION, result.getKey().getProviderTypeKey().getVersion()); assertEquals(result.getConfiguration(), providerConfiguration); } }
@Override public int hashCode() { int result = provider != null ? provider.hashCode() : 0; result = ~~result; return result; } }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } AddNewRuntimeEvent that = (AddNewRuntimeEvent) o; return provider != null ? provider.equals(that.provider) : that.provider == null; }
/** * @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; } }
@Override public Collection<Provider> getProviders(final ProviderType providerType) { checkNotNull("providerType", providerType); return getAllProviders().stream() .filter(provider -> provider.getKey().getProviderTypeKey().equals(providerType.getKey())) .collect(toList()); }
@Test public void testToModelWhenHandlerIsConfigured() { when(handlerRegistry.ensureHandler(providerTypeKey)).thenReturn(providerHandler); when(providerHandler.getProviderConfigConverter()).thenReturn(providerConfigConverter); when(providerConfigConverter.toModel(providerConfig)).thenReturn(providerConfiguration); Provider result = converter.toModel(provider); assertNotNull(result); assertEquals(PROVIDER_ID, result.getKey().getId()); assertEquals(PROVIDER_TYPE_NAME, result.getKey().getProviderTypeKey().getId()); assertEquals(PROVIDER_VERSION, result.getKey().getProviderTypeKey().getVersion()); assertEquals(result.getConfiguration(), providerConfiguration); } }
@Override public int hashCode() { int result = provider != null ? provider.hashCode() : 0; result = ~~result; result = 31 * result + (runtimeItems != null ? runtimeItems.hashCode() : 0); result = ~~result; return result; } }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } RuntimesInfo that = (RuntimesInfo) o; if (provider != null ? !provider.equals(that.provider) : that.provider != null) { return false; } return runtimeItems != null ? runtimeItems.equals(that.runtimeItems) : that.runtimeItems == null; }
public void removeProvider() { providerService.call(response -> { notification.fire(new NotificationEvent(view.getRemoveProviderSuccessMessage(), NotificationEvent.NotificationType.SUCCESS)); providerTypeSelectedEvent.fire(new ProviderTypeSelectedEvent(provider.getKey().getProviderTypeKey())); }, (message, throwable) -> { notification.fire(new NotificationEvent(view.getRemoveProviderErrorMessage(), NotificationEvent.NotificationType.ERROR)); providerTypeSelectedEvent.fire(new ProviderTypeSelectedEvent(provider.getKey().getProviderTypeKey())); return false; }).deleteProvider(provider.getKey()); }
@Override public int hashCode() { int result = provider != null ? provider.hashCode() : 0; result = ~~result; result = 31 * result + (runtimeItems != null ? runtimeItems.hashCode() : 0); result = ~~result; return result; } }