2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (c) 2019 IBM
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
22 package org.onap.dmaap.dbcapi.model;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertTrue;
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.onap.dmaap.dbcapi.model.DmaapObject.DmaapObject_Status;
30 import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
32 public class TopicTest {
34 ReflectionHarness rh = new ReflectionHarness();
39 public void setUp() throws Exception {
40 System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
41 f = "org.onap.dmaap.interestingTopic";
42 t = "interestingTopic";
43 d = "A so very interesting topic";
50 rh.reflect("org.onap.dmaap.dbcapi.model.Topic", "get", null);
55 Topic obj = new Topic(f, t, d, e, o);
56 assertTrue(f.equals(obj.getFqtn()));
57 assertTrue(t.equals(obj.getTopicName()));
58 assertTrue(d.equals(obj.getTopicDescription()));
59 assertTrue(e.equals(obj.getTnxEnabled()));
60 assertTrue(o.equals(obj.getOwner()));
65 String v = "Validate";
66 rh.reflect("org.onap.dmaap.dbcapi.model.Topic", "set", v);
70 public void getNumClientsHavingMRClientListNull() {
71 Topic obj = new Topic(f, t, d, e, o);
73 assertEquals(0, obj.getNumClients());
77 public void testTopicInitializationWithInvalidJsonString() {
78 String json = "{\"key\":\"value\"";
79 Topic obj = new Topic(json);
80 assertEquals(DmaapObject_Status.INVALID, obj.getStatus());