summaryrefslogtreecommitdiffstats
path: root/applications/optimization/src
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2019-04-12 11:03:44 -0400
committerPamela Dragosh <pdragosh@research.att.com>2019-04-12 20:28:17 -0400
commit70736cfbf6ad1a068f8ee53adddd4faa3b6fa8a8 (patch)
tree6f883bb4cf79cd18eaac33c46446ac86a42934ce /applications/optimization/src
parenta5b035d9bb633cf5d520a62c451250db4b018a13 (diff)
Add statistics and sonar cleanup and blacklist
* Adding in the statistics for decisions and errors. * Cleaned up sonar issues and added code coverage. * Sped up JUnit tests * Fix JUnit issues with not finding application path * Fix TestDecision not finding persistence.xml * Fix for lingering statistics from previous runs. That needs to be addressed at a later time. * Changed persistence to use properties for configuration of database rather than hard coding the persistence.xml * Fix for Josh's comment to use else-if * Changed to use apache Pair * Added blacklist guard policy Issue-ID: POLICY-1440 Change-Id: I56af8c3dcc82463f7381f1eaea7f1440b76200bd Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'applications/optimization/src')
-rw-r--r--applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java1
-rw-r--r--applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java21
2 files changed, 13 insertions, 9 deletions
diff --git a/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java b/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java
index 337b40d7..91c46746 100644
--- a/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java
+++ b/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java
@@ -93,6 +93,7 @@ public class OptimizationPdpApplication extends StdXacmlApplicationServiceProvid
//
for (ToscaPolicyTypeIdentifier supported : this.supportedPolicyTypes) {
if (policyTypeId.equals(supported)) {
+ LOGGER.info("optimization can support {}", supported);
return true;
}
}
diff --git a/applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java b/applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java
index 046aaa66..6d1afda6 100644
--- a/applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java
+++ b/applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java
@@ -24,6 +24,8 @@ package org.onap.policy.xacml.pdp.application.optimization;
import static org.assertj.core.api.Assertions.assertThat;
+import com.att.research.xacml.api.Response;
+
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -31,6 +33,7 @@ import java.util.Iterator;
import java.util.Properties;
import java.util.ServiceLoader;
+import org.apache.commons.lang3.tuple.Pair;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.FixMethodOrder;
@@ -147,11 +150,11 @@ public class OptimizationPdpApplicationTest {
//
// Ask for a decision
//
- DecisionResponse response = service.makeDecision(requestAffinity);
- LOGGER.info("Decision {}", response);
+ Pair<DecisionResponse, Response> decision = service.makeDecision(requestAffinity);
+ LOGGER.info("Decision {}", decision.getKey());
- assertThat(response).isNotNull();
- assertThat(response.getPolicies().size()).isEqualTo(0);
+ assertThat(decision.getKey()).isNotNull();
+ assertThat(decision.getKey().getPolicies().size()).isEqualTo(0);
}
@Test
@@ -164,14 +167,14 @@ public class OptimizationPdpApplicationTest {
//
// Ask for a decision
//
- DecisionResponse response = service.makeDecision(requestAffinity);
- LOGGER.info("Decision {}", response);
+ Pair<DecisionResponse, Response> decision = service.makeDecision(requestAffinity);
+ LOGGER.info("Decision {}", decision.getKey());
- assertThat(response).isNotNull();
- assertThat(response.getPolicies().size()).isEqualTo(1);
+ assertThat(decision.getKey()).isNotNull();
+ assertThat(decision.getKey().getPolicies().size()).isEqualTo(1);
//
// Dump it out as Json
//
- LOGGER.info(gson.encode(response));
+ LOGGER.info(gson.encode(decision.getKey()));
}
}