summaryrefslogtreecommitdiffstats
path: root/applications
diff options
context:
space:
mode:
Diffstat (limited to 'applications')
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyRequest.java8
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslator.java3
-rw-r--r--applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java25
3 files changed, 27 insertions, 9 deletions
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyRequest.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyRequest.java
index 3038b651..1acf741a 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyRequest.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyRequest.java
@@ -26,7 +26,6 @@ import com.att.research.xacml.std.annotations.XACMLAction;
import com.att.research.xacml.std.annotations.XACMLRequest;
import com.att.research.xacml.std.annotations.XACMLResource;
import com.att.research.xacml.std.annotations.XACMLSubject;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
@@ -59,6 +58,9 @@ public class StdCombinedPolicyRequest {
@XACMLResource(includeInResults = true)
private Collection<String> resource = new ArrayList<>();
+ @XACMLResource(attributeId = "urn:org:onap:policy-type", includeInResults = true)
+ private Collection<String> resourcePolicyType = new ArrayList<>();
+
public StdCombinedPolicyRequest() {
super();
}
@@ -102,7 +104,7 @@ public class StdCombinedPolicyRequest {
if (entrySet.getValue() instanceof Collection) {
addPolicyTypes(request, (Collection) entrySet.getValue());
} else if (entrySet.getValue() instanceof String) {
- request.resource.add(entrySet.getValue().toString());
+ request.resourcePolicyType.add(entrySet.getValue().toString());
}
}
}
@@ -118,7 +120,7 @@ public class StdCombinedPolicyRequest {
private static StdCombinedPolicyRequest addPolicyTypes(StdCombinedPolicyRequest request, Collection<Object> types) {
for (Object type : types) {
- request.resource.add(type.toString());
+ request.resourcePolicyType.add(type.toString());
}
return request;
}
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslator.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslator.java
index 2d7386d9..bd10fb2e 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslator.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslator.java
@@ -32,7 +32,6 @@ import com.att.research.xacml.api.Result;
import com.att.research.xacml.api.XACML3;
import com.att.research.xacml.std.annotations.RequestParser;
import com.google.gson.Gson;
-
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@@ -143,7 +142,7 @@ public class StdCombinedPolicyResultsTranslator implements ToscaPolicyTranslator
@Override
public DecisionResponse convertResponse(Response xacmlResponse) {
- LOGGER.debug("Converting Response {}", xacmlResponse);
+ LOGGER.info("Converting Response {}", xacmlResponse);
DecisionResponse decisionResponse = new DecisionResponse();
//
// Setup policies
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 04c9d20b..2ad83030 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,14 +25,12 @@ package org.onap.policy.xacml.pdp.application.monitoring;
import static org.assertj.core.api.Assertions.assertThat;
import com.att.research.xacml.api.Response;
-
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.ServiceLoader;
-
import org.apache.commons.lang3.tuple.Pair;
import org.junit.BeforeClass;
import org.junit.ClassRule;
@@ -62,6 +60,7 @@ public class MonitoringPdpApplicationTest {
private static File propertiesFile;
private static XacmlApplicationServiceProvider service;
private static DecisionRequest requestSinglePolicy;
+ private static DecisionRequest requestPolicyType;
private static StandardCoder gson = new StandardCoder();
@@ -82,6 +81,12 @@ public class MonitoringPdpApplicationTest {
TextFileUtils
.getTextFileAsString("../../main/src/test/resources/decisions/decision.single.input.json"),
DecisionRequest.class);
+ // Load Single Decision Request
+ //
+ requestPolicyType = gson.decode(
+ TextFileUtils
+ .getTextFileAsString("../../main/src/test/resources/decisions/decision.policytype.input.json"),
+ DecisionRequest.class);
//
// Setup our temporary folder
//
@@ -164,7 +169,7 @@ public class MonitoringPdpApplicationTest {
// into the PDP.
//
//
- // Now load the optimization policies
+ // Now load the monitoring policies
//
final List<ToscaPolicy> loadedPolicies = TestUtils.loadPolicies("src/test/resources/vDNS.policy.input.yaml",
service);
@@ -180,10 +185,22 @@ public class MonitoringPdpApplicationTest {
// Dump it out as Json
//
LOGGER.info(gson.encode(decision.getKey()));
- LOGGER.info("Now testing unloading of policy");
+ //
+ // Ask for a decision based on policy-type
+ //
+ decision = service.makeDecision(requestPolicyType);
+ LOGGER.info("Decision {}", decision);
+
+ assertThat(decision.getKey()).isNotNull();
+ assertThat(decision.getKey().getPolicies().size()).isEqualTo(1);
+ //
+ // Dump it out as Json
+ //
+ LOGGER.info(gson.encode(decision.getKey()));
//
// Now unload it
//
+ LOGGER.info("Now testing unloading of policy");
for (ToscaPolicy policy : loadedPolicies) {
assertThat(service.unloadPolicy(policy)).isTrue();
}