Bulk upload changes and music health check apis
[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 getRolesTest() 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.getRoles(mockedRequest, mockedResponse));
128         }
129
130         @Test
131         public void saveRoleTest() throws Exception {
132                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/role");
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("POST");
140                 Role role = new Role();
141                 assertNull(auxApiRequestMapperController.saveRole(mockedRequest, mockedResponse, role));
142         }
143
144         @Test
145         public void getEPRolesTest() throws Exception {
146                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v4/roles");
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("GET");
154                 assertNull(auxApiRequestMapperController.getRoles(mockedRequest, mockedResponse));
155         }
156
157         @Test
158         public void getUser1Test() throws Exception {
159                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/user/test12");
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.getUser(mockedRequest, mockedResponse, "test12"));
168         }
169
170         @Test
171         public void getRoleTest() throws Exception {
172                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/role/1");
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.getRoleInfo(mockedRequest, mockedResponse, (long) 1));
181         }
182
183         @Test
184         public void getUsersOfApplicationTest() throws Exception {
185                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/users");
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.getUsersOfApplication(mockedRequest, mockedResponse));
194         }
195
196         @Test
197         public void getRoleFunctionsListTest() throws Exception {
198                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/functions");
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.getRoleFunctionsList(mockedRequest, mockedResponse));
207         }
208
209         @Test
210         public void getRoleFunctionTest() throws Exception {
211                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/function/test");
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.getRoleFunction(mockedRequest, mockedResponse, "test"));
220         }
221
222         @Test
223         public void saveRoleFunctionTest() throws Exception {
224                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/roleFunction");
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("POST");
232                 PortalRestResponse<String> response = auxApiRequestMapperController.saveRoleFunction(mockedRequest, mockedResponse, "test");
233                 assertNotNull(response);
234         }
235
236         @Test
237         public void deleteRoleFunctionTest() throws Exception {
238                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/roleFunction/test");
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("DELETE");
246                 assertNull(auxApiRequestMapperController.deleteRoleFunction(mockedRequest, mockedResponse, "test"));
247         }
248
249         @Test
250         public void deleteRoleTest() throws Exception {
251                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/deleteRole/1");
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.deleteRole(mockedRequest, mockedResponse, (long) 1));
260         }
261
262         @Test
263         public void getActiveRolesTest() throws Exception {
264                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/activeRoles");
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("GET");
272                 assertNull(auxApiRequestMapperController.getActiveRoles(mockedRequest, mockedResponse));
273         }
274
275         @Test
276         public void getEcompUserTest() throws Exception {
277                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v4/user/test");
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.getEcompUser(mockedRequest, mockedResponse, "test"));
286         }
287
288         @Test
289         public void getEcompRolesOfApplicationTest() throws Exception {
290                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v4/roles");
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.getEcompRolesOfApplication(mockedRequest, mockedResponse));
299         }
300
301         @Test
302         public void getSessionSlotCheckIntervalTest() throws Exception {
303                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/getSessionSlotCheckInterval");
304                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
305                 Map<String, Object> beans = new HashMap<>();
306                 beans.put("bean1", sessionCommunicationController);
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.getSessionSlotCheckInterval(mockedRequest, mockedResponse));
312         }
313
314         @Test
315         public void extendSessionTimeOutsTest() throws Exception {
316                 String sessionMap = "test";
317                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/extendSessionTimeOuts");
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("POST");
325                 assertNull(auxApiRequestMapperController.extendSessionTimeOuts(mockedRequest, mockedResponse, sessionMap));
326         }
327
328         @Test
329         public void getAnalyticsScriptTest() throws Exception {
330                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/analytics");
331                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
332                 Map<String, Object> beans = new HashMap<>();
333                 beans.put("bean1", webAnalyticsExtAppController);
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("GET");
338                 assertNull(auxApiRequestMapperController.getAnalyticsScript(mockedRequest, mockedResponse));
339         }
340
341         @Test
342         public void storeAnalyticsScriptTest() throws Exception {
343                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/storeAnalytics");
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("POST");
351                 Analytics analyticsMap = new Analytics();
352                 assertNull(auxApiRequestMapperController.storeAnalyticsScript(mockedRequest, mockedResponse, analyticsMap));
353         }
354
355         @Test
356         public void bulkUploadFunctionsTest() throws Exception {
357                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/upload/portal/functions");
358                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
359                 Map<String, Object> beans = new HashMap<>();
360                 beans.put("bean1", rolesController);
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                 PortalRestResponse res = new PortalRestResponse();
366                 res.setStatus(PortalRestStatusEnum.ERROR);
367                 res.setMessage("Failed to bulkUploadFunctions");
368                 res.setResponse("Failed");
369                 assertEquals(res, auxApiRequestMapperController.bulkUploadFunctions(mockedRequest, mockedResponse));
370         }
371
372         @Test
373         public void bulkUploadRolesTest() throws Exception {
374                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/upload/portal/roles");
375                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
376                 Map<String, Object> beans = new HashMap<>();
377                 beans.put("bean1", rolesController);
378                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
379                 PowerMockito.mockStatic(AopUtils.class);
380                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
381                 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
382                 PortalRestResponse res = new PortalRestResponse();
383                 res.setStatus(PortalRestStatusEnum.ERROR);
384                 res.setMessage("Failed to bulkUploadRoles");
385                 res.setResponse("Failed");
386                 assertEquals(res, auxApiRequestMapperController.bulkUploadRoles(mockedRequest, mockedResponse));
387         }
388
389         @Test
390         public void bulkUploadRoleFunctionsTest() throws Exception {
391                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/upload/portal/roleFunctions");
392                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
393                 Map<String, Object> beans = new HashMap<>();
394                 beans.put("bean1", rolesController);
395                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
396                 PowerMockito.mockStatic(AopUtils.class);
397                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
398                 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
399                 PortalRestResponse res = new PortalRestResponse();
400                 res.setStatus(PortalRestStatusEnum.ERROR);
401                 res.setMessage("Failed to bulkUploadRoleFunctions");
402                 res.setResponse("Failed");
403                 assertEquals(res, auxApiRequestMapperController.bulkUploadRoleFunctions(mockedRequest, mockedResponse));
404         }
405
406         @Test
407         public void bulkUploadUserRolesTest() throws Exception {
408                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/upload/portal/userRoles");
409                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
410                 Map<String, Object> beans = new HashMap<>();
411                 beans.put("bean1", rolesController);
412                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
413                 PowerMockito.mockStatic(AopUtils.class);
414                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
415                 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
416                 PortalRestResponse res = new PortalRestResponse();
417                 res.setStatus(PortalRestStatusEnum.ERROR);
418                 res.setMessage("Failed to bulkUploadUserRoles");
419                 res.setResponse("Failed");
420                 assertEquals(res, auxApiRequestMapperController.bulkUploadUserRoles(mockedRequest, mockedResponse));
421         }
422
423         @Test
424         public void bulkUploadUsersSingleRoleTest() throws Exception {
425                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/upload/portal/userRole/1");
426                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
427                 Map<String, Object> beans = new HashMap<>();
428                 beans.put("bean1", rolesController);
429                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
430                 PowerMockito.mockStatic(AopUtils.class);
431                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
432                 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
433                 PortalRestResponse res = new PortalRestResponse();
434                 res.setStatus(PortalRestStatusEnum.ERROR);
435                 res.setMessage("Failed to bulkUploadUsersSingleRole");
436                 res.setResponse("Failed");
437                 assertEquals(res,
438                                 auxApiRequestMapperController.bulkUploadUsersSingleRole(mockedRequest, mockedResponse, (long) 1));
439         }
440
441         @Test
442         public void bulkUploadPartnerFunctionsTest() throws Exception {
443                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/upload/partner/roleFunctions");
444                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
445                 Map<String, Object> beans = new HashMap<>();
446                 beans.put("bean1", rolesController);
447                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
448                 PowerMockito.mockStatic(AopUtils.class);
449                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
450                 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
451                 PortalRestResponse res = new PortalRestResponse();
452                 res.setStatus(PortalRestStatusEnum.ERROR);
453                 res.setMessage("Failed to bulkUploadPartnerRoleFunctions");
454                 res.setResponse("Failed");
455                 assertEquals(res, auxApiRequestMapperController.bulkUploadPartnerFunctions(mockedRequest, mockedResponse));
456         }
457
458         @Test
459         public void bulkUploadPartnerRolesTest() throws Exception {
460                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/upload/partner/roles");
461                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
462                 Map<String, Object> beans = new HashMap<>();
463                 beans.put("bean1", rolesController);
464                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
465                 PowerMockito.mockStatic(AopUtils.class);
466                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
467                 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
468                 List<Role> upload = new ArrayList<>();
469                 PortalRestResponse res = new PortalRestResponse();
470                 res.setStatus(PortalRestStatusEnum.ERROR);
471                 res.setMessage("Failed to bulkUploadRoles");
472                 res.setResponse("Failed");
473                 assertEquals(res, auxApiRequestMapperController.bulkUploadPartnerRoles(mockedRequest, mockedResponse, upload));
474         }
475
476         @Test
477         public void bulkUploadPartnerRoleFunctionsTest() throws Exception {
478                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/upload/partner/roleFunctions");
479                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
480                 Map<String, Object> beans = new HashMap<>();
481                 beans.put("bean1", rolesController);
482                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
483                 PowerMockito.mockStatic(AopUtils.class);
484                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
485                 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
486                 PortalRestResponse res = new PortalRestResponse();
487                 res.setStatus(PortalRestStatusEnum.ERROR);
488                 res.setMessage("Failed to bulkUploadPartnerRoleFunctions");
489                 res.setResponse("Failed");
490                 assertEquals(res, auxApiRequestMapperController.bulkUploadPartnerRoleFunctions(mockedRequest, mockedResponse));
491         }
492
493         @Test
494         public void getMenuFunctionsTest() throws Exception {
495                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/menuFunctions");
496                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
497                 Map<String, Object> beans = new HashMap<>();
498                 beans.put("bean1", rolesController);
499                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
500                 PowerMockito.mockStatic(AopUtils.class);
501                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
502                 Mockito.when(mockedRequest.getMethod()).thenReturn("GET");
503                 assertNull(auxApiRequestMapperController.getMenuFunctions(mockedRequest, mockedResponse));
504         }
505
506         @Test
507         public void postUserProfileTest() throws Exception {
508                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/userProfile");
509                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
510                 Map<String, Object> beans = new HashMap<>();
511                 beans.put("bean1", rolesApprovalSystemController);
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("POST");
516                 ExternalSystemUser extSysUser = new ExternalSystemUser();
517                 assertNull(auxApiRequestMapperController.postUserProfile(mockedRequest, extSysUser, mockedResponse));
518         }
519
520         @Test
521         public void putUserProfileTest() 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("PUT");
530                 ExternalSystemUser extSysUser = new ExternalSystemUser();
531                 assertNull(auxApiRequestMapperController.putUserProfile(mockedRequest, extSysUser, mockedResponse));
532         }
533
534         @Test
535         public void deleteUserProfileTest() 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("DELETE");
544                 ExternalSystemUser extSysUser = new ExternalSystemUser();
545                 assertNull(auxApiRequestMapperController.deleteUserProfile(mockedRequest, extSysUser, mockedResponse));
546         }
547
548         @Test
549         public void handleRequestTest() throws Exception {
550                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/ticketevent");
551                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
552                 Map<String, Object> beans = new HashMap<>();
553                 beans.put("bean1", ticketEventVersionController);
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("POST");
558                 assertNull(auxApiRequestMapperController.handleRequest(mockedRequest, mockedResponse, "test"));
559         }
560
561         @Test
562         public void postPortalAdminTest() throws Exception {
563                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/portalAdmin");
564                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
565                 Map<String, Object> beans = new HashMap<>();
566                 beans.put("bean1", appsControllerExternalVersionRequest);
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                 EPUser epUser = new EPUser();
572                 assertNull(auxApiRequestMapperController.postPortalAdmin(mockedRequest, mockedResponse, epUser));
573         }
574
575         @Test
576         public void getOnboardAppExternalTest() throws Exception {
577                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/onboardApp/1");
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("GET");
585                 assertNull(auxApiRequestMapperController.getOnboardAppExternal(mockedRequest, mockedResponse, (long) 1));
586         }
587
588         @Test
589         public void postOnboardAppExternalTest() throws Exception {
590                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/onboardApp");
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("POST");
598                 OnboardingApp newOnboardApp = new OnboardingApp();
599                 assertNull(auxApiRequestMapperController.postOnboardAppExternal(mockedRequest, mockedResponse, newOnboardApp));
600         }
601
602         @Test
603         public void putOnboardAppExternalTest() throws Exception {
604                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/onboardApp/1");
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("PUT");
612                 OnboardingApp newOnboardApp = new OnboardingApp();
613                 assertNull(auxApiRequestMapperController.putOnboardAppExternal(mockedRequest, mockedResponse, (long) 1,
614                                 newOnboardApp));
615         }
616
617         @Test
618         public void publishNotificationTest() throws Exception {
619                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/publishNotification");
620                 Mockito.when(mockedRequest.getHeader("MinorVersion")).thenReturn("0");
621                 Map<String, Object> beans = new HashMap<>();
622                 beans.put("bean1", externalAppsRestfulVersionController);
623                 Mockito.when(context.getBeansWithAnnotation(ApiVersion.class)).thenReturn(beans);
624                 PowerMockito.mockStatic(AopUtils.class);
625                 Mockito.when(AopUtils.isAopProxy(Matchers.anyObject())).thenReturn(false);
626                 Mockito.when(mockedRequest.getMethod()).thenReturn("POST");
627                 EpNotificationItem notificationItem = new EpNotificationItem();
628                 assertNull(auxApiRequestMapperController.publishNotification(mockedRequest, notificationItem, mockedResponse));
629         }
630
631         @Test
632         public void getFavoritesForUserTest() throws Exception {
633                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/getFavorites");
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("GET");
641                 assertNull(auxApiRequestMapperController.getFavoritesForUser(mockedRequest, mockedResponse));
642         }
643
644         @Test
645         public void functionalMenuItemsForUserTest() throws Exception {
646                 Mockito.when(mockedRequest.getRequestURI()).thenReturn("/auxapi/v3/functionalMenuItemsForUser");
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.getFunctionalMenuItemsForUser(mockedRequest, mockedResponse));
655         }
656 }