aboutsummaryrefslogtreecommitdiffstats
path: root/applications/monitoring/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'applications/monitoring/src/test')
-rw-r--r--applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java68
-rw-r--r--applications/monitoring/src/test/resources/vDNS.policy.input.yaml7
-rw-r--r--applications/monitoring/src/test/resources/xacml.properties11
3 files changed, 28 insertions, 58 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
diff --git a/applications/monitoring/src/test/resources/vDNS.policy.input.yaml b/applications/monitoring/src/test/resources/vDNS.policy.input.yaml
index 763af75f..7d8120e5 100644
--- a/applications/monitoring/src/test/resources/vDNS.policy.input.yaml
+++ b/applications/monitoring/src/test/resources/vDNS.policy.input.yaml
@@ -1,7 +1,8 @@
tosca_definitions_version: tosca_simple_yaml_1_0_0
-policies:
- -
- onap.scaleout.tca:
+topology_template:
+ policies:
+ -
+ onap.scaleout.tca:
type: onap.policies.monitoring.cdap.tca.hi.lo.app
version: 1.0.0
metadata:
diff --git a/applications/monitoring/src/test/resources/xacml.properties b/applications/monitoring/src/test/resources/xacml.properties
index 36eac3cd..5ea247cf 100644
--- a/applications/monitoring/src/test/resources/xacml.properties
+++ b/applications/monitoring/src/test/resources/xacml.properties
@@ -19,8 +19,13 @@ xacml.att.functionDefinitionFactory=com.att.research.xacmlatt.pdp.std.StdFunctio
#
xacml.att.policyFinderFactory=org.onap.policy.pdp.xacml.application.common.OnapPolicyFinderFactory
-# Policies to load
#
-xacml.rootPolicies=monitoring
-monitoring.file=../../packages/policy-xacmlpdp-tarball/src/main/resources/apps/monitoring/RootMonitoringPolicy.xml
+# Use a root combining algorithm
+#
+xacml.att.policyFinderFactory.combineRootPolicies=urn:com:att:xacml:3.0:policy-combining-algorithm:combined-permit-overrides
+#
+# Policies to load
+#
+xacml.rootPolicies=
+xacml.referencedPolicies= \ No newline at end of file