diff options
Diffstat (limited to 'ecomp-sdk/epsdk-fw/src/test/java')
6 files changed, 552 insertions, 4 deletions
diff --git a/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxyTest.java b/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxyTest.java index 62234679..ce1035e7 100644 --- a/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxyTest.java +++ b/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxyTest.java @@ -37,7 +37,263 @@ */ package org.onap.portalsdk.core.onboarding.crossapi; -//@RunWith(PowerMockRunner.class) +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.HashMap; + +import javax.servlet.ServletException; +import javax.servlet.ServletInputStream; +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.Mock; +import org.mockito.Mockito; +import org.onap.portalsdk.core.onboarding.exception.PortalAPIException; +import org.onap.portalsdk.core.onboarding.util.PortalApiConstants; +import org.onap.portalsdk.core.restful.domain.EcompUser; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import com.fasterxml.jackson.databind.ObjectMapper; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({PortalRestAPIProxy.class}) public class PortalRestAPIProxyTest { + @Mock + HttpServletRequest request; + @Mock + HttpServletResponse response; + @Mock + PrintWriter writer; + @Mock + PortalRestAPICentralServiceImpl portalRestAPICentralServiceImpl; + @Mock + private Method doPost; + private Method doGet; + private PortalRestAPIProxy portalRestAPIProxyObj; + private Class portalRestAPIProxyClass; + private Field portalRestApiServiceImplField; + private Field isAccessCentralizedField; + private Field mapperField; + @Mock + ObjectMapper mapper; + + @Before + public void setUp() throws Exception { + portalRestAPIProxyClass = PortalRestAPIProxy.class; + portalRestAPIProxyObj = (PortalRestAPIProxy) portalRestAPIProxyClass.newInstance(); + Mockito.when(response.getWriter()).thenReturn(writer); + PowerMockito.doNothing().when(writer).print(Mockito.anyString()); + ServletInputStream in = Mockito.mock(ServletInputStream.class); + Mockito.when(request.getInputStream()).thenReturn(in); + InputStreamReader ir = Mockito.mock(InputStreamReader.class); + PowerMockito.whenNew(InputStreamReader.class).withArguments(in).thenReturn(ir); + BufferedReader br = Mockito.mock(BufferedReader.class); + PowerMockito.whenNew(BufferedReader.class).withArguments(ir).thenReturn(br); + char[] charBuffer = new char[1024]; + Mockito.when(br.read(charBuffer)).thenReturn(0); + PowerMockito.doNothing().when(writer).print(Mockito.anyString()); + portalRestApiServiceImplField = portalRestAPIProxyClass.getDeclaredField("portalRestApiServiceImpl"); + portalRestApiServiceImplField.setAccessible(true); + portalRestApiServiceImplField.set(portalRestAPIProxyClass, portalRestAPICentralServiceImpl); + isAccessCentralizedField = portalRestAPIProxyClass.getDeclaredField("isAccessCentralized"); + isAccessCentralizedField.setAccessible(true); + mapperField = portalRestAPIProxyClass.getDeclaredField("mapper"); + mapperField.setAccessible(true); + Field modifiersField = Field.class.getDeclaredField("modifiers"); + modifiersField.setAccessible(true); + modifiersField.setInt(isAccessCentralizedField, isAccessCentralizedField.getModifiers() & ~Modifier.FINAL); + isAccessCentralizedField.set(null, "remote"); + modifiersField.setInt(mapperField, mapperField.getModifiers() & ~Modifier.FINAL); + ObjectMapper mapper = Mockito.mock(ObjectMapper.class); + mapperField.set(portalRestAPIProxyObj, mapper); + doPost = portalRestAPIProxyClass.getDeclaredMethod("doPost", new Class[]{HttpServletRequest.class, HttpServletResponse.class}); + doPost.setAccessible(true); + doGet = portalRestAPIProxyClass.getDeclaredMethod("doGet", new Class[]{HttpServletRequest.class, HttpServletResponse.class}); + doGet.setAccessible(true); + Mockito.when(portalRestAPICentralServiceImpl.isAppAuthenticated(request)).thenReturn(true); + } + + @Test(expected=ServletException.class) + public void testInit() throws ServletException { + portalRestAPIProxyObj.init(); + } + + @Test + public void testDoPost_WhenProxyObjectIsNull() throws Exception { + portalRestApiServiceImplField.set(portalRestAPIProxyClass, null); + doPost.invoke(portalRestAPIProxyObj, new Object[] {request, response}); + } + + @Test + public void testDoPost_WhenRequestForStoreAnalytics() throws Exception { + Mockito.when(portalRestAPICentralServiceImpl.getUserId(request)).thenReturn("test"); + Mockito.when(portalRestAPICentralServiceImpl.getCredentials()).thenReturn(new HashMap(){{put("username","test");put("password","test");}}); + Mockito.when(request.getRequestURI()).thenReturn(PortalApiConstants.API_PREFIX+"/storeAnalytics"); + doPost.invoke(portalRestAPIProxyObj, new Object[] {request, response}); + } + + @Test + public void testDoPost_WhenRequestForStoreAnalyticsAndUserIdIsNull() throws Exception { + Mockito.when(portalRestAPICentralServiceImpl.getUserId(request)).thenReturn(null); + Mockito.when(request.getRequestURI()).thenReturn(PortalApiConstants.API_PREFIX+"/storeAnalytics"); + doPost.invoke(portalRestAPIProxyObj, new Object[] {request, response}); + } + + @Test(expected=ServletException.class) + public void testDoPost1_WhenExceptionOccurInGetUserID() throws Exception { + Mockito.when(portalRestAPICentralServiceImpl.getUserId(request)).thenThrow(new PortalAPIException("test")); + Mockito.when(request.getRequestURI()).thenReturn(PortalApiConstants.API_PREFIX+"/storeAnalytics"); + doPost.invoke(portalRestAPIProxyObj, new Object[] {request, response}); + } + + @Test + public void testDoPost_WhenRequestForUpdateSessionTimeOuts() throws Exception { + Mockito.when(request.getRequestURI()).thenReturn("/updateSessionTimeOuts"); + doPost.invoke(portalRestAPIProxyObj, new Object[] {request, response}); + } + + @Test + public void testDoPost_WhenRequestForTimeoutSession() throws Exception { + Mockito.when(request.getRequestURI()).thenReturn("/timeoutSession"); + doPost.invoke(portalRestAPIProxyObj, new Object[] {request, response}); + } + + @Test + public void testDoPost_WhenRequestForUserAndEcompUserIsNull() throws Exception { + Mockito.when(request.getRequestURI()).thenReturn("/api/v3/user"); + doPost.invoke(portalRestAPIProxyObj, new Object[] {request, response}); + } + + @Test + public void testDoPost_WhenRequestForUser() throws Exception { + EcompUser ecompUser = Mockito.mock(EcompUser.class); + Mockito.when(mapper.readValue(Mockito.anyString(), Mockito.eq(EcompUser.class))).thenReturn(ecompUser); + Mockito.when(request.getRequestURI()).thenReturn("/api/v3/user"); + doPost.invoke(portalRestAPIProxyObj, new Object[] {request, response}); + } + + @Test + public void testDoPost_WhenRequestForUserButNotRoles() throws Exception { + Mockito.when(request.getRequestURI()).thenReturn("/api/v3/user/role"); + doPost.invoke(portalRestAPIProxyObj, new Object[] {request, response}); + } + + @Test + public void testDoPost_WhenRequestForUserRoles() throws Exception { + Mockito.when(request.getRequestURI()).thenReturn("/api/v3/user/1/roles"); + doPost.invoke(portalRestAPIProxyObj, new Object[] {request, response}); + } + + @Test + public void testDoPost_WhenRequestForUserRolesWithRemote() throws Exception { + isAccessCentralizedField.set(portalRestAPIProxyClass, "remote1"); + Mockito.when(request.getRequestURI()).thenReturn("/api/v3/user/1/roles"); + doPost.invoke(portalRestAPIProxyObj, new Object[] {request, response}); + } + + + @Test + public void testDoPost_WhenIsAppAuthenticatedIsFalse() throws Exception { + Mockito.when(portalRestAPICentralServiceImpl.isAppAuthenticated(request)).thenReturn(false); + Mockito.when(request.getRequestURI()).thenReturn(""); + doPost.invoke(portalRestAPIProxyObj, new Object[] {request, response}); + } + + @Test + public void testDoPost_WhenIsAppAuthenticatedThrowException() throws Exception { + Mockito.when(portalRestAPICentralServiceImpl.isAppAuthenticated(request)).thenThrow(new PortalAPIException()); + Mockito.when(request.getRequestURI()).thenReturn(""); + doPost.invoke(portalRestAPIProxyObj, new Object[] {request, response}); + } + + @Test + public void testDoGet_WhenProxyObjectIsNull() throws Exception { + portalRestApiServiceImplField.set(portalRestAPIProxyClass, null); + doGet.invoke(portalRestAPIProxyObj, new Object[] {request, response}); + } + + @Test + public void testDoGet_WhenRequestForAnalytics() throws Exception { + Mockito.when(portalRestAPICentralServiceImpl.getUserId(request)).thenReturn("test"); + Mockito.when(portalRestAPICentralServiceImpl.getCredentials()).thenReturn(new HashMap(){{put("username","test");put("password","test");}}); + Mockito.when(request.getRequestURI()).thenReturn(PortalApiConstants.API_PREFIX+"/analytics"); + doGet.invoke(portalRestAPIProxyObj, new Object[] {request, response}); + } + + @Test + public void testDoGet_WhenRequestForAnalyticsAndUserIdIsNull() throws Exception { + Mockito.when(portalRestAPICentralServiceImpl.getUserId(request)).thenReturn(null); + Mockito.when(request.getRequestURI()).thenReturn(PortalApiConstants.API_PREFIX+"/analytics"); + doGet.invoke(portalRestAPIProxyObj, new Object[] {request, response}); + } + + @Test(expected=ServletException.class) + public void testDoGet1_WhenExceptionOccurInGetUserID() throws Exception { + Mockito.when(portalRestAPICentralServiceImpl.getUserId(request)).thenThrow(new PortalAPIException("test")); + Mockito.when(request.getRequestURI()).thenReturn(PortalApiConstants.API_PREFIX+"/analytics"); + doGet.invoke(portalRestAPIProxyObj, new Object[] {request, response}); + } + + @Test + public void testDoGet_WhenRequestForSessionTimeOuts() throws Exception { + Mockito.when(request.getRequestURI()).thenReturn("/sessionTimeOuts"); + doGet.invoke(portalRestAPIProxyObj, new Object[] {request, response}); + } + + @Test + public void testDoGet_WhenRequestForUsers() throws Exception { + Mockito.when(request.getRequestURI()).thenReturn("/api/v3/users"); + doGet.invoke(portalRestAPIProxyObj, new Object[] {request, response}); + } + + @Test + public void testDoGet_WhenRequestForRoles() throws Exception { + EcompUser ecompUser = Mockito.mock(EcompUser.class); + Mockito.when(mapper.readValue(Mockito.anyString(), Mockito.eq(EcompUser.class))).thenReturn(ecompUser); + Mockito.when(request.getRequestURI()).thenReturn("/api/v3/roles"); + doGet.invoke(portalRestAPIProxyObj, new Object[] {request, response}); + } + + @Test + public void testDoGet_WhenRequestForUserButNotRoles() throws Exception { + Mockito.when(request.getRequestURI()).thenReturn("/api/v3/user/role"); + doGet.invoke(portalRestAPIProxyObj, new Object[] {request, response}); + } + + @Test + public void testDoGet_WhenRequestForUserRoles() throws Exception { + Mockito.when(request.getRequestURI()).thenReturn("/api/v3/user/1/roles"); + doGet.invoke(portalRestAPIProxyObj, new Object[] {request, response}); + } + + @Test + public void testDoGet_WhenRequestForUserRolesWithRemote() throws Exception { + isAccessCentralizedField.set(portalRestAPIProxyClass, "remote1"); + Mockito.when(request.getRequestURI()).thenReturn("/api/v3/user/1/roles"); + doGet.invoke(portalRestAPIProxyObj, new Object[] {request, response}); + } + + @Test + public void testDoGet_WhenIsAppAuthenticatedIsFalse() throws Exception { + Mockito.when(portalRestAPICentralServiceImpl.isAppAuthenticated(request)).thenReturn(false); + Mockito.when(request.getRequestURI()).thenReturn(""); + doGet.invoke(portalRestAPIProxyObj, new Object[] {request, response}); + } + + @Test + public void testDoGet_WhenIsAppAuthenticatedThrowException() throws Exception { + Mockito.when(portalRestAPICentralServiceImpl.isAppAuthenticated(request)).thenThrow(new PortalAPIException()); + Mockito.when(request.getRequestURI()).thenReturn(""); + doGet.invoke(portalRestAPIProxyObj, new Object[] {request, response}); + } } diff --git a/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/onboarding/listener/PortalTimeoutHandlerTest.java b/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/onboarding/listener/PortalTimeoutHandlerTest.java index 3027cbee..3e6eb33a 100644 --- a/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/onboarding/listener/PortalTimeoutHandlerTest.java +++ b/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/onboarding/listener/PortalTimeoutHandlerTest.java @@ -104,7 +104,6 @@ public class PortalTimeoutHandlerTest { MockitoAnnotations.initMocks(this); - //port = Mockito.spy(PortalTimeoutHandler.class); Mockito.when(session.getAttribute(PortalApiConstants.PORTAL_JSESSION_ID)).thenReturn("test-Phrase"); @@ -198,7 +197,6 @@ public class PortalTimeoutHandlerTest { Mockito.when(session.getServletContext()).thenReturn(servCont); - //Mockito.when(session.getAttribute(PortalApiConstants.SESSION_PREVIOUS_ACCESS_TIME)).thenReturn(previousToLastAccessTime); Mockito.when(session.getServletContext().getAttribute(PortalApiConstants.PORTAL_SESSION_SLOT_CHECK)).thenReturn(null); @@ -217,7 +215,6 @@ public class PortalTimeoutHandlerTest { Mockito.when(session.getServletContext().getAttribute(PortalApiConstants.PORTAL_SESSION_SLOT_CHECK)).thenReturn(2000); - //session.setAttribute(PortalApiConstants.PORTAL_SESSION_SLOT_CHECK,2000); port.synchronizeSessionForLastMinuteRequests(request, ecompRestURL, userName, pwd, uebKey, _sessionComm); diff --git a/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/onboarding/util/CipherUtilTest.java b/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/onboarding/util/CipherUtilTest.java new file mode 100644 index 00000000..a0e17fe2 --- /dev/null +++ b/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/onboarding/util/CipherUtilTest.java @@ -0,0 +1,85 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * 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============================================ + * + * + */ +package org.onap.portalsdk.core.onboarding.util; + +import java.security.InvalidKeyException; + +import org.junit.Test; +import org.onap.portalsdk.core.onboarding.exception.CipherUtilException; + +public class CipherUtilTest { + @Test + public void testEncrypt() throws CipherUtilException { + CipherUtil.encrypt("Test"); + } + + @Test(expected=CipherUtilException.class) + public void testeEncryptWithKey() throws CipherUtilException { + CipherUtil.encrypt("Test","Test"); + } + + @Test(expected=CipherUtilException.class) + public void testEncryptPKCWithKey() throws CipherUtilException { + CipherUtil.encryptPKC("Test","Test"); + } + + @Test + public void testEncryptPKC() throws CipherUtilException { + CipherUtil.encryptPKC("Test"); + } + + @Test(expected=CipherUtilException.class) + public void testDecryptPKCWith() throws CipherUtilException { + CipherUtil.decryptPKC("Test","Test"); + } + + @Test(expected=CipherUtilException.class) + public void testDecrypt() throws CipherUtilException { + CipherUtil.decrypt("Test"); + } + + @Test(expected=CipherUtilException.class) + public void testeDecryptWithKey() throws CipherUtilException { + CipherUtil.decrypt("Test","Test"); + } + + @Test(expected=CipherUtilException.class) + public void testDecryptPKC() throws CipherUtilException { + CipherUtil.decryptPKC("Test"); + } +} diff --git a/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/onboarding/util/SSOFilterTest.java b/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/onboarding/util/SSOFilterTest.java new file mode 100644 index 00000000..2913f887 --- /dev/null +++ b/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/onboarding/util/SSOFilterTest.java @@ -0,0 +1,74 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * 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============================================ + * + * + */ +package org.onap.portalsdk.core.onboarding.util; + +import java.io.IOException; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.onap.portalsdk.core.onboarding.crossapi.PortalRestAPICentralServiceImpl; +import org.onap.portalsdk.core.onboarding.crossapi.PortalRestAPIProxy; +import org.onap.portalsdk.core.onboarding.exception.PortalAPIException; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({PortalRestAPIProxy.class}) +public class SSOFilterTest { + @Test + public void test() throws IOException, ServletException, PortalAPIException { + PowerMockito.mockStatic(PortalRestAPIProxy.class); + HttpServletRequest request = Mockito.mock(HttpServletRequest.class); + HttpServletResponse response = Mockito.mock(HttpServletResponse.class); + Mockito.when(request.getServerName()).thenReturn("test"); + Mockito.when(request.getContextPath()).thenReturn("test"); + Mockito.when(request.getRequestURI()).thenReturn("testURI"); + FilterChain chain = Mockito.mock(FilterChain.class); + PortalRestAPICentralServiceImpl s = Mockito.mock(PortalRestAPICentralServiceImpl.class); + Mockito.when(PortalRestAPIProxy.getPortalRestApiServiceImpl()).thenReturn(s); + Mockito.when(s.getUserId(request)).thenReturn(null); + new SSOFilter().doFilter(request, response, chain); + } +} diff --git a/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/onboarding/util/SSOUtilTest.java b/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/onboarding/util/SSOUtilTest.java new file mode 100644 index 00000000..1a9a310d --- /dev/null +++ b/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/onboarding/util/SSOUtilTest.java @@ -0,0 +1,55 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * 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============================================ + * + * + */ +package org.onap.portalsdk.core.onboarding.util; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.junit.Test; +import org.mockito.Mockito; + +public class SSOUtilTest { + @Test + public void test() { + HttpServletRequest request = Mockito.mock(HttpServletRequest.class); + HttpServletResponse response = Mockito.mock(HttpServletResponse.class); + Mockito.when(request.getServerName()).thenReturn("test"); + Mockito.when(request.getContextPath()).thenReturn("test"); + SSOUtil.getECOMPSSORedirectURL(request, response, "test"); + } +} diff --git a/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/restful/domain/EcompRoleFunctionTest.java b/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/restful/domain/EcompRoleFunctionTest.java new file mode 100644 index 00000000..7fe9fcc0 --- /dev/null +++ b/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/restful/domain/EcompRoleFunctionTest.java @@ -0,0 +1,81 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * 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============================================ + * + * + */ +package org.onap.portalsdk.core.restful.domain; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class EcompRoleFunctionTest { + EcompRoleFunction ecompRoleFunction; + private String NAME = "test"; + private String CODE = "1"; + private String TYPE = "test"; + private String ACTION = "test"; + + @Before + public void setUp() { + ecompRoleFunction = new EcompRoleFunction(); + ecompRoleFunction.setAction(ACTION); + ecompRoleFunction.setName(NAME); + ecompRoleFunction.setCode(CODE); + ecompRoleFunction.setType(TYPE); + } + + + @Test + public void testNotNull() { + assertNotNull(ecompRoleFunction); + } + + @Test + public void testEcompRoleFunctionProperties() { + assertEquals(ACTION, ecompRoleFunction.getAction()); + assertEquals(CODE, ecompRoleFunction.getCode()); + assertEquals(NAME, ecompRoleFunction.getName()); + assertEquals(TYPE, ecompRoleFunction.getType()); + } + + @Test + public void testCompareTo() { + assertEquals(0, ecompRoleFunction.compareTo(ecompRoleFunction)); + } + +} |