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.After;
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.onap.dmaap.dbcapi.model.DmaapObject.DmaapObject_Status;
31 import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
33 public class TopicTest {
35 ReflectionHarness rh = new ReflectionHarness();
40 public void setUp() throws Exception {
41 f = "org.onap.dmaap.interestingTopic";
42 t = "interestingTopic";
43 d = "A so very interesting topic";
49 public void tearDown() throws Exception {
54 rh.reflect("org.onap.dmaap.dbcapi.model.Topic", "get", null);
59 Topic obj = new Topic(f, t, d, e, o);
60 assertTrue(f.equals(obj.getFqtn()));
61 assertTrue(t.equals(obj.getTopicName()));
62 assertTrue(d.equals(obj.getTopicDescription()));
63 assertTrue(e.equals(obj.getTnxEnabled()));
64 assertTrue(o.equals(obj.getOwner()));
69 String v = "Validate";
70 rh.reflect("org.onap.dmaap.dbcapi.model.Topic", "set", v);
74 public void getNumClientsHavingMRClientListNull() {
75 Topic obj = new Topic(f, t, d, e, o);
77 assertEquals(0, obj.getNumClients());
81 public void testTopicInitializationWithInvalidJsonString() {
82 String json = "{\"key\":\"value\"";
83 Topic obj = new Topic(json);
84 assertEquals(DmaapObject_Status.INVALID, obj.getStatus());