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/internal | |
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/internal')
3 files changed, 49 insertions, 2 deletions
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.java index 83a94bd5..5628a239 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.java @@ -22,6 +22,7 @@ package org.onap.policy.common.endpoints.event.comm.bus.internal; 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; @@ -77,6 +78,13 @@ public class BusTopicBaseTest extends TopicTestBase { } @Test + public void testTopic() { + assertEquals(MY_TOPIC, base.getTopic()); + assertEquals(MY_EFFECTIVE_TOPIC, base.getEffectiveTopic()); + assertNotEquals(base.getTopic(), base.getEffectiveTopic()); + } + + @Test public void testAnyNullOrEmpty() { assertFalse(base.anyNullOrEmpty()); assertFalse(base.anyNullOrEmpty("any-none-null", "any-none-null-B")); diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParamsTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParamsTest.java index 8f1ab9bc..8d1c6343 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParamsTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParamsTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * policy-endpoints * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,6 +65,7 @@ public class BusTopicParamsTest extends TopicTestBase { assertEquals(MY_PORT, params.getPort()); assertEquals(servers, params.getServers()); assertEquals(MY_TOPIC, params.getTopic()); + assertEquals(MY_EFFECTIVE_TOPIC, params.getEffectiveTopic()); assertEquals(true, params.isUseHttps()); assertEquals(MY_USERNAME, params.getUserName()); 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. * ================================================================================ @@ -74,6 +74,27 @@ public class TopicBaseTest extends TopicTestBase { } @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); } @@ -209,6 +230,12 @@ public class TopicBaseTest extends TopicTestBase { } @Test + public void testGetEffectiveTopic() { + assertEquals(MY_TOPIC, base.getTopic()); + assertEquals(MY_TOPIC, base.getEffectiveTopic()); + } + + @Test public void testIsAlive() { assertFalse(base.isAlive()); base.start(); @@ -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<String> servers, String topic, String effectiveTopic) { + super(servers, topic, effectiveTopic); + } + @Override public CommInfrastructure getTopicCommInfrastructure() { return CommInfrastructure.NOOP; |