[DMAAP-BC] Fix failing jenkins
[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.Before;
28 import org.junit.Test;
29 import org.onap.dmaap.dbcapi.model.DmaapObject.DmaapObject_Status;
30 import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
31
32 public class TopicTest {
33
34     ReflectionHarness rh = new ReflectionHarness();
35
36     String f, t, d, e, o;
37
38     @Before
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";
44         e = "Yes";
45         o = "m12345";
46     }
47
48     @Test
49     public void test1() {
50         rh.reflect("org.onap.dmaap.dbcapi.model.Topic", "get", null);
51     }
52
53     @Test
54     public void test2() {
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()));
61     }
62
63     @Test
64     public void test3() {
65         String v = "Validate";
66         rh.reflect("org.onap.dmaap.dbcapi.model.Topic", "set", v);
67     }
68
69     @Test
70     public void getNumClientsHavingMRClientListNull() {
71         Topic obj = new Topic(f, t, d, e, o);
72         obj.setClients(null);
73         assertEquals(0, obj.getNumClients());
74     }
75
76     @Test
77     public void testTopicInitializationWithInvalidJsonString() {
78         String json = "{\"key\":\"value\"";
79         Topic obj = new Topic(json);
80         assertEquals(DmaapObject_Status.INVALID, obj.getStatus());
81     }
82
83 }