diff options
author | 2017-09-25 16:07:54 -0400 | |
---|---|---|
committer | 2017-09-25 16:09:15 -0400 | |
commit | 23634dba70b166ad3c79b5eadfbd32b5375d44be (patch) | |
tree | ab0ea364c8da4f91fb8c7e2819692498939fb419 /ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ECOMPLogoutControllerTest.java | |
parent | 4ba6a0f20a190030700917a6065a6779ca9d308f (diff) |
MariaDB Connector and Sonar Scans; clean nl
PORTAL-50: Fix to get the Sonar coverage for ONAP
PORTAL-72: Sonar scan - resolving severity Blocker issues
PORTAL-86: Remove internal att.com usages from tests and other files
PORTAL-102: Fixed the page refresh issue on App Account Management page
PORTAL-103: Fix to enhanced notification ticket source for ONAP
PORTAL-104: Replaced mysql DB connector with mariaDB
Issue: PORTAL-50 PORTAL-72 PORTAL-86 PORTAL-102 PORTAL-103 PORTAL-104
Change-Id: Iae78ad34ed9ce5ae1f2d36fcbb93fbc1e39944e5
Signed-off-by: Christopher Lott (cl778h) <clott@research.att.com>
Diffstat (limited to 'ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ECOMPLogoutControllerTest.java')
-rw-r--r-- | ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ECOMPLogoutControllerTest.java | 77 |
1 files changed, 77 insertions, 0 deletions
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 new file mode 100644 index 00000000..729debaa --- /dev/null +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ECOMPLogoutControllerTest.java @@ -0,0 +1,77 @@ +package org.openecomp.portalapp.portal.controller; + +import static org.junit.Assert.*; + +import javax.servlet.ServletRequestWrapper; +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.mockito.stubbing.OngoingStubbing; +import org.openecomp.portalapp.controller.ECOMPLogoutController; +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; +import org.powermock.modules.junit4.PowerMockRunner; +import org.springframework.core.NamedThreadLocal; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import org.springframework.web.servlet.ModelAndView; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({EPUserUtils.class, EPCommonSystemProperties.class,RequestContextHolder.class,RequestAttributes.class}) +public class ECOMPLogoutControllerTest { + + @Mock + DashboardSearchService searchService = new DashboardSearchServiceImpl(); + + @InjectMocks + ECOMPLogoutController ecompLogoutController = new ECOMPLogoutController(); + + @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 + RequestContextHolder requestContextHolder; + + @Mock + RequestAttributes requestAttributes; + + @Test + public void logOutTest() throws Exception{ + ModelAndView actualData = new ModelAndView("redirect:login.htm"); + ModelAndView expedtedData = null; + ThreadLocal<RequestAttributes> requestAttributesHolder = + new NamedThreadLocal<RequestAttributes>("Request attributes"); + RequestAttributes requestAttributes = new ServletRequestAttributes(mockedRequest); + PowerMockito.mockStatic(RequestContextHolder.class); + PowerMockito.mockStatic(RequestAttributes.class); + Mockito.when((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes()).thenReturn((ServletRequestAttributes) requestAttributes); + expedtedData = ecompLogoutController.logOut(mockedRequest, mockedResponse); + assertEquals(actualData.getViewName(),expedtedData.getViewName()); + } + +} |