aboutsummaryrefslogtreecommitdiffstats
path: root/applications/optimization/src/test/java/org/onap
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2019-08-30 15:21:05 -0400
committerPamela Dragosh <pdragosh@research.att.com>2019-09-09 15:27:30 -0400
commit85b5178017e89c815af7792826f52a90814f5dba (patch)
tree1cc49f6763f1af2cab372bb75ae6b9e5391c3ad7 /applications/optimization/src/test/java/org/onap
parentdc68da3c00c0a814110e0f7529365d695bff571b (diff)
Integrate using Policy Type to find Matchable
Utilize's Jim's helper class to pull from API policy types definitions so that Xacml PDP can determine which properties are "matchable". Override initialize to set translator parameters. Utilize the metadata section of ToscaProperties to store the matchable field. Updated Matchable Request to be dynamic with respect to the incoming resource attributes. Stored the policy types as JSON. Issue-ID: POLICY-1899 Change-Id: Icff3605495b0a34ebfcdfa54346095ce2d8468a4 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'applications/optimization/src/test/java/org/onap')
-rw-r--r--applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java26
1 files changed, 22 insertions, 4 deletions
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 6d1afda6..a356926d 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
@@ -23,16 +23,18 @@
package org.onap.policy.xacml.pdp.application.optimization;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
import com.att.research.xacml.api.Response;
-
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
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;
@@ -40,6 +42,7 @@ import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runners.MethodSorters;
+import org.onap.policy.common.endpoints.parameters.RestServerParameters;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.resources.TextFileUtils;
@@ -62,6 +65,11 @@ public class OptimizationPdpApplicationTest {
private static XacmlApplicationServiceProvider service;
private static StandardCoder gson = new StandardCoder();
private static DecisionRequest requestAffinity;
+ private static RestServerParameters clientParams;
+ private static String[] listPolicyTypeFiles = { "onap.policies.Optimization",
+ "onap.policies.optimization.AffinityPolicy",
+ "onap.policies.optimization.DistancePolicy",
+ "onap.policies.optimization.SubscriberPolicy"};
@ClassRule
public static final TemporaryFolder policyFolder = new TemporaryFolder();
@@ -73,6 +81,9 @@ public class OptimizationPdpApplicationTest {
*/
@BeforeClass
public static void setUp() throws Exception {
+ clientParams = mock(RestServerParameters.class);
+ when(clientParams.getHost()).thenReturn("localhost");
+ when(clientParams.getPort()).thenReturn(6969);
//
// Load Single Decision Request
//
@@ -88,6 +99,13 @@ public class OptimizationPdpApplicationTest {
propertiesFile = XacmlPolicyUtils.copyXacmlPropertiesContents("src/test/resources/xacml.properties",
properties, myCreator);
//
+ // Copy the test policy types into data area
+ //
+ for (String policy : listPolicyTypeFiles) {
+ Files.copy(Paths.get("src/test/resources", policy + "-1.0.0.json"),
+ Paths.get(policyFolder.getRoot().getAbsolutePath(), policy + "-1.0.0.json"));
+ }
+ //
// Load service
//
ServiceLoader<XacmlApplicationServiceProvider> applicationLoader =
@@ -121,7 +139,7 @@ public class OptimizationPdpApplicationTest {
// Tell it to initialize based on the properties file
// we just built for it.
//
- service.initialize(propertiesFile.toPath().getParent());
+ service.initialize(propertiesFile.toPath().getParent(), clientParams);
}
@Test
@@ -171,7 +189,7 @@ public class OptimizationPdpApplicationTest {
LOGGER.info("Decision {}", decision.getKey());
assertThat(decision.getKey()).isNotNull();
- assertThat(decision.getKey().getPolicies().size()).isEqualTo(1);
+ assertThat(decision.getKey().getPolicies().size()).isEqualTo(4);
//
// Dump it out as Json
//