diff options
author | Idan Amit <ia096e@intl.att.com> | 2018-03-15 18:07:16 +0200 |
---|---|---|
committer | Michael Lando <ml636r@att.com> | 2018-03-18 08:39:31 +0000 |
commit | d03d20a800a41dc04e70803ae2c6851bfb9948b9 (patch) | |
tree | 680b2b345ba0628acbba175db9d9347f982aab7b /catalog-fe/src/test/java/org | |
parent | de67b61f2fcd1bfc3cd6c44d9f1e66786777a238 (diff) |
Add timeout and connection status
Added timeout and connection status to the plugins configuration.
Added support in ui to display a temporary error screen in case a plugin in offline
Change-Id: Id4a0909cc704903be6183f22c67caec6f5050103
Issue-ID: SDC-1081
Signed-off-by: Idan Amit <ia096e@intl.att.com>
Diffstat (limited to 'catalog-fe/src/test/java/org')
-rw-r--r-- | catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/PluginStatusBLTest.java | 36 |
1 files changed, 27 insertions, 9 deletions
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 index baef6858a3..25fef8968b 100644 --- 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 @@ -12,6 +12,7 @@ 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.Before; import org.junit.BeforeClass; import org.junit.Test; import org.mockito.Mockito; @@ -35,7 +36,8 @@ public class PluginStatusBLTest { 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<Plugin> testPluginsList = new ArrayList<>(); + static List<Plugin> testPluginsList = new ArrayList<>(); + static List<Plugin> assertPluginList = new ArrayList<>(); final static String offlinePluginsDisplayName = "offlinePlugin"; final static String offlinePluginDiscoveryPath = "http://192.168.10.1:1000/offline"; @@ -53,34 +55,50 @@ public class PluginStatusBLTest { onlinePlugin.setPluginId(onlinePluginDisplayName); onlinePlugin.setPluginDiscoveryUrl(onlinePluginDiscoveryPath); - + } + + @Before + public void beforeTest() { + testPluginsList = new ArrayList<>(); + assertPluginList = new ArrayList<>(); } @Test - public void TestOfflinePluginNotBeingReturnedWhenCallingCheckPluginsListAvailability() throws ClientProtocolException, IOException { + public void TestOfflinePluginBeingReturnedWithIsOnlineValueFalse() 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); + + offlinePlugin.setOnline(false); + assertPluginList.add(offlinePlugin); + + String result = gson.toJson(assertPluginList); + String actualResult = pluginStatusBL.checkPluginsListAvailability(); + + System.out.println(result); + System.out.println(actualResult); - assertTrue(pluginStatusBL.checkPluginsListAvailability().equals("[]")); - + assertTrue(pluginStatusBL.checkPluginsListAvailability().equals(result)); } @Test - public void TestOnlinePluginNotBeingReturnedWhenCallingCheckPluginsListAvailability() throws ClientProtocolException, IOException { + public void TestOnlinePluginBeingReturnedWithIsOnlineValueTrue() 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); + + onlinePlugin.setOnline(true); + assertPluginList.add(onlinePlugin); + + String result = gson.toJson(assertPluginList); - String result = gson.toJson(testPluginsList); - - assertTrue(pluginStatusBL.checkPluginsListAvailability().contains(result)); + assertTrue(pluginStatusBL.checkPluginsListAvailability().equals(result)); } |