@Test
public void testAlertNoticeSorting() throws Exception {

  m_helper.addHost(m_clusters, m_cluster, HOSTNAME);
  m_helper.installHdfsService(m_cluster, m_serviceFactory, m_componentFactory, m_schFactory, HOSTNAME);
  m_helper.installYarnService(m_cluster, m_serviceFactory, m_componentFactory, m_schFactory, HOSTNAME);
  m_alertHelper.populateData(m_cluster);
  List<SortRequestProperty> sortProperties = new ArrayList<>();
  SortRequest sortRequest = new SortRequestImpl(sortProperties);
  AlertNoticeRequest request = new AlertNoticeRequest();
  request.Sort = sortRequest;
  Predicate clusterPredicate = new PredicateBuilder().property(
      AlertNoticeResourceProvider.ALERT_NOTICE_CLUSTER_NAME).equals("c1").toPredicate();
  request.Predicate = clusterPredicate;
  sortProperties.add(new SortRequestProperty(
      AlertNoticeResourceProvider.ALERT_NOTICE_ID, Order.ASC));
  // get back all 3
  List<AlertNoticeEntity> notices = m_dao.findAllNotices(request);
  assertEquals(3, notices.size());
  // assert sorting ASC
  long lastId = 0L;
  for (AlertNoticeEntity notice : notices) {
    if (lastId == 0L) {
      lastId = notice.getNotificationId();
      continue;
    }
    long currentId = notice.getNotificationId();
    assertTrue(lastId < currentId);
    lastId = currentId;
  }
  // clear and do DESC
  sortProperties.clear();
  sortProperties.add(new SortRequestProperty(
      AlertNoticeResourceProvider.ALERT_NOTICE_ID, Order.DESC));
  notices = m_dao.findAllNotices(request);
  assertEquals(3, notices.size());
  // assert sorting DESC
  lastId = 0L;
  for (AlertNoticeEntity notice : notices) {
    if (lastId == 0L) {
      lastId = notice.getNotificationId();
      continue;
    }
    long currentId = notice.getNotificationId();
    assertTrue(lastId > currentId);
    lastId = currentId;
  }
}