X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ecomp-portal-BE-common%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fportalapp%2Fportal%2Fcontroller%2FUserNotificationControllerTest.java;h=bbb3ddbf4ab9e9f88de9c99ba013979601b35f9e;hb=aa9b320ff93511280cf51b03d38fb9254af6b530;hp=047d60f30e32004d7cebf481fd329cebc675b490;hpb=fe3a67c11b65d7989a6ef648c3f34eee8abe7394;p=portal.git diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/UserNotificationControllerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/UserNotificationControllerTest.java index 047d60f3..bbb3ddbf 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/UserNotificationControllerTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/UserNotificationControllerTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START========================================== * ONAP Portal * =================================================================== - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * =================================================================== * * Unless otherwise specified, all software contained herein is licensed @@ -56,9 +56,9 @@ import org.mockito.Matchers; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.onap.portalapp.portal.controller.UserNotificationController; import org.onap.portalapp.portal.core.MockEPUser; import org.onap.portalapp.portal.domain.EPUser; +import org.onap.portalapp.portal.domain.EcompAppRole; import org.onap.portalapp.portal.ecomp.model.PortalRestResponse; import org.onap.portalapp.portal.ecomp.model.PortalRestStatusEnum; import org.onap.portalapp.portal.framework.MockitoTestSuite; @@ -68,6 +68,7 @@ import org.onap.portalapp.portal.service.UserNotificationService; import org.onap.portalapp.portal.service.UserNotificationServiceImpl; import org.onap.portalapp.portal.transport.EpNotificationItem; import org.onap.portalapp.portal.transport.EpNotificationItemVO; +import org.onap.portalapp.portal.transport.EpRoleNotificationItem; import org.onap.portalapp.portal.transport.FunctionalMenuRole; import org.onap.portalapp.util.EPUserUtils; import org.onap.portalsdk.core.util.SystemProperties; @@ -278,4 +279,56 @@ public class UserNotificationControllerTest { assertTrue(actualPortalRestResponse.equals(expectedPortalRestResponse)); } + @Test + public void notificationRead() { + PowerMockito.mockStatic(UserUtils.class); + Mockito.when(UserUtils.getUserId(mockedRequest)).thenReturn(1); + userNotificationController.notificationRead("1", mockedRequest); + } + + @Test + public void notificationRead_Error() { + PowerMockito.mockStatic(UserUtils.class); + Mockito.when(UserUtils.getUserId(mockedRequest)).thenReturn(1); + userNotificationController.notificationRead("Test", mockedRequest); + } + + @Test + public void getNotificationHistory() { + PowerMockito.mockStatic(EPUserUtils.class); + EPUser user = mockUser.mockEPUser(); + HttpSession session = mockedRequest.getSession(); + session.setAttribute("user", user); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + userNotificationController.getNotificationHistory(mockedRequest, mockedResponse); + } + + @Test + public void testGetRoles() { + + List NotifRoles =new ArrayList<>(); + EpRoleNotificationItem epRole=new EpRoleNotificationItem(); + epRole.setId(1l); + + Mockito.when(userNotificationService.getNotificationRoles(1l)).thenReturn(NotifRoles); + userNotificationController.testGetRoles(mockedRequest, 1l); + + + } + + @Test + public void getNotificationAppRoles() { + List epAppRoleList =new ArrayList<>(); + Mockito.when(userNotificationService.getAppRoleList()).thenReturn(epAppRoleList); + userNotificationController.getNotificationAppRoles(mockedRequest, mockedResponse); + } + + + @Test + public void getMessageRecipients() { + + Mockito.when(userNotificationService.getMessageRecipients(1l)).thenReturn(new ArrayList<>()); + userNotificationController.getMessageRecipients(1l); + } + }