adding more tests for notificationmanagementserviceImpl

revert-70aa11f8
Nirothipan 7 years ago
parent 4b0cab79cb
commit 768e39fecf

@ -83,7 +83,8 @@ public class NotificationManagementServiceImplTests {
deviceMgtService.registerDeviceType(new TestDeviceManagementService(DEVICE_TYPE, deviceMgtService.registerDeviceType(new TestDeviceManagementService(DEVICE_TYPE,
MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)); MultitenantConstants.SUPER_TENANT_DOMAIN_NAME));
for (Device device : devices) { for (Device device : devices) {
deviceMgtService.enrollDevice(device); Assert.assertTrue(deviceMgtService.enrollDevice(device), "Device with Identifier - " +
device.getDeviceIdentifier() + " is not enrolled.");
} }
List<Device> returnedDevices = deviceMgtService.getAllDevices(DEVICE_TYPE); List<Device> returnedDevices = deviceMgtService.getAllDevices(DEVICE_TYPE);
@ -127,14 +128,24 @@ public class NotificationManagementServiceImplTests {
DEVICE_TYPE), notification); 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" + @Test(dependsOnMethods = "addNotification", description = "This tests the updateNotification Method" +
" and check whether it returns true ( got updated )") " and check whether it returns true ( got updated )")
public void updateNotification() throws NotificationManagementException { public void updateNotification() throws NotificationManagementException {
for (int i = 1; i <= NO_OF_DEVICES; i++) { for (int i = 1; i <= NO_OF_DEVICES; i++) {
DeviceIdentifier testDeviceIdentifier = new DeviceIdentifier(DEVICE_ID_PREFIX + i, DEVICE_TYPE); DeviceIdentifier testDeviceIdentifier = new DeviceIdentifier(DEVICE_ID_PREFIX + i, DEVICE_TYPE);
Notification notification = TestDataHolder.getNotification(i, Notification.Status.CHECKED.toString(), Notification notification = TestDataHolder.getNotification(i, Notification.Status.CHECKED.toString(),
testDeviceIdentifier.toString(), TEST_NOTIFICATION_DESCRIPTION, DEVICE_ID_PREFIX + i, NOTIFICATION_OPERATION_ID, testDeviceIdentifier.toString(), TEST_NOTIFICATION_DESCRIPTION, DEVICE_ID_PREFIX + i,
DEVICE_TYPE); NOTIFICATION_OPERATION_ID, DEVICE_TYPE);
Assert.assertTrue(notificationManagementService.updateNotification(notification)); 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. ") " passing pagination request & status and validates the no. of total records and filtered records. ")
public void getAllNotificationsWithPaginationRequestAndStatus() throws NotificationManagementException { public void getAllNotificationsWithPaginationRequestAndStatus() throws NotificationManagementException {
PaginationRequest request = new PaginationRequest(1, 2); 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.getRecordsFiltered(), NO_OF_NOTIFICATIONS);
Assert.assertEquals(result.getRecordsTotal(), NO_OF_NOTIFICATIONS); Assert.assertEquals(result.getRecordsTotal(), NO_OF_NOTIFICATIONS);
} }
} }

Loading…
Cancel
Save