Use new addTopic() method in models 03/92303/2
authorJim Hahn <jrh3@att.com>
Tue, 30 Jul 2019 14:33:13 +0000 (10:33 -0400)
committerJim Hahn <jrh3@att.com>
Wed, 31 Jul 2019 13:23:08 +0000 (09:23 -0400)
Replaced ParameterUtils with the use of the new
addTopic(TopicParameterGroup) method.
Used separate addTopicXxx() methods per review comment.

Change-Id: I755b75f986a5c42f01bcad5a22472a46766d192d
Issue-ID: POLICY-1953
Signed-off-by: Jim Hahn <jrh3@att.com>
models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java
models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorActivator.java
models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorMain.java
models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/TestPdpSimulatorActivator.java
models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/comm/TestPdpStateChangeListener.java
models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/comm/TestPdpUpdateListener.java

index 7567d8a..249e1fc 100644 (file)
@@ -22,6 +22,7 @@
 package org.onap.policy.controlloop.actor.appc;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
@@ -168,6 +169,7 @@ public class AppcServiceProviderTest {
         assertTrue(jsonRequest.contains(KEY2));
         assertTrue(jsonRequest.contains(SUBKEY));
         assertTrue(jsonRequest.contains(SUBVALUE));
+        assertFalse(jsonRequest.contains(SUBVALUE + ".0"));
 
         Response appcResponse = new Response(appcRequest);
         appcResponse.getStatus().setCode(ResponseCode.SUCCESS.getValue());
index 735784e..2c3f8f7 100644 (file)
@@ -22,7 +22,6 @@
 package org.onap.policy.models.sim.pdp;
 
 import java.util.List;
-import java.util.Properties;
 import java.util.Random;
 import lombok.Getter;
 import lombok.Setter;
@@ -77,13 +76,13 @@ public class PdpSimulatorActivator {
      * Instantiate the activator for onappf PDP-A.
      *
      * @param pdpSimulatorParameterGroup the parameters for the onappf PDP-A service
-     * @param topicProperties properties used to configure the topics
      */
-    public PdpSimulatorActivator(final PdpSimulatorParameterGroup pdpSimulatorParameterGroup,
-            final Properties topicProperties) {
+    public PdpSimulatorActivator(final PdpSimulatorParameterGroup pdpSimulatorParameterGroup) {
 
-        topicSinks = TopicEndpointManager.getManager().addTopicSinks(topicProperties);
-        topicSources = TopicEndpointManager.getManager().addTopicSources(topicProperties);
+        topicSinks = TopicEndpointManager.getManager()
+                        .addTopicSinks(pdpSimulatorParameterGroup.getTopicParameterGroup().getTopicSinks());
+        topicSources = TopicEndpointManager.getManager()
+                        .addTopicSources(pdpSimulatorParameterGroup.getTopicParameterGroup().getTopicSources());
 
         final int random = RANDOM.nextInt();
         final String instanceId = "pdp_" + random;
index ee974c5..e367cca 100644 (file)
@@ -22,8 +22,6 @@
 package org.onap.policy.models.sim.pdp;
 
 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;
@@ -79,11 +77,8 @@ public class PdpSimulatorMain {
             return;
         }
 
-        // Read the properties
-        Properties topicProperties = ParameterUtils.getTopicProperties(parameterGroup.getTopicParameterGroup());
-
         // create the activator
-        activator = new PdpSimulatorActivator(parameterGroup, topicProperties);
+        activator = new PdpSimulatorActivator(parameterGroup);
         Registry.register(PdpSimulatorConstants.REG_PDP_SIMULATOR_ACTIVATOR, activator);
         // Start the activator
         try {
index b2ab087..1ebd2a0 100644 (file)
@@ -28,11 +28,9 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
-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;
@@ -62,8 +60,7 @@ public class TestPdpSimulatorActivator {
                 new PdpSimulatorCommandLineArguments(pdpSimulatorConfigParameters);
         final PdpSimulatorParameterGroup parGroup = new PdpSimulatorParameterHandler().getParameters(arguments);
 
-        final Properties props = ParameterUtils.getTopicProperties(parGroup.getTopicParameterGroup());
-        activator = new PdpSimulatorActivator(parGroup, props);
+        activator = new PdpSimulatorActivator(parGroup);
     }
 
     /**
index 2b37047..93015e9 100644 (file)
@@ -31,12 +31,10 @@ import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Properties;
 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;
@@ -88,10 +86,7 @@ public class TestPdpStateChangeListener {
         // Read the parameters
         pdpSimulatorParameterGroup = new PdpSimulatorParameterHandler().getParameters(arguments);
 
-        // Read the properties
-        final Properties topicProperties =
-            ParameterUtils.getTopicProperties(pdpSimulatorParameterGroup.getTopicParameterGroup());
-        activator = new PdpSimulatorActivator(pdpSimulatorParameterGroup, topicProperties);
+        activator = new PdpSimulatorActivator(pdpSimulatorParameterGroup);
         Registry.register(PdpSimulatorConstants.REG_PDP_SIMULATOR_ACTIVATOR, activator);
         activator.initialize();
     }
index 9ae8d37..7bf70dd 100644 (file)
@@ -31,12 +31,10 @@ import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Properties;
 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;
@@ -82,10 +80,7 @@ public class TestPdpUpdateListener {
         // Read the parameters
         pdpSimulatorParameterGroup = new PdpSimulatorParameterHandler().getParameters(arguments);
 
-        // Read the properties
-        final Properties topicProperties =
-            ParameterUtils.getTopicProperties(pdpSimulatorParameterGroup.getTopicParameterGroup());
-        activator = new PdpSimulatorActivator(pdpSimulatorParameterGroup, topicProperties);
+        activator = new PdpSimulatorActivator(pdpSimulatorParameterGroup);
         Registry.register(PdpSimulatorConstants.REG_PDP_SIMULATOR_ACTIVATOR, activator);
         activator.initialize();
         pdpUpdateMessageListener = new PdpUpdateListener();