diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2019-03-20 13:45:30 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-03-20 13:45:30 +0000 |
commit | 232bd030951905cb5ad2f1ddad5400a005fe40c6 (patch) | |
tree | 240eebda61412744b9346c6b44bc2c36a7757290 | |
parent | 8fa0f6670063657249f75d9656d61fed5bf0b79f (diff) | |
parent | cc4765116c0b5716f8edf4dc23970e964bb1fe5d (diff) |
Merge "Add method to support configure all topics at once"
3 files changed, 27 insertions, 0 deletions
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 @@ -43,6 +43,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<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 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 @@ -56,6 +56,13 @@ class TopicEndpointProxy implements TopicEndpoint { 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 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 @@ -145,6 +145,17 @@ public class TopicEndpointProxyTest { } @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(); |