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