220062700eb33a870f9944fbadd00b2edb026a88
[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.*;
23
24 import org.junit.After;
25 import org.junit.Before;
26 import org.junit.Test;
27 import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
28 public class MR_ClusterTest {
29         String d, fqdn, repGrp, p1, p2, prot, p0;
30
31         ReflectionHarness rh = new ReflectionHarness();
32
33         @Before
34         public void setUp() throws Exception {
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         @After
48         public void tearDown() throws Exception {
49         }
50
51
52         @Test
53         public void testMR_ClusterClassDefaultConstructor() {
54
55                 MR_Cluster t = new MR_Cluster();
56         
57                 assertTrue( t.getDcaeLocationName() == null  );
58                 assertTrue( t.getFqdn() == null  );
59         
60         }
61
62         @Test
63         public void testMR_ClusterClassConstructor() {
64
65                 MR_Cluster t = new MR_Cluster( d, fqdn, prot, p0);
66         
67                 assertTrue( t.getDcaeLocationName() == d  );
68                 assertTrue( t.getFqdn() == fqdn  );
69                 assertTrue( t.getTopicProtocol() == prot );
70                 assertTrue( t.getTopicPort() == p0 );
71                 
72                 // pass null params to trigger default settings
73                  t = new MR_Cluster( d, fqdn, null, null );
74                 
75                 assertTrue( t.getDcaeLocationName() == d  );
76                 assertTrue( t.getFqdn() == fqdn  );
77                 assertTrue( t.getTopicProtocol() != null );
78                 assertTrue( t.getTopicPort() != null );
79         }
80         
81         @Test
82         public void testMR_ClusterManyArgsClassConstructor() {
83
84                 MR_Cluster t = new MR_Cluster( d, fqdn, prot, p0, repGrp, p1, p2 );
85         
86                 assertTrue( t.getDcaeLocationName() == d  );
87                 assertTrue( t.getFqdn() == fqdn  );
88                 assertTrue( t.getTopicProtocol() == prot );
89                 assertTrue( t.getTopicPort() == p0 );
90                 assertTrue( t.getReplicationGroup() == repGrp  );
91                 assertTrue( t.getSourceReplicationPort() == p1  );
92                 assertTrue( t.getTargetReplicationPort() == p2 );
93                 
94                 // pass null params to trigger default settings
95                 t = new MR_Cluster( d, fqdn, null, null, null, null, null );
96                 
97                 assertTrue( t.getDcaeLocationName() == d  );
98                 assertTrue( t.getFqdn() == fqdn  );
99                 assertTrue( t.getTopicProtocol() != null );
100                 assertTrue( t.getTopicPort() != null );
101                 assertTrue( t.getReplicationGroup() != null  );
102                 assertTrue( t.getSourceReplicationPort() != null  );
103                 assertTrue( t.getTargetReplicationPort() != null );
104         }
105
106         @Test
107         public void testw3() {
108
109                 MR_Cluster t = new MR_Cluster();
110         
111                 assertTrue( t.getDcaeLocationName() == null  );
112                 assertTrue( t.getFqdn() == null  );
113
114                 String override = "cluster2.onap.org";
115                 String  topic2 = "org.onap.topic2";
116                 String fqtn = t.genTopicURL( override, topic2 );        
117                 assertTrue( fqtn.contains( override) && fqtn.contains(topic2));
118                 
119                 fqtn = t.genTopicURL( null, "org.onap.topic2" );
120                 assertTrue(fqtn.contains(topic2));
121         }
122
123
124
125         @Test
126         public void testsetter() {
127
128                 String v = "validate";
129
130
131                 rh.reflect( "org.onap.dmaap.dbcapi.model.MR_Cluster", "set", v );       
132         
133         }
134
135 }