@Test(groups = "slow") public void testBasic() throws InterruptedException { final String ownerId = UUID.randomUUID().toString(); final String notificationKey = UUID.randomUUID().toString(); final DateTime effDt = new DateTime(); final Notification notif = new DefaultNotification( "testBasic", hostname, notificationKey.getClass().getName(), notificationKey, accountId, effDt); dao.insertNotification(notif); Thread.sleep(1000); final DateTime now = new DateTime(); final List<Notification> notifications = dao.getReadyNotifications(now.toDate(), hostname, 3, "testBasic"); assertNotNull(notifications); assertEquals(notifications.size(), 1); Notification notification = notifications.get(0); assertEquals(notification.getNotificationKey(), notificationKey); validateDate(notification.getEffectiveDate(), effDt); assertEquals(notification.getOwner(), null); assertEquals(notification.getProcessingState(), PersistentQueueEntryLifecycleState.AVAILABLE); assertEquals(notification.getNextAvailableDate(), null); final DateTime nextAvailable = now.plusMinutes(5); final int res = dao.claimNotification( ownerId, nextAvailable.toDate(), notification.getId().toString(), now.toDate()); assertEquals(res, 1); dao.insertClaimedHistory(ownerId, now.toDate(), notification.getId().toString()); notification = fetchNotification(notification.getId().toString()); assertEquals(notification.getNotificationKey(), notificationKey); validateDate(notification.getEffectiveDate(), effDt); assertEquals(notification.getOwner(), ownerId); assertEquals( notification.getProcessingState(), PersistentQueueEntryLifecycleState.IN_PROCESSING); validateDate(notification.getNextAvailableDate(), nextAvailable); dao.clearNotification(notification.getId().toString(), ownerId); notification = fetchNotification(notification.getId().toString()); assertEquals(notification.getNotificationKey(), notificationKey); validateDate(notification.getEffectiveDate(), effDt); // assertEquals(notification.getOwner(), null); assertEquals(notification.getProcessingState(), PersistentQueueEntryLifecycleState.PROCESSED); validateDate(notification.getNextAvailableDate(), nextAvailable); }