summaryrefslogtreecommitdiffstats
path: root/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicPropertyBuilder.java
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2018-09-28 09:53:14 -0400
committerJim Hahn <jrh3@att.com>2018-09-28 16:52:08 -0400
commit53f06d93dc2c4d292ea1c7dad24df0d72cc01dc5 (patch)
treedf98f63e1410b3eb0224cbb79fe4d45f754f9a9b /policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicPropertyBuilder.java
parentb2cbec29c685f6aef49a5828761045acee17224b (diff)
Add junit coverage to rest of policy-endpoint bus
Also extracted out common code from tests. Fix checkstyle issues. Be consistent in returning IllegalStateException when topic is not found by any Topic Factory. Added/updated some comments. Use better name for "validate" argument. Renamed test() to testDestroy(). Added NoopTopicPropertyBuilder. Renamed BusTopicTestBase to TopicTestBase. Change-Id: Id4c7ab9f2b5572dc5195b0da116e285c5e9b6f06 Issue-ID: POLICY-1148 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicPropertyBuilder.java')
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicPropertyBuilder.java20
1 files changed, 15 insertions, 5 deletions
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicPropertyBuilder.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicPropertyBuilder.java
index 4982d11d..e8031c1a 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicPropertyBuilder.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicPropertyBuilder.java
@@ -25,7 +25,7 @@ import java.util.Properties;
/**
* Builder of properties used when configuring topics.
*/
-public class TopicPropertyBuilder {
+public abstract class TopicPropertyBuilder {
private final Properties properties = new Properties();
private final String prefix;
private String topicPrefix;
@@ -37,7 +37,6 @@ public class TopicPropertyBuilder {
*/
public TopicPropertyBuilder(String prefix) {
this.prefix = prefix;
- properties.setProperty(prefix, "");
}
/**
@@ -53,6 +52,15 @@ public class TopicPropertyBuilder {
}
/**
+ * Adds a topic to the list of topics, configuring all of its properties with default
+ * values.
+ *
+ * @param topic the topic to be added
+ * @return this builder
+ */
+ public abstract TopicPropertyBuilder makeTopic(String topic);
+
+ /**
* Adds a topic to the list of topics. Also sets the current topic so that subsequent
* invocations of property methods will manipulate the topic's properties.
*
@@ -62,10 +70,12 @@ public class TopicPropertyBuilder {
public TopicPropertyBuilder addTopic(String topic) {
// add topic to the list of topics
String topicList = properties.getProperty(prefix);
- if (!topicList.isEmpty()) {
- topicList += ",";
+ if (topicList == null || topicList.isEmpty()) {
+ topicList = topic;
+ } else {
+ topicList += "," + topic;
}
- topicList += topic;
+
properties.setProperty(prefix, topicList);
setTopic(topic);