CADI AAF Integration and merging the code
[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.assertEquals;
40 import static org.junit.Assert.assertNotNull;
41 import static org.junit.Assert.assertNull;
42
43 import java.lang.reflect.Method;
44 import java.util.ArrayList;
45 import java.util.HashMap;
46 import java.util.List;
47 import java.util.Map;
48
49 import javax.servlet.http.HttpServletRequest;
50 import javax.servlet.http.HttpServletResponse;
51
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;
76
77 @RunWith(PowerMockRunner.class)
78 @PrepareForTest(AopUtils.class)
79 public class AuxApiRequestMapperControllerTest {
80         @InjectMocks
81         AuxApiRequestMapperController auxApiRequestMapperController = new AuxApiRequestMapperController();
82
83         @Before
84         public void setup() {
85                 MockitoAnnotations.initMocks(this);
86         }
87
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();
95
96         @Mock
97         ApplicationContext context;
98         Method method;
99
100         MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
101         HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
102         HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
103         NullPointerException nullPointerException = new NullPointerException();
104
105         @Test
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"));
116         }
117         
118         @Test
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"));
129         }
130
131         @Test
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));
142         }
143
144         @Test
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));
156         }
157
158         @Test
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));
169         }
170
171         @Test
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"));
182         }
183
184         @Test
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));
195         }
196
197         @Test
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));
208         }
209
210         @Test
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));
221         }
222
223         @Test
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"));
234         }
235
236         @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);
248         }
249
250         @Test
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"));
261         }
262
263         @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));
274         }
275
276         @Test
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));
287         }
288
289         @Test
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"));
300         }
301
302         @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));
313         }
314
315         @Test
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));
326         }
327
328         @Test
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));
340         }
341
342         @Test
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));
353         }
354
355         @Test
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));
367         }
368
369         @Test
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));
384         }
385
386         @Test
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));
401         }
402
403         @Test
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));
418         }
419
420         @Test
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));
435         }
436
437         @Test
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");
451                 assertEquals(res,
452                                 auxApiRequestMapperController.bulkUploadUsersSingleRole(mockedRequest, mockedResponse, (long) 1));
453         }
454
455         @Test
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));
470         }
471
472         @Test
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));
488         }
489
490         @Test
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));
505         }
506
507         @Test
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));
518         }
519
520         @Test
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));
532         }
533
534         @Test
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));
546         }
547
548         @Test
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));
560         }
561
562         @Test
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"));
573         }
574
575         @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));
587         }
588
589         @Test
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));
600         }
601
602         @Test
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));
614         }
615
616         @Test
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,
628                                 newOnboardApp));
629         }
630
631         @Test
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                 assertNull(auxApiRequestMapperController.publishNotification(mockedRequest, notificationItem, mockedResponse));
643         }
644
645         @Test
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));
656         }
657
658         @Test
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));
669         }
670         
671         @Test
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);
687         }
688
689 }