aboutsummaryrefslogtreecommitdiffstats
path: root/models-sim/policy-models-sim-pdp/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'models-sim/policy-models-sim-pdp/src/test')
-rw-r--r--models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/TestPdpSimulatorActivator.java11
-rw-r--r--models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/TestPdpSimulatorMain.java3
-rw-r--r--models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/comm/TestPdpStateChangeListener.java12
-rw-r--r--models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/comm/TestPdpUpdateListener.java12
-rw-r--r--models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/CommonTestData.java33
-rw-r--r--models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpSimulatorParameterGroup.java19
-rw-r--r--models-sim/policy-models-sim-pdp/src/test/resources/PdpSimulatorConfigParameters.json28
-rw-r--r--models-sim/policy-models-sim-pdp/src/test/resources/PdpSimulatorConfigParameters_sim.json12
-rw-r--r--models-sim/policy-models-sim-pdp/src/test/resources/TestConfigParameters.json28
-rw-r--r--models-sim/policy-models-sim-pdp/src/test/resources/topic.properties22
-rw-r--r--models-sim/policy-models-sim-pdp/src/test/resources/topic_sim.properties22
11 files changed, 130 insertions, 72 deletions
diff --git a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/TestPdpSimulatorActivator.java b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/TestPdpSimulatorActivator.java
index e75bb6d26..dbf7bbcea 100644
--- a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/TestPdpSimulatorActivator.java
+++ b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/TestPdpSimulatorActivator.java
@@ -33,6 +33,7 @@ import java.util.Properties;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.onap.policy.common.endpoints.utils.ParameterUtils;
import org.onap.policy.common.utils.services.Registry;
import org.onap.policy.models.pdp.concepts.PdpStatus;
import org.onap.policy.models.sim.pdp.exception.PdpSimulatorException;
@@ -57,18 +58,12 @@ public class TestPdpSimulatorActivator {
@Before
public void setUp() throws Exception {
Registry.newRegistry();
- final String[] pdpSimulatorConfigParameters = { "-c", "src/test/resources/PdpSimulatorConfigParameters.json",
- "-p", "src/test/resources/topic.properties" };
+ final String[] pdpSimulatorConfigParameters = { "-c", "src/test/resources/PdpSimulatorConfigParameters.json" };
final PdpSimulatorCommandLineArguments arguments =
new PdpSimulatorCommandLineArguments(pdpSimulatorConfigParameters);
final PdpSimulatorParameterGroup parGroup = new PdpSimulatorParameterHandler().getParameters(arguments);
- final Properties props = new Properties();
- final String propFile = arguments.getFullPropertyFilePath();
- try (FileInputStream stream = new FileInputStream(propFile)) {
- props.load(stream);
- }
-
+ final Properties props = ParameterUtils.getTopicProperties(parGroup.getTopicParameterGroup());
activator = new PdpSimulatorActivator(parGroup, props);
}
diff --git a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/TestPdpSimulatorMain.java b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/TestPdpSimulatorMain.java
index 7a3239891..4b7944436 100644
--- a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/TestPdpSimulatorMain.java
+++ b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/TestPdpSimulatorMain.java
@@ -64,8 +64,7 @@ public class TestPdpSimulatorMain {
@Test
public void testPdpSimulator() throws PdpSimulatorException {
- final String[] pdpSimulatorConfigParameters = { "-c", "src/test/resources/PdpSimulatorConfigParameters.json",
- "-p", "src/test/resources/topic.properties" };
+ final String[] pdpSimulatorConfigParameters = { "-c", "src/test/resources/PdpSimulatorConfigParameters.json" };
pdpSimulator = new PdpSimulatorMain(pdpSimulatorConfigParameters);
assertTrue(pdpSimulator.getParameters().isValid());
assertEquals(CommonTestData.PDP_SIMULATOR_GROUP_NAME, pdpSimulator.getParameters().getName());
diff --git a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/comm/TestPdpStateChangeListener.java b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/comm/TestPdpStateChangeListener.java
index 324edd7c5..2b3704738 100644
--- a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/comm/TestPdpStateChangeListener.java
+++ b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/comm/TestPdpStateChangeListener.java
@@ -23,7 +23,6 @@ package org.onap.policy.models.sim.pdp.comm;
import static org.junit.Assert.assertEquals;
-import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
@@ -37,6 +36,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.endpoints.utils.ParameterUtils;
import org.onap.policy.common.utils.services.Registry;
import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpStatus;
@@ -73,8 +73,7 @@ public class TestPdpStateChangeListener {
pdpUpdateMessageListener = new PdpUpdateListener();
pdpStateChangeListener = new PdpStateChangeListener();
Registry.newRegistry();
- final String[] pdpSimulatorConfigParameters = { "-c", "src/test/resources/PdpSimulatorConfigParameters.json",
- "-p", "src/test/resources/topic.properties" };
+ final String[] pdpSimulatorConfigParameters = { "-c", "src/test/resources/PdpSimulatorConfigParameters.json" };
final PdpSimulatorCommandLineArguments arguments = new PdpSimulatorCommandLineArguments();
PdpSimulatorParameterGroup pdpSimulatorParameterGroup;
// The arguments return a string if there is a message to print and we should
@@ -90,11 +89,8 @@ public class TestPdpStateChangeListener {
pdpSimulatorParameterGroup = new PdpSimulatorParameterHandler().getParameters(arguments);
// Read the properties
- final Properties topicProperties = new Properties();
- final String propFile = arguments.getFullPropertyFilePath();
- try (FileInputStream stream = new FileInputStream(propFile)) {
- topicProperties.load(stream);
- }
+ final Properties topicProperties =
+ ParameterUtils.getTopicProperties(pdpSimulatorParameterGroup.getTopicParameterGroup());
activator = new PdpSimulatorActivator(pdpSimulatorParameterGroup, topicProperties);
Registry.register(PdpSimulatorConstants.REG_PDP_SIMULATOR_ACTIVATOR, activator);
activator.initialize();
diff --git a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/comm/TestPdpUpdateListener.java b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/comm/TestPdpUpdateListener.java
index e5eebf066..9ae8d370a 100644
--- a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/comm/TestPdpUpdateListener.java
+++ b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/comm/TestPdpUpdateListener.java
@@ -23,7 +23,6 @@ package org.onap.policy.models.sim.pdp.comm;
import static org.junit.Assert.assertEquals;
-import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
@@ -37,6 +36,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.endpoints.utils.ParameterUtils;
import org.onap.policy.common.utils.services.Registry;
import org.onap.policy.models.pdp.concepts.PdpStatus;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
@@ -67,8 +67,7 @@ public class TestPdpUpdateListener {
@Before
public void setUp() throws Exception {
Registry.newRegistry();
- final String[] pdpSimulatorConfigParameters = { "-c", "src/test/resources/PdpSimulatorConfigParameters.json",
- "-p", "src/test/resources/topic.properties" };
+ final String[] pdpSimulatorConfigParameters = { "-c", "src/test/resources/PdpSimulatorConfigParameters.json" };
final PdpSimulatorCommandLineArguments arguments = new PdpSimulatorCommandLineArguments();
PdpSimulatorParameterGroup pdpSimulatorParameterGroup;
// The arguments return a string if there is a message to print and we should
@@ -84,11 +83,8 @@ public class TestPdpUpdateListener {
pdpSimulatorParameterGroup = new PdpSimulatorParameterHandler().getParameters(arguments);
// Read the properties
- final Properties topicProperties = new Properties();
- final String propFile = arguments.getFullPropertyFilePath();
- try (FileInputStream stream = new FileInputStream(propFile)) {
- topicProperties.load(stream);
- }
+ final Properties topicProperties =
+ ParameterUtils.getTopicProperties(pdpSimulatorParameterGroup.getTopicParameterGroup());
activator = new PdpSimulatorActivator(pdpSimulatorParameterGroup, topicProperties);
Registry.register(PdpSimulatorConstants.REG_PDP_SIMULATOR_ACTIVATOR, activator);
activator.initialize();
diff --git a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/CommonTestData.java b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/CommonTestData.java
index e0da3d805..123aa4444 100644
--- a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/CommonTestData.java
+++ b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/CommonTestData.java
@@ -25,7 +25,7 @@ import java.util.Arrays;
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;
@@ -48,6 +48,7 @@ public class CommonTestData {
public static final String POLICY_VERSION = "0.0.1";
protected static final List<ToscaPolicyTypeIdentifierParameters> SUPPORTED_POLICY_TYPES =
Arrays.asList(getSupportedPolicyTypes(POLICY_NAME, POLICY_VERSION));
+ public static final List<TopicParameters> TOPIC_PARAMS = Arrays.asList(getTopicParams());
private static final String REST_SERVER_PASS = "zb!XztG34";
private static final String REST_SERVER_USER = "healthcheck";
private static final int REST_SERVER_PORT = 6969;
@@ -70,6 +71,19 @@ public class CommonTestData {
}
/**
+ * Returns topic parameters for test cases.
+ *
+ * @return topic parameters
+ */
+ public static TopicParameters getTopicParams() {
+ final TopicParameters topicParams = new TopicParameters();
+ topicParams.setTopic("POLICY-PDP-PAP");
+ topicParams.setTopicCommInfrastructure("dmaap");
+ topicParams.setServers(Arrays.asList("message-router"));
+ return topicParams;
+ }
+
+ /**
* Converts the contents of a map to a parameter class.
*
* @param source property map
@@ -98,7 +112,7 @@ public class CommonTestData {
map.put("name", name);
map.put("restServerParameters", getRestServerParametersMap(false));
map.put("pdpStatusParameters", getPdpStatusParametersMap(false));
-
+ map.put("topicParameterGroup", getTopicParametersMap(false));
return map;
}
@@ -142,4 +156,19 @@ public class CommonTestData {
return map;
}
+
+ /**
+ * Returns a property map for a TopicParameters map for test cases.
+ *
+ * @param isEmpty boolean value to represent that object created should be empty or not
+ * @return a property map suitable for constructing an object
+ */
+ public Map<String, Object> getTopicParametersMap(final boolean isEmpty) {
+ final Map<String, Object> map = new TreeMap<>();
+ if (!isEmpty) {
+ map.put("topicSources", TOPIC_PARAMS);
+ map.put("topicSinks", TOPIC_PARAMS);
+ }
+ return map;
+ }
}
diff --git a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpSimulatorParameterGroup.java b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpSimulatorParameterGroup.java
index b4a54b8ae..df24f3eb9 100644
--- a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpSimulatorParameterGroup.java
+++ b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpSimulatorParameterGroup.java
@@ -27,6 +27,7 @@ import static org.junit.Assert.assertTrue;
import java.util.Map;
import org.junit.Test;
+import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
import org.onap.policy.common.parameters.GroupValidationResult;
/**
@@ -49,6 +50,7 @@ public class TestPdpSimulatorParameterGroup {
commonTestData.getPdpSimulatorParameterGroupMap(CommonTestData.PDP_SIMULATOR_GROUP_NAME),
PdpSimulatorParameterGroup.class);
final PdpStatusParameters pdpStatusParameters = pdpSimulatorParameters.getPdpStatusParameters();
+ final TopicParameterGroup topicParameterGroup = pdpSimulatorParameters.getTopicParameterGroup();
final GroupValidationResult validationResult = pdpSimulatorParameters.validate();
assertTrue(validationResult.isValid());
assertEquals(CommonTestData.PDP_SIMULATOR_GROUP_NAME, pdpSimulatorParameters.getName());
@@ -56,6 +58,8 @@ public class TestPdpSimulatorParameterGroup {
assertEquals(CommonTestData.PDP_TYPE, pdpStatusParameters.getPdpType());
assertEquals(CommonTestData.DESCRIPTION, pdpStatusParameters.getDescription());
assertEquals(CommonTestData.SUPPORTED_POLICY_TYPES, pdpStatusParameters.getSupportedPolicyTypes());
+ assertEquals(CommonTestData.TOPIC_PARAMS, topicParameterGroup.getTopicSinks());
+ assertEquals(CommonTestData.TOPIC_PARAMS, topicParameterGroup.getTopicSources());
}
@Test
@@ -104,4 +108,19 @@ public class TestPdpSimulatorParameterGroup {
+ "parameter group has status INVALID"));
}
+ @Test
+ public void testApexStarterParameterGroupp_EmptyTopicParameters() {
+ final Map<String, Object> map =
+ commonTestData.getPdpSimulatorParameterGroupMap(CommonTestData.PDP_SIMULATOR_GROUP_NAME);
+ map.put("topicParameterGroup", commonTestData.getTopicParametersMap(true));
+
+ final PdpSimulatorParameterGroup parGroup =
+ commonTestData.toObject(map, PdpSimulatorParameterGroup.class);
+ final GroupValidationResult validationResult = parGroup.validate();
+ assertFalse(validationResult.isValid());
+ assertTrue(validationResult.getResult()
+ .contains("\"org.onap.policy.common.endpoints.parameters.TopicParameterGroup\" INVALID, "
+ + "parameter group has status INVALID"));
+ }
+
}
diff --git a/models-sim/policy-models-sim-pdp/src/test/resources/PdpSimulatorConfigParameters.json b/models-sim/policy-models-sim-pdp/src/test/resources/PdpSimulatorConfigParameters.json
index e1772c1c7..61028a99e 100644
--- a/models-sim/policy-models-sim-pdp/src/test/resources/PdpSimulatorConfigParameters.json
+++ b/models-sim/policy-models-sim-pdp/src/test/resources/PdpSimulatorConfigParameters.json
@@ -5,5 +5,33 @@
"pdpType":"apex",
"description":"Pdp Heartbeat",
"supportedPolicyTypes":[{"name":"onap.policies.controlloop.operational.Apex","version":"1.0.0"}]
+ },
+ "topicParameterGroup": {
+ "topicSources" : [ {
+ "topic" : "ueb-source",
+ "servers" : [ "my-server" ],
+ "topicCommInfrastructure" : "ueb"
+ },{
+ "topic" : "POLICY-PDP-PAP1",
+ "servers" : [ "message-router1, message-router2" ],
+ "topicCommInfrastructure" : "dmaap"
+ },{
+ "topic" : "POLICY-PDP-PAP2",
+ "servers" : [ "message-router2, message-router3" ],
+ "topicCommInfrastructure" : "dmaap"
+ }],
+ "topicSinks" : [ {
+ "topic" : "ueb-sink",
+ "servers" : [ "my-server" ],
+ "topicCommInfrastructure" : "ueb"
+ },{
+ "topic" : "POLICY-PDP-PAP2",
+ "servers" : [ "message-router1, message-router2" ],
+ "topicCommInfrastructure" : "dmaap"
+ },{
+ "topic" : "POLICY-PDP-PAP3",
+ "servers" : [ "message-router2, message-router3" ],
+ "topicCommInfrastructure" : "dmaap"
+ }]
}
} \ No newline at end of file
diff --git a/models-sim/policy-models-sim-pdp/src/test/resources/PdpSimulatorConfigParameters_sim.json b/models-sim/policy-models-sim-pdp/src/test/resources/PdpSimulatorConfigParameters_sim.json
index d583b81da..40320d8a6 100644
--- a/models-sim/policy-models-sim-pdp/src/test/resources/PdpSimulatorConfigParameters_sim.json
+++ b/models-sim/policy-models-sim-pdp/src/test/resources/PdpSimulatorConfigParameters_sim.json
@@ -5,5 +5,17 @@
"pdpType":"apex",
"description":"Pdp Heartbeat",
"supportedPolicyTypes":[{"name":"onap.policies.controlloop.operational.Apex","version":"1.0.0"}]
+ },
+ "topicParameterGroup": {
+ "topicSources" : [{
+ "topic" : "POLICY-PDP-PAP",
+ "servers" : [ "localhost:6845" ],
+ "topicCommInfrastructure" : "dmaap"
+ }],
+ "topicSinks" : [{
+ "topic" : "POLICY-PDP-PAP",
+ "servers" : [ "localhost:6845" ],
+ "topicCommInfrastructure" : "dmaap"
+ }]
}
}
diff --git a/models-sim/policy-models-sim-pdp/src/test/resources/TestConfigParameters.json b/models-sim/policy-models-sim-pdp/src/test/resources/TestConfigParameters.json
index 360b02095..e77cb5a87 100644
--- a/models-sim/policy-models-sim-pdp/src/test/resources/TestConfigParameters.json
+++ b/models-sim/policy-models-sim-pdp/src/test/resources/TestConfigParameters.json
@@ -5,5 +5,33 @@
"pdpType":"apex",
"description":"Pdp heartbeat",
"supportedPolicyTypes":[{"name":"onap.policies.controlloop.operational.Apex","version":"1.0.0"}]
+ },
+ "topicParameterGroup": {
+ "topicSources" : [ {
+ "topic" : "ueb-source",
+ "servers" : [ "my-server" ],
+ "topicCommInfrastructure" : "ueb"
+ },{
+ "topic" : "POLICY-PDP-PAP1",
+ "servers" : [ "message-router1, message-router2" ],
+ "topicCommInfrastructure" : "dmaap"
+ },{
+ "topic" : "POLICY-PDP-PAP2",
+ "servers" : [ "message-router2, message-router3" ],
+ "topicCommInfrastructure" : "dmaap"
+ }],
+ "topicSinks" : [ {
+ "topic" : "ueb-sink",
+ "servers" : [ "my-server" ],
+ "topicCommInfrastructure" : "ueb"
+ },{
+ "topic" : "POLICY-PDP-PAP2",
+ "servers" : [ "message-router1, message-router2" ],
+ "topicCommInfrastructure" : "dmaap"
+ },{
+ "topic" : "POLICY-PDP-PAP3",
+ "servers" : [ "message-router2, message-router3" ],
+ "topicCommInfrastructure" : "dmaap"
+ }]
}
} \ No newline at end of file
diff --git a/models-sim/policy-models-sim-pdp/src/test/resources/topic.properties b/models-sim/policy-models-sim-pdp/src/test/resources/topic.properties
deleted file mode 100644
index 9f3c21dff..000000000
--- a/models-sim/policy-models-sim-pdp/src/test/resources/topic.properties
+++ /dev/null
@@ -1,22 +0,0 @@
-# ============LICENSE_START=======================================================
-# Copyright (C) 2019 Nordix Foundation.
-# ================================================================================
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# SPDX-License-Identifier: Apache-2.0
-# ============LICENSE_END=========================================================
-
-noop.sink.topics=POLICY-PDP-PAP
-noop.sink.topics.POLICY-PDP-PAP.servers=anyserver
-noop.source.topics=POLICY-PDP-PAP
-noop.source.topics.POLICY-PDP-PAP.servers=anyserver \ No newline at end of file
diff --git a/models-sim/policy-models-sim-pdp/src/test/resources/topic_sim.properties b/models-sim/policy-models-sim-pdp/src/test/resources/topic_sim.properties
deleted file mode 100644
index 2bdf8c7b1..000000000
--- a/models-sim/policy-models-sim-pdp/src/test/resources/topic_sim.properties
+++ /dev/null
@@ -1,22 +0,0 @@
-# ============LICENSE_START=======================================================
-# Copyright (C) 2019 Nordix Foundation.
-# ================================================================================
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# SPDX-License-Identifier: Apache-2.0
-# ============LICENSE_END=========================================================
-
-dmaap.sink.topics=POLICY-PDP-PAP
-dmaap.sink.topics.POLICY-PDP-PAP.servers=localhost:6845
-dmaap.source.topics=POLICY-PDP-PAP
-dmaap.source.topics.POLICY-PDP-PAP.servers=localhost:6845