summaryrefslogtreecommitdiffstats
path: root/catalog-fe/src
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-fe/src')
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/PluginStatusBL.java23
-rw-r--r--catalog-fe/src/main/resources/config/plugins-configuration.yaml6
-rw-r--r--catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/PluginStatusBLTest.java36
3 files changed, 42 insertions, 23 deletions
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/PluginStatusBL.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/PluginStatusBL.java
index 563dc22507..5ed4585e10 100644
--- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/PluginStatusBL.java
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/PluginStatusBL.java
@@ -23,11 +23,13 @@ public class PluginStatusBL {
private static Logger log = LoggerFactory.getLogger(PluginStatusBL.class.getName());
private static Gson gson = new GsonBuilder().setPrettyPrinting().create();
private CloseableHttpClient client = null;
-
+ private PluginsConfiguration pluginsConfiguration = ConfigurationManager.getConfigurationManager().getPluginsConfiguration();
+ private Integer connectionTimeout;
+
public PluginStatusBL() {
this.client = HttpClients.createDefault();
}
-
+
public PluginStatusBL(CloseableHttpClient client) {
this.client = client;
@@ -36,21 +38,18 @@ public class PluginStatusBL {
public String checkPluginsListAvailability() {
String result = null;
- PluginsConfiguration pluginsConfiguration = ConfigurationManager.getConfigurationManager()
- .getPluginsConfiguration();
-
if (pluginsConfiguration == null || pluginsConfiguration.getPluginsList() == null) {
log.warn("Configuration of type {} was not found", PluginsConfiguration.class);
} else {
log.debug("The value returned from getConfig is {}", pluginsConfiguration);
+ connectionTimeout = pluginsConfiguration.getConnectionTimeout();
List<Plugin> availablePluginsList = new ArrayList<>();
- pluginsConfiguration.getPluginsList().forEach(value -> {
- if (checkPluginAvailability(value)) {
- availablePluginsList.add(value);
- }
+ pluginsConfiguration.getPluginsList().forEach(plugin -> {
+ plugin.setOnline(checkPluginAvailability(plugin));
+ availablePluginsList.add(plugin);
});
result = gson.toJson(availablePluginsList);
}
@@ -62,9 +61,9 @@ public class PluginStatusBL {
HttpHead head = new HttpHead(plugin.getPluginDiscoveryUrl());
RequestConfig requestConfig = RequestConfig.custom()
- .setSocketTimeout(1000)
- .setConnectTimeout(1000)
- .setConnectionRequestTimeout(1000).build();
+ .setSocketTimeout(connectionTimeout)
+ .setConnectTimeout(connectionTimeout)
+ .setConnectionRequestTimeout(connectionTimeout).build();
head.setConfig(requestConfig);
diff --git a/catalog-fe/src/main/resources/config/plugins-configuration.yaml b/catalog-fe/src/main/resources/config/plugins-configuration.yaml
index 69598e0ebe..eb36945715 100644
--- a/catalog-fe/src/main/resources/config/plugins-configuration.yaml
+++ b/catalog-fe/src/main/resources/config/plugins-configuration.yaml
@@ -17,5 +17,7 @@ pluginsList:
displayName: "WORKFLOW"
context:
displayName: "Workflow Designer"
- displayContext: ["VF"]
- displayRoles: ["DESIGNER", "TESTER"] \ No newline at end of file
+ displayContext: ["VF", "SERVICE"]
+ displayRoles: ["DESIGNER", "TESTER"]
+
+connectionTimeout: 1000 \ No newline at end of file
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));
}