diff options
author | 2017-12-14 15:58:32 -0800 | |
---|---|---|
committer | 2017-12-15 09:09:12 -0800 | |
commit | 4c8000e91a9dee0738e55e2bda930b94af474157 (patch) | |
tree | 578fdc9102ea43ad4765ba2d2dbb1322b24a37a2 /controlloop/common/guard/src/main/java/org | |
parent | 5cfd3b7066e6a6305e140fa59b1fccb8e3c5f81b (diff) |
Add guard junits
Added a few junit files which test most functionality in the guard
submodule. Some minor bugs were found by the junits and fixed those
newly found bugs. Added persistence.xml for use by junits in guard.
Issue-ID: POLICY-490
Change-Id: Ied7e276cfd417e1f396b5a6685a2e9acc9efd109
Signed-off-by: Temoc Rodriguez <cr056n@att.com>
Diffstat (limited to 'controlloop/common/guard/src/main/java/org')
4 files changed, 11 insertions, 6 deletions
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java index 9b2644b95..6ba1a5a5f 100644 --- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java +++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java @@ -338,7 +338,7 @@ public class PIPEngineGetHistory extends StdConfigurableEngine{ }catch(Exception ex){ logger.error("PIP thread got Exception. Can't connect to Operations History DB -- {}", OpsHistPU); logger.error("getCountFromDB threw: ", ex); - return 0; + return -1; } DateUtil dateUtil = new DateUtil(){ @@ -406,9 +406,9 @@ public class PIPEngineGetHistory extends StdConfigurableEngine{ + " and endtime between '" + new Timestamp(diff) + "' and '" + new Timestamp(now) + "'"; Query nq = em.createNativeQuery(sql); - nq.setParameter(0, actor); - nq.setParameter(1, operation); - nq.setParameter(2, target); + nq.setParameter(1, actor); + nq.setParameter(2, operation); + nq.setParameter(3, target); int ret = -1; try{ diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java index 0703b7611..cbaa8edde 100644 --- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java +++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java @@ -104,12 +104,12 @@ public class PolicyGuardXacmlHelper { jsonReq.put("decisionAttributes", attributes); jsonReq.put("onapName", "PDPD"); - URLEntry urlEntry = restUrls[restUrlIndex]; try { // // Call RESTful PDP // + URLEntry urlEntry = restUrls[restUrlIndex]; netLogger.info("[OUT|{}|{}|]{}{}", "GUARD", urlEntry.restURL, System.lineSeparator(), jsonReq.toString()); response = callRESTfulPDP(new ByteArrayInputStream(jsonReq .toString().getBytes()), urlEntry.restURL, diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardYamlToXacml.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardYamlToXacml.java index 72b723c1f..aef86f320 100644 --- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardYamlToXacml.java +++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardYamlToXacml.java @@ -244,7 +244,7 @@ public class PolicyGuardYamlToXacml { xacmlFileContent = m.replaceAll("<AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">" + target + "</AttributeValue>" - + "\n\t\t\t\t\t\t\\$\\{blackListElement\\}"); + + "\n\t\t\t\t\t\t\\$\\{blackListElement\\}\n"); } p = Pattern.compile("\t\t\t\t\t\t\\$\\{blackListElement\\}\n"); diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java index ca62f6149..93bdc0c37 100644 --- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java +++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java @@ -68,6 +68,11 @@ public final class Util { public static final String PERMIT = "Permit"; public static final String DENY = "Deny"; + /* + * Junit props + */ + protected static final String PU_KEY = "OperationsHistoryPU"; + protected static final String JUNITPU = "TestOperationsHistoryPU"; private static final Logger logger = LoggerFactory.getLogger(Util.class); public static class Pair<A, B> { |