@Test
public void testAlertNoticePredicate() 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);
  Predicate clusterPredicate = null;
  Predicate hdfsPredicate = null;
  Predicate yarnPredicate = null;
  Predicate adminPredicate = null;
  Predicate adminOrOperatorPredicate = null;
  Predicate pendingPredicate = null;
  Predicate noticeIdPredicate = null;
  clusterPredicate = new PredicateBuilder().property(
      AlertNoticeResourceProvider.ALERT_NOTICE_CLUSTER_NAME).equals("c1").toPredicate();
  hdfsPredicate = new PredicateBuilder().property(
      AlertNoticeResourceProvider.ALERT_NOTICE_SERVICE_NAME).equals("HDFS").toPredicate();
  yarnPredicate = new PredicateBuilder().property(
      AlertNoticeResourceProvider.ALERT_NOTICE_SERVICE_NAME).equals("YARN").toPredicate();
  adminPredicate = new PredicateBuilder().property(
      AlertNoticeResourceProvider.ALERT_NOTICE_TARGET_NAME).equals(
      "Administrators").toPredicate();
  adminOrOperatorPredicate = new PredicateBuilder().property(
      AlertNoticeResourceProvider.ALERT_NOTICE_TARGET_NAME).equals(
      "Administrators").or().property(
      AlertNoticeResourceProvider.ALERT_NOTICE_TARGET_NAME).equals(
      "Operators").toPredicate();
  pendingPredicate = new PredicateBuilder().property(
      AlertNoticeResourceProvider.ALERT_NOTICE_STATE).equals(
      NotificationState.PENDING.name()).toPredicate();
  AlertNoticeRequest request = new AlertNoticeRequest();
  request.Predicate = clusterPredicate;
  List<AlertNoticeEntity> notices = m_dao.findAllNotices(request);
  assertEquals(3, notices.size());
  request.Predicate = hdfsPredicate;
  notices = m_dao.findAllNotices(request);
  assertEquals(2, notices.size());
  request.Predicate = yarnPredicate;
  notices = m_dao.findAllNotices(request);
  assertEquals(1, notices.size());
  request.Predicate = adminPredicate;
  notices = m_dao.findAllNotices(request);
  assertEquals(2, notices.size());
  request.Predicate = adminOrOperatorPredicate;
  notices = m_dao.findAllNotices(request);
  assertEquals(3, notices.size());
  request.Predicate = pendingPredicate;
  notices = m_dao.findAllNotices(request);
  assertEquals(1, notices.size());
  noticeIdPredicate = new PredicateBuilder().property(
      AlertNoticeResourceProvider.ALERT_NOTICE_ID).equals(
      notices.get(0).getNotificationId()).toPredicate();
  request.Predicate = noticeIdPredicate;
  notices = m_dao.findAllNotices(request);
  assertEquals(1, notices.size());
}