@Test(groups = "slow")
  public void testGetByAccountAndDate() throws InterruptedException {
    final String notificationKey = UUID.randomUUID().toString();
    final DateTime effDt = new DateTime();
    final Notification notif1 =
        new DefaultNotification(
            "testBasic1",
            hostname,
            notificationKey.getClass().getName(),
            notificationKey,
            accountId,
            effDt);
    dao.insertNotification(notif1);

    final Notification notif2 =
        new DefaultNotification(
            "testBasic2",
            hostname,
            notificationKey.getClass().getName(),
            notificationKey,
            accountId,
            effDt);
    dao.insertNotification(notif2);

    List<Notification> notifications =
        dao.getNotificationForAccountAndDate(accountId.toString(), effDt.toDate());
    assertEquals(notifications.size(), 2);
    for (final Notification cur : notifications) {
      Assert.assertEquals(cur.getProcessingState(), PersistentQueueEntryLifecycleState.AVAILABLE);
      dao.removeNotification(cur.getId().toString());
    }

    notifications = dao.getNotificationForAccountAndDate(accountId.toString(), effDt.toDate());
    assertEquals(notifications.size(), 2);
    for (final Notification cur : notifications) {
      Assert.assertEquals(cur.getProcessingState(), PersistentQueueEntryLifecycleState.REMOVED);
    }
  }
  @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);
  }