From 4c1c6891ed6cd4a9e5c2e0b3bacd0c2df89364a7 Mon Sep 17 00:00:00 2001 From: Jorge Hernandez Date: Tue, 19 Feb 2019 20:05:31 -0600 Subject: Support for lab contextual topic names. This work allows a drools application, with its drl template to refer to the topic name by its invariable canonical name, ie. POLICY-CL-MGT. Since the drl is a design time artifact, it is desired to know topics by its canonical non-changeable name. The actual per lab environment topic name may change on a per deployment basis, for example POLICY-CL-MGT-WINDRIVER or POLICY-CL-MGT-TLAB. The template can still use POLICY-CL-MGT without modification but the actual installation configuration would use the "effectiveTopic" property to point to the right topic on a per lab basis. This also helps with installation (long story) since the canonical topics will be known ahead of time. Change-Id: I8322bf7e427569c37a76eea5ce6d5b9547cb2ff3 Issue-ID: POLICY-1534 Signed-off-by: Jorge Hernandez --- .../event/comm/bus/internal/TopicBaseTest.java | 40 +++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.java') diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.java index a8ea84fc..55b2b404 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * ONAP Policy Engine - Common Modules + * ONAP * ================================================================================ * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ @@ -73,6 +73,27 @@ public class TopicBaseTest extends TopicTestBase { new TopicBaseImpl(servers, ""); } + @Test + public void testTopicBase_EffectiveTopic() { + TopicBase baseEf = new TopicBaseImpl(servers, MY_TOPIC, MY_EFFECTIVE_TOPIC); + assertEquals(MY_TOPIC, baseEf.getTopic()); + assertEquals(MY_EFFECTIVE_TOPIC, baseEf.getEffectiveTopic()); + } + + @Test + public void testTopicBase_NullEffectiveTopic() { + TopicBase baseEf = new TopicBaseImpl(servers, MY_TOPIC, null); + assertEquals(MY_TOPIC, baseEf.getTopic()); + assertEquals(MY_TOPIC, baseEf.getEffectiveTopic()); + } + + @Test + public void testTopicBase_EmptyEffectiveTopic() { + TopicBase baseEf = new TopicBaseImpl(servers, MY_TOPIC, ""); + assertEquals(MY_TOPIC, baseEf.getTopic()); + assertEquals(MY_TOPIC, baseEf.getEffectiveTopic()); + } + @Test public void testSerialize() { new GsonTestUtils().compareGson(base, TopicBaseTest.class); @@ -208,6 +229,12 @@ public class TopicBaseTest extends TopicTestBase { assertEquals(MY_TOPIC, base.getTopic()); } + @Test + public void testGetEffectiveTopic() { + assertEquals(MY_TOPIC, base.getTopic()); + assertEquals(MY_TOPIC, base.getEffectiveTopic()); + } + @Test public void testIsAlive() { assertFalse(base.isAlive()); @@ -260,6 +287,17 @@ public class TopicBaseTest extends TopicTestBase { super(servers, topic); } + /** + * Constructor. + * + * @param servers list of servers + * @param topic topic name + * @param effectiveTopic effective topic name for network communication + */ + public TopicBaseImpl(List servers, String topic, String effectiveTopic) { + super(servers, topic, effectiveTopic); + } + @Override public CommInfrastructure getTopicCommInfrastructure() { return CommInfrastructure.NOOP; -- cgit 1.2.3-korg