Added Junits
[portal.git] / ecomp-portal-BE-common / src / test / java / org / onap / portalapp / portal / core / RestURLsTestSuite.java
1 package org.onap.portalapp.portal.core;
2 /*-
3  * ============LICENSE_START==========================================
4  * ONAP Portal
5  * ===================================================================
6  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
7  * ===================================================================
8  *
9  * Unless otherwise specified, all software contained herein is licensed
10  * under the Apache License, Version 2.0 (the "License");
11  * you may not use this software except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  *             http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  * Unless otherwise specified, all documentation contained herein is licensed
23  * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
24  * you may not use this documentation except in compliance with the License.
25  * You may obtain a copy of the License at
26  *
27  *             https://creativecommons.org/licenses/by/4.0/
28  *
29  * Unless required by applicable law or agreed to in writing, documentation
30  * distributed under the License is distributed on an "AS IS" BASIS,
31  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32  * See the License for the specific language governing permissions and
33  * limitations under the License.
34  *
35  * ============LICENSE_END============================================
36  *
37  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
38  */
39 //package org.onap.portalapp.portal.core;
40 //
41 //import static org.junit.Assert.assertEquals;
42 //import static org.junit.Assert.assertTrue;
43 //
44 //import java.io.IOException;
45 //import java.nio.charset.Charset;
46 //import java.util.ArrayList;
47 //
48 //import org.junit.Assert;
49 //import org.junit.Test;
50 //import org.onap.portalapp.framework.ApplicationCommonContextTestSuite;
51 //import org.onap.portalapp.portal.domain.EPUser;
52 //import org.onap.portalapp.portal.test.core.MockEPUser;
53 //import org.onap.portalapp.portal.transport.AppNameIdIsAdmin;
54 //import org.onap.portalapp.portal.transport.AppsListWithAdminRole;
55 //import org.onap.portalsdk.core.util.SystemProperties;
56 //import org.springframework.http.MediaType;
57 //import org.springframework.test.web.servlet.ResultActions;
58 //import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
59 //import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
60 //
61 //import com.fasterxml.jackson.annotation.JsonInclude;
62 //import com.fasterxml.jackson.databind.ObjectMapper;
63 //
64 ///**
65 // * 
66 // * Use RestURLsTestSuite to test Rest API URL's
67 // */
68 //public class RestURLsTestSuite extends ApplicationCommonContextTestSuite {
69 //
70 //      public static final MediaType APPLICATION_JSON_UTF8 = new MediaType(MediaType.APPLICATION_JSON.getType(),
71 //                      MediaType.APPLICATION_JSON.getSubtype(), Charset.forName("utf8"));
72 //
73 //      String url = null;
74 //
75 //      MockEPUser mockUser = new MockEPUser();
76 //
77 //      public byte[] convertObjectToJsonBytes(Object object) throws IOException {
78 //              ObjectMapper mapper = new ObjectMapper();
79 //              mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
80 //              return mapper.writeValueAsBytes(object);
81 //      }
82 //
83 //      public void requestBuilder(String url) throws Exception {
84 //              EPUser user = mockUser.mockEPUser();
85 //
86 //              MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get(url);
87 //              requestBuilder.sessionAttr(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user);
88 //              ResultActions ra = getMockMvc().perform(requestBuilder);
89 //              assertData(ra);
90 //      }
91 //
92 //      public void assertData(ResultActions ra) {
93 //              Assert.assertEquals("application/json", ra.andReturn().getResponse().getContentType());
94 //              Assert.assertEquals(200, ra.andReturn().getResponse().getStatus());
95 //
96 //      }
97 //
98 //      @Test
99 //      public void getMenuItemsTest() throws Exception {
100 //              url = "/portalApi/functionalMenu";
101 //              requestBuilder(url);
102 //      }
103 //
104 //      @Test
105 //      public void getMenuItemsForNotificationsTest() throws Exception {
106 //              url = "/portalApi/functionalMenuForNotificationTree";
107 //              requestBuilder(url);
108 //      }
109 //
110 //      @Test
111 //      public void getUserAppsTestnew() throws Exception {
112 //              url = "/portalApi/userApps";
113 //              requestBuilder(url);
114 //      }
115 //
116 //      @Test
117 //      public void getPersUserAppsTest() throws Exception {
118 //              url = "/portalApi/persUserApps";
119 //              requestBuilder(url);
120 //      }
121 //
122 //      @Test
123 //      public void getAppCatalogTest() throws Exception {
124 //              url = "/portalApi/appCatalog";
125 //              requestBuilder(url);
126 //      }
127 //
128 //      @Test
129 //      public void getAppListNewTest() throws Exception {
130 //              ResultActions ra = getMockMvc()
131 //                              .perform(MockMvcRequestBuilders.get("/portalApi/userApplicationRoles").param("userId", "guest"));
132 //              assertData(ra);
133 //      }
134 //
135 //      @Test
136 //      public void getAvailableAppListTest() throws Exception {
137 //              url = "/portalApi/availableApps";
138 //              requestBuilder(url);
139 //      }
140 //
141 //      @Test
142 //      public void getAllAppsTest() throws Exception {
143 //              url = "/portalApi/allAvailableApps";
144 //              requestBuilder(url);
145 //      }
146 //
147 //      @Test
148 //      public void getUserProfileTest() throws Exception {
149 //              url = "/portalApi/userProfile";
150 //              requestBuilder(url);
151 //      }
152 //
153 //      @Test
154 //      public void getRolesByAppTest() throws Exception {
155 //              EPUser user = mockUser.mockEPUser();
156 //              MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get("/portalApi/adminAppsRoles/550");
157 //              requestBuilder.sessionAttr(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user);
158 //              ResultActions ra = getMockMvc().perform(requestBuilder);
159 //              assertData(ra);
160 //      }
161 //
162 //      @Test
163 //      public void getAppsWithAdminRoleStateForUserTest() throws Exception {
164 //              url = "/portalApi/adminAppsRoles?user=guest";
165 //              requestBuilder(url);
166 //
167 //      }
168 //
169 //      @Test
170 //      public void getUsersFromAppEndpointTest() throws Exception {
171 //              url = "/portalApi/app/550/users";
172 //              requestBuilder(url);
173 //      }
174 //
175 //      @Test
176 //      public void getOnboardingAppsTest() throws Exception {
177 //              url = "/portalApi/onboardingApps";
178 //              requestBuilder(url);
179 //      }
180 //
181 //      @Test
182 //      public void getMenuItemsForAuthUserTest() throws Exception {
183 //              url = "/portalApi/functionalMenuForAuthUser";
184 //              requestBuilder(url);
185 //      }
186 //
187 //      @Test
188 //      public void getMenuItemsForEditingTest() throws Exception {
189 //              url = "/portalApi/functionalMenuForEditing";
190 //              requestBuilder(url);
191 //      }
192 //
193 //      @Test
194 //      public void getAppRolesTest() throws Exception {
195 //              url = "/portalApi/appRoles/455";
196 //              requestBuilder(url);
197 //      }
198 //
199 //      @Test
200 //      public void regenerateAncestorTableTest() throws Exception {
201 //
202 //              EPUser user = mockUser.mockEPUser();
203 //
204 //              MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders
205 //                              .get("/portalApi/regenerateFunctionalMenuAncestors");
206 //              requestBuilder.sessionAttr(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user);
207 //              ResultActions ra = getMockMvc().perform(requestBuilder);
208 //              assertEquals("application/json;charset=UTF-8", ra.andReturn().getResponse().getContentType());
209 //              Assert.assertEquals(200, ra.andReturn().getResponse().getStatus());
210 //
211 //      }
212 //
213 //      @Test
214 //      public void getAppListTest() throws Exception {
215 //              url = "/portalApi/getAppList";
216 //              requestBuilder(url);
217 //      }
218 //
219 //      @Test
220 //      public void getFavoritesForUserTest() throws Exception {
221 //              url = "/portalApi/getFavoriteItems";
222 //              requestBuilder(url);
223 //      }
224 //
225 //      @Test
226 //      public void getManifestTest() throws Exception {
227 //              url = "/portalApi/manifest";
228 //              requestBuilder(url);
229 //      }
230 //
231 //      @Test
232 //      public void getActiveUsersTest() throws Exception {
233 //              url = "/portalApi/dashboard/activeUsers";
234 //              requestBuilder(url);
235 //      }
236 //
237 //      @Test
238 //      public void searchPortalTest() throws Exception {
239 //              EPUser user = mockUser.mockEPUser();
240 //              MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get("/portalApi/dashboard/search")
241 //                              .param("searchString", "guest");
242 //              requestBuilder.sessionAttr(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user);
243 //              ResultActions ra = getMockMvc().perform(requestBuilder);
244 //              assertData(ra);
245 //      }
246 //
247 //      @Test
248 //      public void getWidgetDataTest() throws Exception {
249 //              EPUser user = mockUser.mockEPUser();
250 //              MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get("/portalApi/dashboard/widgetData")
251 //                              .param("resourceType", "guest");
252 //              requestBuilder.sessionAttr(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user);
253 //              ResultActions ra = getMockMvc().perform(requestBuilder);
254 //              assertData(ra);
255 //      }
256 //
257 //      @Test
258 //      public void getAppsAndContactsTest() throws Exception {
259 //              url = "/portalApi/contactus/allapps";
260 //              requestBuilder(url);
261 //      }
262 //
263 //      @Test
264 //      public void getPortalDetailsTest() throws Exception {
265 //              url = "/portalApi/contactus/feedback";
266 //              requestBuilder(url);
267 //      }
268 //
269 //      @Test
270 //      public void getAppCategoryFunctionsTest() throws Exception {
271 //              url = "/portalApi/contactus/functions";
272 //              requestBuilder(url);
273 //      }
274 //
275 //      @Test
276 //      public void getOnlineUserUpdateRateTest() throws Exception {
277 //              url = "/portalApi/dashboard/onlineUserUpdateRate";
278 //              requestBuilder(url);
279 //      }
280 //
281 //      @Test
282 //      public void getMenuIdRoleIdTest() throws Exception {
283 //              url = "/portalApi/getFunctionalMenuRole";
284 //              requestBuilder(url);
285 //      }
286 //
287 //      @Test
288 //      public void getNotificationsTest() throws Exception {
289 //              url = "/portalApi/getNotifications";
290 //              requestBuilder(url);
291 //      }
292 //
293 //      @Test
294 //      public void getAdminNotificationsTest() throws Exception {
295 //              url = "/portalApi/getAdminNotifications";
296 //              requestBuilder(url);
297 //      }
298 //
299 //      @Test
300 //      public void getNotificationAppRolesTest() throws Exception {
301 //              url = "/portalApi/getNotificationAppRoles";
302 //              requestBuilder(url);
303 //      }
304 //
305 //      @Test
306 //      public void getNotificationUpdateRateTest() throws Exception {
307 //              url = "/portalApi/notificationUpdateRate";
308 //              requestBuilder(url);
309 //      }
310 //
311 //      @Test
312 //      public void notificationReadTest() throws Exception {
313 //              url = "/portalApi/notificationRead?notificationId=262";
314 //              requestBuilder(url);
315 //      }
316 //
317 //      @Test
318 //      public void testGetRolesTest() throws Exception {
319 //              url = "/portalApi/notificationRole/248/roles";
320 //              requestBuilder(url);
321 //      }
322 //
323 //      @Test
324 //      public void putAppsWithAdminRoleStateForUserTest() throws Exception {
325 //
326 //              AppsListWithAdminRole appsListWithAdminRole = new AppsListWithAdminRole();
327 //              appsListWithAdminRole.setOrgUserId("guest");
328 //              ArrayList<AppNameIdIsAdmin> appsRoles = new ArrayList<AppNameIdIsAdmin>();
329 //              AppNameIdIsAdmin appNameIdIsAdmin = new AppNameIdIsAdmin();
330 //              appNameIdIsAdmin.setId((long) 455);
331 //              appNameIdIsAdmin.setAppName("CCD");
332 //              appNameIdIsAdmin.setIsAdmin(true);
333 //              appNameIdIsAdmin.setRestrictedApp(false);
334 //              appsRoles.add(appNameIdIsAdmin);
335 //              appsListWithAdminRole.setAppsRoles(appsRoles);
336 //              EPUser user = mockUser.mockEPUser();
337 //              MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.put("/portalApi/adminAppsRoles")
338 //                              .contentType(APPLICATION_JSON_UTF8).content(convertObjectToJsonBytes(appsListWithAdminRole));
339 //
340 //              requestBuilder.sessionAttr(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user);
341 //              ResultActions ra = getMockMvc().perform(requestBuilder);
342 //              assertData(ra);
343 //      }
344 //
345 //      @Test
346 //      public void ticketEventControllerForExternalSystem() throws Exception {
347 //              String ticketEventJson = "{\"application\": \"cbus\",\"event\": {\"body\": {\"ticketStatePhrase\": \"We recently detected a problem with the equipment at your site. The event is in queue for immediate work.\", \"ivrNotificationFlag\": \"1\",\"expectedRestoreDate\": 0,\"bridgeTransport\": \"AOTS\",  \"reptRequestType\": 0,\"ticketNum\": \"000002000857405\",\"assetID\": \"CISCO_1921C1_ISR_G2\", \"eventDate\": 1490545134601,\"eventAbstract\": \"ospfIfConfigError trap received from Cisco_1921c1_ISR_G2 with arguments: ospfRouterId=Cisco_1921c1_ISR_G2; ospfIfIpAddress=1921c1_288266; ospfAddressLessIf=0; ospfPacketSrc=172.17.0.11; ospfConfigErrorType=2; ospfPacketType=1\",\"severity\": \"2 - Major\",\"ticketPriority\": \"3\",\"reportedCustomerImpact\": 0,\"testAutoIndicator\": 0,\"supportGroupName\": \"US-TEST-ORT\",\"lastModifiedDate\": \"1487687703\",\"messageGroup\": \"SNMP\",\"csi\": 0,\"mfabRestoredTime\": 0},\"header\": {\"timestamp\": \"2017-02-21T14:35:05.219+0000\",\"eventSource\": \"aotstm\",\"entityId\": \"000002000857405\",      \"sequenceNumber\": 2 },\"blinkMsgId\": \"f38c071e-1a47-4b55-9e72-1db830100a61\",\"sourceIP\": \"130.4.165.158\"},\"SubscriberInfo\": {\"UserList\": [\"hk8777\"] }}";
348 //              MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.post("/auxapi/ticketevent")
349 //                              .contentType(APPLICATION_JSON_UTF8).content(ticketEventJson);
350 //              ResultActions ra = getMockMvc().perform(requestBuilder);
351 //              assertTrue(ra.andReturn().getResponse().getContentType().contains("application/json"));
352 //      }
353 //}