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 50e98971ca9..c381d73e357 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 @@ -83,7 +83,8 @@ public class NotificationManagementServiceImplTests { deviceMgtService.registerDeviceType(new TestDeviceManagementService(DEVICE_TYPE, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)); for (Device device : devices) { - deviceMgtService.enrollDevice(device); + Assert.assertTrue(deviceMgtService.enrollDevice(device), "Device with Identifier - " + + device.getDeviceIdentifier() + " is not enrolled."); } List returnedDevices = deviceMgtService.getAllDevices(DEVICE_TYPE); @@ -127,14 +128,24 @@ public class NotificationManagementServiceImplTests { DEVICE_TYPE), notification); } + @Test(expectedExceptions = NotificationManagementException.class, description = "This tests the method getDevice which" + + " is called internally in addNotification fot DeviceManagementException exception passing null device Id.") + public void getDevice() throws NotificationManagementException { + DeviceIdentifier testDeviceIdentifier = new DeviceIdentifier(DEVICE_ID_PREFIX + 123, DEVICE_TYPE); + Notification notification = TestDataHolder.getNotification(1, Notification.Status.NEW.toString(), + testDeviceIdentifier.toString(), TEST_NOTIFICATION_DESCRIPTION, DEVICE_ID_PREFIX + 123, + NOTIFICATION_OPERATION_ID, DEVICE_TYPE); + notificationManagementService.addNotification(null, notification); + } + @Test(dependsOnMethods = "addNotification", description = "This tests the updateNotification Method" + " and check whether it returns true ( got updated )") public void updateNotification() throws NotificationManagementException { for (int i = 1; i <= NO_OF_DEVICES; i++) { DeviceIdentifier testDeviceIdentifier = new DeviceIdentifier(DEVICE_ID_PREFIX + i, DEVICE_TYPE); Notification notification = TestDataHolder.getNotification(i, Notification.Status.CHECKED.toString(), - testDeviceIdentifier.toString(), TEST_NOTIFICATION_DESCRIPTION, DEVICE_ID_PREFIX + i, NOTIFICATION_OPERATION_ID, - DEVICE_TYPE); + testDeviceIdentifier.toString(), TEST_NOTIFICATION_DESCRIPTION, DEVICE_ID_PREFIX + i, + NOTIFICATION_OPERATION_ID, DEVICE_TYPE); Assert.assertTrue(notificationManagementService.updateNotification(notification)); } } @@ -185,9 +196,11 @@ public class NotificationManagementServiceImplTests { " 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); + PaginationResult result = notificationManagementService.getNotificationsByStatus(Notification.Status.CHECKED, + request); Assert.assertEquals(result.getRecordsFiltered(), NO_OF_NOTIFICATIONS); Assert.assertEquals(result.getRecordsTotal(), NO_OF_NOTIFICATIONS); } + }