Add method to support configure all topics at once

regardless of type (source or sink)

Change-Id: Idaebae611746e364364d35375519173a7461ae61
Issue-ID: POLICY-1608
Signed-off-by: Jorge Hernandez <jorge.hernandez-herrero@att.com>
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpoint.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpoint.java
index 52c1f07..ff8b951 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpoint.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpoint.java
@@ -43,6 +43,15 @@
     TopicEndpoint manager = new TopicEndpointProxy();
 
     /**
+     * Add topics configuration (sources and sinks) into a single list.
+     *
+     * @param properties topic configuration
+     * @return topic list
+     * @throws IllegalArgumentException when invalid arguments are provided
+     */
+    List<Topic> addTopics(Properties properties);
+
+    /**
      * Add Topic Sources to the communication infrastructure initialized per properties.
      *
      * @param properties properties for Topic Source construction
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxy.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxy.java
index ebed381..806d077 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxy.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxy.java
@@ -56,6 +56,13 @@
     private volatile boolean alive = false;
 
     @Override
+    public List<Topic> addTopics(Properties properties) {
+        List<Topic> topics = new ArrayList<>(addTopicSources(properties));
+        topics.addAll(addTopicSinks(properties));
+        return topics;
+    }
+
+    @Override
     public List<TopicSource> addTopicSources(Properties properties) {
 
         // 1. Create UEB Sources
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.java
index a311c0b..ba5fe18 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.java
@@ -145,6 +145,17 @@
     }
 
     @Test
+    public void addTopics() {
+        TopicEndpoint manager = new TopicEndpointProxy();
+
+        List<Topic>  topics = manager.addTopics(configuration);
+        assertSame(6, topics.size());
+
+        assertTrue(allSources(topics));
+        assertTrue(allSinks(topics));
+    }
+
+    @Test
     public void getTopicSources() {
         TopicEndpoint manager = new TopicEndpointProxy();