summaryrefslogtreecommitdiffstats
path: root/applications/monitoring/src/test/java
diff options
context:
space:
mode:
authorMichael Mokry <michael.mokry@att.com>2019-04-10 09:53:44 -0500
committerPamela Dragosh <pdragosh@research.att.com>2019-04-10 23:14:16 -0400
commita9c7e7322eb09672c8dfba32503653d12e685543 (patch)
treec655701bb30f1276f3cae5b51fe91eefa3d3d7da /applications/monitoring/src/test/java
parentbfb8d12818346b96c9ab918e72327e1d13662321 (diff)
XACML PDP DmaaP Deploy/UnDeploy Function
1. Added PDPUpdate listener 2. Added PDPUpdate Publisher 3. Added code to handle PdpUpdate messages and load policies being deployed 4. Modified Activator to register listener 5. Provided placeholder code to get policies from pdpx for return PdpStatus response to the PAP 6. Other minor modifications 7. Fix XacmlPdpApplicationManager to only load policy if supports policy type. 8. Checkstyle fixes 9. Updated applications to support loadPolicy(ToscaPolicy) and all the translators, JUnit tests. 10. Consolidated some duplicate code in the applications. Can probably do more in that area. 11. Fixed bug in Properties not really having a copy constructor. Change-Id: Ic29ad426061cbdb79c1339314667bb8ff8decb88 Issue-ID: POLICY-1451 Signed-off-by: Michael Mokry <michael.mokry@att.com> Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'applications/monitoring/src/test/java')
-rw-r--r--applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java68
1 files changed, 16 insertions, 52 deletions
diff --git a/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java b/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java
index 8099ffdd..cc11dcf6 100644
--- a/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java
+++ b/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java
@@ -25,13 +25,8 @@ package org.onap.policy.xacml.pdp.application.monitoring;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
import java.util.Properties;
import java.util.ServiceLoader;
@@ -47,12 +42,12 @@ import org.onap.policy.common.utils.resources.TextFileUtils;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
import org.onap.policy.models.decisions.concepts.DecisionResponse;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.pdp.xacml.application.common.TestUtils;
import org.onap.policy.pdp.xacml.application.common.XacmlApplicationException;
import org.onap.policy.pdp.xacml.application.common.XacmlApplicationServiceProvider;
import org.onap.policy.pdp.xacml.application.common.XacmlPolicyUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.yaml.snakeyaml.Yaml;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class MonitoringPdpApplicationTest {
@@ -156,7 +151,6 @@ public class MonitoringPdpApplicationTest {
assertThat(response.getPolicies().size()).isEqualTo(0);
}
- @SuppressWarnings("unchecked")
@Test
public void test3AddvDnsPolicy() throws IOException, CoderException, XacmlApplicationException {
//
@@ -164,52 +158,22 @@ public class MonitoringPdpApplicationTest {
// the pdp can support it and have it load
// into the PDP.
//
- try (InputStream is = new FileInputStream("src/test/resources/vDNS.policy.input.yaml")) {
- //
- // Have yaml parse it
- //
- Yaml yaml = new Yaml();
- Map<String, Object> toscaObject = yaml.load(is);
- List<Object> policies = (List<Object>) toscaObject.get("policies");
- //
- // Sanity check to ensure the policy type and version are supported
- //
- for (Object policyObject : policies) {
- //
- // Get the contents
- //
- Map<String, Object> policyContents = (Map<String, Object>) policyObject;
- for (Entry<String, Object> entrySet : policyContents.entrySet()) {
- LOGGER.info("Entry set {}", entrySet.getKey());
- Map<String, Object> policyDefinition = (Map<String, Object>) entrySet.getValue();
- //
- // Find the type and make sure the engine supports it
- //
- assertThat(policyDefinition.containsKey("type")).isTrue();
- assertThat(service.canSupportPolicyType(
- new ToscaPolicyTypeIdentifier(
- policyDefinition.get("type").toString(),
- policyDefinition.get("version").toString())))
- .isTrue();
- }
- }
- //
- // Load the policies
- //
- service.loadPolicies(toscaObject);
- //
- // Ask for a decision
- //
- DecisionResponse response = service.makeDecision(requestSinglePolicy);
- LOGGER.info("Decision {}", response);
+ //
+ // Now load the optimization policies
+ //
+ TestUtils.loadPolicies("src/test/resources/vDNS.policy.input.yaml", service);
+ //
+ // Ask for a decision
+ //
+ DecisionResponse response = service.makeDecision(requestSinglePolicy);
+ LOGGER.info("Decision {}", response);
- assertThat(response).isNotNull();
- assertThat(response.getPolicies().size()).isEqualTo(1);
- //
- // Dump it out as Json
- //
- LOGGER.info(gson.encode(response));
- }
+ assertThat(response).isNotNull();
+ assertThat(response.getPolicies().size()).isEqualTo(1);
+ //
+ // Dump it out as Json
+ //
+ LOGGER.info(gson.encode(response));
}
@Test