summaryrefslogtreecommitdiffstats
path: root/policy-endpoints/src
diff options
context:
space:
mode:
Diffstat (limited to 'policy-endpoints/src')
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParamsTest.java16
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.java16
2 files changed, 27 insertions, 5 deletions
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 c00f2b56..93e5067e 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-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2020 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.
@@ -41,7 +41,7 @@ public class BusTopicParamsTest extends TopicTestBase {
}
@Test
- public void test() {
+ public void testGetters() {
BusTopicParams params = makeBuilder().build();
assertEquals(addProps, params.getAdditionalProps());
@@ -69,11 +69,19 @@ public class BusTopicParamsTest extends TopicTestBase {
assertEquals(MY_EFFECTIVE_TOPIC, params.getEffectiveTopic());
assertEquals(true, params.isUseHttps());
assertEquals(MY_USERNAME, params.getUserName());
+ }
+ @Test
+ public void testBooleanGetters() {
// ensure that booleans are independent of each other
testBoolean("true:false:false", (bldr, flag) -> bldr.allowSelfSignedCerts(flag));
testBoolean("false:true:false", (bldr, flag) -> bldr.managed(flag));
testBoolean("false:false:true", (bldr, flag) -> bldr.useHttps(flag));
+ }
+
+ @Test
+ public void testValidators() {
+ BusTopicParams params = makeBuilder().build();
// test validity methods
assertTrue(params.isAdditionalPropsValid());
@@ -94,8 +102,10 @@ public class BusTopicParamsTest extends TopicTestBase {
assertFalse(params.isServersInvalid());
assertFalse(params.isTopicInvalid());
assertTrue(params.isUserNameValid());
+ }
- // test inverted validity
+ @Test
+ public void testInvertedValidators() {
assertFalse(makeBuilder().additionalProps(null).build().isAdditionalPropsValid());
assertTrue(makeBuilder().aftEnvironment("").build().isAftEnvironmentInvalid());
assertFalse(makeBuilder().apiKey("").build().isApiKeyValid());
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 67b84ea8..0f09b12e 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
@@ -194,9 +194,15 @@ public class TopicBaseTest extends TopicTestBase {
assertTrue(base.unlock());
assertEquals(1, base.startCount);
assertEquals(1, base.stopCount);
+ }
+
+ /**
+ * Tests lock/unlock when the stop/start methods return false.
+ */
+ @Test
+ public void testLock_testUnlock_FalseReturns() {
// lock, but stop returns false
- base = new TopicBaseImpl(servers, MY_TOPIC);
base.stopReturn = false;
assertFalse(base.lock());
assertTrue(base.isLocked());
@@ -207,9 +213,15 @@ public class TopicBaseTest extends TopicTestBase {
assertFalse(base.unlock());
assertFalse(base.isLocked());
assertTrue(base.unlock());
+ }
+
+ /**
+ * Tests lock/unlock when the start method throws an exception.
+ */
+ @Test
+ public void testLock_testUnlock_Exception() {
// lock & re-lock, but start throws an exception
- base = new TopicBaseImpl(servers, MY_TOPIC);
base.startEx = true;
assertTrue(base.lock());
assertFalse(base.unlock());