From eedaaf983d731d0179916b3f3a8e4d3a0d80981b Mon Sep 17 00:00:00 2001 From: Idan Amit Date: Wed, 31 Jan 2018 13:27:33 +0200 Subject: Change designer to plugin in code Changed all the use of the designer configuration in the code to be plugin Change-Id: Id9792cbd4fb9385446780c28fb7fb5418772acf6 Issue-ID: SDC-974 Signed-off-by: Idan Amit --- .../sdc/fe/servlets/DesignerStatusBLTest.java | 107 --------------------- .../sdc/fe/servlets/PluginStatusBLTest.java | 107 +++++++++++++++++++++ 2 files changed, 107 insertions(+), 107 deletions(-) delete mode 100644 catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/DesignerStatusBLTest.java create mode 100644 catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/PluginStatusBLTest.java (limited to 'catalog-fe/src/test') diff --git a/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/DesignerStatusBLTest.java b/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/DesignerStatusBLTest.java deleted file mode 100644 index db0fd736ec..0000000000 --- a/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/DesignerStatusBLTest.java +++ /dev/null @@ -1,107 +0,0 @@ -package org.openecomp.sdc.fe.servlets; - -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.apache.http.StatusLine; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpHead; -import org.apache.http.impl.client.CloseableHttpClient; -import org.junit.BeforeClass; -import org.junit.Test; -import org.mockito.Mockito; -import org.openecomp.sdc.fe.config.ConfigurationManager; -import org.openecomp.sdc.fe.config.DesignersConfiguration; -import org.openecomp.sdc.fe.config.DesignersConfiguration.Designer; -import org.openecomp.sdc.fe.impl.DesignerStatusBL; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -public class DesignerStatusBLTest { - - final static CloseableHttpClient httpClient = Mockito.mock(CloseableHttpClient.class); - DesignerStatusBL designerStatusBL = new DesignerStatusBL(httpClient); - private static Gson gson = new GsonBuilder().setPrettyPrinting().create(); - - final static ConfigurationManager configurationManager = Mockito.mock(ConfigurationManager.class); - final static DesignersConfiguration designersConfiguration = Mockito.mock(DesignersConfiguration.class); - final static Designer offlineDesigner = new Designer(); - final static Designer onlineDesigner = new Designer(); - final static CloseableHttpResponse httpResponse = Mockito.mock(CloseableHttpResponse.class); - final static StatusLine statusLine = Mockito.mock(StatusLine.class); - final static List testDesignersList = new ArrayList<>(); - - final static String offlineDesignerDisplayName = "offlineDesigner"; - final static String offlineDesignerHost = "192.168.10.1"; - final static String offlineDesignerPort = "1000"; - final static String offlineDesignerPath = "/offline"; - final static String offlineDesignerProtocol = "http"; - - final static String onlineDesignerDisplayName = "onlineDesigner"; - final static String onlineDesignerHost = "192.168.20.2"; - final static String onlineDesignerPort = "2000"; - final static String onlineDesignerPath = "/online"; - final static String onlineDesignerProtocol = "http"; - - @BeforeClass - public static void beforeClass() { - ConfigurationManager.setTestInstance(configurationManager); - when(configurationManager.getDesignersConfiguration()).thenReturn(designersConfiguration); - - offlineDesigner.setDesignerId(offlineDesignerDisplayName); - offlineDesigner.setDesignerHost(offlineDesignerHost); - offlineDesigner.setDesignerPort(offlineDesignerPort); - offlineDesigner.setDesignerPath(offlineDesignerPath); - offlineDesigner.setDesignerProtocol(offlineDesignerProtocol); - - StringBuilder offlineRequestString = new StringBuilder(); - offlineRequestString.append(offlineDesignerProtocol).append("://").append(onlineDesignerHost).append(":") - .append(offlineDesignerPort).append(offlineDesignerPath); - - onlineDesigner.setDesignerId(onlineDesignerDisplayName); - onlineDesigner.setDesignerHost(onlineDesignerHost); - onlineDesigner.setDesignerPort(onlineDesignerPort); - onlineDesigner.setDesignerPath(onlineDesignerPath); - onlineDesigner.setDesignerProtocol(onlineDesignerProtocol); - - StringBuilder onlineRequestString = new StringBuilder(); - onlineRequestString.append(onlineDesignerProtocol).append("://").append(onlineDesignerHost).append(":") - .append(offlineDesignerPort).append(offlineDesignerPath); - - } - - @Test - public void TestOfflineDesignerNotBeingReturnedWhenCallingCheckDesignerListAvailability() throws ClientProtocolException, IOException { - testDesignersList.add(offlineDesigner); - when(designersConfiguration.getDesignersList()).thenReturn(testDesignersList); - - when(statusLine.getStatusCode()).thenReturn(404); - when(httpResponse.getStatusLine()).thenReturn(statusLine); - when(httpClient.execute(Mockito.any(HttpHead.class))).thenReturn(httpResponse); - - assertTrue(designerStatusBL.checkDesignerListAvailability().equals("[]")); - - } - - @Test - public void TestOnlineDesignerNotBeingReturnedWhenCallingCheckDesignerListAvailability() throws ClientProtocolException, IOException { - testDesignersList.add(onlineDesigner); - when(designersConfiguration.getDesignersList()).thenReturn(testDesignersList); - - when(statusLine.getStatusCode()).thenReturn(200); - when(httpResponse.getStatusLine()).thenReturn(statusLine); - when(httpClient.execute(Mockito.any())).thenReturn(httpResponse); - - String result = gson.toJson(testDesignersList); - - assertTrue(designerStatusBL.checkDesignerListAvailability().contains(result)); - - } - -} diff --git a/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/PluginStatusBLTest.java b/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/PluginStatusBLTest.java new file mode 100644 index 0000000000..8a796a4993 --- /dev/null +++ b/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/PluginStatusBLTest.java @@ -0,0 +1,107 @@ +package org.openecomp.sdc.fe.servlets; + +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.apache.http.StatusLine; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpHead; +import org.apache.http.impl.client.CloseableHttpClient; +import org.junit.BeforeClass; +import org.junit.Test; +import org.mockito.Mockito; +import org.openecomp.sdc.fe.config.ConfigurationManager; +import org.openecomp.sdc.fe.config.PluginsConfiguration; +import org.openecomp.sdc.fe.config.PluginsConfiguration.Plugin; +import org.openecomp.sdc.fe.impl.PluginStatusBL; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +public class PluginStatusBLTest { + + final static CloseableHttpClient httpClient = Mockito.mock(CloseableHttpClient.class); + PluginStatusBL pluginStatusBL = new PluginStatusBL(httpClient); + private static Gson gson = new GsonBuilder().setPrettyPrinting().create(); + + final static ConfigurationManager configurationManager = Mockito.mock(ConfigurationManager.class); + final static PluginsConfiguration pluginsConfiguration = Mockito.mock(PluginsConfiguration.class); + final static Plugin offlinePlugin = new Plugin(); + final static Plugin onlinePlugin = new Plugin(); + final static CloseableHttpResponse httpResponse = Mockito.mock(CloseableHttpResponse.class); + final static StatusLine statusLine = Mockito.mock(StatusLine.class); + final static List testPluginsList = new ArrayList<>(); + + final static String offlinePluginsDisplayName = "offlinePlugin"; + final static String offlinePluginHost = "192.168.10.1"; + final static String offlinePluginPort = "1000"; + final static String offlinePluginPath = "/offline"; + final static String offlinePluginProtocol = "http"; + + final static String onlinePluginDisplayName = "onlinePlugin"; + final static String onlinePluginHost = "192.168.20.2"; + final static String onlinePluginPort = "2000"; + final static String onlinePluginPath = "/online"; + final static String onlinePluginProtocol = "http"; + + @BeforeClass + public static void beforeClass() { + ConfigurationManager.setTestInstance(configurationManager); + when(configurationManager.getPluginsConfiguration()).thenReturn(pluginsConfiguration); + + offlinePlugin.setPluginId(offlinePluginsDisplayName); + offlinePlugin.setPluginHost(offlinePluginHost); + offlinePlugin.setPluginPort(offlinePluginPort); + offlinePlugin.setPluginPath(offlinePluginPath); + offlinePlugin.setPluginProtocol(offlinePluginProtocol); + + StringBuilder offlineRequestString = new StringBuilder(); + offlineRequestString.append(offlinePluginProtocol).append("://").append(onlinePluginHost).append(":") + .append(offlinePluginPort).append(offlinePluginPath); + + onlinePlugin.setPluginId(onlinePluginDisplayName); + onlinePlugin.setPluginHost(onlinePluginHost); + onlinePlugin.setPluginPort(onlinePluginPort); + onlinePlugin.setPluginPath(onlinePluginPath); + onlinePlugin.setPluginProtocol(onlinePluginProtocol); + + StringBuilder onlineRequestString = new StringBuilder(); + onlineRequestString.append(onlinePluginProtocol).append("://").append(onlinePluginHost).append(":") + .append(offlinePluginPort).append(offlinePluginPath); + + } + + @Test + public void TestOfflinePluginNotBeingReturnedWhenCallingCheckPluginsListAvailability() throws ClientProtocolException, IOException { + testPluginsList.add(offlinePlugin); + when(pluginsConfiguration.getPluginsList()).thenReturn(testPluginsList); + + when(statusLine.getStatusCode()).thenReturn(404); + when(httpResponse.getStatusLine()).thenReturn(statusLine); + when(httpClient.execute(Mockito.any(HttpHead.class))).thenReturn(httpResponse); + + assertTrue(pluginStatusBL.checkPluginsListAvailability().equals("[]")); + + } + + @Test + public void TestOnlinePluginNotBeingReturnedWhenCallingCheckPluginsListAvailability() throws ClientProtocolException, IOException { + testPluginsList.add(onlinePlugin); + when(pluginsConfiguration.getPluginsList()).thenReturn(testPluginsList); + + when(statusLine.getStatusCode()).thenReturn(200); + when(httpResponse.getStatusLine()).thenReturn(statusLine); + when(httpClient.execute(Mockito.any())).thenReturn(httpResponse); + + String result = gson.toJson(testPluginsList); + + assertTrue(pluginStatusBL.checkPluginsListAvailability().contains(result)); + + } + +} -- cgit 1.2.3-korg