aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorCommandLineArguments.java1
-rw-r--r--models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorMain.java13
-rw-r--r--models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/parameters/PdpSimulatorParameterGroup.java3
-rw-r--r--models-sim/policy-models-sim-pdp/src/main/package/docker/pdp-sim.sh13
-rw-r--r--models-sim/policy-models-sim-pdp/src/main/package/tarball/assembly.xml1
-rw-r--r--models-sim/policy-models-sim-pdp/src/main/resources/config/OnapPfConfig.json12
-rw-r--r--models-sim/policy-models-sim-pdp/src/main/resources/config/topic.properties22
-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
18 files changed, 149 insertions, 118 deletions
diff --git a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorCommandLineArguments.java b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorCommandLineArguments.java
index 50d2bd2ad..8eff1af42 100644
--- a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorCommandLineArguments.java
+++ b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorCommandLineArguments.java
@@ -165,7 +165,6 @@ public class PdpSimulatorCommandLineArguments {
*/
public void validate() throws PdpSimulatorException {
validateReadableFile("pdp simulator configuration", configurationFilePath);
- validateReadableFile("pdp simulator properties", propertyFilePath);
}
/**
diff --git a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorMain.java b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorMain.java
index 78330135a..ee974c579 100644
--- a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorMain.java
+++ b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorMain.java
@@ -21,9 +21,9 @@
package org.onap.policy.models.sim.pdp;
-import java.io.FileInputStream;
import java.util.Arrays;
import java.util.Properties;
+import org.onap.policy.common.endpoints.utils.ParameterUtils;
import org.onap.policy.common.utils.services.Registry;
import org.onap.policy.models.sim.pdp.exception.PdpSimulatorException;
import org.onap.policy.models.sim.pdp.parameters.PdpSimulatorParameterGroup;
@@ -80,16 +80,7 @@ public class PdpSimulatorMain {
}
// Read the properties
- final Properties topicProperties = new Properties();
- try {
- final String propFile = arguments.getFullPropertyFilePath();
- try (FileInputStream stream = new FileInputStream(propFile)) {
- topicProperties.load(stream);
- }
- } catch (final Exception e) {
- LOGGER.error(PDP_SIMULATOR_FAIL_MSG, e);
- return;
- }
+ Properties topicProperties = ParameterUtils.getTopicProperties(parameterGroup.getTopicParameterGroup());
// create the activator
activator = new PdpSimulatorActivator(parameterGroup, topicProperties);
diff --git a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/parameters/PdpSimulatorParameterGroup.java b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/parameters/PdpSimulatorParameterGroup.java
index 58c583901..1b4df7bc6 100644
--- a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/parameters/PdpSimulatorParameterGroup.java
+++ b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/parameters/PdpSimulatorParameterGroup.java
@@ -21,7 +21,7 @@
package org.onap.policy.models.sim.pdp.parameters;
import lombok.Getter;
-
+import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
import org.onap.policy.common.parameters.ParameterGroupImpl;
import org.onap.policy.common.parameters.annotations.NotBlank;
import org.onap.policy.common.parameters.annotations.NotNull;
@@ -36,6 +36,7 @@ import org.onap.policy.common.parameters.annotations.NotNull;
@Getter
public class PdpSimulatorParameterGroup extends ParameterGroupImpl {
private PdpStatusParameters pdpStatusParameters;
+ private TopicParameterGroup topicParameterGroup;
/**
* Create the pdp simulator parameter group.
diff --git a/models-sim/policy-models-sim-pdp/src/main/package/docker/pdp-sim.sh b/models-sim/policy-models-sim-pdp/src/main/package/docker/pdp-sim.sh
index b0e3ba0e5..2316ccecf 100644
--- a/models-sim/policy-models-sim-pdp/src/main/package/docker/pdp-sim.sh
+++ b/models-sim/policy-models-sim-pdp/src/main/package/docker/pdp-sim.sh
@@ -30,13 +30,11 @@ KEYSTORE_PASSWD="Pol1cy_0nap"
TRUSTSTORE="${PDP_SIM_HOME}/etc/ssl/policy-truststore"
TRUSTSTORE_PASSWD="Pol1cy_0nap"
-if [ "$#" -eq 2 ]
+if [ "$#" -eq 1 ]
then
CONFIG_FILE=$1
- PROPERTIES_FILE=$2
else
CONFIG_FILE=${CONFIG_FILE}
- PROPERTIES_FILE=${PROPERTIES_FILE}
fi
if [ -z "$CONFIG_FILE" ]
@@ -44,12 +42,7 @@ then
CONFIG_FILE="$PDP_SIM_HOME/etc/config/OnapPfConfig.json"
fi
-if [ -z "$PROPERTIES_FILE" ]
-then
- PROPERTIES_FILE="$PDP_SIM_HOME/etc/config/topic.properties"
-fi
-
-echo "PDP simulatior configuration file: $CONFIG_FILE and properties file: $PROPERTIES_FILE"
+echo "PDP simulatior configuration file: $CONFIG_FILE
$JAVA_HOME/bin/java \
-cp "$PDP_SIM_HOME/etc:$PDP_SIM_HOME/lib/*" \
@@ -59,4 +52,4 @@ $JAVA_HOME/bin/java \
-Djavax.net.ssl.trustStorePassword="$TRUSTSTORE_PASSWD" \
-Dlogback.configurationFile=$PDP_SIM_HOME/etc/logback.xml \
org.onap.policy.models.sim.pdp.PdpSimulatorMain \
- -c $CONFIG_FILE -p $PROPERTIES_FILE
+ -c $CONFIG_FILE
diff --git a/models-sim/policy-models-sim-pdp/src/main/package/tarball/assembly.xml b/models-sim/policy-models-sim-pdp/src/main/package/tarball/assembly.xml
index 25ffc65a9..2fc66d12b 100644
--- a/models-sim/policy-models-sim-pdp/src/main/package/tarball/assembly.xml
+++ b/models-sim/policy-models-sim-pdp/src/main/package/tarball/assembly.xml
@@ -50,7 +50,6 @@
</directory>
<includes>
<include>OnapPfConfig.json</include>
- <include>topic.properties</include>
</includes>
<outputDirectory>etc/config</outputDirectory>
<lineEnding>unix</lineEnding>
diff --git a/models-sim/policy-models-sim-pdp/src/main/resources/config/OnapPfConfig.json b/models-sim/policy-models-sim-pdp/src/main/resources/config/OnapPfConfig.json
index ff7903c78..cb8c4dd0f 100644
--- a/models-sim/policy-models-sim-pdp/src/main/resources/config/OnapPfConfig.json
+++ b/models-sim/policy-models-sim-pdp/src/main/resources/config/OnapPfConfig.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" : [ "message-router:3904" ],
+ "topicCommInfrastructure" : "dmaap"
+ }],
+ "topicSinks" : [{
+ "topic" : "POLICY-PDP-PAP",
+ "servers" : [ "message-router:3904" ],
+ "topicCommInfrastructure" : "dmaap"
+ }]
}
} \ No newline at end of file
diff --git a/models-sim/policy-models-sim-pdp/src/main/resources/config/topic.properties b/models-sim/policy-models-sim-pdp/src/main/resources/config/topic.properties
deleted file mode 100644
index 0139bb38a..000000000
--- a/models-sim/policy-models-sim-pdp/src/main/resources/config/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=========================================================
-
-dmaap.source.topics=POLICY-PDP-PAP
-dmaap.sink.topics=POLICY-PDP-PAP
-dmaap.source.topics.POLICY-PDP-PAP.servers= message-router:3904
-dmaap.sink.topics.POLICY-PDP-PAP.servers= message-router:3904 \ No newline at end of file
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