summaryrefslogtreecommitdiffstats
path: root/controlloop/common/msb/src/main
diff options
context:
space:
mode:
authoreeimmis <michael.morris@ericsson.com>2018-02-06 09:43:40 +0000
committermmis <michael.morris@ericsson.com>2018-02-07 15:27:54 +0000
commit81bd67a59dfe34d976c504e5ba330ce99f175220 (patch)
tree7629ecd51979c44026f4a834bcef6c36f1f3b803 /controlloop/common/msb/src/main
parentdd41f2509cfd5538ece6446dd3b3f1ced85c9e5d (diff)
Fix technical debt/JUnit on MSB
Unit tests added and technical debt removed Issue-ID: POLICY-455 Change-Id: Ib10613ff7cac64bb576046e038b2acbd66152648 Signed-off-by: mmis <michael.morris@ericsson.com>
Diffstat (limited to 'controlloop/common/msb/src/main')
-rw-r--r--controlloop/common/msb/src/main/java/org/onap/policy/msb/client/MSBServiceFactory.java16
-rw-r--r--controlloop/common/msb/src/main/java/org/onap/policy/msb/client/MSBServiceManager.java3
2 files changed, 7 insertions, 12 deletions
diff --git a/controlloop/common/msb/src/main/java/org/onap/policy/msb/client/MSBServiceFactory.java b/controlloop/common/msb/src/main/java/org/onap/policy/msb/client/MSBServiceFactory.java
index 5332c0df2..7ebb5d6dc 100644
--- a/controlloop/common/msb/src/main/java/org/onap/policy/msb/client/MSBServiceFactory.java
+++ b/controlloop/common/msb/src/main/java/org/onap/policy/msb/client/MSBServiceFactory.java
@@ -20,7 +20,6 @@ import java.io.Serializable;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import java.util.Iterator;
import java.util.Properties;
import org.onap.msb.sdk.discovery.common.RouteException;
@@ -34,7 +33,7 @@ import org.slf4j.LoggerFactory;
public class MSBServiceFactory implements Serializable {
private static final long serialVersionUID = 4638414146278012425L;
private static final Logger logger = LoggerFactory.getLogger(MSBServiceFactory.class);
- private static final String msbPropertyFile = "msb.policy.properties";
+ private static final String MSB_PROPERTY_FILE = "msb.policy.properties";
private static final String MSB_IP = "msb.ip";
private static final String MSB_PORT = "msb.port";
private transient MSBServiceClient msbClient;
@@ -50,15 +49,16 @@ public class MSBServiceFactory implements Serializable {
private void init() throws MSBServiceException,IOException {
properties = new Properties();
- Path file = Paths.get(System.getProperty(msbPropertyFile));
- if (file == null) {
+ String propertyFilePath = System.getProperty(MSB_PROPERTY_FILE);
+ if (propertyFilePath == null) {
throw new MSBServiceException("No msb.policy.properties specified.");
}
- if (Files.notExists(file)) {
+ Path file = Paths.get(propertyFilePath);
+ if (!file.toFile().exists()) {
throw new MSBServiceException("No msb.policy.properties specified.");
}
- if (Files.isReadable(file) == false) {
+ if (!Files.isReadable(file)) {
throw new MSBServiceException ("Repository is NOT readable: " + file.toAbsolutePath());
}
try(InputStream is = new FileInputStream(file.toFile())){
@@ -94,9 +94,7 @@ public class MSBServiceFactory implements Serializable {
node.setName(serviceName);
try {
MicroServiceFullInfo serviceInfo = msbClient.queryMicroServiceInfo(serviceName,version);
- Iterator iterator = serviceInfo.getNodes().iterator();
- while(iterator.hasNext()) {
- NodeInfo nodeInfo = (NodeInfo)iterator.next();
+ for (NodeInfo nodeInfo: serviceInfo.getNodes()){
node.setIp(nodeInfo.getIp());
node.setPort(nodeInfo.getPort());
}
diff --git a/controlloop/common/msb/src/main/java/org/onap/policy/msb/client/MSBServiceManager.java b/controlloop/common/msb/src/main/java/org/onap/policy/msb/client/MSBServiceManager.java
index cbff8d88a..ccb13ece4 100644
--- a/controlloop/common/msb/src/main/java/org/onap/policy/msb/client/MSBServiceManager.java
+++ b/controlloop/common/msb/src/main/java/org/onap/policy/msb/client/MSBServiceManager.java
@@ -14,14 +14,11 @@
package org.onap.policy.msb.client;
import org.onap.msb.sdk.httpclient.msb.MSBServiceClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.Serializable;
public class MSBServiceManager implements Serializable {
- private static final Logger logger = LoggerFactory.getLogger(MSBServiceManager.class);
private static final long serialVersionUID = -2517971308551895215L;
private MSBServiceFactory factory;