Fix pap due to sonar changes in common 41/91041/1
authorjrh3 <jrh3@att.com>
Mon, 8 Jul 2019 19:30:51 +0000 (15:30 -0400)
committerjrh3 <jrh3@att.com>
Mon, 8 Jul 2019 19:30:51 +0000 (15:30 -0400)
Fixed breakages due to changes made in policy/common to satisfy
sonar.

Issue-ID: POLICY-1791
Signed-off-by: jrh3 <jrh3@att.com>
Change-Id: If8685462e1dd5cbbe58c329defff74ff2accf559

main/src/main/java/org/onap/policy/pap/main/rest/PapRestServer.java
main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
main/src/test/java/org/onap/policy/pap/main/comm/PublisherTest.java
main/src/test/java/org/onap/policy/pap/main/rest/CommonPapRestServer.java
main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndContext.java
main/src/test/java/org/onap/policy/pap/main/startstop/TestMain.java
main/src/test/java/org/onap/policy/pap/main/startstop/TestPapActivator.java

index c86cb81..a4727d0 100644 (file)
@@ -27,6 +27,7 @@ import java.util.Properties;
 
 import org.onap.policy.common.capabilities.Startable;
 import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
 import org.onap.policy.common.endpoints.parameters.RestServerParameters;
 import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
 import org.onap.policy.common.gson.GsonMessageBodyHandler;
@@ -63,7 +64,7 @@ public class PapRestServer implements Startable {
     @Override
     public boolean start() {
         try {
-            servers = HttpServletServer.factory.build(getServerProperties());
+            servers = HttpServletServerFactoryInstance.getServerFactory().build(getServerProperties());
             for (final HttpServletServer server : servers) {
                 if (server.isAaf()) {
                     server.addFilterClass(null, PapAafFilter.class.getName());
index e1ad80e..5ceb55a 100644 (file)
@@ -24,7 +24,7 @@ package org.onap.policy.pap.main.startstop;
 import java.util.Arrays;
 import java.util.Properties;
 import java.util.concurrent.atomic.AtomicReference;
-import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
+import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
 import org.onap.policy.common.endpoints.event.comm.TopicSource;
 import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher;
 import org.onap.policy.common.endpoints.listeners.RequestIdDispatcher;
@@ -90,8 +90,8 @@ public class PapActivator extends ServiceManagerContainer {
     public PapActivator(final PapParameterGroup papParameterGroup, final Properties topicProperties) {
         super("Policy PAP");
 
-        TopicEndpoint.manager.addTopicSinks(topicProperties);
-        TopicEndpoint.manager.addTopicSources(topicProperties);
+        TopicEndpointManager.getManager().addTopicSinks(topicProperties);
+        TopicEndpointManager.getManager().addTopicSources(topicProperties);
 
         try {
             this.papParameterGroup = papParameterGroup;
@@ -142,8 +142,8 @@ public class PapActivator extends ServiceManagerContainer {
             this::unregisterMsgDispatcher);
 
         addAction("topics",
-            TopicEndpoint.manager::start,
-            TopicEndpoint.manager::shutdown);
+            TopicEndpointManager.getManager()::start,
+            TopicEndpointManager.getManager()::shutdown);
 
         addAction("PAP statistics",
             () -> Registry.register(PapConstants.REG_STATISTICS_MANAGER, new PapStatisticsManager()),
@@ -240,7 +240,7 @@ public class PapActivator extends ServiceManagerContainer {
      * Registers the dispatcher with the topic source(s).
      */
     private void registerMsgDispatcher() {
-        for (final TopicSource source : TopicEndpoint.manager
+        for (final TopicSource source : TopicEndpointManager.getManager()
                 .getTopicSources(Arrays.asList(PapConstants.TOPIC_POLICY_PDP_PAP))) {
             source.register(msgDispatcher);
         }
@@ -250,7 +250,7 @@ public class PapActivator extends ServiceManagerContainer {
      * Unregisters the dispatcher from the topic source(s).
      */
     private void unregisterMsgDispatcher() {
-        for (final TopicSource source : TopicEndpoint.manager
+        for (final TopicSource source : TopicEndpointManager.getManager()
                 .getTopicSources(Arrays.asList(PapConstants.TOPIC_POLICY_PDP_PAP))) {
             source.unregister(msgDispatcher);
         }
index cadae12..d399f63 100644 (file)
@@ -36,7 +36,7 @@ import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
+import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
 import org.onap.policy.common.endpoints.event.comm.TopicListener;
 import org.onap.policy.common.endpoints.utils.ParameterUtils;
 import org.onap.policy.common.utils.coder.Coder;
@@ -91,15 +91,15 @@ public class PublisherTest extends Threaded {
         final PapCommandLineArguments arguments = new PapCommandLineArguments(papConfigParameters);
         final PapParameterGroup parameterGroup = new PapParameterHandler().getParameters(arguments);
         Properties props = ParameterUtils.getTopicProperties(parameterGroup.getTopicParameterGroup());
-        TopicEndpoint.manager.shutdown();
+        TopicEndpointManager.getManager().shutdown();
 
-        TopicEndpoint.manager.addTopics(props);
-        TopicEndpoint.manager.start();
+        TopicEndpointManager.getManager().addTopics(props);
+        TopicEndpointManager.getManager().start();
     }
 
     @AfterClass
     public static void tearDownAfterClass() throws Exception {
-        TopicEndpoint.manager.shutdown();
+        TopicEndpointManager.getManager().shutdown();
     }
 
     /**
@@ -114,7 +114,7 @@ public class PublisherTest extends Threaded {
         pub = new Publisher(PapConstants.TOPIC_POLICY_PDP_PAP);
 
         listener = new MyListener();
-        TopicEndpoint.manager.getNoopTopicSink(PapConstants.TOPIC_POLICY_PDP_PAP).register(listener);
+        TopicEndpointManager.getManager().getNoopTopicSink(PapConstants.TOPIC_POLICY_PDP_PAP).register(listener);
     }
 
     /**
@@ -124,7 +124,7 @@ public class PublisherTest extends Threaded {
      */
     @After
     public void tearDown() throws Exception {
-        TopicEndpoint.manager.getNoopTopicSink(PapConstants.TOPIC_POLICY_PDP_PAP).unregister(listener);
+        TopicEndpointManager.getManager().getNoopTopicSink(PapConstants.TOPIC_POLICY_PDP_PAP).unregister(listener);
 
         super.tearDown();
     }
index 4abe6f1..9124508 100644 (file)
@@ -43,8 +43,8 @@ import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
-import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
-import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
+import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
 import org.onap.policy.common.gson.GsonMessageBodyHandler;
 import org.onap.policy.common.utils.network.NetworkUtil;
 import org.onap.policy.common.utils.services.Registry;
@@ -94,8 +94,8 @@ public class CommonPapRestServer {
 
         makeConfigFile();
 
-        HttpServletServer.factory.destroy();
-        TopicEndpoint.manager.shutdown();
+        HttpServletServerFactoryInstance.getServerFactory().destroy();
+        TopicEndpointManager.getManager().shutdown();
 
         CommonTestData.newDb();
 
index fe0f682..38ffe8d 100644 (file)
@@ -33,7 +33,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 import lombok.Getter;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
+import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
 import org.onap.policy.common.endpoints.event.comm.TopicListener;
 import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicSource;
 import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher;
@@ -129,9 +129,9 @@ public class End2EndContext {
      * Constructs the object.
      */
     public End2EndContext() {
-        toPapTopic = TopicEndpoint.manager.getNoopTopicSource(PapConstants.TOPIC_POLICY_PDP_PAP);
+        toPapTopic = TopicEndpointManager.getManager().getNoopTopicSource(PapConstants.TOPIC_POLICY_PDP_PAP);
 
-        TopicEndpoint.manager.getNoopTopicSink(PapConstants.TOPIC_POLICY_PDP_PAP).register(topicListener);
+        TopicEndpointManager.getManager().getNoopTopicSink(PapConstants.TOPIC_POLICY_PDP_PAP).register(topicListener);
 
         dispatcher = new MessageTypeDispatcher("messageName");
         dispatcher.register(PdpMessageType.PDP_UPDATE.name(), new UpdateListener());
@@ -200,7 +200,7 @@ public class End2EndContext {
         toPap.clear();
         pdps.forEach(pdp -> toPap.add(DONE));
 
-        TopicEndpoint.manager.getNoopTopicSink(PapConstants.TOPIC_POLICY_PDP_PAP).unregister(topicListener);
+        TopicEndpointManager.getManager().getNoopTopicSink(PapConstants.TOPIC_POLICY_PDP_PAP).unregister(topicListener);
     }
 
     /**
index 016e120..2658b36 100644 (file)
@@ -28,7 +28,7 @@ import static org.junit.Assert.assertTrue;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
 import org.onap.policy.common.utils.services.Registry;
 import org.onap.policy.pap.main.PapConstants;
 import org.onap.policy.pap.main.PolicyPapException;
@@ -48,7 +48,7 @@ public class TestMain {
     @Before
     public void setUp() {
         Registry.newRegistry();
-        HttpServletServer.factory.destroy();
+        HttpServletServerFactoryInstance.getServerFactory().destroy();
     }
 
     /**
index fe2e837..2ebd234 100644 (file)
@@ -32,7 +32,7 @@ import java.util.Properties;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
 import org.onap.policy.common.endpoints.utils.ParameterUtils;
 import org.onap.policy.common.utils.services.Registry;
 import org.onap.policy.pap.main.PapConstants;
@@ -61,7 +61,7 @@ public class TestPapActivator {
     @Before
     public void setUp() throws Exception {
         Registry.newRegistry();
-        HttpServletServer.factory.destroy();
+        HttpServletServerFactoryInstance.getServerFactory().destroy();
 
         final String[] papConfigParameters = {"-c", "parameters/PapConfigParameters.json"};
         final PapCommandLineArguments arguments = new PapCommandLineArguments(papConfigParameters);