[DMAAP-BC] Fix failing jenkins
[dmaap/buscontroller.git] / dmaap-bc / src / test / java / org / onap / dmaap / dbcapi / model / MRClientTest.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
23 package org.onap.dmaap.dbcapi.model;
24
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertTrue;
27
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
31
32 public class MRClientTest {
33
34     ReflectionHarness rh = new ReflectionHarness();
35
36     String d, t, f, c, m;
37
38     @Before
39     public void setUp() throws Exception {
40         System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
41         d = "central-onap";
42         t = "org.onap.dmaap.interestingTopic";
43         f = "mrc.onap.org:3904/events/org.onap.dmaap.interestingTopic";
44         c = "publisher";
45         m = "m12345";
46     }
47
48     @Test
49     public void test1() {
50         // can't use simple reflection to test for null since null constructor
51         // initializes some fields.
52         // rh.reflect( "org.onap.dmaap.dbcapi.model.MR_Client", "get", null );
53         // so brute force instead...
54         String[] a = { "put", "view" };
55         MR_Client m = new MR_Client();
56
57         assertTrue(null == m.getDcaeLocationName());
58         assertTrue(null == m.getFqtn());
59         assertTrue(null == m.getClientRole());
60         assertTrue(null == m.getAction());
61
62     }
63
64     @Test
65     public void test2() {
66         String[] a = { "put", "view" };
67         MR_Client m = new MR_Client(d, f, c, a);
68
69         assertTrue(d.equals(m.getDcaeLocationName()));
70         assertTrue(f.equals(m.getFqtn()));
71         assertTrue(c.equals(m.getClientRole()));
72         String[] ma = m.getAction();
73         assertTrue(a.length == ma.length);
74         for (int i = 0; i < a.length; i++) {
75             assertTrue(a[i].equals(ma[i]));
76         }
77     }
78
79     @Test
80     public void test3() {
81         String v = "Validate";
82         rh.reflect("org.onap.dmaap.dbcapi.model.MR_Client", "set", v);
83     }
84
85     @Test
86     public void test4() {
87         MR_Client mrClient = new MR_Client();
88         String stringArray[] = { "test" };
89         mrClient.setAction(stringArray);
90         mrClient.hasAction("");
91         mrClient.setMrClientId("mrClientId");
92         mrClient.setTopicURL("testTopicURL");
93         mrClient.setClientIdentity("clientIdentity");
94
95         assertEquals("clientIdentity", mrClient.getClientIdentity());
96         assertEquals("testTopicURL", mrClient.getTopicURL());
97         assertEquals("mrClientId", mrClient.getMrClientId());
98         assertEquals(false, mrClient.isPublisher());
99         assertEquals(false, mrClient.isSubscriber());
100         assertEquals("test", mrClient.getAction()[0]);
101     }
102
103 }