From cc4765116c0b5716f8edf4dc23970e964bb1fe5d Mon Sep 17 00:00:00 2001 From: Jorge Hernandez Date: Tue, 19 Mar 2019 16:10:37 -0500 Subject: 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 --- .../policy/common/endpoints/event/comm/TopicEndpoint.java | 9 +++++++++ .../common/endpoints/event/comm/TopicEndpointProxy.java | 7 +++++++ .../common/endpoints/event/comm/TopicEndpointProxyTest.java | 11 +++++++++++ 3 files changed, 27 insertions(+) (limited to 'policy-endpoints') 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 52c1f07b..ff8b9513 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 @@ -42,6 +42,15 @@ public interface TopicEndpoint extends Startable, Lockable { */ 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 addTopics(Properties properties); + /** * Add Topic Sources to the communication infrastructure initialized per properties. * 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 ebed381d..806d077c 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 @@ -55,6 +55,13 @@ class TopicEndpointProxy implements TopicEndpoint { */ private volatile boolean alive = false; + @Override + public List addTopics(Properties properties) { + List topics = new ArrayList<>(addTopicSources(properties)); + topics.addAll(addTopicSinks(properties)); + return topics; + } + @Override public List addTopicSources(Properties properties) { 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 a311c0b0..ba5fe18e 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 @@ -144,6 +144,17 @@ public class TopicEndpointProxyTest { assertTrue(allSinks(sinks)); } + @Test + public void addTopics() { + TopicEndpoint manager = new TopicEndpointProxy(); + + List topics = manager.addTopics(configuration); + assertSame(6, topics.size()); + + assertTrue(allSources(topics)); + assertTrue(allSinks(topics)); + } + @Test public void getTopicSources() { TopicEndpoint manager = new TopicEndpointProxy(); -- cgit 1.2.3-korg