@Test public void testBuildParams() { when(view.getRuntimeName()).thenReturn(RUNTIME_NAME_VALUE); when(view.getImageStreamsURL()).thenReturn(DEFAULT_OPEN_SHIFT_IMAGE_STREAMS_VALUE); when(view.getSecretsFileURL()).thenReturn(DEFAULT_OPEN_SHIFT_SECRETS_VALUE); when(openShiftClientService.isValidProjectName(RUNTIME_NAME_VALUE)).thenReturn(true); presenter.onRuntimeNameChange(); when(view.getTemplateURL()).thenReturn(DEFAULT_OPEN_SHIFT_TEMPLATE_VALUE); when(openShiftClientService.getTemplateModel(DEFAULT_OPEN_SHIFT_TEMPLATE_VALUE)).thenReturn(templateDescriptorModel); presenter.onTemplateURLChange(); List<ContainerConfig> containerConfigs = mockContainerConfigList(CONTAINER_CONFIG_COUNT); presenter.onContainerConfigurationsChange(new ContainerConfigParamsChangeEvent(containerConfigs)); for (int i = 0; i < allTemplateParams.size(); i++) { String paramValue = "PARAM_VALUE" + String.valueOf(i); allTemplateParams.get(i).setValue(paramValue); } StringBuilder templateParamsValueBuilder = new StringBuilder(); managedTemplateParams.forEach(param -> { if (templateParamsValueBuilder.length() > 0) { templateParamsValueBuilder.append(","); } templateParamsValueBuilder.append(param.getName()); templateParamsValueBuilder.append("="); templateParamsValueBuilder.append(param.getValue()); }); templateParamsValueBuilder.append("," + IMAGE_STREAM_NAMESPACE_TEMPLATE_PARAM + "=" + RUNTIME_NAME_VALUE); templateParamsValueBuilder.append("," + APPLICATION_NAME_TEMPLATE_PARAM + "=" + RUNTIME_NAME_VALUE); Map<String, String> expectedParams = new HashMap<>(); expectedParams.put(NewDeployWizard.RUNTIME_NAME, RUNTIME_NAME_VALUE); expectedParams.put(PROJECT_NAME, RUNTIME_NAME_VALUE); expectedParams.put(APPLICATION_NAME, RUNTIME_NAME_VALUE); expectedParams.put(SERVICE_NAME, RUNTIME_NAME_VALUE + SERVICE_NAME_SUFFIX); expectedParams.put(RESOURCE_TEMPLATE_URI, DEFAULT_OPEN_SHIFT_TEMPLATE_VALUE); expectedParams.put(RESOURCE_STREAMS_URI, DEFAULT_OPEN_SHIFT_IMAGE_STREAMS_VALUE); expectedParams.put(RESOURCE_SECRETS_URI, DEFAULT_OPEN_SHIFT_SECRETS_VALUE); expectedParams.put(KIE_SERVER_CONTAINER_DEPLOYMENT, buildExpectedContainerDeploymentParamValue(containerConfigs)); expectedParams.put(RESOURCE_TEMPLATE_PARAM_VALUES, templateParamsValueBuilder.toString()); Map<String, String> result = presenter.buildParams(); assertEquals(expectedParams, result); }
@Override public Map<String, String> buildParams() { final Map<String, String> pipelineParams = new HashMap<>(); String runtimeName = getRuntimeName(); String projectName = runtimeName; String applicationName = runtimeName; String serviceName = runtimeName + SERVICE_NAME_SUFFIX; String imageStreamNamespace = projectName; pipelineParams.put(NewDeployWizard.RUNTIME_NAME, runtimeName); pipelineParams.put(PROJECT_NAME, projectName); pipelineParams.put(APPLICATION_NAME, applicationName); pipelineParams.put(SERVICE_NAME, serviceName); pipelineParams.put(RESOURCE_TEMPLATE_URI, getTemplateURL()); pipelineParams.put(RESOURCE_STREAMS_URI, getImageStreamsURL()); pipelineParams.put(RESOURCE_SECRETS_URI, getSecretsFileURL()); if (configuredContainers != null && !configuredContainers.isEmpty()) { pipelineParams.put(KIE_SERVER_CONTAINER_DEPLOYMENT, buildContainerDeploymentParamValue(configuredContainers)); } StringBuilder builder = new StringBuilder(); params.forEach(param -> { if (!isBanned(param.getName()) && !isEmpty(param.getValue())) { addTemplateParam(builder, param.getName(), param.getValue()); } }); addTemplateParam(builder, IMAGE_STREAM_NAMESPACE_TEMPLATE_PARAM, imageStreamNamespace); addTemplateParam(builder, APPLICATION_NAME_TEMPLATE_PARAM, applicationName); pipelineParams.put(RESOURCE_TEMPLATE_PARAM_VALUES, builder.toString()); return pipelineParams; }
TemplateParamsFormPresenter extends AbstractHasContentChangeHandlers implements PipelineParamsForm { @Override public Map<String, String> buildParams() { final Map<String, String> pipelineParams = new HashMap<>(); String runtimeName = getRuntimeName(); String projectName = runtimeName; String applicationName = runtimeName; String serviceName = runtimeName + SERVICE_NAME_SUFFIX; String imageStreamNamespace = projectName; pipelineParams.put(NewDeployWizard.RUNTIME_NAME, runtimeName); pipelineParams.put(PROJECT_NAME, projectName); pipelineParams.put(APPLICATION_NAME, applicationName); pipelineParams.put(SERVICE_NAME, serviceName); pipelineParams.put(RESOURCE_TEMPLATE_URI, getTemplateURL()); pipelineParams.put(RESOURCE_STREAMS_URI, getImageStreamsURL()); pipelineParams.put(RESOURCE_SECRETS_URI, getSecretsFileURL()); if (configuredContainers != null && !configuredContainers.isEmpty()) { pipelineParams.put(KIE_SERVER_CONTAINER_DEPLOYMENT, buildContainerDeploymentParamValue(configuredContainers)); } StringBuilder builder = new StringBuilder(); params.forEach(param -> { if (!isBanned(param.getName()) && !isEmpty(param.getValue())) { addTemplateParam(builder, param.getName(), param.getValue()); } }); addTemplateParam(builder, IMAGE_STREAM_NAMESPACE_TEMPLATE_PARAM, imageStreamNamespace); addTemplateParam(builder, APPLICATION_NAME_TEMPLATE_PARAM, applicationName); pipelineParams.put(RESOURCE_TEMPLATE_PARAM_VALUES, builder.toString()); return pipelineParams; } }
TemplateParamsFormPresenter extends AbstractHasContentChangeHandlers implements PipelineParamsForm { @Override public Map<String, String> buildParams() { final Map<String, String> pipelineParams = new HashMap<>(); String runtimeName = getRuntimeName(); String projectName = runtimeName; String applicationName = runtimeName; String serviceName = runtimeName + SERVICE_NAME_SUFFIX; String imageStreamNamespace = projectName; pipelineParams.put(NewDeployWizard.RUNTIME_NAME, runtimeName); pipelineParams.put(PROJECT_NAME, projectName); pipelineParams.put(APPLICATION_NAME, applicationName); pipelineParams.put(SERVICE_NAME, serviceName); pipelineParams.put(RESOURCE_TEMPLATE_URI, getTemplateURL()); pipelineParams.put(RESOURCE_STREAMS_URI, getImageStreamsURL()); pipelineParams.put(RESOURCE_SECRETS_URI, getSecretsFileURL()); if (configuredContainers != null && !configuredContainers.isEmpty()) { pipelineParams.put(KIE_SERVER_CONTAINER_DEPLOYMENT, buildContainerDeploymentParamValue(configuredContainers)); } StringBuilder builder = new StringBuilder(); params.forEach(param -> { if (!isBanned(param.getName()) && !isEmpty(param.getValue())) { addTemplateParam(builder, param.getName(), param.getValue()); } }); addTemplateParam(builder, IMAGE_STREAM_NAMESPACE_TEMPLATE_PARAM, imageStreamNamespace); addTemplateParam(builder, APPLICATION_NAME_TEMPLATE_PARAM, applicationName); pipelineParams.put(RESOURCE_TEMPLATE_PARAM_VALUES, builder.toString()); return pipelineParams; } @Inject  TemplateParamsFormPresenter(final View view,
                                       final TemplateParamsTablePresenter paramsEditorPresenter,
                                       final TranslationService translationService,
                                       final PopupHelper popupHelper,
                                       final Caller<OpenShiftClientService> openShiftClientService,
                                       final OpenShiftClientValidationService openShiftClientValidationService); }
TemplateParamsFormPresenter extends AbstractHasContentChangeHandlers implements PipelineParamsForm { @Override public Map<String, String> buildParams() { final Map<String, String> pipelineParams = new HashMap<>(); String runtimeName = getRuntimeName(); String projectName = runtimeName; String applicationName = runtimeName; String serviceName = runtimeName + SERVICE_NAME_SUFFIX; String imageStreamNamespace = projectName; pipelineParams.put(NewDeployWizard.RUNTIME_NAME, runtimeName); pipelineParams.put(PROJECT_NAME, projectName); pipelineParams.put(APPLICATION_NAME, applicationName); pipelineParams.put(SERVICE_NAME, serviceName); pipelineParams.put(RESOURCE_TEMPLATE_URI, getTemplateURL()); pipelineParams.put(RESOURCE_STREAMS_URI, getImageStreamsURL()); pipelineParams.put(RESOURCE_SECRETS_URI, getSecretsFileURL()); if (configuredContainers != null && !configuredContainers.isEmpty()) { pipelineParams.put(KIE_SERVER_CONTAINER_DEPLOYMENT, buildContainerDeploymentParamValue(configuredContainers)); } StringBuilder builder = new StringBuilder(); params.forEach(param -> { if (!isBanned(param.getName()) && !isEmpty(param.getValue())) { addTemplateParam(builder, param.getName(), param.getValue()); } }); addTemplateParam(builder, IMAGE_STREAM_NAMESPACE_TEMPLATE_PARAM, imageStreamNamespace); addTemplateParam(builder, APPLICATION_NAME_TEMPLATE_PARAM, applicationName); pipelineParams.put(RESOURCE_TEMPLATE_PARAM_VALUES, builder.toString()); return pipelineParams; } @Inject  TemplateParamsFormPresenter(final View view,
                                       final TemplateParamsTablePresenter paramsEditorPresenter,
                                       final TranslationService translationService,
                                       final PopupHelper popupHelper,
                                       final Caller<OpenShiftClientService> openShiftClientService,
                                       final OpenShiftClientValidationService openShiftClientValidationService); @PostConstruct void init(); @Override String getWizardTitle(); @Override View getView(); @Override Map<String, String> buildParams(); @Override void initialise(); @Override void prepareView(); @Override void isComplete(final Callback<Boolean> callback); @Override void clear(); }
TemplateParamsFormPresenter extends AbstractHasContentChangeHandlers implements PipelineParamsForm { @Override public Map<String, String> buildParams() { final Map<String, String> pipelineParams = new HashMap<>(); String runtimeName = getRuntimeName(); String projectName = runtimeName; String applicationName = runtimeName; String serviceName = runtimeName + SERVICE_NAME_SUFFIX; String imageStreamNamespace = projectName; pipelineParams.put(NewDeployWizard.RUNTIME_NAME, runtimeName); pipelineParams.put(PROJECT_NAME, projectName); pipelineParams.put(APPLICATION_NAME, applicationName); pipelineParams.put(SERVICE_NAME, serviceName); pipelineParams.put(RESOURCE_TEMPLATE_URI, getTemplateURL()); pipelineParams.put(RESOURCE_STREAMS_URI, getImageStreamsURL()); pipelineParams.put(RESOURCE_SECRETS_URI, getSecretsFileURL()); if (configuredContainers != null && !configuredContainers.isEmpty()) { pipelineParams.put(KIE_SERVER_CONTAINER_DEPLOYMENT, buildContainerDeploymentParamValue(configuredContainers)); } StringBuilder builder = new StringBuilder(); params.forEach(param -> { if (!isBanned(param.getName()) && !isEmpty(param.getValue())) { addTemplateParam(builder, param.getName(), param.getValue()); } }); addTemplateParam(builder, IMAGE_STREAM_NAMESPACE_TEMPLATE_PARAM, imageStreamNamespace); addTemplateParam(builder, APPLICATION_NAME_TEMPLATE_PARAM, applicationName); pipelineParams.put(RESOURCE_TEMPLATE_PARAM_VALUES, builder.toString()); return pipelineParams; } @Inject  TemplateParamsFormPresenter(final View view,
                                       final TemplateParamsTablePresenter paramsEditorPresenter,
                                       final TranslationService translationService,
                                       final PopupHelper popupHelper,
                                       final Caller<OpenShiftClientService> openShiftClientService,
                                       final OpenShiftClientValidationService openShiftClientValidationService); @PostConstruct void init(); @Override String getWizardTitle(); @Override View getView(); @Override Map<String, String> buildParams(); @Override void initialise(); @Override void prepareView(); @Override void isComplete(final Callback<Boolean> callback); @Override void clear(); static final String PARAM_DELIMITER; static final String PARAM_ASSIGNER; static final String CONTAINER_DELIMITER; static final String RESOURCE_TEMPLATE_PARAM_VALUES; static final String RESOURCE_TEMPLATE_URI; static final String RESOURCE_SECRETS_URI; static final String RESOURCE_STREAMS_URI; static final String APPLICATION_NAME; static final String PROJECT_NAME; static final String SERVICE_NAME; static final String KIE_SERVER_CONTAINER_DEPLOYMENT; static final String IMAGE_STREAM_NAMESPACE_TEMPLATE_PARAM; static final String APPLICATION_NAME_TEMPLATE_PARAM; static final String SERVICE_NAME_SUFFIX; static final String HORNETQ_QUEUES; static final String HORNETQ_TOPICS; static final String HORNETQ_CLUSTER_PASSWORD; }