diff options
author | 2018-02-20 12:00:10 -0500 | |
---|---|---|
committer | 2018-02-20 12:00:10 -0500 | |
commit | 724ff8f8b22d6503ce5070ebc13f6f5fbc48c8cf (patch) | |
tree | 063414ae8d035fe9957cba3833661a915c1f8eff /ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/FnMenuControllerTest.java | |
parent | 20602aa99841048e65a36dc26d8bfc4d6a11fcc9 (diff) |
Increase JUNIT Coverage
Issue-ID: PORTAL-136
Change-Id: I2223003924f36043753bef401ed1d8ee87f4a65e
Signed-off-by: st782s <statta@research.att.com>
Diffstat (limited to 'ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/FnMenuControllerTest.java')
-rw-r--r-- | ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/FnMenuControllerTest.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/FnMenuControllerTest.java b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/FnMenuControllerTest.java index 1f1d2db3..d82e1ed5 100644 --- a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/FnMenuControllerTest.java +++ b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/FnMenuControllerTest.java @@ -48,12 +48,16 @@ import java.io.StringReader; import java.io.StringWriter; import java.util.ArrayList; import java.util.List; +import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import org.junit.Assert; 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; @@ -63,12 +67,21 @@ import org.onap.portalsdk.core.domain.Menu; import org.onap.portalsdk.core.domain.MenuData; import org.onap.portalsdk.core.domain.RoleFunction; import org.onap.portalsdk.core.domain.User; +import org.onap.portalsdk.core.menu.MenuBuilder; +import org.onap.portalsdk.core.service.AppService; +import org.onap.portalsdk.core.service.DataAccessService; import org.onap.portalsdk.core.service.FnMenuService; import org.onap.portalsdk.core.service.FunctionalMenuListService; import org.onap.portalsdk.core.web.support.UserUtils; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.springframework.mock.web.MockHttpServletRequest; import com.fasterxml.jackson.databind.ObjectMapper; +@RunWith(PowerMockRunner.class) +@PrepareForTest({UserUtils.class}) public class FnMenuControllerTest { @InjectMocks @@ -79,6 +92,15 @@ public class FnMenuControllerTest { @Mock FunctionalMenuListService functionalMenuListService; + + @Mock + private MenuBuilder menuBuilder; + + @Mock + private DataAccessService dataAccessService; + + @Mock + private AppService appService; @Before public void setup() { @@ -226,4 +248,15 @@ public class FnMenuControllerTest { String actualResult = fnMenuController.getViewName(); assertEquals(expectedResult, actualResult); } + + @Test + public void getMenuTest() { + HttpServletRequest request = Mockito.mock(HttpServletRequest.class); + PowerMockito.mockStatic(UserUtils.class); + HttpSession session = Mockito.mock(HttpSession.class); + Mockito.when(request.getSession()).thenReturn(session); + Mockito.when(UserUtils.getUserSession(request)).thenReturn(new User()); + Map<String, Object> model = fnMenuController.getMenu(request); + Assert.assertTrue(model.size() > 0 ); + } } |