aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/test
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-03-17 15:10:17 -0400
committerJim Hahn <jrh3@att.com>2021-03-17 16:30:13 -0400
commit3e9fe84af892cd75c564da90481800a4131fc009 (patch)
tree8b54a93f852b43be17e43e909bd0ae8822a7a861 /main/src/test
parent2cb02e53d2eb0374b13b92e87afaf86b0b4c7383 (diff)
Change RestServerParameters to BusTopicParams
HTTP client parameters should be based on BusTopicParams instead of RestServerParameters, modified the policyApiParameters. Issue-ID: POLICY-3147 Change-Id: I73aa34bec3ab7e27e7a3474260f411ed55b6f933 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'main/src/test')
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/parameters/CommonTestData.java14
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterGroup.java39
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java4
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/rest/TestDecision.java4
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManagerTest.java8
-rw-r--r--main/src/test/resources/parameters/MinimumParameters.json2
-rw-r--r--main/src/test/resources/parameters/NoParameters.json4
-rw-r--r--main/src/test/resources/parameters/XacmlPdpConfigParameters.json2
-rw-r--r--main/src/test/resources/parameters/XacmlPdpConfigParameters_InvalidName.json4
-rw-r--r--main/src/test/resources/parameters/XacmlPdpConfigParameters_InvalidPdpGroup.json4
-rw-r--r--main/src/test/resources/parameters/XacmlPdpConfigParameters_InvalidPdpType.json4
-rw-r--r--main/src/test/resources/parameters/XacmlPdpConfigParameters_InvalidRestServerParameters.json2
-rw-r--r--main/src/test/resources/parameters/XacmlPdpConfigParameters_Std.json4
13 files changed, 49 insertions, 46 deletions
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/parameters/CommonTestData.java b/main/src/test/java/org/onap/policy/pdpx/main/parameters/CommonTestData.java
index 6f73df56..ca8b763d 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/parameters/CommonTestData.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/parameters/CommonTestData.java
@@ -27,7 +27,6 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.onap.policy.common.endpoints.parameters.TopicParameters;
-import org.onap.policy.common.parameters.ParameterGroup;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -41,9 +40,10 @@ public class CommonTestData {
private static final String PASS_KEY = "password";
private static final String USER_KEY = "userName";
private static final String PORT_KEY = "port";
- private static final String HOST_KEY = "host";
+ private static final String SERVER_HOST_KEY = "host";
+ private static final String API_HOST_KEY = "hostname";
private static final String AAF_KEY = "aaf";
- private static final String HTTPS_KEY = "https";
+ private static final String HTTPS_KEY = "useHttps";
private static final String REST_SERVER_PASS = "zb!XztG34";
private static final String REST_SERVER_USER = "healthcheck";
@@ -92,7 +92,7 @@ public class CommonTestData {
map.put(AAF_KEY, REST_SERVER_AAF);
if (!isEmpty) {
- map.put(HOST_KEY, REST_SERVER_HOST);
+ map.put(SERVER_HOST_KEY, REST_SERVER_HOST);
map.put(PORT_KEY, REST_SERVER_PORT);
map.put(USER_KEY, REST_SERVER_USER);
map.put(PASS_KEY, REST_SERVER_PASS);
@@ -111,7 +111,7 @@ public class CommonTestData {
final Map<String, Object> map = new TreeMap<>();
map.put(HTTPS_KEY, REST_SERVER_HTTPS);
map.put(AAF_KEY, REST_SERVER_AAF);
- map.put(HOST_KEY, REST_SERVER_HOST);
+ map.put(SERVER_HOST_KEY, REST_SERVER_HOST);
map.put(PORT_KEY, port);
map.put(USER_KEY, REST_SERVER_USER);
map.put(PASS_KEY, REST_SERVER_PASS);
@@ -126,7 +126,7 @@ public class CommonTestData {
* @param clazz class of object to be created from the map
* @return a new object represented by the map
*/
- public <T extends ParameterGroup> T toObject(final Map<String, Object> source, final Class<T> clazz) {
+ public <T> T toObject(final Map<String, Object> source, final Class<T> clazz) {
try {
return coder.decode(coder.encode(source), clazz);
@@ -147,7 +147,7 @@ public class CommonTestData {
map.put(AAF_KEY, POLICY_API_AAF);
if (!isEmpty) {
- map.put(HOST_KEY, POLICY_API_HOST);
+ map.put(API_HOST_KEY, POLICY_API_HOST);
map.put(PORT_KEY, POLICY_API_PORT);
map.put(USER_KEY, POLICY_API_USER);
map.put(PASS_KEY, POLICY_API_PASS);
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterGroup.java b/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterGroup.java
index dfd3216e..1c4cf1d0 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterGroup.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterGroup.java
@@ -22,6 +22,7 @@
package org.onap.policy.pdpx.main.parameters;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -32,6 +33,7 @@ import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
+import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.parameters.RestServerParameters;
import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
import org.onap.policy.common.parameters.GroupValidationResult;
@@ -57,8 +59,8 @@ public class TestXacmlPdpParameterGroup {
public void testXacmlPdpParameterGroup() throws IOException {
final RestServerParameters restServerParameters =
testData.toObject(testData.getRestServerParametersMap(false), RestServerParameters.class);
- final RestServerParameters policyApiParameters =
- testData.toObject(testData.getPolicyApiParametersMap(false), RestServerParameters.class);
+ final BusTopicParams policyApiParameters =
+ testData.toObject(testData.getPolicyApiParametersMap(false), BusTopicParams.class);
final TopicParameterGroup topicParameterGroup =
testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class);
final XacmlPdpParameterGroup pdpxParameters =
@@ -66,6 +68,7 @@ public class TestXacmlPdpParameterGroup {
CommonTestData.PDPX_GROUP, "flavor", restServerParameters, policyApiParameters,
topicParameterGroup, applicationPath.getAbsolutePath());
final GroupValidationResult validationResult = pdpxParameters.validate();
+ assertThat(validationResult.getResult()).isNull();
assertTrue(validationResult.isValid());
assertEquals(restServerParameters.getHost(), pdpxParameters.getRestServerParameters().getHost());
assertEquals(restServerParameters.getPort(), pdpxParameters.getRestServerParameters().getPort());
@@ -81,8 +84,8 @@ public class TestXacmlPdpParameterGroup {
public void testXacmlPdpParameterGroup_NullParameterGroupName() {
final RestServerParameters restServerParameters =
testData.toObject(testData.getRestServerParametersMap(false), RestServerParameters.class);
- final RestServerParameters policyApiParameters =
- testData.toObject(testData.getPolicyApiParametersMap(false), RestServerParameters.class);
+ final BusTopicParams policyApiParameters =
+ testData.toObject(testData.getPolicyApiParametersMap(false), BusTopicParams.class);
final TopicParameterGroup topicParameterGroup =
testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class);
final XacmlPdpParameterGroup pdpxParameters = new XacmlPdpParameterGroup(null, CommonTestData.PDPX_GROUP,
@@ -99,8 +102,8 @@ public class TestXacmlPdpParameterGroup {
public void testXacmlPdpParameterGroup_EmptyParameterGroupName() {
final RestServerParameters restServerParameters =
testData.toObject(testData.getRestServerParametersMap(false), RestServerParameters.class);
- final RestServerParameters policyApiParameters =
- testData.toObject(testData.getPolicyApiParametersMap(false), RestServerParameters.class);
+ final BusTopicParams policyApiParameters =
+ testData.toObject(testData.getPolicyApiParametersMap(false), BusTopicParams.class);
final TopicParameterGroup topicParameterGroup =
testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class);
final XacmlPdpParameterGroup pdpxParameters = new XacmlPdpParameterGroup("", CommonTestData.PDPX_GROUP,
@@ -117,8 +120,8 @@ public class TestXacmlPdpParameterGroup {
public void testXacmlPdpParameterGroup_NullPdpGroup() {
final RestServerParameters restServerParameters =
testData.toObject(testData.getRestServerParametersMap(false), RestServerParameters.class);
- final RestServerParameters policyApiParameters =
- testData.toObject(testData.getPolicyApiParametersMap(false), RestServerParameters.class);
+ final BusTopicParams policyApiParameters =
+ testData.toObject(testData.getPolicyApiParametersMap(false), BusTopicParams.class);
final TopicParameterGroup topicParameterGroup =
testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class);
final XacmlPdpParameterGroup pdpxParameters =
@@ -136,8 +139,8 @@ public class TestXacmlPdpParameterGroup {
public void testXacmlPdpParameterGroup_EmptyPdpGroup() {
final RestServerParameters restServerParameters =
testData.toObject(testData.getRestServerParametersMap(false), RestServerParameters.class);
- final RestServerParameters policyApiParameters =
- testData.toObject(testData.getPolicyApiParametersMap(false), RestServerParameters.class);
+ final BusTopicParams policyApiParameters =
+ testData.toObject(testData.getPolicyApiParametersMap(false), BusTopicParams.class);
final TopicParameterGroup topicParameterGroup =
testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class);
final XacmlPdpParameterGroup pdpxParameters =
@@ -155,8 +158,8 @@ public class TestXacmlPdpParameterGroup {
public void testXacmlPdpParameterGroup_EmptyRestServerParameters() {
final RestServerParameters restServerParameters =
testData.toObject(testData.getRestServerParametersMap(true), RestServerParameters.class);
- final RestServerParameters policyApiParameters =
- testData.toObject(testData.getPolicyApiParametersMap(false), RestServerParameters.class);
+ final BusTopicParams policyApiParameters =
+ testData.toObject(testData.getPolicyApiParametersMap(false), BusTopicParams.class);
final TopicParameterGroup topicParameterGroup =
testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class);
final XacmlPdpParameterGroup pdpxParameters =
@@ -173,8 +176,8 @@ public class TestXacmlPdpParameterGroup {
public void testXacmlPdpParameterGroup_EmptyPolicyApiParameters() {
final RestServerParameters restServerParameters =
testData.toObject(testData.getRestServerParametersMap(false), RestServerParameters.class);
- final RestServerParameters policyApiParameters =
- testData.toObject(testData.getPolicyApiParametersMap(true), RestServerParameters.class);
+ final BusTopicParams policyApiParameters =
+ testData.toObject(testData.getPolicyApiParametersMap(true), BusTopicParams.class);
final TopicParameterGroup topicParameterGroup =
testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class);
final XacmlPdpParameterGroup pdpxParameters =
@@ -183,16 +186,16 @@ public class TestXacmlPdpParameterGroup {
topicParameterGroup, applicationPath.getAbsolutePath());
final GroupValidationResult validationResult = pdpxParameters.validate();
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult()
- .contains("parameter group \"policyApiParameters\""));
+ assertThat(validationResult.getResult())
+ .contains("field \"policyApiParameters\"");
}
@Test
public void testXacmlPdpParameterGroup_EmptyTopicParameterGroup() {
final RestServerParameters restServerParameters =
testData.toObject(testData.getRestServerParametersMap(false), RestServerParameters.class);
- final RestServerParameters policyApiParameters =
- testData.toObject(testData.getPolicyApiParametersMap(false), RestServerParameters.class);
+ final BusTopicParams policyApiParameters =
+ testData.toObject(testData.getPolicyApiParametersMap(false), BusTopicParams.class);
final TopicParameterGroup topicParameterGroup =
testData.toObject(testData.getTopicParametersMap(true), TopicParameterGroup.class);
final XacmlPdpParameterGroup pdpxParameters =
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java
index dbf977f2..93e541de 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java
@@ -84,7 +84,7 @@ public class TestAbbreviateDecisionResults {
private static File propertiesFile;
private static XacmlApplicationServiceProvider service;
- private static RestServerParameters policyApiParameters;
+ private static BusTopicParams policyApiParameters;
@ClassRule
public static final TemporaryFolder appsFolder = new TemporaryFolder();
@@ -116,7 +116,7 @@ public class TestAbbreviateDecisionResults {
// Create parameters for XacmlPdPService
RestServerParameters rest = testData.toObject(testData.getRestServerParametersMap(port),
RestServerParameters.class);
- policyApiParameters = testData.toObject(testData.getPolicyApiParametersMap(false), RestServerParameters.class);
+ policyApiParameters = testData.toObject(testData.getPolicyApiParametersMap(false), BusTopicParams.class);
TopicParameterGroup topicParameterGroup = testData.toObject(testData.getTopicParametersMap(false),
TopicParameterGroup.class);
XacmlPdpParameterGroup params =
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestDecision.java b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestDecision.java
index 2d71543c..7fa552f4 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestDecision.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestDecision.java
@@ -104,8 +104,8 @@ public class TestDecision {
//
RestServerParameters rest =
testData.toObject(testData.getRestServerParametersMap(port), RestServerParameters.class);
- RestServerParameters policyApiParameters =
- testData.toObject(testData.getPolicyApiParametersMap(false), RestServerParameters.class);
+ BusTopicParams policyApiParameters =
+ testData.toObject(testData.getPolicyApiParametersMap(false), BusTopicParams.class);
TopicParameterGroup topicParameterGroup =
testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class);
XacmlPdpParameterGroup params =
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManagerTest.java b/main/src/test/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManagerTest.java
index 4670e785..1673c043 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManagerTest.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManagerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,7 +35,7 @@ import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
-import org.onap.policy.common.endpoints.parameters.RestServerParameters;
+import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardYamlCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
@@ -53,7 +53,7 @@ import org.slf4j.LoggerFactory;
public class XacmlPdpApplicationManagerTest {
private static final Logger LOGGER = LoggerFactory.getLogger(XacmlPdpApplicationManagerTest.class);
private static final StandardYamlCoder yamlCoder = new StandardYamlCoder();
- private static final RestServerParameters params = new RestServerParameters();
+ private static final BusTopicParams params = new BusTopicParams();
private static Path appsDirectory;
private static ToscaServiceTemplate completedJtst;
@@ -70,7 +70,7 @@ public class XacmlPdpApplicationManagerTest {
//
// No need to do more than this
//
- params.setName("policyApiParameters");
+ params.setClientName("policyApiParameters");
//
// Load an example policy
//
diff --git a/main/src/test/resources/parameters/MinimumParameters.json b/main/src/test/resources/parameters/MinimumParameters.json
index 487a18d1..48706b85 100644
--- a/main/src/test/resources/parameters/MinimumParameters.json
+++ b/main/src/test/resources/parameters/MinimumParameters.json
@@ -9,7 +9,7 @@
"password": "zb!XztG34"
},
"policyApiParameters": {
- "host": "0.0.0.0",
+ "hostname": "0.0.0.0",
"port": 6970,
"userName": "healthcheck",
"password": "zb!XztG34"
diff --git a/main/src/test/resources/parameters/NoParameters.json b/main/src/test/resources/parameters/NoParameters.json
index 1b25951c..89e2b27f 100644
--- a/main/src/test/resources/parameters/NoParameters.json
+++ b/main/src/test/resources/parameters/NoParameters.json
@@ -6,7 +6,7 @@
"password": "zb!XztG34"
},
"policyApiParameters": {
- "host": "0.0.0.0",
+ "hostname": "0.0.0.0",
"port": 6970,
"userName": "healthcheck",
"password": "zb!XztG34"
@@ -23,4 +23,4 @@
"topicCommInfrastructure" : "noop"
}]
}
-} \ No newline at end of file
+}
diff --git a/main/src/test/resources/parameters/XacmlPdpConfigParameters.json b/main/src/test/resources/parameters/XacmlPdpConfigParameters.json
index a1376464..9ccd732b 100644
--- a/main/src/test/resources/parameters/XacmlPdpConfigParameters.json
+++ b/main/src/test/resources/parameters/XacmlPdpConfigParameters.json
@@ -9,7 +9,7 @@
"password": "zb!XztG34"
},
"policyApiParameters": {
- "host": "0.0.0.0",
+ "hostname": "0.0.0.0",
"port": 6970,
"userName": "healthcheck",
"password": "zb!XztG34"
diff --git a/main/src/test/resources/parameters/XacmlPdpConfigParameters_InvalidName.json b/main/src/test/resources/parameters/XacmlPdpConfigParameters_InvalidName.json
index dcc5cd93..ca779723 100644
--- a/main/src/test/resources/parameters/XacmlPdpConfigParameters_InvalidName.json
+++ b/main/src/test/resources/parameters/XacmlPdpConfigParameters_InvalidName.json
@@ -9,7 +9,7 @@
"https":true
},
"policyApiParameters": {
- "host": "0.0.0.0",
+ "hostname": "0.0.0.0",
"port": 6970,
"userName": "healthcheck",
"password": "zb!XztG34"
@@ -27,4 +27,4 @@
"topicCommInfrastructure" : "noop"
}]
}
-} \ No newline at end of file
+}
diff --git a/main/src/test/resources/parameters/XacmlPdpConfigParameters_InvalidPdpGroup.json b/main/src/test/resources/parameters/XacmlPdpConfigParameters_InvalidPdpGroup.json
index 18e486d5..3e1d4f57 100644
--- a/main/src/test/resources/parameters/XacmlPdpConfigParameters_InvalidPdpGroup.json
+++ b/main/src/test/resources/parameters/XacmlPdpConfigParameters_InvalidPdpGroup.json
@@ -9,7 +9,7 @@
"https":true
},
"policyApiParameters": {
- "host": "0.0.0.0",
+ "hostname": "0.0.0.0",
"port": 6970,
"userName": "healthcheck",
"password": "zb!XztG34"
@@ -27,4 +27,4 @@
"topicCommInfrastructure" : "noop"
}]
}
-} \ No newline at end of file
+}
diff --git a/main/src/test/resources/parameters/XacmlPdpConfigParameters_InvalidPdpType.json b/main/src/test/resources/parameters/XacmlPdpConfigParameters_InvalidPdpType.json
index 803b789c..d0c429c2 100644
--- a/main/src/test/resources/parameters/XacmlPdpConfigParameters_InvalidPdpType.json
+++ b/main/src/test/resources/parameters/XacmlPdpConfigParameters_InvalidPdpType.json
@@ -10,7 +10,7 @@
"https":true
},
"policyApiParameters": {
- "host": "0.0.0.0",
+ "hostname": "0.0.0.0",
"port": 6970,
"userName": "healthcheck",
"password": "zb!XztG34"
@@ -28,4 +28,4 @@
"topicCommInfrastructure" : "noop"
}]
}
-} \ No newline at end of file
+}
diff --git a/main/src/test/resources/parameters/XacmlPdpConfigParameters_InvalidRestServerParameters.json b/main/src/test/resources/parameters/XacmlPdpConfigParameters_InvalidRestServerParameters.json
index 4aad68b2..8211c8e6 100644
--- a/main/src/test/resources/parameters/XacmlPdpConfigParameters_InvalidRestServerParameters.json
+++ b/main/src/test/resources/parameters/XacmlPdpConfigParameters_InvalidRestServerParameters.json
@@ -8,7 +8,7 @@
"password": ""
},
"policyApiParameters": {
- "host": "0.0.0.0",
+ "hostname": "0.0.0.0",
"port": 6970,
"userName": "healthcheck",
"password": "zb!XztG34"
diff --git a/main/src/test/resources/parameters/XacmlPdpConfigParameters_Std.json b/main/src/test/resources/parameters/XacmlPdpConfigParameters_Std.json
index ec898b6f..33885b50 100644
--- a/main/src/test/resources/parameters/XacmlPdpConfigParameters_Std.json
+++ b/main/src/test/resources/parameters/XacmlPdpConfigParameters_Std.json
@@ -10,7 +10,7 @@
"https":true
},
"policyApiParameters": {
- "host": "0.0.0.0",
+ "hostname": "0.0.0.0",
"port": 6970,
"userName": "healthcheck",
"password": "zb!XztG34"
@@ -28,4 +28,4 @@
"topicCommInfrastructure" : "noop"
}]
}
-} \ No newline at end of file
+}