From b33289a81b44e0d51d79f784fc92e0f6b5719e32 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Thu, 28 Sep 2017 11:51:13 +0530 Subject: [PATCH] adding test cases for NotificationManagementServiceImpl --- .../mgt/core/common/TestDataHolder.java | 1 + ...otificationManagementServiceImplTests.java | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDataHolder.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDataHolder.java index a6af04fad7a..d063c9594da 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDataHolder.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDataHolder.java @@ -18,6 +18,7 @@ package org.wso2.carbon.device.mgt.core.common; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.EnrolmentInfo; +import org.wso2.carbon.device.mgt.common.PaginationRequest; import org.wso2.carbon.device.mgt.common.app.mgt.Application; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup; import org.wso2.carbon.device.mgt.common.notification.mgt.Notification; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/notification/mgt/NotificationManagementServiceImplTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/notification/mgt/NotificationManagementServiceImplTests.java index 87de3578308..50e98971ca9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/notification/mgt/NotificationManagementServiceImplTests.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/notification/mgt/NotificationManagementServiceImplTests.java @@ -25,6 +25,8 @@ import org.testng.annotations.Test; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.EntityDoesNotExistException; +import org.wso2.carbon.device.mgt.common.PaginationRequest; +import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.mgt.common.notification.mgt.Notification; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException; import org.wso2.carbon.device.mgt.core.TestDeviceManagementService; @@ -170,5 +172,22 @@ public class NotificationManagementServiceImplTests { Assert.assertEquals(returnedNotifications.size(), NO_OF_NOTIFICATIONS); } + @Test(dependsOnMethods = "addNotification", description = "this tests for getAllNotification method by passing " + + "pagination request and validates the no. of total records and filtered records. ") + public void getAllNotificationsWithPaginationRequest() throws NotificationManagementException { + PaginationRequest request = new PaginationRequest(1, 2); + PaginationResult result = notificationManagementService.getAllNotifications(request); + Assert.assertEquals(result.getRecordsFiltered(), NO_OF_NOTIFICATIONS); + Assert.assertEquals(result.getRecordsTotal(), NO_OF_NOTIFICATIONS); + } + + @Test(dependsOnMethods = "updateNotificationStatus", description = "this tests for getAllNotification method by" + + " passing pagination request & status and validates the no. of total records and filtered records. ") + public void getAllNotificationsWithPaginationRequestAndStatus() throws NotificationManagementException { + PaginationRequest request = new PaginationRequest(1, 2); + PaginationResult result = notificationManagementService.getNotificationsByStatus(Notification.Status.CHECKED, request); + Assert.assertEquals(result.getRecordsFiltered(), NO_OF_NOTIFICATIONS); + Assert.assertEquals(result.getRecordsTotal(), NO_OF_NOTIFICATIONS); + } }