@Test
  public void testAlertHistoryPagination() throws Exception {
    m_helper.installHdfsService(m_cluster, m_serviceFactory,
        m_componentFactory, m_schFactory, HOSTNAME);
    m_alertHelper.populateData(m_cluster);

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

    // get back all 3
    List<AlertHistoryEntity> histories = m_dao.findAll(request);
    assertEquals(3, histories.size());

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

    histories = m_dao.findAll(request);
    assertEquals(2, histories.size());

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

    histories = m_dao.findAll(request);
    assertEquals(1, histories.size());

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

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

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