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.
45 base = new BusTopicBaseImpl(builder.build());
49 public void testToString() {
50 assertNotNull(base.toString());
54 public void testSerialize() {
55 new GsonTestUtils().compareGson(base, BusTopicBaseTest.class);
59 public void testGetApiKey() {
60 assertEquals(MY_API_KEY, base.getApiKey());
64 public void testGetApiSecret() {
65 assertEquals(MY_API_SECRET, base.getApiSecret());
69 public void testIsUseHttps() {
70 assertEquals(true, base.isUseHttps());
71 assertEquals(false, new BusTopicBaseImpl(builder.useHttps(false).build()).isUseHttps());
75 public void testIsAllowSelfSignedCerts() {
76 assertEquals(true, base.isAllowSelfSignedCerts());
77 assertEquals(false, new BusTopicBaseImpl(builder.allowSelfSignedCerts(false).build()).isAllowSelfSignedCerts());
81 public void testTopic() {
82 assertEquals(MY_TOPIC, base.getTopic());
83 assertEquals(MY_EFFECTIVE_TOPIC, base.getEffectiveTopic());
84 assertNotEquals(base.getTopic(), base.getEffectiveTopic());
88 public void testAnyNullOrEmpty() {
89 assertFalse(base.anyNullOrEmpty());
90 assertFalse(base.anyNullOrEmpty("any-none-null", "any-none-null-B"));
92 assertTrue(base.anyNullOrEmpty(null, "any-first-null"));
93 assertTrue(base.anyNullOrEmpty("any-middle-null", null, "any-middle-null-B"));
94 assertTrue(base.anyNullOrEmpty("any-last-null", null));
95 assertTrue(base.anyNullOrEmpty("any-empty", ""));
99 public void testAllNullOrEmpty() {
100 assertTrue(base.allNullOrEmpty());
101 assertTrue(base.allNullOrEmpty(""));
102 assertTrue(base.allNullOrEmpty(null, ""));
104 assertFalse(base.allNullOrEmpty("all-ok-only-one"));
105 assertFalse(base.allNullOrEmpty("all-ok-one", "all-ok-two"));
106 assertFalse(base.allNullOrEmpty("all-ok-null", null));
107 assertFalse(base.allNullOrEmpty("", "all-ok-empty"));
108 assertFalse(base.allNullOrEmpty("", "all-one-ok", null));
111 private static class BusTopicBaseImpl extends BusTopicBase {
113 public BusTopicBaseImpl(BusTopicParams busTopicParams) {
114 super(busTopicParams);
118 public CommInfrastructure getTopicCommInfrastructure() {
119 return CommInfrastructure.NOOP;
123 public boolean start() {
128 public boolean stop() {
133 public void shutdown() {