c56fa46c8841e5182fc0d658a9265fc46de927bb
[portal.git] / ecomp-portal-BE-common / src / test / java / org / onap / portalapp / portal / transport / CentralAppTest.java
1 /*-
2  * ============LICENSE_START==========================================
3  * ONAP Portal
4  * ===================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ===================================================================
7  *
8  * Unless otherwise specified, all software contained herein is licensed
9  * under the Apache License, Version 2.0 (the "License");
10  * you may not use this software 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  *
21  * Unless otherwise specified, all documentation contained herein is licensed
22  * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23  * you may not use this documentation except in compliance with the License.
24  * You may obtain a copy of the License at
25  *
26  *             https://creativecommons.org/licenses/by/4.0/
27  *
28  * Unless required by applicable law or agreed to in writing, documentation
29  * distributed under the License is distributed on an "AS IS" BASIS,
30  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31  * See the License for the specific language governing permissions and
32  * limitations under the License.
33  *
34  * ============LICENSE_END============================================
35  *
36  * 
37  */
38 package org.onap.portalapp.portal.transport;
39
40 import static org.junit.Assert.*;
41
42 import java.util.Date;
43
44 import org.junit.Test;
45 import org.onap.portalapp.portal.transport.CentralApp;
46
47 public class CentralAppTest {
48         
49         CentralApp centralApp=new CentralApp();
50
51         private static final String TEST="test";
52         public CentralApp mockCentralApp(){
53                 CentralApp centralApp = new CentralApp((long)1, null, null, (long)1, (long)1, (long)1, TEST, TEST, TEST, TEST, TEST, TEST, TEST, TEST, TEST, 
54                                 TEST, TEST, TEST, TEST, null, TEST, TEST, TEST, TEST);
55                                 return centralApp;
56         }
57         
58         @Test
59         public void centralAppTest(){
60                 CentralApp centralApp = mockCentralApp();
61                 
62                 CentralApp centralApp1 = buildCentralApp();
63                 
64                 assertEquals(centralApp.getId(), new Long(1));
65                 assertEquals(centralApp.getCreatedId(), new Long(1));
66                 assertEquals(centralApp.getModifiedId(), new Long(1));
67                 assertEquals(centralApp.getRowNum(), new Long(1));
68                 assertEquals(centralApp.getName(), TEST);
69                 assertEquals(centralApp.getImageUrl(), TEST);
70                 assertEquals(centralApp.getDescription(), TEST);
71                 assertEquals(centralApp.getNotes(), TEST);
72                 assertEquals(centralApp.getUrl(), TEST);
73                 assertEquals(centralApp.getAlternateUrl(), TEST);
74                 assertEquals(centralApp.getRestEndpoint(), TEST);
75                 assertEquals(centralApp.getMlAppName(), TEST);
76                 assertEquals(centralApp.getMlAppAdminId(), TEST);
77                 assertEquals(centralApp.getMotsId(), TEST);
78                 assertEquals(centralApp.getAppPassword(), TEST);
79                 assertEquals(centralApp.getOpen(), TEST);
80                 assertEquals(centralApp.getEnabled(), TEST);
81                 assertEquals(centralApp.getUsername(), TEST);
82                 assertEquals(centralApp.getUebKey(), TEST);
83                 assertEquals(centralApp.getUebSecret(), TEST);
84                 assertEquals(centralApp.getUebTopicName(), TEST);
85                 
86                 assertTrue(centralApp.equals(centralApp1));
87                 assertEquals(centralApp.hashCode(), centralApp1.hashCode());
88         }
89         
90         private CentralApp buildCentralApp() {
91                 CentralApp centralApp =  new CentralApp();
92                 centralApp.setId(1l);
93                 centralApp.setCreatedId(1l);
94                 centralApp.setModifiedId(1l);
95                 centralApp.setRowNum(1l);
96                 centralApp.setName(TEST);
97                 centralApp.setImageUrl(TEST);
98                 centralApp.setDescription(TEST);
99                 centralApp.setNotes(TEST);
100                 centralApp.setUrl(TEST);
101                 centralApp.setAlternateUrl(TEST);
102                 centralApp.setRestEndpoint(TEST);
103                 centralApp.setMlAppAdminId(TEST);
104                 centralApp.setMlAppName(TEST);
105                 centralApp.setMotsId(TEST);
106                 centralApp.setAppPassword(TEST);
107                 centralApp.setOpen(TEST);
108                 centralApp.setEnabled(TEST);
109                 centralApp.setUsername(TEST);
110                 centralApp.setUebKey(TEST);
111                 centralApp.setUebSecret(TEST);
112                 centralApp.setUebTopicName(TEST);
113                 
114                 
115                 
116                 
117                 
118                 
119                 
120                 
121                 return centralApp;
122                 
123         }
124         
125         
126         @Test
127         public void unt_IdTest(){
128                 Long defaultValue=123L;
129                 centralApp.setId(defaultValue);
130                 assertEquals(defaultValue, centralApp.getId());
131         }
132         
133         @Test
134         public void unt_createdTest(){
135                 Date defaultValue=new Date();
136                 centralApp.setCreated(defaultValue);
137                 assertEquals(defaultValue, centralApp.getCreated());
138         }
139         
140         @Test
141         public void unt_modifiedTest(){
142                 Date defaultValue=new Date();
143                 centralApp.setCreated(defaultValue);
144                 assertEquals(defaultValue, centralApp.getCreated());
145         }
146         
147         @Test
148         public void unt_craetedIdTest(){
149                 Long defaultValue=123L;
150                 centralApp.setCreatedId(defaultValue);
151                 assertEquals(defaultValue, centralApp.getCreatedId());
152         }
153         
154         @Test
155         public void unt_modifiedIdTest(){
156                 Long defaultValue=123L;
157                 centralApp.setModifiedId(defaultValue);
158                 assertEquals(defaultValue, centralApp.getModifiedId());
159         }
160         
161         @Test
162         public void unt_rowNumTest(){
163                 Long defaultValue=123L;
164                 centralApp.setRowNum(defaultValue);
165                 assertEquals(defaultValue, centralApp.getRowNum());
166         }
167         
168
169         @Test
170         public void unt_nameTest(){
171                 String defaultValue="test";
172                 centralApp.setName(defaultValue);
173                 assertEquals(defaultValue, centralApp.getName());
174         }
175         
176         @Test
177         public void unt_ImageUrlTest(){
178                 String defaultValue="test";
179                 centralApp.setImageUrl(defaultValue);
180                 assertEquals(defaultValue, centralApp.getImageUrl());
181         }
182         
183         @Test
184         public void unt_descriptionTest(){
185                 String defaultValue="test";
186                 centralApp.setDescription(defaultValue);
187                 assertEquals(defaultValue, centralApp.getDescription());
188         }
189         
190         @Test
191         public void unt_notesTest(){
192                 String defaultValue="test";
193                 centralApp.setNotes(defaultValue);
194                 assertEquals(defaultValue, centralApp.getNotes());
195         }
196         
197         @Test
198         public void unt_urlTest(){
199                 String defaultValue="testUrl";
200                 centralApp.setUrl(defaultValue);
201                 assertEquals(defaultValue, centralApp.getUrl());
202         }
203         
204         @Test
205         public void unt_alternateUrlTest(){
206                 String defaultValue="testUrl";
207                 centralApp.setAlternateUrl(defaultValue);
208                 assertEquals(defaultValue, centralApp.getAlternateUrl());
209         }
210         
211         @Test
212         public void unt_restendpointTest(){
213                 String defaultValue="testUrl";
214                 centralApp.setRestEndpoint(defaultValue);
215                 assertEquals(defaultValue, centralApp.getRestEndpoint());
216         }
217         
218         @Test
219         public void unt_mlAppNameTest(){
220                 String defaultValue="testAppName";
221                 centralApp.setMlAppName(defaultValue);
222                 assertEquals(defaultValue, centralApp.getMlAppName());
223         }
224         
225         @Test
226         public void unt_mlAppAdminIdTest(){
227                 String defaultValue="testAppAdminId";
228                 centralApp.setMlAppAdminId(defaultValue);
229                 assertEquals(defaultValue, centralApp.getMlAppAdminId());
230         }
231         
232         @Test
233         public void unt_motsIdIdTest(){
234                 String defaultValue="testmotsid";
235                 centralApp.setMotsId(defaultValue);
236                 assertEquals(defaultValue, centralApp.getMotsId());
237         }
238         
239         @Test
240         public void unt_appPasswordTest(){
241                 String defaultValue="TestAppPassword";
242                 centralApp.setAppPassword(defaultValue);
243                 assertEquals(defaultValue, centralApp.getAppPassword());
244         }
245         
246         @Test
247         public void unt_openTest(){
248                 String defaultValue="Testopen";
249                 centralApp.setOpen(defaultValue);
250                 assertEquals(defaultValue, centralApp.getOpen());
251         }
252         
253         @Test
254         public void unt_enabledTest(){
255                 String defaultValue="Testenable";
256                 centralApp.setEnabled(defaultValue);
257                 assertEquals(defaultValue, centralApp.getEnabled());
258         }
259         
260         @Test
261         public void unt_thumbnailTest(){
262                 byte[] defaultValue={1,2,3};
263                 centralApp.setThumbnail(defaultValue);
264                 assertEquals(defaultValue, centralApp.getThumbnail());
265         }
266         
267         @Test
268         public void unt_userNameTest(){
269                 String defaultValue="Testusername";
270                 centralApp.setUsername(defaultValue);
271                 assertEquals(defaultValue, centralApp.getUsername());
272         }
273         
274         @Test
275         public void unt_uebKeyTest(){
276                 String defaultValue="Testuebkey";
277                 centralApp.setUebKey(defaultValue);
278                 assertEquals(defaultValue, centralApp.getUebKey());
279         }
280         
281         @Test
282         public void unt_uebSecreteTest(){
283                 String defaultValue="Testuebscrete";
284                 centralApp.setUebSecret(defaultValue);
285                 assertEquals(defaultValue, centralApp.getUebSecret());
286         }
287         
288         @Test
289         public void unt_uebTopicNameTest(){
290                 String defaultValue="Testuebtopicname";
291                 centralApp.setUebTopicName(defaultValue);
292                 assertEquals(defaultValue, centralApp.getUebTopicName());
293         }
294         
295         @Test
296         public void unt_hashCodeWithNullTest(){
297                 CentralApp centralApp=new CentralApp(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
298                 
299                 CentralApp centralApp1=new CentralApp(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
300
301                 assertEquals(centralApp.hashCode(), centralApp1.hashCode());
302                 assertTrue(centralApp.equals(centralApp1));
303                 
304         }
305         
306         @Test
307         public void unt_hashCodeTest(){
308                 CentralApp centralApp=new CentralApp((long)1, null, null, (long)1, (long)1, (long)1, "test", "test", "test", "test", "test", "test", "test", "test", "test", 
309                                 "test", "test", "test", "test", null, "test", "test", "test", "test");
310                 
311                 CentralApp centralApp1=new CentralApp((long)1, null, null, (long)1, (long)1, (long)1, "test", "test", "test", "test", "test", "test", "test", "test", "test", 
312                                 "test", "test", "test", "test", null, "test", "test", "test", "test");
313
314                 assertEquals(centralApp.hashCode(), centralApp1.hashCode());
315                 assertTrue(centralApp.equals(centralApp1));
316                 
317         }
318         
319         @Test
320         public void unt_hashCodeTestWithNull(){
321                 CentralApp centralApp=new CentralApp((long)1, null, null, (long)1, (long)1, (long)1, "test", "test", "test", "test", "test", "test", "test", "test", "test", 
322                                 "test", "test", "test", "test", null, "test", "test", "test", "test");
323                 CentralApp centralApp1=new CentralApp((long)1, null, null, (long)1, (long)1, (long)1, "test", "test", "test", "test", "test", "test", "test", "test", "test", 
324                                 "test", "test", "test", "test", null, "test", "test", "test", "test");
325                 assertEquals(centralApp.hashCode(), centralApp1.hashCode());
326                 assertFalse(centralApp.equals(null));
327                 
328         }
329         
330         @Test
331         public void unt_hashCodeTestWithNull1(){
332                 CentralApp centralApp=new CentralApp(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
333                 CentralApp centralApp1=new CentralApp((long)1, null, null, (long)1, (long)1, (long)1, "test", "test", "test", "test", "test", "test", "test", "test", "test", 
334                                 "test", "test", "test", "test", null, "test", "test", "test", "test");
335                 assertFalse(centralApp.equals(centralApp1));
336                 
337         }
338         
339         @Test
340         public void unt_hashCodeTestWithalternateURL(){
341                 CentralApp centralApp=new CentralApp(null, null, null, null, null, null, null, null, null, null, null, "test1", null, null, null, null, null, null, null, null, null, null, null, null);
342                 CentralApp centralApp1=new CentralApp((long)1, null, null, (long)1, (long)1, (long)1, "test", "test", "test", "test", "test", "test", "test", "test", "test", 
343                                 "test", "test", "test", "test", null, "test", "test", "test", "test");
344                 assertFalse(centralApp.equals(centralApp1));
345                 
346         }
347         
348         @Test
349         public void unt_hashCodeTestWithpassword(){
350                 CentralApp centralApp=new CentralApp(null, null, null, null, null, null, null, null, null, null, null, "test", null, null, null, null, "testPass", null, null, null, null, null, null, null);
351                 CentralApp centralApp1=new CentralApp((long)1, null, null, (long)1, (long)1, (long)1, "test", "test", "test", "test", "test", "test", "test", "test", "test", 
352                                 "test", "test", "test", "test", null, "test", "test", "test", "test");
353                 assertFalse(centralApp.equals(centralApp1));
354                 
355         }
356         
357         @Test
358         public void unt_hashCodeTestWithcreateId(){
359                 CentralApp centralApp=new CentralApp(null, null, null, 123L, null, null, null, null, null, null, null, "test", null, null, null, null, "test", null, null, null, null, null, null, null);
360                 CentralApp centralApp1=new CentralApp((long)1, null, null, (long)1, (long)1, (long)1, "test", "test", "test", "test", "test", "test", "test", "test", "test", 
361                                 "test", "test", "test", "test", null, "test", "test", "test", "test");
362                 assertFalse(centralApp.equals(centralApp1));
363                 
364         }
365         
366         @Test
367         public void unt_hashCodeTestWithcreateId1(){
368                 CentralApp centralApp=new CentralApp(12L, null, null, 123L, 123L, 123L, "test1", "test1", "test1", "test1", "test1", "test", "tests1", "test1", "test1", null, "test", null, null, null, null, null, null, null);
369                 CentralApp centralApp1=new CentralApp((long)1, null, null, (long)1, (long)1, (long)1, "test", "test", "test", "test", "test", "test", "test", "test", "test", 
370                                 "test", "test", "test", "test", null, "test", "test", "test", "test");
371                 assertFalse(centralApp.equals(centralApp1));
372                 
373         }
374 }