diff options
Diffstat (limited to 'ecomp-portal-BE-os/src/test/java')
22 files changed, 1267 insertions, 283 deletions
diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/OpenIdConnectLoginStrategyTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/OpenIdConnectLoginStrategyTest.java index 4386ccd7..2d0f795a 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/OpenIdConnectLoginStrategyTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/OpenIdConnectLoginStrategyTest.java @@ -1,3 +1,40 @@ +/*- + * ============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 + * + * 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.authentication; import static org.junit.Assert.*; diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/SessionTimeoutInterceptorTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/SessionTimeoutInterceptorTest.java index fc827f78..c4946c68 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/SessionTimeoutInterceptorTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/SessionTimeoutInterceptorTest.java @@ -1,3 +1,40 @@ +/*- + * ============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 + * + * 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.authentication; import static org.junit.Assert.assertFalse; diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/SimpleLoginStrategyTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/SimpleLoginStrategyTest.java index 5093fae0..588bd89c 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/SimpleLoginStrategyTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/SimpleLoginStrategyTest.java @@ -1,3 +1,40 @@ +/*- + * ============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 + * + * 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.authentication; import static org.junit.Assert.assertFalse; diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/AppsControllerExternalRequestOSTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/AppsControllerExternalRequestOSTest.java deleted file mode 100644 index 049f7239..00000000 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/AppsControllerExternalRequestOSTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/*package org.openecomp.portalapp.portal.controller; - -import static org.junit.Assert.assertEquals; - -import java.util.ArrayList; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.openecomp.portalapp.portal.domain.EPUser; -import org.openecomp.portalapp.portal.ecomp.model.PortalRestResponse; -import org.openecomp.portalapp.portal.ecomp.model.PortalRestStatusEnum; -import org.openecomp.portalapp.portal.service.AdminRolesService; -import org.openecomp.portalapp.portal.service.EPAppService; -import org.openecomp.portalapp.portal.service.PortalAdminService; -import org.openecomp.portalapp.portal.test.core.MockEPUser; -import org.openecomp.portalapp.portal.transport.FieldsValidator; -import org.openecomp.portalapp.portal.transport.OnboardingApp; -import org.openecomp.portalapp.test.framework.MockitoTestSuite; -import org.openecomp.portalapp.util.EPUserUtils; - -public class AppsControllerExternalRequestOSTest { - - @Mock - AdminRolesService adminRolesService; - - @Mock - EPAppService appService; - - @Mock - PortalAdminService portalAdminService; - - - @InjectMocks - AppsControllerExternalRequest appsControllerExternalRequest = new AppsControllerExternalRequest(); - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - } - - MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); - - HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); - HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse(); - NullPointerException nullPointerException = new NullPointerException(); - - MockEPUser mockUser = new MockEPUser(); - @Mock - EPUserUtils ePUserUtils = new EPUserUtils(); - - @Test - public void postOnboardAppExternalFieldValidatorTestTest() { - PortalRestResponse<String> expectedportalRestResponse = new PortalRestResponse<String>(); - expectedportalRestResponse.setMessage("FieldsValidator [httpStatusCode=500, errorCode=null, fields=null]"); - expectedportalRestResponse.setResponse(null); - PortalRestStatusEnum portalRestStatusEnum = null; - expectedportalRestResponse.setStatus(portalRestStatusEnum.ERROR); - OnboardingApp expectedOnboardingApp = new OnboardingApp(); - expectedOnboardingApp.id = null; - expectedOnboardingApp.name = "Test"; - expectedOnboardingApp.url = "Test"; - expectedOnboardingApp.restUrl = "Test"; - expectedOnboardingApp.restrictedApp = false; - expectedOnboardingApp.isOpen = false; - expectedOnboardingApp.isEnabled = false; - List<EPUser> userList = new ArrayList<EPUser>(); - EPUser user = mockUser.mockEPUser(); - userList.add(user); - FieldsValidator expectedFieldValidator = new FieldsValidator(); - expectedFieldValidator.setHttpStatusCode((long) 500); - expectedFieldValidator.setFields(null); - expectedFieldValidator.setErrorCode(null); - Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(true); - Mockito.when(appService.addOnboardingApp(expectedOnboardingApp, user)).thenReturn(expectedFieldValidator); - PortalRestResponse<String> actualPortalRestResponse = appsControllerExternalRequest - .postOnboardAppExternal(mockedRequest, mockedResponse, expectedOnboardingApp); - assertEquals(actualPortalRestResponse, expectedportalRestResponse); - - } - - @Test - public void postOnboardAppExternalIfSuperAdminTest() { - PortalRestResponse<String> expectedportalRestResponse = new PortalRestResponse<String>(); - expectedportalRestResponse.setMessage(null); - expectedportalRestResponse.setResponse(null); - PortalRestStatusEnum portalRestStatusEnum = null; - expectedportalRestResponse.setStatus(portalRestStatusEnum.OK); - OnboardingApp expectedOnboardingApp = new OnboardingApp(); - expectedOnboardingApp.id = null; - expectedOnboardingApp.name = "Test"; - expectedOnboardingApp.url = "Test"; - expectedOnboardingApp.restUrl = "Test"; - expectedOnboardingApp.restrictedApp = false; - expectedOnboardingApp.isOpen = false; - expectedOnboardingApp.isEnabled = false; - List<EPUser> userList = new ArrayList<EPUser>(); - EPUser user = mockUser.mockEPUser(); - userList.add(user); - FieldsValidator expectedFieldValidator = new FieldsValidator(); - expectedFieldValidator.setHttpStatusCode((long) 200); - expectedFieldValidator.setFields(null); - expectedFieldValidator.setErrorCode(null); - Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(true); - Mockito.when(appService.addOnboardingApp(expectedOnboardingApp, user)).thenReturn(expectedFieldValidator); - PortalRestResponse<String> actualPortalRestResponse = appsControllerExternalRequest - .postOnboardAppExternal(mockedRequest, mockedResponse, expectedOnboardingApp); - assertEquals(actualPortalRestResponse, expectedportalRestResponse); - - } -} -*/
\ No newline at end of file diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/AppsOSControllerTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/AppsOSControllerTest.java index 70e7a0ca..eb2ea32e 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/AppsOSControllerTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/AppsOSControllerTest.java @@ -1,6 +1,43 @@ +/*- + * ============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 + * + * 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; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; import java.util.ArrayList; import java.util.List; @@ -8,7 +45,6 @@ import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.drools.core.command.assertion.AssertEquals; import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -18,12 +54,12 @@ import org.mockito.MockitoAnnotations; import org.openecomp.portalapp.portal.domain.EPUser; import org.openecomp.portalapp.portal.ecomp.model.PortalRestResponse; import org.openecomp.portalapp.portal.ecomp.model.PortalRestStatusEnum; +import org.openecomp.portalapp.portal.framework.MockEPUser; +import org.openecomp.portalapp.portal.framework.MockitoTestSuite; import org.openecomp.portalapp.portal.service.AdminRolesService; import org.openecomp.portalapp.portal.service.EPAppService; import org.openecomp.portalapp.portal.service.PersUserAppService; import org.openecomp.portalapp.portal.service.UserService; -import org.openecomp.portalapp.portal.framework.MockEPUser; -import org.openecomp.portalapp.portal.framework.MockitoTestSuite; import org.openecomp.portalapp.util.EPUserUtils; public class AppsOSControllerTest { diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/DashboardSearchResultControllerTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/DashboardSearchResultControllerTest.java new file mode 100644 index 00000000..b2a6c431 --- /dev/null +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/DashboardSearchResultControllerTest.java @@ -0,0 +1,359 @@ +/*- + * ============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 + * + * 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; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestResponse; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestStatusEnum; +import org.openecomp.portalapp.portal.ecomp.model.SearchResultItem; +import org.openecomp.portalapp.portal.framework.MockEPUser; +import org.openecomp.portalapp.portal.framework.MockitoTestSuite; +import org.openecomp.portalapp.portal.service.DashboardSearchService; +import org.openecomp.portalapp.portal.transport.CommonWidget; +import org.openecomp.portalapp.portal.transport.CommonWidgetMeta; +import org.openecomp.portalapp.util.EPUserUtils; + +public class DashboardSearchResultControllerTest { + + @Mock + DashboardSearchService searchService; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + @InjectMocks + DashboardSearchResultController dashboardSearchResultController = new DashboardSearchResultController(); + + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse(); + NullPointerException nullPointerException = new NullPointerException(); + MockEPUser mockUser = new MockEPUser(); + + @Test + public void getWidgetDataTest() { + PortalRestResponse<CommonWidgetMeta> ecpectedPortalRestResponse = new PortalRestResponse<CommonWidgetMeta>(); + ecpectedPortalRestResponse.setMessage("success"); + ecpectedPortalRestResponse.setResponse(new CommonWidgetMeta()); + ecpectedPortalRestResponse.setStatus(PortalRestStatusEnum.OK); + CommonWidgetMeta commonWidgetMeta = new CommonWidgetMeta(); + Mockito.when(searchService.getWidgetData("test")).thenReturn(commonWidgetMeta); + PortalRestResponse<CommonWidgetMeta> actualPortalRestResponse = dashboardSearchResultController + .getWidgetData(mockedRequest, "test"); + assertEquals(ecpectedPortalRestResponse.getStatus(), actualPortalRestResponse.getStatus()); + } + + @Test + public void saveWidgetDataBulkIfCatrgoryNullTest() { + PortalRestResponse<String> ecpectedPortalRestResponse = new PortalRestResponse<String>(); + ecpectedPortalRestResponse.setMessage("ERROR"); + ecpectedPortalRestResponse.setResponse("Category cannot be null or empty"); + ecpectedPortalRestResponse.setStatus(PortalRestStatusEnum.ERROR); + CommonWidgetMeta commonWidgetMeta = new CommonWidgetMeta(); + commonWidgetMeta.setCategory(null); + PortalRestResponse<String> actualPortalRestResponse = dashboardSearchResultController + .saveWidgetDataBulk(commonWidgetMeta); + assertEquals(ecpectedPortalRestResponse, actualPortalRestResponse); + } + + @Test + public void saveWidgetDataBulkTest() { + PortalRestResponse<String> ecpectedPortalRestResponse = new PortalRestResponse<String>(); + ecpectedPortalRestResponse.setMessage("success"); + ecpectedPortalRestResponse.setResponse(null); + ecpectedPortalRestResponse.setStatus(PortalRestStatusEnum.OK); + CommonWidgetMeta commonWidgetMeta = new CommonWidgetMeta(); + commonWidgetMeta.setCategory("test"); + List<CommonWidget> items = new ArrayList<>(); + + CommonWidget commonWidget = new CommonWidget(); + commonWidget.setId((long) 1); + commonWidget.setEventDate("2017-06-06"); + items.add(commonWidget); + commonWidgetMeta.setItems(items); + PortalRestResponse<String> actualPortalRestResponse = dashboardSearchResultController + .saveWidgetDataBulk(commonWidgetMeta); + assertEquals(ecpectedPortalRestResponse, actualPortalRestResponse); + } + + @Test + public void saveWidgetDataBulkExceptionTest() { + PortalRestResponse<String> ecpectedPortalRestResponse = new PortalRestResponse<String>(); + ecpectedPortalRestResponse.setMessage("java.text.ParseException: Unparseable date: \"date\""); + ecpectedPortalRestResponse.setResponse(null); + ecpectedPortalRestResponse.setStatus(PortalRestStatusEnum.ERROR); + CommonWidgetMeta commonWidgetMeta = new CommonWidgetMeta(); + commonWidgetMeta.setCategory("test"); + List<CommonWidget> items = new ArrayList<>(); + + CommonWidget commonWidget = new CommonWidget(); + commonWidget.setId((long) 1); + commonWidget.setEventDate("date"); + items.add(commonWidget); + commonWidgetMeta.setItems(items); + PortalRestResponse<String> actualPortalRestResponse = dashboardSearchResultController + .saveWidgetDataBulk(commonWidgetMeta); + assertEquals(ecpectedPortalRestResponse, actualPortalRestResponse); + } + + @Test + public void saveWidgetDataIfCatagoryNullTest() { + PortalRestResponse<String> ecpectedPortalRestResponse = new PortalRestResponse<String>(); + ecpectedPortalRestResponse.setMessage("ERROR"); + ecpectedPortalRestResponse.setResponse("Cateogry cannot be null or empty"); + ecpectedPortalRestResponse.setStatus(PortalRestStatusEnum.ERROR); + CommonWidget commonWidget = new CommonWidget(); + commonWidget.setCategory(null); + PortalRestResponse<String> actualPortalRestResponse = dashboardSearchResultController + .saveWidgetData(commonWidget); + assertEquals(ecpectedPortalRestResponse, actualPortalRestResponse); + } + + @Test + public void saveWidgetDataTest() { + PortalRestResponse<String> ecpectedPortalRestResponse = new PortalRestResponse<String>(); + ecpectedPortalRestResponse.setMessage("success"); + ecpectedPortalRestResponse.setResponse(null); + ecpectedPortalRestResponse.setStatus(PortalRestStatusEnum.OK); + CommonWidget commonWidget = new CommonWidget(); + commonWidget.setCategory("test"); + commonWidget.setId((long) 1); + commonWidget.setEventDate("2017-06-06"); + PortalRestResponse<String> actualPortalRestResponse = dashboardSearchResultController + .saveWidgetData(commonWidget); + assertEquals(ecpectedPortalRestResponse, actualPortalRestResponse); + } + + @Test + public void saveWidgetDataExceptionTest() { + PortalRestResponse<String> ecpectedPortalRestResponse = new PortalRestResponse<String>(); + ecpectedPortalRestResponse.setMessage("java.text.ParseException: Unparseable date: \"date\""); + ecpectedPortalRestResponse.setResponse(null); + ecpectedPortalRestResponse.setStatus(PortalRestStatusEnum.ERROR); + CommonWidget commonWidget = new CommonWidget(); + commonWidget.setCategory("test"); + commonWidget.setId((long) 1); + commonWidget.setEventDate("date"); + PortalRestResponse<String> actualPortalRestResponse = dashboardSearchResultController + .saveWidgetData(commonWidget); + assertEquals(ecpectedPortalRestResponse, actualPortalRestResponse); + } + + @Test + public void deleteWidgetDataTest() + { + PortalRestResponse<String> ecpectedPortalRestResponse = new PortalRestResponse<String>(); + ecpectedPortalRestResponse.setMessage("success"); + ecpectedPortalRestResponse.setResponse(null); + ecpectedPortalRestResponse.setStatus(PortalRestStatusEnum.OK); + CommonWidget commonWidget = new CommonWidget(); + Mockito.when(searchService.deleteWidgetData(commonWidget)).thenReturn("test"); + PortalRestResponse<String> actualPortalRestResponse = dashboardSearchResultController + .deleteWidgetData(commonWidget); + assertEquals(ecpectedPortalRestResponse.getStatus(), actualPortalRestResponse.getStatus()); + } + + @Test + public void searchPortalIfUserIsTest() + { + EPUser user = null; + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + String searchString = "test"; + PortalRestResponse<Map<String, List<SearchResultItem>>> expectedResult = new PortalRestResponse<Map<String, List<SearchResultItem>>>(); + expectedResult.setMessage("searchPortal: User object is null? - check logs"); + expectedResult.setResponse(new HashMap<String, List<SearchResultItem>>()); + expectedResult.setStatus(PortalRestStatusEnum.ERROR); + PortalRestResponse<Map<String, List<SearchResultItem>>> actualResult = dashboardSearchResultController + .searchPortal(mockedRequest, searchString); + System.out.println(actualResult); + + assertEquals(expectedResult, actualResult); + } + + + @Test + public void getActiveUsersTest() { + List<String> expectedActiveUsers = new ArrayList<String>(); + EPUser user = mockUser.mockEPUser(); + ; + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + String userId = user.getOrgUserId(); + Mockito.when(searchService.getRelatedUsers(userId)).thenReturn(expectedActiveUsers); + List<String> actualOnlineUsers = dashboardSearchResultController.getActiveUsers(mockedRequest); + assertEquals(expectedActiveUsers, actualOnlineUsers); + + } + + @Test + public void getActiveUsersExceptionTest() { + List<String> expectedActiveUsers = new ArrayList<String>(); + EPUser user = mockUser.mockEPUser(); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + String userId = user.getOrgUserId(); + Mockito.when(searchService.getRelatedUsers(userId)).thenThrow(nullPointerException); + List<String> actualOnlineUsers = dashboardSearchResultController.getActiveUsers(mockedRequest); + assertEquals(expectedActiveUsers, actualOnlineUsers); + + } + + @Test + public void activeUsersTest() { + EPUser user = mockUser.mockEPUser(); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + PortalRestResponse<List<String>> expectedResult = new PortalRestResponse<List<String>>(); + expectedResult.setMessage("success"); + expectedResult.setResponse(new ArrayList<>()); + expectedResult.setStatus(PortalRestStatusEnum.OK); + PortalRestResponse<List<String>> actualResult = dashboardSearchResultController.activeUsers(mockedRequest); + + assertEquals(actualResult, expectedResult); + + } + + @Test + public void activeUsersIfUserNullTest() { + EPUser user = null; + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + PortalRestResponse<List<String>> expectedResult = new PortalRestResponse<List<String>>(); + expectedResult.setMessage("User object is null? - check logs"); + expectedResult.setResponse(new ArrayList<>()); + expectedResult.setStatus(PortalRestStatusEnum.ERROR); + PortalRestResponse<List<String>> actualResult = dashboardSearchResultController.activeUsers(mockedRequest); + assertEquals(actualResult, expectedResult); + + } + + @Test + public void activeUsersExceptionTest() { + EPUser user = mockUser.mockEPUser(); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + PortalRestResponse<List<String>> expectedResult = new PortalRestResponse<List<String>>(); + expectedResult.setMessage("null - check logs."); + expectedResult.setResponse(new ArrayList<>()); + expectedResult.setStatus(PortalRestStatusEnum.ERROR); + Mockito.when(searchService.getRelatedUsers(user.getLoginId())).thenThrow(nullPointerException); + PortalRestResponse<List<String>> actualResult = dashboardSearchResultController.activeUsers(mockedRequest); + assertEquals(actualResult, expectedResult); + + } + + @Test + public void searchPortalIfSearchStringNullTest() { + EPUser user = mockUser.mockEPUser(); + ; + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + String searchString = null; + + PortalRestResponse<Map<String, List<SearchResultItem>>> expectedResult = new PortalRestResponse<Map<String, List<SearchResultItem>>>(); + expectedResult.setMessage("searchPortal: String string is null"); + expectedResult.setResponse(new HashMap<String, List<SearchResultItem>>()); + expectedResult.setStatus(PortalRestStatusEnum.ERROR); + + PortalRestResponse<Map<String, List<SearchResultItem>>> actualResult = dashboardSearchResultController + .searchPortal(mockedRequest, searchString); + assertEquals(expectedResult, actualResult); + } + + @Test + public void searchPortalIfSearchTest() { + EPUser user = mockUser.mockEPUser(); + ; + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + String searchString = "test"; + List<SearchResultItem> searchResultItemList = new ArrayList<SearchResultItem>(); + SearchResultItem searchResultItem = new SearchResultItem(); + + searchResultItem.setId((long) 1); + searchResultItem.setCategory("test"); + searchResultItem.setName("test_name"); + searchResultItem.setTarget("test_target"); + searchResultItem.setUuid("test_UUId"); + searchResultItemList.add(searchResultItem); + Map<String, List<SearchResultItem>> expectedResultMap = new HashMap<String, List<SearchResultItem>>(); + expectedResultMap.put(searchString, searchResultItemList); + + PortalRestResponse<Map<String, List<SearchResultItem>>> expectedResult = new PortalRestResponse<Map<String, List<SearchResultItem>>>(); + expectedResult.setMessage("success"); + expectedResult.setResponse(expectedResultMap); + expectedResult.setStatus(PortalRestStatusEnum.OK); + + Mockito.when(searchService.searchResults(user.getLoginId(), searchString)).thenReturn(expectedResultMap); + PortalRestResponse<Map<String, List<SearchResultItem>>> actualResult = dashboardSearchResultController + .searchPortal(mockedRequest, searchString); + assertEquals(expectedResult, actualResult); + + } + + @Test + public void searchPortalIfSearchExcptionTest() { + EPUser user = mockUser.mockEPUser(); + ; + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + String searchString = "test"; + + PortalRestResponse<Map<String, List<SearchResultItem>>> expectedResult = new PortalRestResponse<Map<String, List<SearchResultItem>>>(); + expectedResult.setMessage("null - check logs."); + expectedResult.setResponse(new HashMap<String, List<SearchResultItem>>()); + expectedResult.setStatus(PortalRestStatusEnum.ERROR); + + Mockito.when(searchService.searchResults(user.getLoginId(), searchString)).thenThrow(nullPointerException); + PortalRestResponse<Map<String, List<SearchResultItem>>> actualResult = dashboardSearchResultController + .searchPortal(mockedRequest, searchString); + assertEquals(expectedResult, actualResult); + } + +} diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ECOMPLogoutControllerTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ECOMPLogoutControllerTest.java index 729debaa..954ff0c4 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ECOMPLogoutControllerTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ECOMPLogoutControllerTest.java @@ -1,8 +1,44 @@ +/*- + * ============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 + * + * 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; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; -import javax.servlet.ServletRequestWrapper; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -13,13 +49,12 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.mockito.stubbing.OngoingStubbing; import org.openecomp.portalapp.controller.ECOMPLogoutController; +import org.openecomp.portalapp.portal.framework.MockEPUser; +import org.openecomp.portalapp.portal.framework.MockitoTestSuite; import org.openecomp.portalapp.portal.service.DashboardSearchService; import org.openecomp.portalapp.portal.service.DashboardSearchServiceImpl; -import org.openecomp.portalapp.portal.framework.MockEPUser; import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; -import org.openecomp.portalapp.portal.framework.MockitoTestSuite; import org.openecomp.portalapp.util.EPUserUtils; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ExternalAppsRestfulControllerOSTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ExternalAppsRestfulControllerOSTest.java new file mode 100644 index 00000000..0f92bb3e --- /dev/null +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ExternalAppsRestfulControllerOSTest.java @@ -0,0 +1,198 @@ +/*- + * ============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 + * + * 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; + +import static org.junit.Assert.*; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.framework.MockEPUser; +import org.openecomp.portalapp.portal.framework.MockitoTestSuite; +import org.openecomp.portalapp.portal.service.AdminRolesService; +import org.openecomp.portalapp.portal.service.EPLoginService; +import org.openecomp.portalapp.portal.service.FunctionalMenuService; +import org.openecomp.portalapp.portal.transport.FavoritesFunctionalMenuItemJson; +import org.openecomp.portalapp.portal.transport.FunctionalMenuItem; +import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; +import org.openecomp.portalapp.portal.utils.EPSystemProperties; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.slf4j.MDC; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ MDC.class, EPSystemProperties.class , EcompPortalUtils.class}) +public class ExternalAppsRestfulControllerOSTest { + + + @InjectMocks + ExternalAppsRestfulController externalAppsRestfulController = new ExternalAppsRestfulController(); + @Mock + FunctionalMenuService functionalMenuService; + + @Mock + EPLoginService epLoginService; + + @Mock + AdminRolesService adminRolesService; + + + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse(); + NullPointerException nullPointerException = new NullPointerException(); + + MockEPUser mockUser = new MockEPUser(); + + @Test + public void getFavoritesForUserTest() throws Exception + { + PowerMockito.mockStatic(EPSystemProperties.class); + PowerMockito.mockStatic(MDC.class); + PowerMockito.mockStatic(EcompPortalUtils.class); + EPUser epUser = mockUser.mockEPUser(); + epUser.setId((long) 1); + epUser.setLoginId("guestT"); + String loginId = "guestT"; + Mockito.when(MDC.get(EPSystemProperties.PARTNER_NAME)).thenReturn("Test"); + List<FavoritesFunctionalMenuItemJson> favorites = new ArrayList<FavoritesFunctionalMenuItemJson>(); + FavoritesFunctionalMenuItemJson favoritesFunctionalMenuItemJson = new FavoritesFunctionalMenuItemJson(); + favorites.add(favoritesFunctionalMenuItemJson); + Mockito.when(mockedRequest.getHeader(EPCommonSystemProperties.MDC_LOGIN_ID)).thenReturn("Login_URL"); + Mockito.when(MDC.get(EPSystemProperties.PARTNER_NAME)).thenReturn("Test"); + Mockito.when(epLoginService.findUserWithoutPwd("Login_URL")).thenReturn(epUser); + Mockito.when(functionalMenuService.getFavoriteItems(epUser.getId())).thenReturn(favorites); + List<FavoritesFunctionalMenuItemJson> actaulFavorites = externalAppsRestfulController + .getFavoritesForUser(mockedRequest, mockedResponse); + assertEquals(actaulFavorites.size(), 1); + } + + @Test + public void getFunctionalMenuItemsForUserIfSuperAdminTest() throws Exception { + PowerMockito.mockStatic(EPSystemProperties.class); + PowerMockito.mockStatic(MDC.class); + PowerMockito.mockStatic(EcompPortalUtils.class); + EPUser epUser = mockUser.mockEPUser(); + epUser.setId((long) 1); + epUser.setLoginId("guestT"); + String loginId = "guestT"; + Mockito.when(MDC.get(EPSystemProperties.PARTNER_NAME)).thenReturn("Test"); + Mockito.when(epLoginService.findUserWithoutPwd(loginId)).thenReturn(epUser); + List<FunctionalMenuItem> expectedList = new ArrayList<FunctionalMenuItem>(); + FunctionalMenuItem functionalMenuItem = new FunctionalMenuItem(); + expectedList.add(functionalMenuItem); + Mockito.when(mockedRequest.getHeader("LoginId")).thenReturn("guestT"); + Mockito.when(adminRolesService.isSuperAdmin(epUser)).thenReturn(true); + Mockito.when(functionalMenuService.getFunctionalMenuItems()).thenReturn(expectedList); + List<FunctionalMenuItem> actualList = externalAppsRestfulController.getFunctionalMenuItemsForUser(mockedRequest, + mockedResponse); + assertNull(actualList.get(0).menuId); + } + + @Test(expected = Exception.class) + public void getFunctionalMenuItemsForUserIfUSerNullTest() throws + Exception + { + PowerMockito.mockStatic(EPSystemProperties.class); + PowerMockito.mockStatic(EcompPortalUtils.class); + PowerMockito.mockStatic(MDC.class); + EPUser epUser = null; + String loginId = "guestT"; + Mockito.when(MDC.get(EPSystemProperties.PARTNER_NAME)).thenReturn("Test"); + Mockito.when(epLoginService.findUserWithoutPwd(loginId)).thenReturn(epUser); + externalAppsRestfulController.getFunctionalMenuItemsForUser(mockedRequest, + mockedResponse); + } + + @Test + public void getFunctionalMenuItemsForUserTest() throws Exception { + PowerMockito.mockStatic(EPSystemProperties.class); + PowerMockito.mockStatic(MDC.class); + EPUser epUser = mockUser.mockEPUser(); + epUser.setId((long) 1); + epUser.setLoginId("guestT"); + String loginId = "guestT"; + Mockito.when(MDC.get(EPSystemProperties.PARTNER_NAME)).thenReturn("Test"); + Mockito.when(epLoginService.findUserWithoutPwd(loginId)).thenReturn(epUser); + List<FunctionalMenuItem> expectedList = new ArrayList<FunctionalMenuItem>(); + FunctionalMenuItem functionalMenuItem = new FunctionalMenuItem(); + expectedList.add(functionalMenuItem); + Mockito.when(mockedRequest.getHeader("LoginId")).thenReturn("guestT"); + Mockito.when(adminRolesService.isSuperAdmin(epUser)).thenReturn(false); + Mockito.when(functionalMenuService.getFunctionalMenuItemsForUser(epUser.getOrgUserId())) + .thenReturn(expectedList); + List<FunctionalMenuItem> actualList = externalAppsRestfulController.getFunctionalMenuItemsForUser(mockedRequest, + mockedResponse); + assertNull(actualList.get(0).menuId); + } + + @Test(expected = Exception.class) + public void getFavoritesForUserIfUserNullTest() throws Exception { + List<FavoritesFunctionalMenuItemJson> favorites = new ArrayList<FavoritesFunctionalMenuItemJson>(); + FavoritesFunctionalMenuItemJson favoritesFunctionalMenuItemJson = new FavoritesFunctionalMenuItemJson(); + favorites.add(favoritesFunctionalMenuItemJson); + PowerMockito.mockStatic(EPSystemProperties.class); + PowerMockito.mockStatic(MDC.class); + Mockito.when(mockedRequest.getHeader(EPSystemProperties.MDC_LOGIN_ID)).thenReturn("Login_URL"); + Mockito.when(MDC.get(EPSystemProperties.PARTNER_NAME)).thenReturn("Test"); + EPUser epUser = null; + externalAppsRestfulController.getFavoritesForUser(mockedRequest, mockedResponse); + } + + +} diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/LoginControllerTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/LoginControllerTest.java index 968f5811..a02e1b2f 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/LoginControllerTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/LoginControllerTest.java @@ -1,3 +1,40 @@ +/*- + * ============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 + * + * 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; import static org.junit.Assert.*; @@ -70,7 +107,7 @@ public class LoginControllerTest { PowerMockito.mockStatic(SystemProperties.class); Mockito.when(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM)).thenReturn("OIDC"); ModelAndView result = loginController.login(mockedRequest); - assertEquals(result.getViewName(),"openIdLogin") ; + assertEquals(result.getViewName(),"login") ; } @Test diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ONAPLoginControllerTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ONAPLoginControllerTest.java index 06dfc902..46218302 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ONAPLoginControllerTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ONAPLoginControllerTest.java @@ -1,3 +1,40 @@ +/*- + * ============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 + * + * 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; import static org.junit.Assert.assertEquals; @@ -57,6 +94,8 @@ public class ONAPLoginControllerTest { ModelAndView actualModelandView = null; Mockito.when(loginStrategy.doLogin(mockedRequest, mockedResponse)).thenReturn(expectedModelandView); actualModelandView= oNAPLoginController.doLogin(mockedRequest, mockedResponse); + oNAPLoginController.setViewName("test"); + assertEquals("test", oNAPLoginController.getViewName()); assertEquals(actualModelandView,expectedModelandView); } diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ONAPWelcomeControllerTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ONAPWelcomeControllerTest.java index c15f366a..b7399fbe 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ONAPWelcomeControllerTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ONAPWelcomeControllerTest.java @@ -1,6 +1,45 @@ +/*- + * ============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 + * + * 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; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; + +import java.security.Principal; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -8,15 +47,19 @@ import javax.servlet.http.HttpServletResponse; import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; +import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.openecomp.portalapp.controller.ONAPWelcomeController; import org.openecomp.portalapp.portal.framework.MockitoTestSuite; +import org.springframework.web.servlet.ModelAndView; public class ONAPWelcomeControllerTest { @InjectMocks ONAPWelcomeController oNAPWelcomeController = new ONAPWelcomeController(); + @Mock + Principal p; @Before public void setup() { MockitoAnnotations.initMocks(this); @@ -43,5 +86,14 @@ public class ONAPWelcomeControllerTest { { assertEquals(oNAPWelcomeController.user(null), "oid-user"); } - + + @Test + public void loginTest() + { + ModelAndView expectedView = new ModelAndView(); + expectedView.setViewName("openIdLogin"); + ModelAndView md = oNAPWelcomeController.login(p); + System.out.println(md.getViewName()); + assertEquals(md.getViewName(), expectedView.getViewName()); + } } diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/PortalAdminControllerOSTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/PortalAdminControllerOSTest.java index 65925977..aa7cb46a 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/PortalAdminControllerOSTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/PortalAdminControllerOSTest.java @@ -1,4 +1,41 @@ -/*package org.openecomp.portalapp.portal.controller; +/*- + * ============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 + * + * 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; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -17,14 +54,15 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.openecomp.portalapp.portal.domain.EPRole; import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.framework.MockEPUser; +import org.openecomp.portalapp.portal.framework.MockitoTestSuite; import org.openecomp.portalapp.portal.service.AdminRolesService; import org.openecomp.portalapp.portal.service.AdminRolesServiceImpl; import org.openecomp.portalapp.portal.service.PortalAdminService; import org.openecomp.portalapp.portal.service.PortalAdminServiceImpl; -import org.openecomp.portalapp.portal.test.core.MockEPUser; import org.openecomp.portalapp.portal.transport.FieldsValidator; +import org.openecomp.portalapp.portal.transport.PortalAdmin; import org.openecomp.portalapp.portal.utils.EcompPortalUtils; -import org.openecomp.portalapp.test.framework.MockitoTestSuite; import org.openecomp.portalapp.util.EPUserUtils; import org.openecomp.portalsdk.core.service.AuditService; import org.openecomp.portalsdk.core.service.AuditServiceImpl; @@ -69,7 +107,7 @@ public class PortalAdminControllerOSTest { EPUser user = mockUser.mockEPUser(); Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(false); - String userInfo = "1-test"; + Long userInfo = (long) 12; assertNull(portalAdminController.deletePortalAdmin(mockedRequest, userInfo, mockedResponse)); } @@ -85,11 +123,11 @@ public class PortalAdminControllerOSTest { expectedFieldValidator.setFields(null); expectedFieldValidator.setErrorCode(null); FieldsValidator actualFieldValidator = new FieldsValidator(); - String userInfo = "1-test"; + Long userInfo = (long) 12; Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(true); - Mockito.when(portalAdminService.deletePortalAdmin((long) 1)).thenReturn(expectedFieldValidator); + Mockito.when(portalAdminService.deletePortalAdmin((long) 12)).thenReturn(expectedFieldValidator); actualFieldValidator = portalAdminController.deletePortalAdmin(mockedRequest, userInfo, mockedResponse); - assertEquals(actualFieldValidator,expectedFieldValidator); + assertEquals(actualFieldValidator,expectedFieldValidator); } @@ -99,7 +137,7 @@ public class PortalAdminControllerOSTest { EPUser user = mockUser.mockEPUser(); Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(false); - String userInfo = ""; + Long userInfo = null; assertNull(portalAdminController.deletePortalAdmin(mockedRequest, userInfo, mockedResponse)); } @@ -138,5 +176,66 @@ public class PortalAdminControllerOSTest { List<EPRole> actualRoleList = portalAdminController.getRolesByApp(mockedRequest, appId, mockedResponse); assertEquals(actualRoleList,expectedRoleList); } + + @Test + public void createPortalAdminIfUserNullTest() + { + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(null); + assertNull(portalAdminController.createPortalAdmin(mockedRequest, "guestT", mockedResponse)); + } + + + @Test + public void createPortalAdminIfUserIsSuperAdminTest() + { + + EPUser user = mockUser.mockEPUser(); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + FieldsValidator expectedFieldValidator = new FieldsValidator(); + expectedFieldValidator.setHttpStatusCode((long) 200); + expectedFieldValidator.setFields(null); + expectedFieldValidator.setErrorCode(null); + FieldsValidator actualFieldValidator = new FieldsValidator(); + Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(true); + Mockito.when(portalAdminService.createPortalAdmin("guestT")).thenReturn(expectedFieldValidator); + actualFieldValidator = portalAdminController.createPortalAdmin(mockedRequest, "guestT", mockedResponse); + assertEquals(actualFieldValidator,expectedFieldValidator); + } + + @Test + public void createPortalAdminIfUserIsNotSuperAdminTest() + { + EPUser user = mockUser.mockEPUser(); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(false); + assertNull(portalAdminController.createPortalAdmin(mockedRequest, "guestT", mockedResponse)); + } + + @Test + public void getPortalAdminsIfUserNullTest() + { + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(null); + assertNull(portalAdminController.getPortalAdmins(mockedRequest, mockedResponse)); + } + + @Test + public void getPortalAdminsIfUserAdminTest() + { + EPUser user = mockUser.mockEPUser(); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + List<PortalAdmin> portalAdmins = new ArrayList<>(); + Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(true); + Mockito.when(portalAdminService.getPortalAdmins()).thenReturn(portalAdmins); + List<PortalAdmin> actualortalAdmins = portalAdminController.getPortalAdmins(mockedRequest, mockedResponse); + assertEquals(actualortalAdmins,portalAdmins); + } + + @Test + public void getPortalAdminIfUserIsNotSuperAdminTest() + { + EPUser user = mockUser.mockEPUser(); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(false); + assertNull(portalAdminController.getPortalAdmins(mockedRequest, mockedResponse)); + } } -*/
\ No newline at end of file diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextRestClient.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextRestClient.java index c3ca2430..f4196db8 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextRestClient.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextRestClient.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; diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextRestControllerTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextRestControllerTest.java index 5bb7a456..e4061785 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextRestControllerTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextRestControllerTest.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; diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextTestProperties.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextTestProperties.java index 9344150f..1c849420 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextTestProperties.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextTestProperties.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; diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockEPUser.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockEPUser.java index d132ccf3..d38b21a0 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockEPUser.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockEPUser.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.framework; diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockitoTestSuite.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockitoTestSuite.java index 3ff837dc..529dd5ae 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockitoTestSuite.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockitoTestSuite.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.framework; diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/listener/HealthMonitorTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/listener/HealthMonitorTest.java index f87f5bd1..651f7f61 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/listener/HealthMonitorTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/listener/HealthMonitorTest.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.listener; diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/RemoteWebServiceCallServiceImplTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/RemoteWebServiceCallServiceImplTest.java index d38525b3..f3218a70 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/RemoteWebServiceCallServiceImplTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/RemoteWebServiceCallServiceImplTest.java @@ -1,6 +1,44 @@ +/*- + * ============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 + * + * 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.service; -import static org.junit.Assert.*; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.List; @@ -8,7 +46,6 @@ import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.openecomp.portalsdk.core.util.SystemProperties; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -18,10 +55,10 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.openecomp.portalapp.portal.domain.EPApp; import org.openecomp.portalapp.portal.framework.MockitoTestSuite; -import org.openecomp.portalapp.portal.utils.EcompPortalUtils; import org.openecomp.portalapp.service.RemoteWebServiceCallServiceImpl; import org.openecomp.portalsdk.core.onboarding.util.CipherUtil; import org.openecomp.portalsdk.core.service.DataAccessService; +import org.openecomp.portalsdk.core.util.SystemProperties; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/SearchServiceImplTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/SearchServiceImplTest.java index fd6578f8..71671da3 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/SearchServiceImplTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/SearchServiceImplTest.java @@ -1,3 +1,40 @@ +/*- + * ============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 + * + * 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.service; import static org.junit.Assert.*; diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/UserServiceImplTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/UserServiceImplTest.java deleted file mode 100644 index 63a710eb..00000000 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/UserServiceImplTest.java +++ /dev/null @@ -1,63 +0,0 @@ -//package org.openecomp.portalapp.portal.service; -// -//import javax.servlet.http.HttpServletRequest; -//import javax.servlet.http.HttpServletResponse; -// -//import org.junit.Before; -//import org.junit.Test; -//import org.junit.runner.RunWith; -//import org.mockito.InjectMocks; -//import org.mockito.Mock; -//import org.mockito.Mockito; -//import org.mockito.MockitoAnnotations; -//import org.openecomp.portalapp.portal.framework.MockitoTestSuite; -//import org.openecomp.portalapp.portal.utils.EPSystemProperties; -//import org.openecomp.portalsdk.core.service.DataAccessService; -//import org.openecomp.portalsdk.core.util.SystemProperties; -//import org.powermock.api.mockito.PowerMockito; -// -//import java.io.BufferedReader; -//import java.io.IOException; -//import java.io.InputStreamReader; -//import java.io.UnsupportedEncodingException; -//import java.net.HttpURLConnection; -//import org.powermock.core.classloader.annotations.PrepareForTest; -//import org.powermock.modules.junit4.PowerMockRunner; -// -// -//@RunWith(PowerMockRunner.class) -//@PrepareForTest({ SystemProperties.class , EPSystemProperties.class , SystemProperties.class}) -//public class UserServiceImplTest { -// -// -// @InjectMocks -// UserServiceImpl userServiceImpl = new UserServiceImpl(); -// -// @Mock -// DataAccessService dataAccessService; -// -// @Mock -// HttpURLConnection con; -// -// @Before -// public void setup() { -// MockitoAnnotations.initMocks(this); -// } -// -// MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); -// -// HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); -// HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse(); -// -// @Test -// public void getUserByUserIdTest() throws UnsupportedEncodingException, IOException -// { -// BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8")); -// PowerMockito.mockStatic(SystemProperties.class); -// PowerMockito.mockStatic(EPSystemProperties.class); -// Mockito.when(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM)).thenReturn("OIDC"); -// Mockito.when(EPSystemProperties.getProperty(EPSystemProperties.AUTH_USER_SERVER)).thenReturn("http://www.google.com"); -// Mockito.when(new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"))).thenReturn(reader).thenReturn(reader); -// userServiceImpl.getUserByUserId("guestT"); -// } -//} diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/utils/EcompPortalUtilsTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/utils/EcompPortalUtilsTest.java index b1dd853f..d9a54360 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/utils/EcompPortalUtilsTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/utils/EcompPortalUtilsTest.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.utils; |