2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
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
26 * https://creativecommons.org/licenses/by/4.0/
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.
34 * ============LICENSE_END============================================
37 package org.onap.portalapp.portal.controller;
39 import static org.junit.Assert.assertEquals;
40 import static org.junit.Assert.assertNotNull;
41 import static org.junit.Assert.assertNull;
43 import java.lang.reflect.Method;
44 import java.util.ArrayList;
45 import java.util.HashMap;
46 import java.util.List;
49 import javax.servlet.http.HttpServletRequest;
50 import javax.servlet.http.HttpServletResponse;
52 import org.junit.Before;
53 import org.junit.Test;
54 import org.junit.runner.RunWith;
55 import org.mockito.InjectMocks;
56 import org.mockito.Matchers;
57 import org.mockito.Mock;
58 import org.mockito.Mockito;
59 import org.mockito.MockitoAnnotations;
60 import org.onap.portalapp.annotation.ApiVersion;
61 import org.onap.portalapp.controller.sessionmgt.SessionCommunicationVersionController;
62 import org.onap.portalapp.externalsystemapproval.model.ExternalSystemUser;
63 import org.onap.portalapp.portal.domain.EPUser;
64 import org.onap.portalapp.portal.ecomp.model.PortalRestResponse;
65 import org.onap.portalapp.portal.ecomp.model.PortalRestStatusEnum;
66 import org.onap.portalapp.portal.framework.MockitoTestSuite;
67 import org.onap.portalapp.portal.transport.Analytics;
68 import org.onap.portalapp.portal.transport.EpNotificationItem;
69 import org.onap.portalapp.portal.transport.OnboardingApp;
70 import org.onap.portalsdk.core.domain.Role;
71 import org.powermock.api.mockito.PowerMockito;
72 import org.powermock.core.classloader.annotations.PrepareForTest;
73 import org.powermock.modules.junit4.PowerMockRunner;
74 import org.springframework.aop.support.AopUtils;
75 import org.springframework.context.ApplicationContext;
77 @RunWith(PowerMockRunner.class)
78 @PrepareForTest(AopUtils.class)
79 public class AuxApiRequestMapperControllerTest {
81 AuxApiRequestMapperController auxApiRequestMapperController = new AuxApiRequestMapperController();
85 MockitoAnnotations.initMocks(this);
88 RolesController rolesController = new RolesController();
89 SessionCommunicationVersionController sessionCommunicationController = new SessionCommunicationVersionController();
90 WebAnalyticsExtAppVersionController webAnalyticsExtAppController = new WebAnalyticsExtAppVersionController();
91 RolesApprovalSystemVersionController rolesApprovalSystemController = new RolesApprovalSystemVersionController();
92 TicketEventVersionController ticketEventVersionController = new TicketEventVersionController();
93 AppsControllerExternalVersionRequest appsControllerExternalVersionRequest = new AppsControllerExternalVersionRequest();
94 ExternalAppsRestfulVersionController externalAppsRestfulVersionController = new ExternalAppsRestfulVersionController();
97 ApplicationContext context;
100 MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
101 HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
102 HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
103 NullPointerException nullPointerException = new NullPointerException();
106 public void getUserTest() throws Exception {
107 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/roles");
108 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
109 Map<String, Object> beans = new HashMap<>();
110 beans.put("bean1", rolesController);
111 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
112 PowerMockito.mockStatic(AopUtils.class);
113 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
114 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
115 assertNull(auxApiRequestMapperController.getUser(mockedRequest, mockedResponse, "test12"));
119 public void getUserTestWithException() throws Exception {
120 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/roles");
121 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
122 Map<String, Object> beans = new HashMap<>();
123 beans.put("bean1", rolesController);
124 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
125 PowerMockito.mockStatic(AopUtils.class);
126 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
127 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
128 assertNull(auxApiRequestMapperController.getUser(mockedRequest, mockedResponse, "test12"));
132 public void getRolesTest() throws Exception {
133 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/roles");
134 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
135 Map<String, Object> beans = new HashMap<>();
136 beans.put("bean1", rolesController);
137 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
138 PowerMockito.mockStatic(AopUtils.class);
139 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
140 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
141 assertNull(auxApiRequestMapperController.getRoles(mockedRequest, mockedResponse));
145 public void saveRoleTest() throws Exception {
146 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/role");
147 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
148 Map<String, Object> beans = new HashMap<>();
149 beans.put("bean1", rolesController);
150 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
151 PowerMockito.mockStatic(AopUtils.class);
152 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
153 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
154 Role role = new Role();
155 assertNull(auxApiRequestMapperController.saveRole(mockedRequest, mockedResponse, role));
159 public void getEPRolesTest() throws Exception {
160 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v4/roles");
161 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
162 Map<String, Object> beans = new HashMap<>();
163 beans.put("bean1", rolesController);
164 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
165 PowerMockito.mockStatic(AopUtils.class);
166 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
167 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
168 assertNull(auxApiRequestMapperController.getRoles(mockedRequest, mockedResponse));
172 public void getUser1Test() throws Exception {
173 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/user/test12");
174 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
175 Map<String, Object> beans = new HashMap<>();
176 beans.put("bean1", rolesController);
177 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
178 PowerMockito.mockStatic(AopUtils.class);
179 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
180 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
181 assertNull(auxApiRequestMapperController.getUser(mockedRequest, mockedResponse, "test12"));
185 public void getRoleTest() throws Exception {
186 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/role/1");
187 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
188 Map<String, Object> beans = new HashMap<>();
189 beans.put("bean1", rolesController);
190 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
191 PowerMockito.mockStatic(AopUtils.class);
192 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
193 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
194 assertNull(auxApiRequestMapperController.getRoleInfo(mockedRequest, mockedResponse, (long) 1));
198 public void getUsersOfApplicationTest() throws Exception {
199 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/users");
200 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
201 Map<String, Object> beans = new HashMap<>();
202 beans.put("bean1", rolesController);
203 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
204 PowerMockito.mockStatic(AopUtils.class);
205 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
206 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
207 assertNull(auxApiRequestMapperController.getUsersOfApplication(mockedRequest, mockedResponse));
211 public void getRoleFunctionsListTest() throws Exception {
212 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/functions");
213 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
214 Map<String, Object> beans = new HashMap<>();
215 beans.put("bean1", rolesController);
216 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
217 PowerMockito.mockStatic(AopUtils.class);
218 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
219 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
220 assertNull(auxApiRequestMapperController.getRoleFunctionsList(mockedRequest, mockedResponse));
224 public void getRoleFunctionTest() throws Exception {
225 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/function/test");
226 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
227 Map<String, Object> beans = new HashMap<>();
228 beans.put("bean1", rolesController);
229 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
230 PowerMockito.mockStatic(AopUtils.class);
231 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
232 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
233 assertNull(auxApiRequestMapperController.getRoleFunction(mockedRequest, mockedResponse, "test"));
237 public void saveRoleFunctionTest() throws Exception {
238 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/roleFunction");
239 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
240 Map<String, Object> beans = new HashMap<>();
241 beans.put("bean1", rolesController);
242 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
243 PowerMockito.mockStatic(AopUtils.class);
244 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
245 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
246 PortalRestResponse<String> response = auxApiRequestMapperController.saveRoleFunction(mockedRequest, mockedResponse, "test");
247 assertNotNull(response);
251 public void deleteRoleFunctionTest() throws Exception {
252 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/roleFunction/test");
253 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
254 Map<String, Object> beans = new HashMap<>();
255 beans.put("bean1", rolesController);
256 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
257 PowerMockito.mockStatic(AopUtils.class);
258 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
259 Mockito.when(mockedRequest.getMethod()).thenReturn("DELETE");
260 assertNull(auxApiRequestMapperController.deleteRoleFunction(mockedRequest, mockedResponse, "test"));
264 public void deleteRoleTest() throws Exception {
265 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/deleteRole/1");
266 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
267 Map<String, Object> beans = new HashMap<>();
268 beans.put("bean1", rolesController);
269 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
270 PowerMockito.mockStatic(AopUtils.class);
271 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
272 Mockito.when(mockedRequest.getMethod()).thenReturn("DELETE");
273 assertNull(auxApiRequestMapperController.deleteRole(mockedRequest, mockedResponse, (long) 1));
277 public void getActiveRolesTest() throws Exception {
278 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/activeRoles");
279 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
280 Map<String, Object> beans = new HashMap<>();
281 beans.put("bean1", rolesController);
282 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
283 PowerMockito.mockStatic(AopUtils.class);
284 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
285 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
286 assertNull(auxApiRequestMapperController.getActiveRoles(mockedRequest, mockedResponse));
290 public void getEcompUserTest() throws Exception {
291 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v4/user/test");
292 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
293 Map<String, Object> beans = new HashMap<>();
294 beans.put("bean1", rolesController);
295 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
296 PowerMockito.mockStatic(AopUtils.class);
297 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
298 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
299 assertNull(auxApiRequestMapperController.getEcompUser(mockedRequest, mockedResponse, "test"));
303 public void getEcompRolesOfApplicationTest() throws Exception {
304 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v4/roles");
305 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
306 Map<String, Object> beans = new HashMap<>();
307 beans.put("bean1", rolesController);
308 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
309 PowerMockito.mockStatic(AopUtils.class);
310 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
311 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
312 assertNull(auxApiRequestMapperController.getEcompRolesOfApplication(mockedRequest, mockedResponse));
316 public void getSessionSlotCheckIntervalTest() throws Exception {
317 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/getSessionSlotCheckInterval");
318 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
319 Map<String, Object> beans = new HashMap<>();
320 beans.put("bean1", sessionCommunicationController);
321 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
322 PowerMockito.mockStatic(AopUtils.class);
323 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
324 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
325 assertNull(auxApiRequestMapperController.getSessionSlotCheckInterval(mockedRequest, mockedResponse));
329 public void extendSessionTimeOutsTest() throws Exception {
330 String sessionMap = "test";
331 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/extendSessionTimeOuts");
332 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
333 Map<String, Object> beans = new HashMap<>();
334 beans.put("bean1", sessionCommunicationController);
335 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
336 PowerMockito.mockStatic(AopUtils.class);
337 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
338 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
339 assertNull(auxApiRequestMapperController.extendSessionTimeOuts(mockedRequest, mockedResponse, sessionMap));
343 public void getAnalyticsScriptTest() throws Exception {
344 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/analytics");
345 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
346 Map<String, Object> beans = new HashMap<>();
347 beans.put("bean1", webAnalyticsExtAppController);
348 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
349 PowerMockito.mockStatic(AopUtils.class);
350 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
351 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
352 assertNull(auxApiRequestMapperController.getAnalyticsScript(mockedRequest, mockedResponse));
356 public void storeAnalyticsScriptTest() throws Exception {
357 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/storeAnalytics");
358 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
359 Map<String, Object> beans = new HashMap<>();
360 beans.put("bean1", webAnalyticsExtAppController);
361 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
362 PowerMockito.mockStatic(AopUtils.class);
363 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
364 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
365 Analytics analyticsMap = new Analytics();
366 assertNull(auxApiRequestMapperController.storeAnalyticsScript(mockedRequest, mockedResponse, analyticsMap));
370 public void bulkUploadFunctionsTest() throws Exception {
371 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/upload/portal/functions");
372 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
373 Map<String, Object> beans = new HashMap<>();
374 beans.put("bean1", rolesController);
375 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
376 PowerMockito.mockStatic(AopUtils.class);
377 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
378 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
379 PortalRestResponse res = new PortalRestResponse();
380 res.setStatus(PortalRestStatusEnum.ERROR);
381 res.setMessage("Failed to bulkUploadFunctions");
382 res.setResponse("Failed");
383 assertEquals(res, auxApiRequestMapperController.bulkUploadFunctions(mockedRequest, mockedResponse));
387 public void bulkUploadRolesTest() throws Exception {
388 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/upload/portal/roles");
389 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
390 Map<String, Object> beans = new HashMap<>();
391 beans.put("bean1", rolesController);
392 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
393 PowerMockito.mockStatic(AopUtils.class);
394 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
395 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
396 PortalRestResponse res = new PortalRestResponse();
397 res.setStatus(PortalRestStatusEnum.ERROR);
398 res.setMessage("Failed to bulkUploadRoles");
399 res.setResponse("Failed");
400 assertEquals(res, auxApiRequestMapperController.bulkUploadRoles(mockedRequest, mockedResponse));
404 public void bulkUploadRoleFunctionsTest() throws Exception {
405 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/upload/portal/roleFunctions");
406 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
407 Map<String, Object> beans = new HashMap<>();
408 beans.put("bean1", rolesController);
409 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
410 PowerMockito.mockStatic(AopUtils.class);
411 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
412 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
413 PortalRestResponse res = new PortalRestResponse();
414 res.setStatus(PortalRestStatusEnum.ERROR);
415 res.setMessage("Failed to bulkUploadRoleFunctions");
416 res.setResponse("Failed");
417 assertEquals(res, auxApiRequestMapperController.bulkUploadRoleFunctions(mockedRequest, mockedResponse));
421 public void bulkUploadUserRolesTest() throws Exception {
422 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/upload/portal/userRoles");
423 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
424 Map<String, Object> beans = new HashMap<>();
425 beans.put("bean1", rolesController);
426 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
427 PowerMockito.mockStatic(AopUtils.class);
428 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
429 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
430 PortalRestResponse res = new PortalRestResponse();
431 res.setStatus(PortalRestStatusEnum.ERROR);
432 res.setMessage("Failed to bulkUploadUserRoles");
433 res.setResponse("Failed");
434 assertEquals(res, auxApiRequestMapperController.bulkUploadUserRoles(mockedRequest, mockedResponse));
438 public void bulkUploadUsersSingleRoleTest() throws Exception {
439 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/upload/portal/userRole/1");
440 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
441 Map<String, Object> beans = new HashMap<>();
442 beans.put("bean1", rolesController);
443 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
444 PowerMockito.mockStatic(AopUtils.class);
445 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
446 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
447 PortalRestResponse res = new PortalRestResponse();
448 res.setStatus(PortalRestStatusEnum.ERROR);
449 res.setMessage("Failed to bulkUploadUsersSingleRole");
450 res.setResponse("Failed");
452 auxApiRequestMapperController.bulkUploadUsersSingleRole(mockedRequest, mockedResponse, (long) 1));
456 public void bulkUploadPartnerFunctionsTest() throws Exception {
457 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/upload/partner/roleFunctions");
458 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
459 Map<String, Object> beans = new HashMap<>();
460 beans.put("bean1", rolesController);
461 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
462 PowerMockito.mockStatic(AopUtils.class);
463 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
464 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
465 PortalRestResponse res = new PortalRestResponse();
466 res.setStatus(PortalRestStatusEnum.ERROR);
467 res.setMessage("Failed to bulkUploadPartnerRoleFunctions");
468 res.setResponse("Failed");
469 assertEquals(res, auxApiRequestMapperController.bulkUploadPartnerFunctions(mockedRequest, mockedResponse));
473 public void bulkUploadPartnerRolesTest() throws Exception {
474 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/upload/partner/roles");
475 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
476 Map<String, Object> beans = new HashMap<>();
477 beans.put("bean1", rolesController);
478 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
479 PowerMockito.mockStatic(AopUtils.class);
480 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
481 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
482 List<Role> upload = new ArrayList<>();
483 PortalRestResponse res = new PortalRestResponse();
484 res.setStatus(PortalRestStatusEnum.ERROR);
485 res.setMessage("Failed to bulkUploadRoles");
486 res.setResponse("Failed");
487 assertEquals(res, auxApiRequestMapperController.bulkUploadPartnerRoles(mockedRequest, mockedResponse, upload));
491 public void bulkUploadPartnerRoleFunctionsTest() throws Exception {
492 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/upload/partner/roleFunctions");
493 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
494 Map<String, Object> beans = new HashMap<>();
495 beans.put("bean1", rolesController);
496 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
497 PowerMockito.mockStatic(AopUtils.class);
498 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
499 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
500 PortalRestResponse res = new PortalRestResponse();
501 res.setStatus(PortalRestStatusEnum.ERROR);
502 res.setMessage("Failed to bulkUploadPartnerRoleFunctions");
503 res.setResponse("Failed");
504 assertEquals(res, auxApiRequestMapperController.bulkUploadPartnerRoleFunctions(mockedRequest, mockedResponse));
508 public void getMenuFunctionsTest() throws Exception {
509 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/menuFunctions");
510 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
511 Map<String, Object> beans = new HashMap<>();
512 beans.put("bean1", rolesController);
513 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
514 PowerMockito.mockStatic(AopUtils.class);
515 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
516 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
517 assertNull(auxApiRequestMapperController.getMenuFunctions(mockedRequest, mockedResponse));
521 public void postUserProfileTest() throws Exception {
522 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/userProfile");
523 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
524 Map<String, Object> beans = new HashMap<>();
525 beans.put("bean1", rolesApprovalSystemController);
526 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
527 PowerMockito.mockStatic(AopUtils.class);
528 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
529 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
530 ExternalSystemUser extSysUser = new ExternalSystemUser();
531 assertNull(auxApiRequestMapperController.postUserProfile(mockedRequest, extSysUser, mockedResponse));
535 public void putUserProfileTest() throws Exception {
536 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/userProfile");
537 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
538 Map<String, Object> beans = new HashMap<>();
539 beans.put("bean1", rolesApprovalSystemController);
540 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
541 PowerMockito.mockStatic(AopUtils.class);
542 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
543 Mockito.when(mockedRequest.getMethod()).thenReturn("PUT");
544 ExternalSystemUser extSysUser = new ExternalSystemUser();
545 assertNull(auxApiRequestMapperController.putUserProfile(mockedRequest, extSysUser, mockedResponse));
549 public void deleteUserProfileTest() throws Exception {
550 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/userProfile");
551 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
552 Map<String, Object> beans = new HashMap<>();
553 beans.put("bean1", rolesApprovalSystemController);
554 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
555 PowerMockito.mockStatic(AopUtils.class);
556 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
557 Mockito.when(mockedRequest.getMethod()).thenReturn("DELETE");
558 ExternalSystemUser extSysUser = new ExternalSystemUser();
559 assertNull(auxApiRequestMapperController.deleteUserProfile(mockedRequest, extSysUser, mockedResponse));
563 public void handleRequestTest() throws Exception {
564 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/ticketevent");
565 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
566 Map<String, Object> beans = new HashMap<>();
567 beans.put("bean1", ticketEventVersionController);
568 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
569 PowerMockito.mockStatic(AopUtils.class);
570 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
571 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
572 assertNull(auxApiRequestMapperController.handleRequest(mockedRequest, mockedResponse, "test"));
576 public void postPortalAdminTest() throws Exception {
577 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/portalAdmin");
578 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
579 Map<String, Object> beans = new HashMap<>();
580 beans.put("bean1", appsControllerExternalVersionRequest);
581 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
582 PowerMockito.mockStatic(AopUtils.class);
583 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
584 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
585 EPUser epUser = new EPUser();
586 assertNull(auxApiRequestMapperController.postPortalAdmin(mockedRequest, mockedResponse, epUser));
590 public void getOnboardAppExternalTest() throws Exception {
591 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/onboardApp/1");
592 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
593 Map<String, Object> beans = new HashMap<>();
594 beans.put("bean1", appsControllerExternalVersionRequest);
595 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
596 PowerMockito.mockStatic(AopUtils.class);
597 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
598 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
599 assertNull(auxApiRequestMapperController.getOnboardAppExternal(mockedRequest, mockedResponse, (long) 1));
603 public void postOnboardAppExternalTest() throws Exception {
604 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/onboardApp");
605 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
606 Map<String, Object> beans = new HashMap<>();
607 beans.put("bean1", appsControllerExternalVersionRequest);
608 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
609 PowerMockito.mockStatic(AopUtils.class);
610 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
611 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
612 OnboardingApp newOnboardApp = new OnboardingApp();
613 assertNull(auxApiRequestMapperController.postOnboardAppExternal(mockedRequest, mockedResponse, newOnboardApp));
617 public void putOnboardAppExternalTest() throws Exception {
618 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/onboardApp/1");
619 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
620 Map<String, Object> beans = new HashMap<>();
621 beans.put("bean1", appsControllerExternalVersionRequest);
622 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
623 PowerMockito.mockStatic(AopUtils.class);
624 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
625 Mockito.when(mockedRequest.getMethod()).thenReturn("PUT");
626 OnboardingApp newOnboardApp = new OnboardingApp();
627 assertNull(auxApiRequestMapperController.putOnboardAppExternal(mockedRequest, mockedResponse, (long) 1,
632 public void publishNotificationTest() throws Exception {
633 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/publishNotification");
634 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
635 Map<String, Object> beans = new HashMap<>();
636 beans.put("bean1", externalAppsRestfulVersionController);
637 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
638 PowerMockito.mockStatic(AopUtils.class);
639 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
640 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
641 EpNotificationItem notificationItem = new EpNotificationItem();
642 assertNotNull(auxApiRequestMapperController.publishNotification(mockedRequest, notificationItem, mockedResponse));
646 public void getFavoritesForUserTest() throws Exception {
647 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/getFavorites");
648 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
649 Map<String, Object> beans = new HashMap<>();
650 beans.put("bean1", externalAppsRestfulVersionController);
651 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
652 PowerMockito.mockStatic(AopUtils.class);
653 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
654 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
655 assertNull(auxApiRequestMapperController.getFavoritesForUser(mockedRequest, mockedResponse));
659 public void functionalMenuItemsForUserTest() throws Exception {
660 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/functionalMenuItemsForUser");
661 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
662 Map<String, Object> beans = new HashMap<>();
663 beans.put("bean1", externalAppsRestfulVersionController);
664 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
665 PowerMockito.mockStatic(AopUtils.class);
666 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
667 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
668 assertNull(auxApiRequestMapperController.getFunctionalMenuItemsForUser(mockedRequest, mockedResponse));
672 public void updateAppRoleDescriptionApiTest() throws Exception {
673 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/update/app/roleDescription");
674 PortalRestResponse<String> expectedportalRestResponse = new PortalRestResponse<String>();
675 expectedportalRestResponse.setMessage("updateAppRoleDescription: null");
676 expectedportalRestResponse.setResponse("Failure");
677 expectedportalRestResponse.setStatus(PortalRestStatusEnum.ERROR);
678 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
679 Map<String, Object> beans = new HashMap<>();
680 beans.put("bean1", rolesController);
681 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
682 PowerMockito.mockStatic(AopUtils.class);
683 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
684 Mockito.when(mockedRequest.getMethod()).thenReturn("PUT");
685 assertEquals(auxApiRequestMapperController.updateAppRoleDescription(mockedRequest, mockedResponse),
686 expectedportalRestResponse);