diff options
author | Jorge Hernandez <jorge.hernandez-herrero@att.com> | 2019-02-19 20:05:31 -0600 |
---|---|---|
committer | Jorge Hernandez <jorge.hernandez-herrero@att.com> | 2019-02-21 11:01:09 -0600 |
commit | 4c1c6891ed6cd4a9e5c2e0b3bacd0c2df89364a7 (patch) | |
tree | 36d229cab77b42d3c2504ce7ebe1f94d656e94da /policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicFactoryTestBase.java | |
parent | 2917a67f12e32a7337e3a9f9b9fd3de4469a921c (diff) |
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 <jorge.hernandez-herrero@att.com>
Diffstat (limited to 'policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicFactoryTestBase.java')
-rw-r--r-- | policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicFactoryTestBase.java | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicFactoryTestBase.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicFactoryTestBase.java index 71d4fe27..919397d9 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicFactoryTestBase.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicFactoryTestBase.java @@ -23,11 +23,13 @@ package org.onap.policy.common.endpoints.event.comm.bus; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_ALLOW_SELF_SIGNED_CERTIFICATES_SUFFIX; import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_HTTP_HTTPS_SUFFIX; import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_MANAGED_SUFFIX; +import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_EFFECTIVE_TOPIC_SUFFIX; import java.util.Arrays; import java.util.List; @@ -74,17 +76,21 @@ public abstract class BusTopicFactoryTestBase<T extends Topic> extends TopicFact initFactory(); // two unmanaged topics - T item = buildTopic(makeBuilder().managed(false).build()); + T item = buildTopic(makeBuilder().managed(false).effectiveTopic(null).build()); T item2 = buildTopic(makeBuilder().managed(false).topic(TOPIC2).build()); assertNotNull(item); assertNotNull(item2); + assertEquals(item.getTopic(), item.getEffectiveTopic()); + assertNotEquals(item2.getTopic(), item2.getEffectiveTopic()); assertTrue(item != item2); // duplicate topics, but since they aren't managed, they should be different T item3 = buildTopic(makeBuilder().managed(false).build()); - T item4 = buildTopic(makeBuilder().managed(false).build()); + T item4 = buildTopic(makeBuilder().managed(false).effectiveTopic(TOPIC2).build()); assertNotNull(item3); assertNotNull(item4); + assertEquals(MY_TOPIC, item4.getTopic()); + assertEquals(TOPIC2, item4.getEffectiveTopic()); assertTrue(item != item3); assertTrue(item != item4); assertTrue(item3 != item4); @@ -143,7 +149,10 @@ public abstract class BusTopicFactoryTestBase<T extends Topic> extends TopicFact public void testBuildProperties() { initFactory(); - assertEquals(1, buildTopics(makePropBuilder().makeTopic(MY_TOPIC).build()).size()); + List<T> topics = buildTopics(makePropBuilder().makeTopic(MY_TOPIC).build()); + assertEquals(1, topics.size()); + assertEquals(MY_TOPIC, topics.get(0).getTopic()); + assertEquals(MY_EFFECTIVE_TOPIC, topics.get(0).getEffectiveTopic()); BusTopicParams params = getLastParams(); assertEquals(true, params.isManaged()); @@ -153,6 +162,13 @@ public abstract class BusTopicFactoryTestBase<T extends Topic> extends TopicFact assertEquals(MY_API_SECRET, params.getApiSecret()); assertEquals(Arrays.asList(SERVER), params.getServers()); assertEquals(MY_TOPIC, params.getTopic()); + assertEquals(MY_EFFECTIVE_TOPIC, params.getEffectiveTopic()); + + List<T> topics2 = buildTopics(makePropBuilder().makeTopic(TOPIC3) + .removeTopicProperty(PROPERTY_TOPIC_EFFECTIVE_TOPIC_SUFFIX).build()); + assertEquals(1, topics2.size()); + assertEquals(TOPIC3, topics2.get(0).getTopic()); + assertEquals(topics2.get(0).getTopic(), topics2.get(0).getEffectiveTopic()); } @Override |