From 1367b73c1d1d761939f5893c711f87716a7baad0 Mon Sep 17 00:00:00 2001 From: ilanap Date: Tue, 26 Nov 2019 11:53:36 +0200 Subject: Add API to retrieve UI configuration Added configuration file with the menu configuration from catalog-ui. Added to the configuration manager. to chef and to the ui rest APIs. Issue-ID: SDC-2663 Signed-off-by: ilanap Change-Id: Ia5e014a273238981241821c0d81b0455bd662b28 Signed-off-by: ilanap --- .../sdc/fe/servlets/ConfigServletTest.java | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'catalog-fe/src/test/java/org') diff --git a/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/ConfigServletTest.java b/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/ConfigServletTest.java index 7f54fc06c4..29a49bc611 100644 --- a/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/ConfigServletTest.java +++ b/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/ConfigServletTest.java @@ -20,11 +20,17 @@ package org.openecomp.sdc.fe.servlets; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import org.apache.http.HttpStatus; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; +import org.openecomp.sdc.common.api.ConfigurationSource; import org.openecomp.sdc.common.api.Constants; +import org.openecomp.sdc.common.impl.ExternalConfiguration; +import org.openecomp.sdc.common.impl.FSConfigurationSource; +import org.openecomp.sdc.fe.config.ConfigurationManager; import org.openecomp.sdc.fe.impl.PluginStatusBL; import javax.servlet.ServletContext; @@ -51,13 +57,31 @@ public class ConfigServletTest { private ServletContext mockedContext; @Mock private PluginStatusBL pluginStatusBL; + @Mock + private ConfigurationManager configManager; @Before public void setUp() { initMocks(this); + String appConfigDir = "src/test/resources/config/catalog-fe"; + ConfigurationSource configurationSource = + new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir); + configManager = new ConfigurationManager(configurationSource); configServlet = new ConfigServlet(); } + @Test + public void validateWorkspaceConfiguration() { + + prepareMocks(); + + Response response = configServlet.getUIWorkspaceConfiguration(httpServletRequest); + + Gson gson = new GsonBuilder().setPrettyPrinting().create(); + String expected = gson.toJson(configManager.getWorkspaceConfiguration()); + assertEquals(expected, response.getEntity().toString()); + assertEquals(response.getStatus(), HttpStatus.SC_OK); + } @Test public void validateGetPluginsConfigurationReturnsCorrectConfiguration() { @@ -120,6 +144,7 @@ public class ConfigServletTest { private void prepareMocks() { when(httpServletRequest.getSession()).thenReturn(httpSession); when(httpSession.getServletContext()).thenReturn(mockedContext); + when(mockedContext.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).thenReturn(configManager); when(mockedContext.getAttribute(Constants.PLUGIN_BL_COMPONENT)).thenReturn(pluginStatusBL); } -- cgit 1.2.3-korg