2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.common.endpoints.event.comm.bus.internal;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertFalse;
25 import static org.junit.Assert.assertNotNull;
26 import static org.junit.Assert.assertTrue;
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.onap.policy.common.endpoints.event.comm.bus.BusTopicTestBase;
32 public class BusTopicBaseTest extends BusTopicTestBase {
34 private BusTopicBaseImpl base;
37 * Initializes the object to be tested.
43 base = new BusTopicBaseImpl(builder.build());
47 public void testToString() {
48 assertNotNull(base.toString());
52 public void testGetApiKey() {
53 assertEquals(MY_API_KEY, base.getApiKey());
57 public void testGetApiSecret() {
58 assertEquals(MY_API_SECRET, base.getApiSecret());
62 public void testIsUseHttps() {
63 assertEquals(true, base.isUseHttps());
64 assertEquals(false, new BusTopicBaseImpl(builder.useHttps(false).build()).isUseHttps());
68 public void testIsAllowSelfSignedCerts() {
69 assertEquals(true, base.isAllowSelfSignedCerts());
70 assertEquals(false, new BusTopicBaseImpl(builder.allowSelfSignedCerts(false).build()).isAllowSelfSignedCerts());
74 public void testAnyNullOrEmpty() {
75 assertFalse(base.anyNullOrEmpty());
76 assertFalse(base.anyNullOrEmpty("any-none-null", "any-none-null-B"));
78 assertTrue(base.anyNullOrEmpty(null, "any-first-null"));
79 assertTrue(base.anyNullOrEmpty("any-middle-null", null, "any-middle-null-B"));
80 assertTrue(base.anyNullOrEmpty("any-last-null", null));
81 assertTrue(base.anyNullOrEmpty("any-empty", ""));
85 public void testAllNullOrEmpty() {
86 assertTrue(base.allNullOrEmpty());
87 assertTrue(base.allNullOrEmpty(""));
88 assertTrue(base.allNullOrEmpty(null, ""));
90 assertFalse(base.allNullOrEmpty("all-ok-only-one"));
91 assertFalse(base.allNullOrEmpty("all-ok-one", "all-ok-two"));
92 assertFalse(base.allNullOrEmpty("all-ok-null", null));
93 assertFalse(base.allNullOrEmpty("", "all-ok-empty"));
94 assertFalse(base.allNullOrEmpty("", "all-one-ok", null));
97 private static class BusTopicBaseImpl extends BusTopicBase {
99 public BusTopicBaseImpl(BusTopicParams busTopicParams) {
100 super(busTopicParams);
104 public CommInfrastructure getTopicCommInfrastructure() {
105 return CommInfrastructure.NOOP;
109 public boolean start() {
114 public boolean stop() {
119 public void shutdown() {