aboutsummaryrefslogtreecommitdiffstats
path: root/ONAP-PAP-REST/src/main/java/org
diff options
context:
space:
mode:
authorbobbymander <bobby.mander@att.com>2019-10-31 15:08:36 -0400
committerbobbymander <bobby.mander@att.com>2019-11-05 09:21:05 -0500
commitf0d99cbc1c5969a6c51af5fe6dcfe546d3a6df66 (patch)
tree148cd98a72baec013c8c62c95dbf48afb75d9e23 /ONAP-PAP-REST/src/main/java/org
parent46b5b531eada52e963f9ca196473a6c1bd8cbf37 (diff)
More JUnit additions for PAP-REST
Issue-ID: POLICY-2130 Change-Id: Ia64bdbb377d26ba209b2d3fc51bc95f5769a7729 Signed-off-by: bobbymander <bobby.mander@att.com>
Diffstat (limited to 'ONAP-PAP-REST/src/main/java/org')
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/NotifyOtherPaps.java16
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/ImportService.java12
2 files changed, 13 insertions, 15 deletions
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/NotifyOtherPaps.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/NotifyOtherPaps.java
index c3171de39..cd290c66c 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/NotifyOtherPaps.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/NotifyOtherPaps.java
@@ -22,7 +22,6 @@
package org.onap.policy.pap.xacml.rest.components;
import com.att.research.xacml.util.XACMLProperties;
-
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
@@ -33,7 +32,6 @@ import java.util.Base64;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
-
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.rest.XacmlRestProperties;
@@ -58,7 +56,7 @@ public class NotifyOtherPaps {
*/
public void notifyOthers(long entityId, String entityType, String newGroupId) {
LOGGER.debug("notifyOthers(long entityId, String entityType, long newGroupId) as notifyOthers(" + entityId + ","
- + entityType + "," + newGroupId + ") called");
+ + entityType + "," + newGroupId + ") called");
failedPaps = new ArrayList<>();
List<?> otherServers = PolicyDbDao.getPolicyDbDaoInstance().getOtherServers();
@@ -70,7 +68,7 @@ public class NotifyOtherPaps {
}
}
- private void startNotifyThreads(List<?> otherServers, long entityId, String entityType, String newGroupId) {
+ protected void startNotifyThreads(List<?> otherServers, long entityId, String entityType, String newGroupId) {
LinkedList<Thread> notifyThreads = new LinkedList<>();
// we're going to run notifications in parallel threads to speed things
// up
@@ -144,11 +142,11 @@ public class NotifyOtherPaps {
return;
}
if (newGroupId == null) {
- url = new URL(otherPap + "?policydbdaourl=" + papUrl + "&entityid=" + entityId + "&entitytype="
- + entityType);
+ url = new URL(
+ otherPap + "?policydbdaourl=" + papUrl + "&entityid=" + entityId + "&entitytype=" + entityType);
} else {
url = new URL(otherPap + "?policydbdaourl=" + papUrl + "&entityid=" + entityId + "&entitytype="
- + entityType + "&extradata=" + newGroupId);
+ + entityType + "&extradata=" + newGroupId);
}
} catch (MalformedURLException e) {
LOGGER.warn("Caught MalformedURLException on: new URL()", e);
@@ -188,7 +186,7 @@ public class NotifyOtherPaps {
int readTimeout;
try {
readTimeout =
- Integer.parseInt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_NOTIFY_TIMEOUT));
+ Integer.parseInt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_NOTIFY_TIMEOUT));
} catch (Exception e) {
LOGGER.error("xacml.rest.pap.notify.timeoutms property not set, using a default.", e);
readTimeout = 10000;
@@ -217,7 +215,7 @@ public class NotifyOtherPaps {
LOGGER.info("PolicyDBDao: NotifyOtherThread received response 200 from pap server on notify");
} else {
LOGGER.warn("PolicyDBDao: NotifyOtherThread connection response code not 200, received: "
- + connection.getResponseCode());
+ + connection.getResponseCode());
failedPaps.add(dbdEntity);
}
} catch (Exception e) {
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/ImportService.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/ImportService.java
index d4801dfcf..050bcc561 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/ImportService.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/ImportService.java
@@ -30,10 +30,9 @@ import java.io.Writer;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
+import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import org.onap.policy.common.logging.eelf.PolicyLogger;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
@@ -74,7 +73,8 @@ public class ImportService {
StringBuilder builder = new StringBuilder();
int ch;
try {
- while ((ch = request.getInputStream().read()) != -1) {
+ ServletInputStream stream = request.getInputStream();
+ while ((ch = stream.read()) != -1) {
builder.append((char) ch);
}
} catch (IOException e) {
@@ -115,7 +115,7 @@ public class ImportService {
}
PolicyLogger.info("Request from API to import new Service");
try (Writer writer = new BufferedWriter(new OutputStreamWriter(
- new FileOutputStream(extractDir + File.separator + randomID + type), "utf-8"))) {
+ new FileOutputStream(extractDir + File.separator + randomID + type), "utf-8"))) {
writer.write(xmi);
} catch (IOException e) {
logger.error(e);
@@ -125,7 +125,7 @@ public class ImportService {
} else {
InputStream inputStream = null;
try (FileOutputStream outputStream =
- new FileOutputStream(extractDir + File.separator + randomID + ".zip")) {
+ new FileOutputStream(extractDir + File.separator + randomID + ".zip")) {
inputStream = request.getInputStream();
byte[] buffer = new byte[4096];
int bytesRead = -1;
@@ -178,7 +178,7 @@ public class ImportService {
}
PolicyLogger.info("Request from API to import new Optimization Service Model");
try (Writer writer = new BufferedWriter(new OutputStreamWriter(
- new FileOutputStream(extractDir + File.separator + randomID + type), "utf-8"))) {
+ new FileOutputStream(extractDir + File.separator + randomID + type), "utf-8"))) {
writer.write(yml);
} catch (IOException e) {
logger.error(e);