Reduce number of parameters in constructor
[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 import java.util.Date;
42 import org.junit.Test;
43
44 public class CentralAppTest {
45
46     CentralApp centralApp = new CentralApp.CentralAppBuilder().createCentralApp();
47
48     private static final String TEST = "test";
49
50     public CentralApp mockCentralApp() {
51         CentralApp centralApp = new CentralApp.CentralAppBuilder().setId((long) 1).setCreated(null).setModified(null)
52                 .setCreatedId((long) 1).setModifiedId((long) 1).setRowNum((long) 1).setName(TEST).setImageUrl(TEST)
53                 .setDescription(TEST).setNotes(TEST).setUrl(TEST).setAlternateUrl(TEST).setRestEndpoint(TEST)
54                 .setMlAppName(TEST).setMlAppAdminId(TEST).setMotsId(TEST).setAppPassword(TEST).setOpen(TEST)
55                 .setEnabled(TEST).setThumbnail(null).setUsername(TEST).setUebKey(TEST).setUebSecret(TEST)
56                 .setUebTopicName(TEST).createCentralApp();
57         return centralApp;
58     }
59
60     @Test
61     public void centralAppTest() {
62         CentralApp centralApp = mockCentralApp();
63
64         CentralApp centralApp1 = buildCentralApp();
65
66         assertEquals(centralApp.getId(), new Long(1));
67         assertEquals(centralApp.getCreatedId(), new Long(1));
68         assertEquals(centralApp.getModifiedId(), new Long(1));
69         assertEquals(centralApp.getRowNum(), new Long(1));
70         assertEquals(centralApp.getName(), TEST);
71         assertEquals(centralApp.getImageUrl(), TEST);
72         assertEquals(centralApp.getDescription(), TEST);
73         assertEquals(centralApp.getNotes(), TEST);
74         assertEquals(centralApp.getUrl(), TEST);
75         assertEquals(centralApp.getAlternateUrl(), TEST);
76         assertEquals(centralApp.getRestEndpoint(), TEST);
77         assertEquals(centralApp.getMlAppName(), TEST);
78         assertEquals(centralApp.getMlAppAdminId(), TEST);
79         assertEquals(centralApp.getMotsId(), TEST);
80         assertEquals(centralApp.getAppPassword(), TEST);
81         assertEquals(centralApp.getOpen(), TEST);
82         assertEquals(centralApp.getEnabled(), TEST);
83         assertEquals(centralApp.getUsername(), TEST);
84         assertEquals(centralApp.getUebKey(), TEST);
85         assertEquals(centralApp.getUebSecret(), TEST);
86         assertEquals(centralApp.getUebTopicName(), TEST);
87
88         assertTrue(centralApp.equals(centralApp1));
89         assertEquals(centralApp.hashCode(), centralApp1.hashCode());
90     }
91
92     private CentralApp buildCentralApp() {
93         CentralApp centralApp = new CentralApp.CentralAppBuilder().createCentralApp();
94         centralApp.setId(1l);
95         centralApp.setCreatedId(1l);
96         centralApp.setModifiedId(1l);
97         centralApp.setRowNum(1l);
98         centralApp.setName(TEST);
99         centralApp.setImageUrl(TEST);
100         centralApp.setDescription(TEST);
101         centralApp.setNotes(TEST);
102         centralApp.setUrl(TEST);
103         centralApp.setAlternateUrl(TEST);
104         centralApp.setRestEndpoint(TEST);
105         centralApp.setMlAppAdminId(TEST);
106         centralApp.setMlAppName(TEST);
107         centralApp.setMotsId(TEST);
108         centralApp.setAppPassword(TEST);
109         centralApp.setOpen(TEST);
110         centralApp.setEnabled(TEST);
111         centralApp.setUsername(TEST);
112         centralApp.setUebKey(TEST);
113         centralApp.setUebSecret(TEST);
114         centralApp.setUebTopicName(TEST);
115         return centralApp;
116     }
117
118     @Test
119     public void unt_IdTest() {
120         Long defaultValue = 123L;
121         centralApp.setId(defaultValue);
122         assertEquals(defaultValue, centralApp.getId());
123     }
124
125     @Test
126     public void unt_createdTest() {
127         Date defaultValue = new Date();
128         centralApp.setCreated(defaultValue);
129         assertEquals(defaultValue, centralApp.getCreated());
130     }
131
132     @Test
133     public void unt_modifiedTest() {
134         Date defaultValue = new Date();
135         centralApp.setCreated(defaultValue);
136         assertEquals(defaultValue, centralApp.getCreated());
137     }
138
139     @Test
140     public void unt_craetedIdTest() {
141         Long defaultValue = 123L;
142         centralApp.setCreatedId(defaultValue);
143         assertEquals(defaultValue, centralApp.getCreatedId());
144     }
145
146     @Test
147     public void unt_modifiedIdTest() {
148         Long defaultValue = 123L;
149         centralApp.setModifiedId(defaultValue);
150         assertEquals(defaultValue, centralApp.getModifiedId());
151     }
152
153     @Test
154     public void unt_rowNumTest() {
155         Long defaultValue = 123L;
156         centralApp.setRowNum(defaultValue);
157         assertEquals(defaultValue, centralApp.getRowNum());
158     }
159
160     @Test
161     public void unt_nameTest() {
162         String defaultValue = "test";
163         centralApp.setName(defaultValue);
164         assertEquals(defaultValue, centralApp.getName());
165     }
166
167     @Test
168     public void unt_ImageUrlTest() {
169         String defaultValue = "test";
170         centralApp.setImageUrl(defaultValue);
171         assertEquals(defaultValue, centralApp.getImageUrl());
172     }
173
174     @Test
175     public void unt_descriptionTest() {
176         String defaultValue = "test";
177         centralApp.setDescription(defaultValue);
178         assertEquals(defaultValue, centralApp.getDescription());
179     }
180
181     @Test
182     public void unt_notesTest() {
183         String defaultValue = "test";
184         centralApp.setNotes(defaultValue);
185         assertEquals(defaultValue, centralApp.getNotes());
186     }
187
188     @Test
189     public void unt_urlTest() {
190         String defaultValue = "testUrl";
191         centralApp.setUrl(defaultValue);
192         assertEquals(defaultValue, centralApp.getUrl());
193     }
194
195     @Test
196     public void unt_alternateUrlTest() {
197         String defaultValue = "testUrl";
198         centralApp.setAlternateUrl(defaultValue);
199         assertEquals(defaultValue, centralApp.getAlternateUrl());
200     }
201
202     @Test
203     public void unt_restendpointTest() {
204         String defaultValue = "testUrl";
205         centralApp.setRestEndpoint(defaultValue);
206         assertEquals(defaultValue, centralApp.getRestEndpoint());
207     }
208
209     @Test
210     public void unt_mlAppNameTest() {
211         String defaultValue = "testAppName";
212         centralApp.setMlAppName(defaultValue);
213         assertEquals(defaultValue, centralApp.getMlAppName());
214     }
215
216     @Test
217     public void unt_mlAppAdminIdTest() {
218         String defaultValue = "testAppAdminId";
219         centralApp.setMlAppAdminId(defaultValue);
220         assertEquals(defaultValue, centralApp.getMlAppAdminId());
221     }
222
223     @Test
224     public void unt_motsIdIdTest() {
225         String defaultValue = "testmotsid";
226         centralApp.setMotsId(defaultValue);
227         assertEquals(defaultValue, centralApp.getMotsId());
228     }
229
230     @Test
231     public void unt_appPasswordTest() {
232         String defaultValue = "TestAppPassword";
233         centralApp.setAppPassword(defaultValue);
234         assertEquals(defaultValue, centralApp.getAppPassword());
235     }
236
237     @Test
238     public void unt_openTest() {
239         String defaultValue = "Testopen";
240         centralApp.setOpen(defaultValue);
241         assertEquals(defaultValue, centralApp.getOpen());
242     }
243
244     @Test
245     public void unt_enabledTest() {
246         String defaultValue = "Testenable";
247         centralApp.setEnabled(defaultValue);
248         assertEquals(defaultValue, centralApp.getEnabled());
249     }
250
251     @Test
252     public void unt_thumbnailTest() {
253         byte[] defaultValue = { 1, 2, 3 };
254         centralApp.setThumbnail(defaultValue);
255         assertEquals(defaultValue, centralApp.getThumbnail());
256     }
257
258     @Test
259     public void unt_userNameTest() {
260         String defaultValue = "Testusername";
261         centralApp.setUsername(defaultValue);
262         assertEquals(defaultValue, centralApp.getUsername());
263     }
264
265     @Test
266     public void unt_uebKeyTest() {
267         String defaultValue = "Testuebkey";
268         centralApp.setUebKey(defaultValue);
269         assertEquals(defaultValue, centralApp.getUebKey());
270     }
271
272     @Test
273     public void unt_uebSecreteTest() {
274         String defaultValue = "Testuebscrete";
275         centralApp.setUebSecret(defaultValue);
276         assertEquals(defaultValue, centralApp.getUebSecret());
277     }
278
279     @Test
280     public void unt_uebTopicNameTest() {
281         String defaultValue = "Testuebtopicname";
282         centralApp.setUebTopicName(defaultValue);
283         assertEquals(defaultValue, centralApp.getUebTopicName());
284     }
285
286     @Test
287     public void unt_hashCodeWithNullTest() {
288         CentralApp centralApp = new CentralApp.CentralAppBuilder().setId(null).setCreated(null).setModified(null)
289                 .setCreatedId(null).setModifiedId(null).setRowNum(null).setName(null).setImageUrl(null)
290                 .setDescription(null).setNotes(null).setUrl(null).setAlternateUrl(null).setRestEndpoint(null)
291                 .setMlAppName(null).setMlAppAdminId(null).setMotsId(null).setAppPassword(null).setOpen(null)
292                 .setEnabled(null).setThumbnail(null).setUsername(null).setUebKey(null).setUebSecret(null)
293                 .setUebTopicName(null).createCentralApp();
294
295         CentralApp centralApp1 = new CentralApp.CentralAppBuilder().setId(null).setCreated(null).setModified(null)
296                 .setCreatedId(null).setModifiedId(null).setRowNum(null).setName(null).setImageUrl(null)
297                 .setDescription(null).setNotes(null).setUrl(null).setAlternateUrl(null).setRestEndpoint(null)
298                 .setMlAppName(null).setMlAppAdminId(null).setMotsId(null).setAppPassword(null).setOpen(null)
299                 .setEnabled(null).setThumbnail(null).setUsername(null).setUebKey(null).setUebSecret(null)
300                 .setUebTopicName(null).createCentralApp();
301
302         assertEquals(centralApp.hashCode(), centralApp1.hashCode());
303         assertTrue(centralApp.equals(centralApp1));
304
305     }
306
307     @Test
308     public void unt_hashCodeTest() {
309         CentralApp centralApp = new CentralApp.CentralAppBuilder().setId((long) 1).setCreated(null).setModified(null)
310                 .setCreatedId((long) 1).setModifiedId((long) 1).setRowNum((long) 1).setName("test").setImageUrl("test")
311                 .setDescription("test").setNotes("test").setUrl("test").setAlternateUrl("test").setRestEndpoint("test")
312                 .setMlAppName("test").setMlAppAdminId("test").setMotsId("test").setAppPassword("test").setOpen("test")
313                 .setEnabled("test").setThumbnail(null).setUsername("test").setUebKey("test").setUebSecret("test")
314                 .setUebTopicName("test").createCentralApp();
315
316         CentralApp centralApp1 = new CentralApp.CentralAppBuilder().setId((long) 1).setCreated(null).setModified(null)
317                 .setCreatedId((long) 1).setModifiedId((long) 1).setRowNum((long) 1).setName("test").setImageUrl("test")
318                 .setDescription("test").setNotes("test").setUrl("test").setAlternateUrl("test").setRestEndpoint("test")
319                 .setMlAppName("test").setMlAppAdminId("test").setMotsId("test").setAppPassword("test").setOpen("test")
320                 .setEnabled("test").setThumbnail(null).setUsername("test").setUebKey("test").setUebSecret("test")
321                 .setUebTopicName("test").createCentralApp();
322
323         assertEquals(centralApp.hashCode(), centralApp1.hashCode());
324         assertTrue(centralApp.equals(centralApp1));
325
326     }
327
328     @Test
329     public void unt_hashCodeTestWithNull() {
330         CentralApp centralApp = new CentralApp.CentralAppBuilder().setId((long) 1).setCreated(null).setModified(null)
331                 .setCreatedId((long) 1).setModifiedId((long) 1).setRowNum((long) 1).setName("test").setImageUrl("test")
332                 .setDescription("test").setNotes("test").setUrl("test").setAlternateUrl("test").setRestEndpoint("test")
333                 .setMlAppName("test").setMlAppAdminId("test").setMotsId("test").setAppPassword("test").setOpen("test")
334                 .setEnabled("test").setThumbnail(null).setUsername("test").setUebKey("test").setUebSecret("test")
335                 .setUebTopicName("test").createCentralApp();
336         CentralApp centralApp1 = new CentralApp.CentralAppBuilder().setId((long) 1).setCreated(null).setModified(null)
337                 .setCreatedId((long) 1).setModifiedId((long) 1).setRowNum((long) 1).setName("test").setImageUrl("test")
338                 .setDescription("test").setNotes("test").setUrl("test").setAlternateUrl("test").setRestEndpoint("test")
339                 .setMlAppName("test").setMlAppAdminId("test").setMotsId("test").setAppPassword("test").setOpen("test")
340                 .setEnabled("test").setThumbnail(null).setUsername("test").setUebKey("test").setUebSecret("test")
341                 .setUebTopicName("test").createCentralApp();
342         assertEquals(centralApp.hashCode(), centralApp1.hashCode());
343         assertFalse(centralApp.equals(null));
344
345     }
346
347     @Test
348     public void unt_hashCodeTestWithNull1() {
349         CentralApp centralApp = new CentralApp.CentralAppBuilder().setId(null).setCreated(null).setModified(null)
350                 .setCreatedId(null).setModifiedId(null).setRowNum(null).setName(null).setImageUrl(null)
351                 .setDescription(null).setNotes(null).setUrl(null).setAlternateUrl(null).setRestEndpoint(null)
352                 .setMlAppName(null).setMlAppAdminId(null).setMotsId(null).setAppPassword(null).setOpen(null)
353                 .setEnabled(null).setThumbnail(null).setUsername(null).setUebKey(null).setUebSecret(null)
354                 .setUebTopicName(null).createCentralApp();
355         CentralApp centralApp1 = new CentralApp.CentralAppBuilder().setId((long) 1).setCreated(null).setModified(null)
356                 .setCreatedId((long) 1).setModifiedId((long) 1).setRowNum((long) 1).setName("test").setImageUrl("test")
357                 .setDescription("test").setNotes("test").setUrl("test").setAlternateUrl("test").setRestEndpoint("test")
358                 .setMlAppName("test").setMlAppAdminId("test").setMotsId("test").setAppPassword("test").setOpen("test")
359                 .setEnabled("test").setThumbnail(null).setUsername("test").setUebKey("test").setUebSecret("test")
360                 .setUebTopicName("test").createCentralApp();
361         assertFalse(centralApp.equals(centralApp1));
362
363     }
364
365     @Test
366     public void unt_hashCodeTestWithalternateURL() {
367         CentralApp centralApp = new CentralApp.CentralAppBuilder().setId(null).setCreated(null).setModified(null)
368                 .setCreatedId(null).setModifiedId(null).setRowNum(null).setName(null).setImageUrl(null)
369                 .setDescription(null).setNotes(null).setUrl(null).setAlternateUrl("test1").setRestEndpoint(null)
370                 .setMlAppName(null).setMlAppAdminId(null).setMotsId(null).setAppPassword(null).setOpen(null)
371                 .setEnabled(null).setThumbnail(null).setUsername(null).setUebKey(null).setUebSecret(null)
372                 .setUebTopicName(null).createCentralApp();
373         CentralApp centralApp1 = new CentralApp.CentralAppBuilder().setId((long) 1).setCreated(null).setModified(null)
374                 .setCreatedId((long) 1).setModifiedId((long) 1).setRowNum((long) 1).setName("test").setImageUrl("test")
375                 .setDescription("test").setNotes("test").setUrl("test").setAlternateUrl("test").setRestEndpoint("test")
376                 .setMlAppName("test").setMlAppAdminId("test").setMotsId("test").setAppPassword("test").setOpen("test")
377                 .setEnabled("test").setThumbnail(null).setUsername("test").setUebKey("test").setUebSecret("test")
378                 .setUebTopicName("test").createCentralApp();
379         assertFalse(centralApp.equals(centralApp1));
380
381     }
382
383     @Test
384     public void unt_hashCodeTestWithpassword() {
385         CentralApp centralApp = new CentralApp.CentralAppBuilder().setId(null).setCreated(null).setModified(null)
386                 .setCreatedId(null).setModifiedId(null).setRowNum(null).setName(null).setImageUrl(null)
387                 .setDescription(null).setNotes(null).setUrl(null).setAlternateUrl("test").setRestEndpoint(null)
388                 .setMlAppName(null).setMlAppAdminId(null).setMotsId(null).setAppPassword("testPass").setOpen(null)
389                 .setEnabled(null).setThumbnail(null).setUsername(null).setUebKey(null).setUebSecret(null)
390                 .setUebTopicName(null).createCentralApp();
391         CentralApp centralApp1 = new CentralApp.CentralAppBuilder().setId((long) 1).setCreated(null).setModified(null)
392                 .setCreatedId((long) 1).setModifiedId((long) 1).setRowNum((long) 1).setName("test").setImageUrl("test")
393                 .setDescription("test").setNotes("test").setUrl("test").setAlternateUrl("test").setRestEndpoint("test")
394                 .setMlAppName("test").setMlAppAdminId("test").setMotsId("test").setAppPassword("test").setOpen("test")
395                 .setEnabled("test").setThumbnail(null).setUsername("test").setUebKey("test").setUebSecret("test")
396                 .setUebTopicName("test").createCentralApp();
397         assertFalse(centralApp.equals(centralApp1));
398
399     }
400
401     @Test
402     public void unt_hashCodeTestWithcreateId() {
403         CentralApp centralApp = new CentralApp.CentralAppBuilder().setId(null).setCreated(null).setModified(null)
404                 .setCreatedId(123L).setModifiedId(null).setRowNum(null).setName(null).setImageUrl(null)
405                 .setDescription(null).setNotes(null).setUrl(null).setAlternateUrl("test").setRestEndpoint(null)
406                 .setMlAppName(null).setMlAppAdminId(null).setMotsId(null).setAppPassword("test").setOpen(null)
407                 .setEnabled(null).setThumbnail(null).setUsername(null).setUebKey(null).setUebSecret(null)
408                 .setUebTopicName(null).createCentralApp();
409         CentralApp centralApp1 = new CentralApp.CentralAppBuilder().setId((long) 1).setCreated(null).setModified(null)
410                 .setCreatedId((long) 1).setModifiedId((long) 1).setRowNum((long) 1).setName("test").setImageUrl("test")
411                 .setDescription("test").setNotes("test").setUrl("test").setAlternateUrl("test").setRestEndpoint("test")
412                 .setMlAppName("test").setMlAppAdminId("test").setMotsId("test").setAppPassword("test").setOpen("test")
413                 .setEnabled("test").setThumbnail(null).setUsername("test").setUebKey("test").setUebSecret("test")
414                 .setUebTopicName("test").createCentralApp();
415         assertFalse(centralApp.equals(centralApp1));
416
417     }
418
419     @Test
420     public void unt_hashCodeTestWithcreateId1() {
421         CentralApp centralApp = new CentralApp.CentralAppBuilder().setId(12L).setCreated(null).setModified(null)
422                 .setCreatedId(123L).setModifiedId(123L).setRowNum(123L).setName("test1").setImageUrl("test1")
423                 .setDescription("test1").setNotes("test1").setUrl("test1").setAlternateUrl("test")
424                 .setRestEndpoint("tests1").setMlAppName("test1").setMlAppAdminId("test1").setMotsId(null)
425                 .setAppPassword("test").setOpen(null).setEnabled(null).setThumbnail(null).setUsername(null)
426                 .setUebKey(null).setUebSecret(null).setUebTopicName(null).createCentralApp();
427         CentralApp centralApp1 = new CentralApp.CentralAppBuilder().setId((long) 1).setCreated(null).setModified(null)
428                 .setCreatedId((long) 1).setModifiedId((long) 1).setRowNum((long) 1).setName("test").setImageUrl("test")
429                 .setDescription("test").setNotes("test").setUrl("test").setAlternateUrl("test").setRestEndpoint("test")
430                 .setMlAppName("test").setMlAppAdminId("test").setMotsId("test").setAppPassword("test").setOpen("test")
431                 .setEnabled("test").setThumbnail(null).setUsername("test").setUebKey("test").setUebSecret("test")
432                 .setUebTopicName("test").createCentralApp();
433         assertFalse(centralApp.equals(centralApp1));
434     }
435 }