56f0e5caf73c44b16ca8317db98b24c181457888
[portal.git] / ecomp-portal-BE-common / src / test / java / org / onap / portalapp / portal / domain / EPAppTest.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.domain;
39
40 import static org.junit.Assert.assertEquals;
41 import static org.junit.Assert.assertFalse;
42 import static org.junit.Assert.assertNotNull;
43 import static org.junit.Assert.assertTrue;
44
45 import org.junit.Test;
46 import org.onap.portalapp.portal.domain.EPApp;
47
48 public class EPAppTest {
49         
50         private static final String TEST="test";
51
52         public EPApp mockEPApp(EPApp epApp){
53                 epApp.setId(1l);                        
54                 epApp.setName(TEST);
55                 epApp.setImageUrl(TEST);
56                 epApp.setDescription(TEST);
57                 epApp.setNotes(TEST);
58                 epApp.setUrl(TEST);
59                 epApp.setAlternateUrl(TEST);
60                 epApp.setAppRestEndpoint(TEST);
61                 epApp.setMlAppName(TEST);
62                 epApp.setMlAppAdminId(TEST);
63                 epApp.setMotsId((long)1);
64                 epApp.setUsername(TEST);
65                 epApp.setAppPassword(TEST);
66                 epApp.setOpen(false);
67                 epApp.setEnabled(false);
68                 epApp.setUebTopicName(TEST);
69                 epApp.setUebSecret(TEST);
70                 epApp.setAppType(1);
71                 epApp.setCentralAuth(false);
72                 epApp.setNameSpace(TEST);
73                 epApp.setRestrictedApp(true);
74                 epApp.setRestrictedApp(false);
75                 epApp.setAppType(null);
76                 epApp.setOpen(null);
77                 epApp.setThumbnail(TEST.getBytes());
78                 epApp.setUebKey(TEST);
79                 
80                 return epApp;
81         }
82         
83         @Test
84         public void epAppTest(){
85                  EPApp epApp1 = new EPApp();
86                   epApp1 = mockEPApp(epApp1);
87                 EPApp epApp=new EPApp();
88                  
89                 epApp.setId(epApp1.getId());                    
90                 epApp.setName(epApp1.getName());
91                 epApp.setImageUrl(epApp1.getImageUrl());
92                 epApp.setDescription(epApp1.getDescription());
93                 epApp.setNotes(epApp1.getNotes());
94                 epApp.setUrl(epApp1.getUrl());
95                 epApp.setAlternateUrl(epApp1.getAlternateUrl());
96                 epApp.setAppRestEndpoint(epApp1.getAppRestEndpoint());
97                 epApp.setMlAppName(epApp1.getMlAppName());
98                 epApp.setMlAppAdminId(epApp1.getMlAppAdminId());
99                 epApp.setMotsId(epApp1.getMotsId());
100                 epApp.setUsername(epApp1.getUsername());
101                 epApp.setAppPassword(epApp1.getAppPassword());
102                 epApp.setOpen(epApp1.getOpen());
103                 epApp.setEnabled(epApp1.getEnabled());
104                 epApp.setUebTopicName(epApp1.getUebTopicName());
105                 epApp.setUebSecret(epApp1.getUebSecret());
106                 epApp.setAppType(epApp1.getAppType());
107                 epApp.setCentralAuth(epApp1.getCentralAuth());
108                 epApp.setNameSpace(epApp1.getNameSpace());
109                 epApp.setRestrictedApp(epApp1.isRestrictedApp());
110         
111                 epApp.setAppType(epApp1.getAppType());
112                 
113                 epApp.setThumbnail(epApp1.getThumbnail());
114                 epApp.setUebKey(epApp1.getUebKey());
115                 epApp.compareTo(epApp1);
116                 assertEquals(epApp.hashCode(), epApp1.hashCode());
117                 assertTrue(epApp.equals(epApp1));
118                 assertFalse(epApp.equals(null));
119         
120                 
121                 assertEquals(epApp.getName(), TEST);
122                 assertEquals(epApp.getId(), Long.valueOf(1l));
123                 assertEquals(epApp.getImageUrl(), TEST);
124                 assertEquals(epApp.getDescription(), TEST);
125                 assertEquals(epApp.getNotes(), TEST);
126                 assertEquals(epApp.getUrl(), TEST);
127                 assertEquals(epApp.getAlternateUrl(), TEST);
128                 assertEquals(epApp.getAppRestEndpoint(), TEST);
129                 assertEquals(epApp.getMlAppName(), TEST);
130                 assertEquals(epApp.getMlAppAdminId(), TEST);
131                 assertEquals(epApp.getMotsId(), new Long(1));
132                 assertEquals(epApp.getUsername(), TEST);
133                 assertEquals(epApp.getAppPassword(), TEST);
134                 assertEquals(epApp.getOpen(), false);
135                 assertEquals(epApp.getEnabled(), false);
136                 assertEquals(epApp.getUebTopicName(), TEST);
137                 assertEquals(epApp.getUebSecret(), TEST);
138                 assertEquals(epApp.getAppType(), Integer.valueOf(1));
139                 assertEquals(epApp.getCentralAuth(), false);
140                 assertEquals(epApp.getNameSpace(), TEST);
141                 assertEquals(epApp.getUebKey(), TEST);
142                 
143                 assertEquals(epApp.getOpen(), false);
144                 assertEquals(epApp.isRestrictedApp(), false);
145                 assertEquals(epApp.hashCode(), epApp1.hashCode());
146                 assertTrue(epApp.equals(epApp1));
147                 //epApp.compareTo(epApp1);
148                 assertNotNull(epApp.toString());
149                 epApp.setContactUs(new AppContactUs());
150                 assertNotNull(epApp.getContactUs());
151                 
152                 
153                 epApp.setUsername(null);
154                 assertFalse(epApp.equals(epApp1));
155                 epApp.setUrl(null);
156                 assertFalse(epApp.equals(epApp1));
157                 epApp.setUebTopicName(null);
158                 assertFalse(epApp.equals(epApp1));
159                 
160                 epApp.setUebSecret(null);
161                 assertFalse(epApp.equals(epApp1));
162                 epApp.setUebKey(null);
163                 assertFalse(epApp.equals(epApp1));
164                 epApp.setOpen(null);
165                 assertFalse(epApp.equals(epApp1));
166                 epApp.setNotes(null);
167                 assertFalse(epApp.equals(epApp1));
168                 epApp.setNameSpace(null);
169                 assertFalse(epApp.equals(epApp1));
170                 
171                 epApp.setName(null);
172                 assertFalse(epApp.equals(epApp1));
173                 epApp.setMotsId(null);
174                 assertFalse(epApp.equals(epApp1));
175                 epApp.setMlAppName(null);
176                 assertFalse(epApp.equals(epApp1));
177                 epApp.setMlAppAdminId(null);
178                 assertFalse(epApp.equals(epApp1));
179                 epApp.setImageUrl(null);
180                 assertFalse(epApp.equals(epApp1));
181                 epApp.setEnabled(null);
182                 assertFalse(epApp.equals(epApp1));
183                 epApp.setDescription(null);
184                 assertFalse(epApp.equals(epApp1));
185                 epApp.setContactUs(null);
186                 assertFalse(epApp.equals(epApp1));
187                 
188                 epApp.setCentralAuth(null);
189                 assertFalse(epApp.equals(epApp1));
190                 
191                 epApp.setAppType(null);
192                 assertFalse(epApp.equals(epApp1));
193                 epApp.setAppRestEndpoint(null);
194                 assertFalse(epApp.equals(epApp1));
195                 epApp.setAppPassword(null);
196                 assertFalse(epApp.equals(epApp1));
197                 
198                 epApp.setAlternateUrl(null);
199                 assertFalse(epApp.equals(epApp1));
200         }       
201 }