2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018-2019 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.assertNotEquals;
26 import static org.junit.Assert.assertNotNull;
27 import static org.junit.Assert.assertTrue;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase;
32 import org.onap.policy.common.utils.gson.GsonTestUtils;
34 public class BusTopicBaseTest extends TopicTestBase {
36 private BusTopicBaseImpl base;
39 * Initializes the object to be tested.
46 base = new BusTopicBaseImpl(builder.build());
50 public void testToString() {
51 assertNotNull(base.toString());
55 public void testSerialize() {
56 new GsonTestUtils().compareGson(base, BusTopicBaseTest.class);
60 public void testGetApiKey() {
61 assertEquals(MY_API_KEY, base.getApiKey());
65 public void testGetApiSecret() {
66 assertEquals(MY_API_SECRET, base.getApiSecret());
70 public void testIsUseHttps() {
71 assertEquals(true, base.isUseHttps());
72 assertEquals(false, new BusTopicBaseImpl(builder.useHttps(false).build()).isUseHttps());
76 public void testIsAllowSelfSignedCerts() {
77 assertEquals(true, base.isAllowSelfSignedCerts());
78 assertEquals(false, new BusTopicBaseImpl(builder.allowSelfSignedCerts(false).build()).isAllowSelfSignedCerts());
82 public void testTopic() {
83 assertEquals(MY_TOPIC, base.getTopic());
84 assertEquals(MY_EFFECTIVE_TOPIC, base.getEffectiveTopic());
85 assertNotEquals(base.getTopic(), base.getEffectiveTopic());
89 public void testAnyNullOrEmpty() {
90 assertFalse(base.anyNullOrEmpty());
91 assertFalse(base.anyNullOrEmpty("any-none-null", "any-none-null-B"));
93 assertTrue(base.anyNullOrEmpty(null, "any-first-null"));
94 assertTrue(base.anyNullOrEmpty("any-middle-null", null, "any-middle-null-B"));
95 assertTrue(base.anyNullOrEmpty("any-last-null", null));
96 assertTrue(base.anyNullOrEmpty("any-empty", ""));
100 public void testAllNullOrEmpty() {
101 assertTrue(base.allNullOrEmpty());
102 assertTrue(base.allNullOrEmpty(""));
103 assertTrue(base.allNullOrEmpty(null, ""));
105 assertFalse(base.allNullOrEmpty("all-ok-only-one"));
106 assertFalse(base.allNullOrEmpty("all-ok-one", "all-ok-two"));
107 assertFalse(base.allNullOrEmpty("all-ok-null", null));
108 assertFalse(base.allNullOrEmpty("", "all-ok-empty"));
109 assertFalse(base.allNullOrEmpty("", "all-one-ok", null));
112 private static class BusTopicBaseImpl extends BusTopicBase {
114 public BusTopicBaseImpl(BusTopicParams busTopicParams) {
115 super(busTopicParams);
119 public CommInfrastructure getTopicCommInfrastructure() {
120 return CommInfrastructure.NOOP;
124 public boolean start() {
129 public boolean stop() {
134 public void shutdown() {