[DMAAP-BC] Fix failing jenkins
[dmaap/buscontroller.git] / dmaap-bc / src / test / java / org / onap / dmaap / dbcapi / model / MR_ClusterTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * org.onap.dmaap
4  * ================================================================================
5  * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.dmaap.dbcapi.model;
21
22 import static org.junit.Assert.assertTrue;
23
24 import org.junit.Before;
25 import org.junit.Test;
26 import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
27 public class MR_ClusterTest {
28         String d, fqdn, repGrp, p1, p2, prot, p0;
29
30         ReflectionHarness rh = new ReflectionHarness();
31
32         @Before
33         public void setUp() throws Exception {
34                 System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
35                 d = "central-onap";
36                 fqdn = "mr.onap.org";
37                 repGrp = "zeppelin";
38                 prot = "http";
39                 p0 = "3904";
40                 p1 = "9092";
41                 p2 = "2323";
42                 
43         
44                 
45         }
46
47         @Test
48         public void testMR_ClusterClassDefaultConstructor() {
49                 MR_Cluster t = new MR_Cluster();
50         
51                 assertTrue( t.getDcaeLocationName() == null  );
52                 assertTrue( t.getFqdn() == null  );
53         
54         }
55
56         @Test
57         public void testMR_ClusterClassConstructor() {
58
59                 MR_Cluster t = new MR_Cluster( d, fqdn, prot, p0);
60         
61                 assertTrue( t.getDcaeLocationName() == d  );
62                 assertTrue( t.getFqdn() == fqdn  );
63                 assertTrue( t.getTopicProtocol() == prot );
64                 assertTrue( t.getTopicPort() == p0 );
65                 
66                 // pass null params to trigger default settings
67                  t = new MR_Cluster( d, fqdn, null, null );
68                 
69                 assertTrue( t.getDcaeLocationName() == d  );
70                 assertTrue( t.getFqdn() == fqdn  );
71                 assertTrue( t.getTopicProtocol() != null );
72                 assertTrue( t.getTopicPort() != null );
73         }
74         
75         @Test
76         public void testMR_ClusterManyArgsClassConstructor() {
77
78                 MR_Cluster t = new MR_Cluster( d, fqdn, prot, p0, repGrp, p1, p2 );
79         
80                 assertTrue( t.getDcaeLocationName() == d  );
81                 assertTrue( t.getFqdn() == fqdn  );
82                 assertTrue( t.getTopicProtocol() == prot );
83                 assertTrue( t.getTopicPort() == p0 );
84                 assertTrue( t.getReplicationGroup() == repGrp  );
85                 assertTrue( t.getSourceReplicationPort() == p1  );
86                 assertTrue( t.getTargetReplicationPort() == p2 );
87                 
88                 // pass null params to trigger default settings
89                 t = new MR_Cluster( d, fqdn, null, null, null, null, null );
90                 
91                 assertTrue( t.getDcaeLocationName() == d  );
92                 assertTrue( t.getFqdn() == fqdn  );
93                 assertTrue( t.getTopicProtocol() != null );
94                 assertTrue( t.getTopicPort() != null );
95                 assertTrue( t.getReplicationGroup() != null  );
96                 assertTrue( t.getSourceReplicationPort() != null  );
97                 assertTrue( t.getTargetReplicationPort() != null );
98         }
99
100         @Test
101         public void testw3() {
102
103                 MR_Cluster t = new MR_Cluster();
104         
105                 assertTrue( t.getDcaeLocationName() == null  );
106                 assertTrue( t.getFqdn() == null  );
107
108                 String override = "cluster2.onap.org";
109                 String  topic2 = "org.onap.topic2";
110                 String fqtn = t.genTopicURL( override, topic2 );        
111                 assertTrue( fqtn.contains( override) && fqtn.contains(topic2));
112                 
113                 fqtn = t.genTopicURL( null, "org.onap.topic2" );
114                 assertTrue(fqtn.contains(topic2));
115         }
116
117         @Test
118         public void testsetter() {
119                 String v = "validate";
120                 rh.reflect( "org.onap.dmaap.dbcapi.model.MR_Cluster", "set", v );
121         }
122
123 }