aboutsummaryrefslogtreecommitdiffstats
path: root/appc-sdc-listener
diff options
context:
space:
mode:
authorJakub Dudycz <jakub.dudycz@nokia.com>2018-02-15 20:40:33 +0100
committerPatrick Brady <pb071s@att.com>2018-02-15 22:22:40 +0000
commite2855d181e760721a4024ee02f7116487242ebd3 (patch)
treea92aecf87ff499e1cd831b99b9b0444c639a3aa8 /appc-sdc-listener
parent0fffe3df2f501d06a536b01730b4c86fe481e360 (diff)
SdcConfig sonar fixes
Change-Id: Ia947837f00401b1c9da900dc2db3b6931fb682fb Issue-ID: APPC-639 Signed-off-by: Jakub Dudycz <jakub.dudycz@nokia.com>
Diffstat (limited to 'appc-sdc-listener')
-rw-r--r--appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcConfig.java65
-rw-r--r--appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/listener/SdcConfigTest.java4
2 files changed, 39 insertions, 30 deletions
diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcConfig.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcConfig.java
index 2acb2e625..4f16bc5c9 100644
--- a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcConfig.java
+++ b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcConfig.java
@@ -26,15 +26,17 @@ package org.onap.appc.sdc.listener;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-import org.openecomp.sdc.api.consumer.IConfiguration;
-
+import com.google.common.collect.Lists;
import java.net.URI;
+import java.net.URISyntaxException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.apache.commons.lang.StringUtils;
+import org.openecomp.sdc.api.consumer.IConfiguration;
public class SdcConfig implements IConfiguration {
@@ -44,9 +46,13 @@ public class SdcConfig implements IConfiguration {
private String env;
private String keystorePath;
private String keystorePass;
- /** Polling internal is time between listening sessions */
+ /**
+ * Polling internal is time between listening sessions
+ */
private int pollingInterval;
- /** Polling timeout is the time to listen for (dmaap timeout url param)/1000 */
+ /**
+ * Polling timeout is the time to listen for (dmaap timeout url param)/1000
+ */
private int pollingTimeout;
private List<String> types = new ArrayList<>();
private String user;
@@ -55,12 +61,12 @@ public class SdcConfig implements IConfiguration {
private Properties props;
private final EELFLogger logger = EELFManager.getInstance().getLogger(SdcConfig.class);
- SdcConfig(Properties props) throws Exception {
+ SdcConfig(Properties props) throws URISyntaxException {
this.props = props;
init();
}
- private void init() throws Exception {
+ private void init() throws URISyntaxException {
if (props == null) {
logger.error("SdcConfig init is skipped due to properties is null");
return;
@@ -92,8 +98,8 @@ public class SdcConfig implements IConfiguration {
if (pollingInterval > pollingTimeout) {
logger.warn(String.format(
- "Message acknowledgement may be delayed by %ds in the ADSC listener. [Listening Time: %s, Poll Period: %s]",
- pollingInterval - pollingTimeout, pollingTimeout, pollingInterval));
+ "Message acknowledgement may be delayed by %ds in the ADSC listener. [Listening Time: %s, Poll Period: %s]",
+ pollingInterval - pollingTimeout, pollingTimeout, pollingInterval));
}
logParams();
@@ -104,7 +110,7 @@ public class SdcConfig implements IConfiguration {
*/
types.add("APPC_CONFIG");
types.add("VF_LICENSE");
- // types.add("TOSCA_CSAR"); commenting it out as we are not listening to TOSCA_CSAR
+ // types.add("TOSCA_CSAR"); commenting it out as we are not listening to TOSCA_CSAR
storeOp = new URI(props.getProperty("appc.sdc.provider.url"));
}
@@ -114,6 +120,7 @@ public class SdcConfig implements IConfiguration {
return false;
}
+ @Override
public boolean isFilterInEmptyResources() {
return false;
}
@@ -174,32 +181,32 @@ public class SdcConfig implements IConfiguration {
}
@Override
- public Boolean isUseHttpsWithDmaap(){
- return true;
+ public Boolean isUseHttpsWithDmaap() {
+ return true;
}
@Override
- public List <String> getMsgBusAddress() {
- return (getMsgBusProperties());
+ public List<String> getMsgBusAddress() {
+ return getMsgBusProperties();
}
public List<String> getMsgBusProperties() {
- List<String> uebAddresses = new ArrayList<String>();
- String uebAddressesList=null;
- if (null != this.props)
+ List<String> uebAddresses;
+ String uebAddressesList;
+ if (null != this.props) {
uebAddressesList = this.props.getProperty("appc.ClosedLoop.poolMembers");
- else {
+ } else {
logger.info("SdcConfig:SdcConfig:getMsgBusProperties()::props is null for SdcConfig");
- return null;
+ return Collections.emptyList();
}
if (null == uebAddressesList) {
logger.info("SdcConfig:SdcConfig:getMsgBusProperties()::uebAddressesList is null for SdcConfig");
- return null;
+ return Collections.emptyList();
}
- logger.debug("SdcConfig:SdcConfig:getMsgBusProperties()::uebAddressesList is="+ uebAddressesList);
+ logger.debug("SdcConfig:SdcConfig:getMsgBusProperties()::uebAddressesList is=" + uebAddressesList);
String[] sList = uebAddressesList.split(",");
- uebAddresses= formatAddresses(sList);
- logger.debug("SdcConfig:getMsgBusProperties:::Returning addresses as "+uebAddresses.toString());
+ uebAddresses = formatAddresses(sList);
+ logger.debug("SdcConfig:getMsgBusProperties:::Returning addresses as " + uebAddresses.toString());
return uebAddresses;
}
@@ -222,16 +229,16 @@ public class SdcConfig implements IConfiguration {
logger.info(String.format("SDC Params: %s", params));
}
- protected List<String> formatAddresses(String[] sList) {
- List<String> uebAddresses = new ArrayList<String>();
- for (String fqdnPort:sList) {
+ private List<String> formatAddresses(String[] sList) {
+ List<String> uebAddresses = new ArrayList<>();
+ for (String fqdnPort : sList) {
if (fqdnPort.startsWith("http")) {
- fqdnPort=StringUtils.substringAfter(fqdnPort, "://");
+ fqdnPort = StringUtils.substringAfter(fqdnPort, "://");
}
- if (null != fqdnPort && fqdnPort.contains(":")) {
- fqdnPort=StringUtils.substringBefore(fqdnPort,":");
+ if (fqdnPort.contains(":")) {
+ fqdnPort = StringUtils.substringBefore(fqdnPort, ":");
}
- logger.debug("SdcConfig:formatAddresses:: "+fqdnPort);
+ logger.debug("SdcConfig:formatAddresses:: " + fqdnPort);
uebAddresses.add(fqdnPort);
}
return uebAddresses;
diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/listener/SdcConfigTest.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/listener/SdcConfigTest.java
index 5d88fe7ea..5ba17c922 100644
--- a/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/listener/SdcConfigTest.java
+++ b/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/listener/SdcConfigTest.java
@@ -24,7 +24,9 @@
package org.onap.appc.sdc.listener;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import java.util.List;
import java.util.Properties;
@@ -41,6 +43,6 @@ public class SdcConfigTest {
properties.setProperty("appc.ClosedLoop.poolMembers","localhost:3905");
SdcConfig sdc = new SdcConfig(properties);
List<String> uebAddresses = sdc.getMsgBusProperties();
- assertNotNull(uebAddresses);
+ assertFalse(uebAddresses.isEmpty());
}
}