1 package org.onap.portalapp.portal.core;
3 * ============LICENSE_START==========================================
5 * ===================================================================
6 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
7 * ===================================================================
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
14 * http://www.apache.org/licenses/LICENSE-2.0
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.
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
27 * https://creativecommons.org/licenses/by/4.0/
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.
35 * ============LICENSE_END============================================
39 //package org.onap.portalapp.portal.core;
41 //import static org.junit.Assert.assertEquals;
42 //import static org.junit.Assert.assertTrue;
44 //import java.io.IOException;
45 //import java.nio.charset.Charset;
46 //import java.util.ArrayList;
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;
61 //import com.fasterxml.jackson.annotation.JsonInclude;
62 //import com.fasterxml.jackson.databind.ObjectMapper;
66 // * Use RestURLsTestSuite to test Rest API URL's
68 //public class RestURLsTestSuite extends ApplicationCommonContextTestSuite {
70 // public static final MediaType APPLICATION_JSON_UTF8 = new MediaType(MediaType.APPLICATION_JSON.getType(),
71 // MediaType.APPLICATION_JSON.getSubtype(), Charset.forName("utf8"));
75 // MockEPUser mockUser = new MockEPUser();
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);
83 // public void requestBuilder(String url) throws Exception {
84 // EPUser user = mockUser.mockEPUser();
86 // MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get(url);
87 // requestBuilder.sessionAttr(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user);
88 // ResultActions ra = getMockMvc().perform(requestBuilder);
92 // public void assertData(ResultActions ra) {
93 // Assert.assertEquals("application/json", ra.andReturn().getResponse().getContentType());
94 // Assert.assertEquals(200, ra.andReturn().getResponse().getStatus());
99 // public void getMenuItemsTest() throws Exception {
100 // url = "/portalApi/functionalMenu";
101 // requestBuilder(url);
105 // public void getMenuItemsForNotificationsTest() throws Exception {
106 // url = "/portalApi/functionalMenuForNotificationTree";
107 // requestBuilder(url);
111 // public void getUserAppsTestnew() throws Exception {
112 // url = "/portalApi/userApps";
113 // requestBuilder(url);
117 // public void getPersUserAppsTest() throws Exception {
118 // url = "/portalApi/persUserApps";
119 // requestBuilder(url);
123 // public void getAppCatalogTest() throws Exception {
124 // url = "/portalApi/appCatalog";
125 // requestBuilder(url);
129 // public void getAppListNewTest() throws Exception {
130 // ResultActions ra = getMockMvc()
131 // .perform(MockMvcRequestBuilders.get("/portalApi/userApplicationRoles").param("userId", "guest"));
136 // public void getAvailableAppListTest() throws Exception {
137 // url = "/portalApi/availableApps";
138 // requestBuilder(url);
142 // public void getAllAppsTest() throws Exception {
143 // url = "/portalApi/allAvailableApps";
144 // requestBuilder(url);
148 // public void getUserProfileTest() throws Exception {
149 // url = "/portalApi/userProfile";
150 // requestBuilder(url);
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);
163 // public void getAppsWithAdminRoleStateForUserTest() throws Exception {
164 // url = "/portalApi/adminAppsRoles?user=guest";
165 // requestBuilder(url);
170 // public void getUsersFromAppEndpointTest() throws Exception {
171 // url = "/portalApi/app/550/users";
172 // requestBuilder(url);
176 // public void getOnboardingAppsTest() throws Exception {
177 // url = "/portalApi/onboardingApps";
178 // requestBuilder(url);
182 // public void getMenuItemsForAuthUserTest() throws Exception {
183 // url = "/portalApi/functionalMenuForAuthUser";
184 // requestBuilder(url);
188 // public void getMenuItemsForEditingTest() throws Exception {
189 // url = "/portalApi/functionalMenuForEditing";
190 // requestBuilder(url);
194 // public void getAppRolesTest() throws Exception {
195 // url = "/portalApi/appRoles/455";
196 // requestBuilder(url);
200 // public void regenerateAncestorTableTest() throws Exception {
202 // EPUser user = mockUser.mockEPUser();
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());
214 // public void getAppListTest() throws Exception {
215 // url = "/portalApi/getAppList";
216 // requestBuilder(url);
220 // public void getFavoritesForUserTest() throws Exception {
221 // url = "/portalApi/getFavoriteItems";
222 // requestBuilder(url);
226 // public void getManifestTest() throws Exception {
227 // url = "/portalApi/manifest";
228 // requestBuilder(url);
232 // public void getActiveUsersTest() throws Exception {
233 // url = "/portalApi/dashboard/activeUsers";
234 // requestBuilder(url);
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);
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);
258 // public void getAppsAndContactsTest() throws Exception {
259 // url = "/portalApi/contactus/allapps";
260 // requestBuilder(url);
264 // public void getPortalDetailsTest() throws Exception {
265 // url = "/portalApi/contactus/feedback";
266 // requestBuilder(url);
270 // public void getAppCategoryFunctionsTest() throws Exception {
271 // url = "/portalApi/contactus/functions";
272 // requestBuilder(url);
276 // public void getOnlineUserUpdateRateTest() throws Exception {
277 // url = "/portalApi/dashboard/onlineUserUpdateRate";
278 // requestBuilder(url);
282 // public void getMenuIdRoleIdTest() throws Exception {
283 // url = "/portalApi/getFunctionalMenuRole";
284 // requestBuilder(url);
288 // public void getNotificationsTest() throws Exception {
289 // url = "/portalApi/getNotifications";
290 // requestBuilder(url);
294 // public void getAdminNotificationsTest() throws Exception {
295 // url = "/portalApi/getAdminNotifications";
296 // requestBuilder(url);
300 // public void getNotificationAppRolesTest() throws Exception {
301 // url = "/portalApi/getNotificationAppRoles";
302 // requestBuilder(url);
306 // public void getNotificationUpdateRateTest() throws Exception {
307 // url = "/portalApi/notificationUpdateRate";
308 // requestBuilder(url);
312 // public void notificationReadTest() throws Exception {
313 // url = "/portalApi/notificationRead?notificationId=262";
314 // requestBuilder(url);
318 // public void testGetRolesTest() throws Exception {
319 // url = "/portalApi/notificationRole/248/roles";
320 // requestBuilder(url);
324 // public void putAppsWithAdminRoleStateForUserTest() throws Exception {
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));
340 // requestBuilder.sessionAttr(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user);
341 // ResultActions ra = getMockMvc().perform(requestBuilder);
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"));