[DMAAP-BC] Consolidate bus controller repos
[dmaap/buscontroller.git] / dmaap-bc / src / test / java / org / onap / dmaap / dbcapi / model / TopicTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * org.onap.dmaap
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
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
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=========================================================
21  */
22 package org.onap.dmaap.dbcapi.model;
23
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertTrue;
26
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;
32
33 public class TopicTest {
34
35     ReflectionHarness rh = new ReflectionHarness();
36
37     String f, t, d, e, o;
38
39     @Before
40     public void setUp() throws Exception {
41         f = "org.onap.dmaap.interestingTopic";
42         t = "interestingTopic";
43         d = "A so very interesting topic";
44         e = "Yes";
45         o = "m12345";
46     }
47
48     @After
49     public void tearDown() throws Exception {
50     }
51
52     @Test
53     public void test1() {
54         rh.reflect("org.onap.dmaap.dbcapi.model.Topic", "get", null);
55     }
56
57     @Test
58     public void test2() {
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()));
65     }
66
67     @Test
68     public void test3() {
69         String v = "Validate";
70         rh.reflect("org.onap.dmaap.dbcapi.model.Topic", "set", v);
71     }
72
73     @Test
74     public void getNumClientsHavingMRClientListNull() {
75         Topic obj = new Topic(f, t, d, e, o);
76         obj.setClients(null);
77         assertEquals(0, obj.getNumClients());
78     }
79
80     @Test
81     public void testTopicInitializationWithInvalidJsonString() {
82         String json = "{\"key\":\"value\"";
83         Topic obj = new Topic(json);
84         assertEquals(DmaapObject_Status.INVALID, obj.getStatus());
85     }
86
87 }