aboutsummaryrefslogtreecommitdiffstats
path: root/policy-endpoints
diff options
context:
space:
mode:
Diffstat (limited to 'policy-endpoints')
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactory.java2
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactory.java2
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactoryTestBase.java24
3 files changed, 26 insertions, 2 deletions
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactory.java
index dc207a84..09078720 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactory.java
@@ -395,7 +395,7 @@ class IndexedDmaapTopicSinkFactory implements DmaapTopicSinkFactory {
if (dmaapTopicWriters.containsKey(topic)) {
return dmaapTopicWriters.get(topic);
} else {
- throw new IllegalStateException("DmaapTopicSink for " + topic + " not found");
+ throw new IllegalArgumentException("DmaapTopicSink for " + topic + " not found");
}
}
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactory.java
index ae6c6c3b..f45164f8 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactory.java
@@ -448,7 +448,7 @@ class IndexedDmaapTopicSourceFactory implements DmaapTopicSourceFactory {
if (dmaapTopicSources.containsKey(topic)) {
return dmaapTopicSources.get(topic);
} else {
- throw new IllegalStateException("DmaapTopiceSource for " + topic + " not found");
+ throw new IllegalArgumentException("DmaapTopiceSource for " + topic + " not found");
}
}
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactoryTestBase.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactoryTestBase.java
index c008a3bf..440120e6 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactoryTestBase.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactoryTestBase.java
@@ -106,4 +106,28 @@ public abstract class DmaapTopicFactoryTestBase<T extends Topic> extends BusTopi
BusTopicParams params = getLastParams();
assertEquals(false, params.isAllowSelfSignedCerts());
}
+
+ /**
+ * Tests exception cases with get(topic). DMaaP topics are special in that they
+ * throw IllegalArgumentException, even for an unknown topic name; all of the
+ * other Topic Factory classes throw IllegalStateException, thus we override
+ * the default test method.
+ */
+ @Override
+ public void testGet_Ex() {
+ // null topic
+ RuntimeException actual = expectException(() -> getTopic(null));
+ assertEquals("null topic", IllegalArgumentException.class, actual.getClass());
+
+ // empty topic
+ actual = expectException(() -> getTopic(""));
+ assertEquals("empty topic", IllegalArgumentException.class, actual.getClass());
+
+ // unknown topic
+ initFactory();
+ buildTopics(makePropBuilder().makeTopic(MY_TOPIC).build());
+
+ actual = expectException(() -> getTopic(TOPIC2));
+ assertEquals("unknown topic", IllegalArgumentException.class, actual.getClass());
+ }
}