38510d9a5efbb53ca77129b502ef316ee3e8c0f9
[portal.git] / ecomp-portal-BE-common / src / test / java / org / onap / portalapp / portal / controller / AuxApiRequestMapperControllerTest.java
1 /*-
2  * ============LICENSE_START==========================================
3  * ONAP Portal
4  * ===================================================================
5  * Copyright (C) 2017 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 package org.onap.portalapp.portal.controller;
38
39 import static org.junit.Assert.*;
40
41 import java.lang.reflect.Method;
42 import java.util.ArrayList;
43 import java.util.HashMap;
44 import java.util.List;
45 import java.util.Map;
46
47 import javax.servlet.http.HttpServletRequest;
48 import javax.servlet.http.HttpServletResponse;
49
50 import org.junit.Before;
51 import org.junit.Test;
52 import org.junit.runner.RunWith;
53 import org.mockito.InjectMocks;
54 import org.mockito.Matchers;
55 import org.mockito.Mock;
56 import org.mockito.Mockito;
57 import org.mockito.MockitoAnnotations;
58 import org.onap.portalapp.annotation.ApiVersion;
59 import org.onap.portalapp.controller.sessionmgt.SessionCommunicationController;
60 import org.onap.portalapp.controller.sessionmgt.SessionCommunicationVersionController;
61 import org.onap.portalapp.externalsystemapproval.model.ExternalSystemUser;
62 import org.onap.portalapp.portal.domain.EPUser;
63 import org.onap.portalapp.portal.ecomp.model.PortalRestResponse;
64 import org.onap.portalapp.portal.ecomp.model.PortalRestStatusEnum;
65 import org.onap.portalapp.portal.framework.MockitoTestSuite;
66 import org.onap.portalapp.portal.transport.Analytics;
67 import org.onap.portalapp.portal.transport.EpNotificationItem;
68 import org.onap.portalapp.portal.transport.OnboardingApp;
69 import org.onap.portalsdk.core.domain.Role;
70 import org.powermock.api.mockito.PowerMockito;
71 import org.powermock.core.classloader.annotations.PrepareForTest;
72 import org.powermock.modules.junit4.PowerMockRunner;
73 import org.springframework.aop.support.AopUtils;
74 import org.springframework.context.ApplicationContext;
75
76 @RunWith(PowerMockRunner.class)
77 @PrepareForTest(AopUtils.class)
78 public class AuxApiRequestMapperControllerTest {
79         @InjectMocks
80         AuxApiRequestMapperController auxApiRequestMapperController = new AuxApiRequestMapperController();
81
82         @Before
83         public void setup() {
84                 MockitoAnnotations.initMocks(this);
85         }
86
87         RolesController rolesController = new RolesController();
88         SessionCommunicationVersionController sessionCommunicationController = new SessionCommunicationVersionController();
89         WebAnalyticsExtAppVersionController webAnalyticsExtAppController = new WebAnalyticsExtAppVersionController();
90         RolesApprovalSystemVersionController rolesApprovalSystemController = new RolesApprovalSystemVersionController();
91         TicketEventVersionController ticketEventVersionController = new TicketEventVersionController();
92         AppsControllerExternalVersionRequest appsControllerExternalVersionRequest = new AppsControllerExternalVersionRequest();
93         ExternalAppsRestfulVersionController externalAppsRestfulVersionController = new ExternalAppsRestfulVersionController();
94
95         @Mock
96         ApplicationContext context;
97         Method method;
98
99         MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
100         HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
101         HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
102         NullPointerException nullPointerException = new NullPointerException();
103
104         @Test
105         public void getUserTest() throws Exception {
106                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/roles");
107                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
108                 Map<String, Object> beans = new HashMap<>();
109                 beans.put("bean1", rolesController);
110                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
111                 PowerMockito.mockStatic(AopUtils.class);
112                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
113                 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
114                 assertNull(auxApiRequestMapperController.getUser(mockedRequest, mockedResponse, "test12"));
115         }
116         
117         @Test
118         public void getUserTestWithException() throws Exception {
119                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/roles");
120                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
121                 Map<String, Object> beans = new HashMap<>();
122                 beans.put("bean1", rolesController);
123                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
124                 PowerMockito.mockStatic(AopUtils.class);
125                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
126                 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
127                 assertNull(auxApiRequestMapperController.getUser(mockedRequest, mockedResponse, "test12"));
128         }
129
130         @Test
131         public void getRolesTest() throws Exception {
132                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/roles");
133                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
134                 Map<String, Object> beans = new HashMap<>();
135                 beans.put("bean1", rolesController);
136                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
137                 PowerMockito.mockStatic(AopUtils.class);
138                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
139                 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
140                 assertNull(auxApiRequestMapperController.getRoles(mockedRequest, mockedResponse));
141         }
142
143         @Test
144         public void saveRoleTest() throws Exception {
145                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/role");
146                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
147                 Map<String, Object> beans = new HashMap<>();
148                 beans.put("bean1", rolesController);
149                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
150                 PowerMockito.mockStatic(AopUtils.class);
151                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
152                 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
153                 Role role = new Role();
154                 assertNull(auxApiRequestMapperController.saveRole(mockedRequest, mockedResponse, role));
155         }
156
157         @Test
158         public void getEPRolesTest() throws Exception {
159                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v4/roles");
160                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
161                 Map<String, Object> beans = new HashMap<>();
162                 beans.put("bean1", rolesController);
163                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
164                 PowerMockito.mockStatic(AopUtils.class);
165                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
166                 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
167                 assertNull(auxApiRequestMapperController.getRoles(mockedRequest, mockedResponse));
168         }
169
170         @Test
171         public void getUser1Test() throws Exception {
172                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/user/test12");
173                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
174                 Map<String, Object> beans = new HashMap<>();
175                 beans.put("bean1", rolesController);
176                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
177                 PowerMockito.mockStatic(AopUtils.class);
178                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
179                 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
180                 assertNull(auxApiRequestMapperController.getUser(mockedRequest, mockedResponse, "test12"));
181         }
182
183         @Test
184         public void getRoleTest() throws Exception {
185                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/role/1");
186                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
187                 Map<String, Object> beans = new HashMap<>();
188                 beans.put("bean1", rolesController);
189                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
190                 PowerMockito.mockStatic(AopUtils.class);
191                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
192                 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
193                 assertNull(auxApiRequestMapperController.getRoleInfo(mockedRequest, mockedResponse, (long) 1));
194         }
195
196         @Test
197         public void getUsersOfApplicationTest() throws Exception {
198                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/users");
199                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
200                 Map<String, Object> beans = new HashMap<>();
201                 beans.put("bean1", rolesController);
202                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
203                 PowerMockito.mockStatic(AopUtils.class);
204                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
205                 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
206                 assertNull(auxApiRequestMapperController.getUsersOfApplication(mockedRequest, mockedResponse));
207         }
208
209         @Test
210         public void getRoleFunctionsListTest() throws Exception {
211                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/functions");
212                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
213                 Map<String, Object> beans = new HashMap<>();
214                 beans.put("bean1", rolesController);
215                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
216                 PowerMockito.mockStatic(AopUtils.class);
217                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
218                 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
219                 assertNull(auxApiRequestMapperController.getRoleFunctionsList(mockedRequest, mockedResponse));
220         }
221
222         @Test
223         public void getRoleFunctionTest() throws Exception {
224                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/function/test");
225                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
226                 Map<String, Object> beans = new HashMap<>();
227                 beans.put("bean1", rolesController);
228                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
229                 PowerMockito.mockStatic(AopUtils.class);
230                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
231                 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
232                 assertNull(auxApiRequestMapperController.getRoleFunction(mockedRequest, mockedResponse, "test"));
233         }
234
235         @Test
236         public void saveRoleFunctionTest() throws Exception {
237                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/roleFunction");
238                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
239                 Map<String, Object> beans = new HashMap<>();
240                 beans.put("bean1", rolesController);
241                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
242                 PowerMockito.mockStatic(AopUtils.class);
243                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
244                 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
245                 PortalRestResponse<String> response = auxApiRequestMapperController.saveRoleFunction(mockedRequest, mockedResponse, "test");
246                 assertNotNull(response);
247         }
248
249         @Test
250         public void deleteRoleFunctionTest() throws Exception {
251                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/roleFunction/test");
252                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
253                 Map<String, Object> beans = new HashMap<>();
254                 beans.put("bean1", rolesController);
255                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
256                 PowerMockito.mockStatic(AopUtils.class);
257                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
258                 Mockito.when(mockedRequest.getMethod()).thenReturn("DELETE");
259                 assertNull(auxApiRequestMapperController.deleteRoleFunction(mockedRequest, mockedResponse, "test"));
260         }
261
262         @Test
263         public void deleteRoleTest() throws Exception {
264                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/deleteRole/1");
265                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
266                 Map<String, Object> beans = new HashMap<>();
267                 beans.put("bean1", rolesController);
268                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
269                 PowerMockito.mockStatic(AopUtils.class);
270                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
271                 Mockito.when(mockedRequest.getMethod()).thenReturn("DELETE");
272                 assertNull(auxApiRequestMapperController.deleteRole(mockedRequest, mockedResponse, (long) 1));
273         }
274
275         @Test
276         public void getActiveRolesTest() throws Exception {
277                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/activeRoles");
278                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
279                 Map<String, Object> beans = new HashMap<>();
280                 beans.put("bean1", rolesController);
281                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
282                 PowerMockito.mockStatic(AopUtils.class);
283                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
284                 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
285                 assertNull(auxApiRequestMapperController.getActiveRoles(mockedRequest, mockedResponse));
286         }
287
288         @Test
289         public void getEcompUserTest() throws Exception {
290                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v4/user/test");
291                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
292                 Map<String, Object> beans = new HashMap<>();
293                 beans.put("bean1", rolesController);
294                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
295                 PowerMockito.mockStatic(AopUtils.class);
296                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
297                 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
298                 assertNull(auxApiRequestMapperController.getEcompUser(mockedRequest, mockedResponse, "test"));
299         }
300
301         @Test
302         public void getEcompRolesOfApplicationTest() throws Exception {
303                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v4/roles");
304                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
305                 Map<String, Object> beans = new HashMap<>();
306                 beans.put("bean1", rolesController);
307                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
308                 PowerMockito.mockStatic(AopUtils.class);
309                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
310                 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
311                 assertNull(auxApiRequestMapperController.getEcompRolesOfApplication(mockedRequest, mockedResponse));
312         }
313
314         @Test
315         public void getSessionSlotCheckIntervalTest() throws Exception {
316                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/getSessionSlotCheckInterval");
317                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
318                 Map<String, Object> beans = new HashMap<>();
319                 beans.put("bean1", sessionCommunicationController);
320                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
321                 PowerMockito.mockStatic(AopUtils.class);
322                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
323                 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
324                 assertNull(auxApiRequestMapperController.getSessionSlotCheckInterval(mockedRequest, mockedResponse));
325         }
326
327         @Test
328         public void extendSessionTimeOutsTest() throws Exception {
329                 String sessionMap = "test";
330                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/extendSessionTimeOuts");
331                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
332                 Map<String, Object> beans = new HashMap<>();
333                 beans.put("bean1", sessionCommunicationController);
334                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
335                 PowerMockito.mockStatic(AopUtils.class);
336                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
337                 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
338                 assertNull(auxApiRequestMapperController.extendSessionTimeOuts(mockedRequest, mockedResponse, sessionMap));
339         }
340
341         @Test
342         public void getAnalyticsScriptTest() throws Exception {
343                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/analytics");
344                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
345                 Map<String, Object> beans = new HashMap<>();
346                 beans.put("bean1", webAnalyticsExtAppController);
347                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
348                 PowerMockito.mockStatic(AopUtils.class);
349                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
350                 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
351                 assertNull(auxApiRequestMapperController.getAnalyticsScript(mockedRequest, mockedResponse));
352         }
353
354         @Test
355         public void storeAnalyticsScriptTest() throws Exception {
356                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/storeAnalytics");
357                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
358                 Map<String, Object> beans = new HashMap<>();
359                 beans.put("bean1", webAnalyticsExtAppController);
360                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
361                 PowerMockito.mockStatic(AopUtils.class);
362                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
363                 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
364                 Analytics analyticsMap = new Analytics();
365                 assertNull(auxApiRequestMapperController.storeAnalyticsScript(mockedRequest, mockedResponse, analyticsMap));
366         }
367
368         @Test
369         public void bulkUploadFunctionsTest() throws Exception {
370                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/upload/portal/functions");
371                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
372                 Map<String, Object> beans = new HashMap<>();
373                 beans.put("bean1", rolesController);
374                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
375                 PowerMockito.mockStatic(AopUtils.class);
376                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
377                 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
378                 PortalRestResponse res = new PortalRestResponse();
379                 res.setStatus(PortalRestStatusEnum.ERROR);
380                 res.setMessage("Failed to bulkUploadFunctions");
381                 res.setResponse("Failed");
382                 assertEquals(res, auxApiRequestMapperController.bulkUploadFunctions(mockedRequest, mockedResponse));
383         }
384
385         @Test
386         public void bulkUploadRolesTest() throws Exception {
387                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/upload/portal/roles");
388                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
389                 Map<String, Object> beans = new HashMap<>();
390                 beans.put("bean1", rolesController);
391                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
392                 PowerMockito.mockStatic(AopUtils.class);
393                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
394                 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
395                 PortalRestResponse res = new PortalRestResponse();
396                 res.setStatus(PortalRestStatusEnum.ERROR);
397                 res.setMessage("Failed to bulkUploadRoles");
398                 res.setResponse("Failed");
399                 assertEquals(res, auxApiRequestMapperController.bulkUploadRoles(mockedRequest, mockedResponse));
400         }
401
402         @Test
403         public void bulkUploadRoleFunctionsTest() throws Exception {
404                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/upload/portal/roleFunctions");
405                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
406                 Map<String, Object> beans = new HashMap<>();
407                 beans.put("bean1", rolesController);
408                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
409                 PowerMockito.mockStatic(AopUtils.class);
410                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
411                 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
412                 PortalRestResponse res = new PortalRestResponse();
413                 res.setStatus(PortalRestStatusEnum.ERROR);
414                 res.setMessage("Failed to bulkUploadRoleFunctions");
415                 res.setResponse("Failed");
416                 assertEquals(res, auxApiRequestMapperController.bulkUploadRoleFunctions(mockedRequest, mockedResponse));
417         }
418
419         @Test
420         public void bulkUploadUserRolesTest() throws Exception {
421                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/upload/portal/userRoles");
422                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
423                 Map<String, Object> beans = new HashMap<>();
424                 beans.put("bean1", rolesController);
425                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
426                 PowerMockito.mockStatic(AopUtils.class);
427                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
428                 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
429                 PortalRestResponse res = new PortalRestResponse();
430                 res.setStatus(PortalRestStatusEnum.ERROR);
431                 res.setMessage("Failed to bulkUploadUserRoles");
432                 res.setResponse("Failed");
433                 assertEquals(res, auxApiRequestMapperController.bulkUploadUserRoles(mockedRequest, mockedResponse));
434         }
435
436         @Test
437         public void bulkUploadUsersSingleRoleTest() throws Exception {
438                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/upload/portal/userRole/1");
439                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
440                 Map<String, Object> beans = new HashMap<>();
441                 beans.put("bean1", rolesController);
442                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
443                 PowerMockito.mockStatic(AopUtils.class);
444                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
445                 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
446                 PortalRestResponse res = new PortalRestResponse();
447                 res.setStatus(PortalRestStatusEnum.ERROR);
448                 res.setMessage("Failed to bulkUploadUsersSingleRole");
449                 res.setResponse("Failed");
450                 assertEquals(res,
451                                 auxApiRequestMapperController.bulkUploadUsersSingleRole(mockedRequest, mockedResponse, (long) 1));
452         }
453
454         @Test
455         public void bulkUploadPartnerFunctionsTest() throws Exception {
456                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/upload/partner/roleFunctions");
457                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
458                 Map<String, Object> beans = new HashMap<>();
459                 beans.put("bean1", rolesController);
460                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
461                 PowerMockito.mockStatic(AopUtils.class);
462                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
463                 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
464                 PortalRestResponse res = new PortalRestResponse();
465                 res.setStatus(PortalRestStatusEnum.ERROR);
466                 res.setMessage("Failed to bulkUploadPartnerRoleFunctions");
467                 res.setResponse("Failed");
468                 assertEquals(res, auxApiRequestMapperController.bulkUploadPartnerFunctions(mockedRequest, mockedResponse));
469         }
470
471         @Test
472         public void bulkUploadPartnerRolesTest() throws Exception {
473                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/upload/partner/roles");
474                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
475                 Map<String, Object> beans = new HashMap<>();
476                 beans.put("bean1", rolesController);
477                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
478                 PowerMockito.mockStatic(AopUtils.class);
479                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
480                 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
481                 List<Role> upload = new ArrayList<>();
482                 PortalRestResponse res = new PortalRestResponse();
483                 res.setStatus(PortalRestStatusEnum.ERROR);
484                 res.setMessage("Failed to bulkUploadRoles");
485                 res.setResponse("Failed");
486                 assertEquals(res, auxApiRequestMapperController.bulkUploadPartnerRoles(mockedRequest, mockedResponse, upload));
487         }
488
489         @Test
490         public void bulkUploadPartnerRoleFunctionsTest() throws Exception {
491                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/upload/partner/roleFunctions");
492                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
493                 Map<String, Object> beans = new HashMap<>();
494                 beans.put("bean1", rolesController);
495                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
496                 PowerMockito.mockStatic(AopUtils.class);
497                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
498                 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
499                 PortalRestResponse res = new PortalRestResponse();
500                 res.setStatus(PortalRestStatusEnum.ERROR);
501                 res.setMessage("Failed to bulkUploadPartnerRoleFunctions");
502                 res.setResponse("Failed");
503                 assertEquals(res, auxApiRequestMapperController.bulkUploadPartnerRoleFunctions(mockedRequest, mockedResponse));
504         }
505
506         @Test
507         public void getMenuFunctionsTest() throws Exception {
508                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/menuFunctions");
509                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
510                 Map<String, Object> beans = new HashMap<>();
511                 beans.put("bean1", rolesController);
512                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
513                 PowerMockito.mockStatic(AopUtils.class);
514                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
515                 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
516                 assertNull(auxApiRequestMapperController.getMenuFunctions(mockedRequest, mockedResponse));
517         }
518
519         @Test
520         public void postUserProfileTest() throws Exception {
521                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/userProfile");
522                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
523                 Map<String, Object> beans = new HashMap<>();
524                 beans.put("bean1", rolesApprovalSystemController);
525                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
526                 PowerMockito.mockStatic(AopUtils.class);
527                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
528                 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
529                 ExternalSystemUser extSysUser = new ExternalSystemUser();
530                 assertNull(auxApiRequestMapperController.postUserProfile(mockedRequest, extSysUser, mockedResponse));
531         }
532
533         @Test
534         public void putUserProfileTest() throws Exception {
535                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/userProfile");
536                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
537                 Map<String, Object> beans = new HashMap<>();
538                 beans.put("bean1", rolesApprovalSystemController);
539                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
540                 PowerMockito.mockStatic(AopUtils.class);
541                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
542                 Mockito.when(mockedRequest.getMethod()).thenReturn("PUT");
543                 ExternalSystemUser extSysUser = new ExternalSystemUser();
544                 assertNull(auxApiRequestMapperController.putUserProfile(mockedRequest, extSysUser, mockedResponse));
545         }
546
547         @Test
548         public void deleteUserProfileTest() throws Exception {
549                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/userProfile");
550                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
551                 Map<String, Object> beans = new HashMap<>();
552                 beans.put("bean1", rolesApprovalSystemController);
553                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
554                 PowerMockito.mockStatic(AopUtils.class);
555                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
556                 Mockito.when(mockedRequest.getMethod()).thenReturn("DELETE");
557                 ExternalSystemUser extSysUser = new ExternalSystemUser();
558                 assertNull(auxApiRequestMapperController.deleteUserProfile(mockedRequest, extSysUser, mockedResponse));
559         }
560
561         @Test
562         public void handleRequestTest() throws Exception {
563                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/ticketevent");
564                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
565                 Map<String, Object> beans = new HashMap<>();
566                 beans.put("bean1", ticketEventVersionController);
567                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
568                 PowerMockito.mockStatic(AopUtils.class);
569                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
570                 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
571                 assertNull(auxApiRequestMapperController.handleRequest(mockedRequest, mockedResponse, "test"));
572         }
573
574         @Test
575         public void postPortalAdminTest() throws Exception {
576                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/portalAdmin");
577                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
578                 Map<String, Object> beans = new HashMap<>();
579                 beans.put("bean1", appsControllerExternalVersionRequest);
580                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
581                 PowerMockito.mockStatic(AopUtils.class);
582                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
583                 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
584                 EPUser epUser = new EPUser();
585                 assertNull(auxApiRequestMapperController.postPortalAdmin(mockedRequest, mockedResponse, epUser));
586         }
587
588         @Test
589         public void getOnboardAppExternalTest() throws Exception {
590                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/onboardApp/1");
591                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
592                 Map<String, Object> beans = new HashMap<>();
593                 beans.put("bean1", appsControllerExternalVersionRequest);
594                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
595                 PowerMockito.mockStatic(AopUtils.class);
596                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
597                 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
598                 assertNull(auxApiRequestMapperController.getOnboardAppExternal(mockedRequest, mockedResponse, (long) 1));
599         }
600
601         @Test
602         public void postOnboardAppExternalTest() throws Exception {
603                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/onboardApp");
604                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
605                 Map<String, Object> beans = new HashMap<>();
606                 beans.put("bean1", appsControllerExternalVersionRequest);
607                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
608                 PowerMockito.mockStatic(AopUtils.class);
609                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
610                 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
611                 OnboardingApp newOnboardApp = new OnboardingApp();
612                 assertNull(auxApiRequestMapperController.postOnboardAppExternal(mockedRequest, mockedResponse, newOnboardApp));
613         }
614
615         @Test
616         public void putOnboardAppExternalTest() throws Exception {
617                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/onboardApp/1");
618                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
619                 Map<String, Object> beans = new HashMap<>();
620                 beans.put("bean1", appsControllerExternalVersionRequest);
621                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
622                 PowerMockito.mockStatic(AopUtils.class);
623                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
624                 Mockito.when(mockedRequest.getMethod()).thenReturn("PUT");
625                 OnboardingApp newOnboardApp = new OnboardingApp();
626                 assertNull(auxApiRequestMapperController.putOnboardAppExternal(mockedRequest, mockedResponse, (long) 1,
627                                 newOnboardApp));
628         }
629
630         @Test
631         public void publishNotificationTest() throws Exception {
632                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/publishNotification");
633                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
634                 Map<String, Object> beans = new HashMap<>();
635                 beans.put("bean1", externalAppsRestfulVersionController);
636                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
637                 PowerMockito.mockStatic(AopUtils.class);
638                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
639                 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
640                 EpNotificationItem notificationItem = new EpNotificationItem();
641                 assertNull(auxApiRequestMapperController.publishNotification(mockedRequest, notificationItem, mockedResponse));
642         }
643
644         @Test
645         public void getFavoritesForUserTest() throws Exception {
646                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/getFavorites");
647                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
648                 Map<String, Object> beans = new HashMap<>();
649                 beans.put("bean1", externalAppsRestfulVersionController);
650                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
651                 PowerMockito.mockStatic(AopUtils.class);
652                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
653                 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
654                 assertNull(auxApiRequestMapperController.getFavoritesForUser(mockedRequest, mockedResponse));
655         }
656
657         @Test
658         public void functionalMenuItemsForUserTest() throws Exception {
659                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/functionalMenuItemsForUser");
660                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
661                 Map<String, Object> beans = new HashMap<>();
662                 beans.put("bean1", externalAppsRestfulVersionController);
663                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
664                 PowerMockito.mockStatic(AopUtils.class);
665                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
666                 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
667                 assertNull(auxApiRequestMapperController.getFunctionalMenuItemsForUser(mockedRequest, mockedResponse));
668         }
669 }