Add doc folder.
[portal.git] / ecomp-portal-BE-common / src / test / java / org / openecomp / portalapp / portal / core / RestURLsTestSuite.java
1 ///*-
2 // * ================================================================================
3 // * ECOMP Portal
4 // * ================================================================================
5 // * Copyright (C) 2017 AT&T Intellectual Property
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 // * ================================================================================
19 // */
20 //package org.openecomp.portalapp.portal.core;
21 //
22 //import static org.junit.Assert.assertEquals;
23 //import static org.junit.Assert.assertTrue;
24 //
25 //import java.io.IOException;
26 //import java.nio.charset.Charset;
27 //import java.util.ArrayList;
28 //
29 //import org.junit.Assert;
30 //import org.junit.Test;
31 //import org.openecomp.portalapp.framework.ApplicationCommonContextTestSuite;
32 //import org.openecomp.portalapp.portal.domain.EPUser;
33 //import org.openecomp.portalapp.portal.test.core.MockEPUser;
34 //import org.openecomp.portalapp.portal.transport.AppNameIdIsAdmin;
35 //import org.openecomp.portalapp.portal.transport.AppsListWithAdminRole;
36 //import org.openecomp.portalsdk.core.util.SystemProperties;
37 //import org.springframework.http.MediaType;
38 //import org.springframework.test.web.servlet.ResultActions;
39 //import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
40 //import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
41 //
42 //import com.fasterxml.jackson.annotation.JsonInclude;
43 //import com.fasterxml.jackson.databind.ObjectMapper;
44 //
45 ///**
46 // * 
47 // * Use RestURLsTestSuite to test Rest API URL's
48 // */
49 //public class RestURLsTestSuite extends ApplicationCommonContextTestSuite {
50 //
51 //      public static final MediaType APPLICATION_JSON_UTF8 = new MediaType(MediaType.APPLICATION_JSON.getType(),
52 //                      MediaType.APPLICATION_JSON.getSubtype(), Charset.forName("utf8"));
53 //
54 //      String url = null;
55 //
56 //      MockEPUser mockUser = new MockEPUser();
57 //
58 //      public byte[] convertObjectToJsonBytes(Object object) throws IOException {
59 //              ObjectMapper mapper = new ObjectMapper();
60 //              mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
61 //              return mapper.writeValueAsBytes(object);
62 //      }
63 //
64 //      public void requestBuilder(String url) throws Exception {
65 //              EPUser user = mockUser.mockEPUser();
66 //
67 //              MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get(url);
68 //              requestBuilder.sessionAttr(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user);
69 //              ResultActions ra = getMockMvc().perform(requestBuilder);
70 //              assertData(ra);
71 //      }
72 //
73 //      public void assertData(ResultActions ra) {
74 //              Assert.assertEquals("application/json", ra.andReturn().getResponse().getContentType());
75 //              Assert.assertEquals(200, ra.andReturn().getResponse().getStatus());
76 //
77 //      }
78 //
79 //      @Test
80 //      public void getMenuItemsTest() throws Exception {
81 //              url = "/portalApi/functionalMenu";
82 //              requestBuilder(url);
83 //      }
84 //
85 //      @Test
86 //      public void getMenuItemsForNotificationsTest() throws Exception {
87 //              url = "/portalApi/functionalMenuForNotificationTree";
88 //              requestBuilder(url);
89 //      }
90 //
91 //      @Test
92 //      public void getUserAppsTestnew() throws Exception {
93 //              url = "/portalApi/userApps";
94 //              requestBuilder(url);
95 //      }
96 //
97 //      @Test
98 //      public void getPersUserAppsTest() throws Exception {
99 //              url = "/portalApi/persUserApps";
100 //              requestBuilder(url);
101 //      }
102 //
103 //      @Test
104 //      public void getAppCatalogTest() throws Exception {
105 //              url = "/portalApi/appCatalog";
106 //              requestBuilder(url);
107 //      }
108 //
109 //      @Test
110 //      public void getAppListNewTest() throws Exception {
111 //              ResultActions ra = getMockMvc()
112 //                              .perform(MockMvcRequestBuilders.get("/portalApi/userApplicationRoles").param("userId", "guest"));
113 //              assertData(ra);
114 //      }
115 //
116 //      @Test
117 //      public void getAvailableAppListTest() throws Exception {
118 //              url = "/portalApi/availableApps";
119 //              requestBuilder(url);
120 //      }
121 //
122 //      @Test
123 //      public void getAllAppsTest() throws Exception {
124 //              url = "/portalApi/allAvailableApps";
125 //              requestBuilder(url);
126 //      }
127 //
128 //      @Test
129 //      public void getUserProfileTest() throws Exception {
130 //              url = "/portalApi/userProfile";
131 //              requestBuilder(url);
132 //      }
133 //
134 //      @Test
135 //      public void getRolesByAppTest() throws Exception {
136 //              EPUser user = mockUser.mockEPUser();
137 //              MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get("/portalApi/adminAppsRoles/550");
138 //              requestBuilder.sessionAttr(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user);
139 //              ResultActions ra = getMockMvc().perform(requestBuilder);
140 //              assertData(ra);
141 //      }
142 //
143 //      @Test
144 //      public void getAppsWithAdminRoleStateForUserTest() throws Exception {
145 //              url = "/portalApi/adminAppsRoles?user=guest";
146 //              requestBuilder(url);
147 //
148 //      }
149 //
150 //      @Test
151 //      public void getUsersFromAppEndpointTest() throws Exception {
152 //              url = "/portalApi/app/550/users";
153 //              requestBuilder(url);
154 //      }
155 //
156 //      @Test
157 //      public void getOnboardingAppsTest() throws Exception {
158 //              url = "/portalApi/onboardingApps";
159 //              requestBuilder(url);
160 //      }
161 //
162 //      @Test
163 //      public void getMenuItemsForAuthUserTest() throws Exception {
164 //              url = "/portalApi/functionalMenuForAuthUser";
165 //              requestBuilder(url);
166 //      }
167 //
168 //      @Test
169 //      public void getMenuItemsForEditingTest() throws Exception {
170 //              url = "/portalApi/functionalMenuForEditing";
171 //              requestBuilder(url);
172 //      }
173 //
174 //      @Test
175 //      public void getAppRolesTest() throws Exception {
176 //              url = "/portalApi/appRoles/455";
177 //              requestBuilder(url);
178 //      }
179 //
180 //      @Test
181 //      public void regenerateAncestorTableTest() throws Exception {
182 //
183 //              EPUser user = mockUser.mockEPUser();
184 //
185 //              MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders
186 //                              .get("/portalApi/regenerateFunctionalMenuAncestors");
187 //              requestBuilder.sessionAttr(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user);
188 //              ResultActions ra = getMockMvc().perform(requestBuilder);
189 //              assertEquals("application/json;charset=UTF-8", ra.andReturn().getResponse().getContentType());
190 //              Assert.assertEquals(200, ra.andReturn().getResponse().getStatus());
191 //
192 //      }
193 //
194 //      @Test
195 //      public void getAppListTest() throws Exception {
196 //              url = "/portalApi/getAppList";
197 //              requestBuilder(url);
198 //      }
199 //
200 //      @Test
201 //      public void getFavoritesForUserTest() throws Exception {
202 //              url = "/portalApi/getFavoriteItems";
203 //              requestBuilder(url);
204 //      }
205 //
206 //      @Test
207 //      public void getManifestTest() throws Exception {
208 //              url = "/portalApi/manifest";
209 //              requestBuilder(url);
210 //      }
211 //
212 //      @Test
213 //      public void getActiveUsersTest() throws Exception {
214 //              url = "/portalApi/dashboard/activeUsers";
215 //              requestBuilder(url);
216 //      }
217 //
218 //      @Test
219 //      public void searchPortalTest() throws Exception {
220 //              EPUser user = mockUser.mockEPUser();
221 //              MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get("/portalApi/dashboard/search")
222 //                              .param("searchString", "guest");
223 //              requestBuilder.sessionAttr(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user);
224 //              ResultActions ra = getMockMvc().perform(requestBuilder);
225 //              assertData(ra);
226 //      }
227 //
228 //      @Test
229 //      public void getWidgetDataTest() throws Exception {
230 //              EPUser user = mockUser.mockEPUser();
231 //              MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get("/portalApi/dashboard/widgetData")
232 //                              .param("resourceType", "guest");
233 //              requestBuilder.sessionAttr(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user);
234 //              ResultActions ra = getMockMvc().perform(requestBuilder);
235 //              assertData(ra);
236 //      }
237 //
238 //      @Test
239 //      public void getAppsAndContactsTest() throws Exception {
240 //              url = "/portalApi/contactus/allapps";
241 //              requestBuilder(url);
242 //      }
243 //
244 //      @Test
245 //      public void getPortalDetailsTest() throws Exception {
246 //              url = "/portalApi/contactus/feedback";
247 //              requestBuilder(url);
248 //      }
249 //
250 //      @Test
251 //      public void getAppCategoryFunctionsTest() throws Exception {
252 //              url = "/portalApi/contactus/functions";
253 //              requestBuilder(url);
254 //      }
255 //
256 //      @Test
257 //      public void getOnlineUserUpdateRateTest() throws Exception {
258 //              url = "/portalApi/dashboard/onlineUserUpdateRate";
259 //              requestBuilder(url);
260 //      }
261 //
262 //      @Test
263 //      public void getMenuIdRoleIdTest() throws Exception {
264 //              url = "/portalApi/getFunctionalMenuRole";
265 //              requestBuilder(url);
266 //      }
267 //
268 //      @Test
269 //      public void getNotificationsTest() throws Exception {
270 //              url = "/portalApi/getNotifications";
271 //              requestBuilder(url);
272 //      }
273 //
274 //      @Test
275 //      public void getAdminNotificationsTest() throws Exception {
276 //              url = "/portalApi/getAdminNotifications";
277 //              requestBuilder(url);
278 //      }
279 //
280 //      @Test
281 //      public void getNotificationAppRolesTest() throws Exception {
282 //              url = "/portalApi/getNotificationAppRoles";
283 //              requestBuilder(url);
284 //      }
285 //
286 //      @Test
287 //      public void getNotificationUpdateRateTest() throws Exception {
288 //              url = "/portalApi/notificationUpdateRate";
289 //              requestBuilder(url);
290 //      }
291 //
292 //      @Test
293 //      public void notificationReadTest() throws Exception {
294 //              url = "/portalApi/notificationRead?notificationId=262";
295 //              requestBuilder(url);
296 //      }
297 //
298 //      @Test
299 //      public void testGetRolesTest() throws Exception {
300 //              url = "/portalApi/notificationRole/248/roles";
301 //              requestBuilder(url);
302 //      }
303 //
304 //      @Test
305 //      public void putAppsWithAdminRoleStateForUserTest() throws Exception {
306 //
307 //              AppsListWithAdminRole appsListWithAdminRole = new AppsListWithAdminRole();
308 //              appsListWithAdminRole.setOrgUserId("guest");
309 //              ArrayList<AppNameIdIsAdmin> appsRoles = new ArrayList<AppNameIdIsAdmin>();
310 //              AppNameIdIsAdmin appNameIdIsAdmin = new AppNameIdIsAdmin();
311 //              appNameIdIsAdmin.setId((long) 455);
312 //              appNameIdIsAdmin.setAppName("CCD");
313 //              appNameIdIsAdmin.setIsAdmin(true);
314 //              appNameIdIsAdmin.setRestrictedApp(false);
315 //              appsRoles.add(appNameIdIsAdmin);
316 //              appsListWithAdminRole.setAppsRoles(appsRoles);
317 //              EPUser user = mockUser.mockEPUser();
318 //              MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.put("/portalApi/adminAppsRoles")
319 //                              .contentType(APPLICATION_JSON_UTF8).content(convertObjectToJsonBytes(appsListWithAdminRole));
320 //
321 //              requestBuilder.sessionAttr(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user);
322 //              ResultActions ra = getMockMvc().perform(requestBuilder);
323 //              assertData(ra);
324 //      }
325 //
326 //      @Test
327 //      public void ticketEventControllerForExternalSystem() throws Exception {
328 //              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\"] }}";
329 //              MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.post("/auxapi/ticketevent")
330 //                              .contentType(APPLICATION_JSON_UTF8).content(ticketEventJson);
331 //              ResultActions ra = getMockMvc().perform(requestBuilder);
332 //              assertTrue(ra.andReturn().getResponse().getContentType().contains("application/json"));
333 //      }
334 //}