@Test
  public void testAlertNoticePagination() 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);

    AlertNoticeRequest request = new AlertNoticeRequest();
    request.Pagination = null;

    // get back all 3
    List<AlertNoticeEntity> notices = m_dao.findAllNotices(request);
    assertEquals(3, notices.size());

    // only the first 2
    request.Pagination = new PageRequestImpl(StartingPoint.Beginning, 2, 0,
        null, null);

    notices = m_dao.findAllNotices(request);
    assertEquals(2, notices.size());

    // the 2nd and 3rd
    request.Pagination = new PageRequestImpl(StartingPoint.Beginning, 1, 2,
        null, null);

    notices = m_dao.findAllNotices(request);
    assertEquals(1, notices.size());

    // none b/c we're out of index
    request.Pagination = new PageRequestImpl(StartingPoint.Beginning, 1, 3,
        null, null);

    notices = m_dao.findAllNotices(request);
    assertEquals(0, notices.size());
  }
Tests that JPA does the pagination work for us.

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/orm/dao/AlertDispatchDAOTest.java