X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ecomp-portal-BE-common%2Fsrc%2Ftest%2Fjava%2Forg%2Fopenecomp%2Fportalapp%2Fportal%2Fcontroller%2FFunctionalMenuControllerTest.java;h=b72ef9af41c92338ddcc0629a603762a327f0933;hb=51d83152697da4f2ef2242471ee43f36e6b64300;hp=af0a588f6b0c7a85d7f51d888f9e4fe24256d07d;hpb=1b29c0944a7eba1c88cfd25c94e4dd7ed0f82dc7;p=portal.git diff --git a/ecomp-portal-BE-common/src/test/java/org/openecomp/portalapp/portal/controller/FunctionalMenuControllerTest.java b/ecomp-portal-BE-common/src/test/java/org/openecomp/portalapp/portal/controller/FunctionalMenuControllerTest.java index af0a588f..b72ef9af 100644 --- a/ecomp-portal-BE-common/src/test/java/org/openecomp/portalapp/portal/controller/FunctionalMenuControllerTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/openecomp/portalapp/portal/controller/FunctionalMenuControllerTest.java @@ -1,21 +1,39 @@ /*- - * ================================================================================ - * ECOMP Portal - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ================================================================================ + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ package org.openecomp.portalapp.portal.controller; @@ -84,6 +102,8 @@ public class FunctionalMenuControllerTest extends MockitoTestSuite { @Mock AdminRolesService adminRolesService = new AdminRolesServiceImpl(); + + NullPointerException nullPointerException = new NullPointerException(); @Before public void setup() { @@ -199,6 +219,16 @@ public class FunctionalMenuControllerTest extends MockitoTestSuite { assertTrue(acutualFieldValidator.equals(expectedFieldValidator)); } + @Test + public void getMenuItemsExceptionTest(){ + List actualmenuItems = null; + List expectedmenuItems = null; + + Mockito.when(functionalMenuController.getMenuItemsForAuthUser(mockedRequest, mockedResponse)).thenThrow(nullPointerException); + actualmenuItems = functionalMenuController.getMenuItemsForAuthUser(mockedRequest, mockedResponse); + assertEquals(actualmenuItems, expectedmenuItems); + } + @Test public void getFunctionalMenuStaticInfoExceptionTest(){ String fnMenuStaticactualResponse = null; @@ -273,6 +303,20 @@ public class FunctionalMenuControllerTest extends MockitoTestSuite { assertEquals(actualmenuItem, expectedmenuItem); } + @Test + public void getFunctionalMenuItemDetailsExceptionTest(){ + Integer menuId = 1234; + FunctionalMenuItem actualmenuItem = null; + FunctionalMenuItem expectedmenuItem = null; + EPUser user = mockUser.mockEPUser(); + Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(true); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + Mockito.when(functionalMenuService.getFunctionalMenuItemDetails(menuId)).thenThrow(nullPointerException); + + actualmenuItem = functionalMenuController.getFunctionalMenuItemDetails(mockedRequest, menuId, mockedResponse); + assertEquals(actualmenuItem, expectedmenuItem); + } + @Test public void getFunctionalMenuItemDetailsTest(){ Integer menuId = 1234; @@ -313,6 +357,27 @@ public class FunctionalMenuControllerTest extends MockitoTestSuite { assertEquals(actualMenuItems, expectedMenuItems); } + @Test + public void getMenuItemsForEditingExceptionTest(){ + List actualMenuItems = null; + List expectedMenuItems = null; + EPUser user = mockUser.mockEPUser(); + Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(true); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + Mockito.when(functionalMenuService.getFunctionalMenuItems(true)).thenThrow(nullPointerException); + actualMenuItems = functionalMenuController.getMenuItemsForEditing(mockedRequest, mockedResponse); + assertEquals(actualMenuItems, expectedMenuItems); + } + + @Test + public void getMenuItemsForNotificationsExceptionTest(){ + List actualMenuItems = null; + List expectedMenuItems = null; + Mockito.when(functionalMenuService.getFunctionalMenuItemsForNotificationTree(true)).thenThrow(nullPointerException); + + actualMenuItems = functionalMenuController.getMenuItemsForNotifications(mockedRequest, mockedResponse); + assertEquals(actualMenuItems, expectedMenuItems); + } @Test public void getMenuItemsForNotificationsTest(){ List actualMenuItems = null; @@ -334,6 +399,17 @@ public class FunctionalMenuControllerTest extends MockitoTestSuite { assertEquals(actualMenuItems, expectedMenuItems); } + @Test + public void getMenuItemsForAppExceptionTest(){ + Integer appId = 1234; + List actualMenuItems = null; + List expectedMenuItems = null; + Mockito.when(functionalMenuService.getFunctionalMenuItemsForApp(appId)).thenThrow(nullPointerException); + + actualMenuItems = functionalMenuController.getMenuItemsForApp(mockedRequest, appId); + assertEquals(actualMenuItems, expectedMenuItems); + } + @Test public void getMenuItemsForUserTest(){ String orgUserId ="test"; @@ -345,6 +421,17 @@ public class FunctionalMenuControllerTest extends MockitoTestSuite { assertEquals(actualMenuItems, expectedMenuItems); } + @Test + public void getMenuItemsForUserExceptionTest(){ + String orgUserId ="test"; + List actualMenuItems = null; + List expectedMenuItems = null; + Mockito.when(functionalMenuService.getFunctionalMenuItemsForUser(orgUserId)).thenThrow(nullPointerException); + + actualMenuItems = functionalMenuController.getMenuItemsForUser(mockedRequest, orgUserId); + assertEquals(actualMenuItems, expectedMenuItems); + } + @Test public void createFunctionalMenuItemTest(){ FieldsValidator actualFieldsValidator = new FieldsValidator(); @@ -503,4 +590,18 @@ public class FunctionalMenuControllerTest extends MockitoTestSuite { assertEquals(actualportalRestResponse, expectedportalRestResponse); } + @Test + public void getECOMPTitleExceptionTest(){ + PortalRestResponse actualportalRestResponse = null; + PortalRestResponse expectedportalRestResponse = new PortalRestResponse(); + expectedportalRestResponse.setStatus(PortalRestStatusEnum.ERROR); + expectedportalRestResponse.setMessage(null); + expectedportalRestResponse.setResponse(null); + PowerMockito.mockStatic(SystemProperties.class); + + Mockito.when(SystemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME)).thenThrow(nullPointerException); + actualportalRestResponse = functionalMenuController.getECOMPTitle(mockedRequest, mockedResponse); + assertEquals(actualportalRestResponse, expectedportalRestResponse); + } + }