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.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.TopicTestBase;
31 import org.onap.policy.common.utils.gson.GsonTestUtils;
33 public class BusTopicBaseTest extends TopicTestBase {
35 private BusTopicBaseImpl base;
38 * Initializes the object to be tested.
44 base = new BusTopicBaseImpl(builder.build());
48 public void testToString() {
49 assertNotNull(base.toString());
53 public void testSerialize() {
54 new GsonTestUtils().compareGson(base, BusTopicBaseTest.class);
58 public void testGetApiKey() {
59 assertEquals(MY_API_KEY, base.getApiKey());
63 public void testGetApiSecret() {
64 assertEquals(MY_API_SECRET, base.getApiSecret());
68 public void testIsUseHttps() {
69 assertEquals(true, base.isUseHttps());
70 assertEquals(false, new BusTopicBaseImpl(builder.useHttps(false).build()).isUseHttps());
74 public void testIsAllowSelfSignedCerts() {
75 assertEquals(true, base.isAllowSelfSignedCerts());
76 assertEquals(false, new BusTopicBaseImpl(builder.allowSelfSignedCerts(false).build()).isAllowSelfSignedCerts());
80 public void testAnyNullOrEmpty() {
81 assertFalse(base.anyNullOrEmpty());
82 assertFalse(base.anyNullOrEmpty("any-none-null", "any-none-null-B"));
84 assertTrue(base.anyNullOrEmpty(null, "any-first-null"));
85 assertTrue(base.anyNullOrEmpty("any-middle-null", null, "any-middle-null-B"));
86 assertTrue(base.anyNullOrEmpty("any-last-null", null));
87 assertTrue(base.anyNullOrEmpty("any-empty", ""));
91 public void testAllNullOrEmpty() {
92 assertTrue(base.allNullOrEmpty());
93 assertTrue(base.allNullOrEmpty(""));
94 assertTrue(base.allNullOrEmpty(null, ""));
96 assertFalse(base.allNullOrEmpty("all-ok-only-one"));
97 assertFalse(base.allNullOrEmpty("all-ok-one", "all-ok-two"));
98 assertFalse(base.allNullOrEmpty("all-ok-null", null));
99 assertFalse(base.allNullOrEmpty("", "all-ok-empty"));
100 assertFalse(base.allNullOrEmpty("", "all-one-ok", null));
103 private static class BusTopicBaseImpl extends BusTopicBase {
105 public BusTopicBaseImpl(BusTopicParams busTopicParams) {
106 super(busTopicParams);
110 public CommInfrastructure getTopicCommInfrastructure() {
111 return CommInfrastructure.NOOP;
115 public boolean start() {
120 public boolean stop() {
125 public void shutdown() {