@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; List<AlertNoticeEntity> notices = m_dao.findAllNotices(request); assertEquals(3, notices.size()); request.Pagination = new PageRequestImpl(StartingPoint.Beginning, 2, 0, null, null); notices = m_dao.findAllNotices(request); assertEquals(2, notices.size()); request.Pagination = new PageRequestImpl(StartingPoint.Beginning, 1, 2, null, null); notices = m_dao.findAllNotices(request); assertEquals(1, notices.size()); request.Pagination = new PageRequestImpl(StartingPoint.Beginning, 1, 3, null, null); notices = m_dao.findAllNotices(request); assertEquals(0, notices.size()); }
@RequiresSession public List<AlertNoticeEntity> findAllNotices() { TypedQuery<AlertNoticeEntity> query = entityManagerProvider.get().createNamedQuery( "AlertNoticeEntity.findAll", AlertNoticeEntity.class); return daoUtils.selectList(query); }
AlertDispatchDAO { @RequiresSession public List<AlertNoticeEntity> findAllNotices() { TypedQuery<AlertNoticeEntity> query = entityManagerProvider.get().createNamedQuery( "AlertNoticeEntity.findAll", AlertNoticeEntity.class); return daoUtils.selectList(query); } }
AlertDispatchDAO { @RequiresSession public List<AlertNoticeEntity> findAllNotices() { TypedQuery<AlertNoticeEntity> query = entityManagerProvider.get().createNamedQuery( "AlertNoticeEntity.findAll", AlertNoticeEntity.class); return daoUtils.selectList(query); }  }
AlertDispatchDAO { @RequiresSession public List<AlertNoticeEntity> findAllNotices() { TypedQuery<AlertNoticeEntity> query = entityManagerProvider.get().createNamedQuery( "AlertNoticeEntity.findAll", AlertNoticeEntity.class); return daoUtils.selectList(query); }  @RequiresSession AlertGroupEntity findGroupById(long groupId); @RequiresSession List<AlertGroupEntity> findGroupsById(List<Long> groupIds); @RequiresSession AlertTargetEntity findTargetById(long targetId); @RequiresSession List<AlertTargetEntity> findTargetsById(List<Long> targetIds); @RequiresSession AlertNoticeEntity findNoticeById(long noticeId); @RequiresSession AlertNoticeEntity findNoticeByUuid(String uuid); @RequiresSession List<AlertNoticeEntity> findPendingNotices(); @RequiresSession AlertGroupEntity findGroupByName(long clusterId, String groupName); @RequiresSession AlertTargetEntity findTargetByName(String targetName); @RequiresSession List<AlertGroupEntity> findAllGroups(); @RequiresSession List<AlertGroupEntity> findAllGroups(long clusterId); @RequiresSession List<AlertTargetEntity> findAllTargets(); @RequiresSession List<AlertTargetEntity> findAllGlobalTargets(); @RequiresSession List<AlertGroupEntity> findGroupsByDefinition(
      AlertDefinitionEntity definitionEntity); @RequiresSession AlertGroupEntity findDefaultServiceGroup(long clusterId,
      String serviceName); @RequiresSession List<AlertNoticeEntity> findAllNotices(); @RequiresSession List<AlertNoticeEntity> findAllNotices(AlertNoticeRequest request); @RequiresSession int getNoticesCount(Predicate predicate); @Transactional void createGroups(List<AlertGroupEntity> entities); @Transactional void create(AlertGroupEntity group); @Transactional AlertGroupEntity createDefaultGroup(long clusterId, String serviceName); @Transactional void refresh(AlertGroupEntity alertGroup); @Transactional AlertGroupEntity merge(AlertGroupEntity alertGroup); @Transactional void remove(AlertGroupEntity alertGroup); @Transactional void removeAllGroups(long clusterId); @Transactional void createTargets(List<AlertTargetEntity> entities); @Transactional List<AlertNoticeEntity> createNotices(List<AlertNoticeEntity> entities); @Transactional void create(AlertTargetEntity alertTarget); @Transactional void refresh(AlertTargetEntity alertTarget); @Transactional AlertTargetEntity merge(AlertTargetEntity alertTarget); @Transactional void remove(AlertTargetEntity alertTarget); @Transactional void create(AlertNoticeEntity alertNotice); @Transactional void refresh(AlertNoticeEntity alertNotice); @Transactional AlertNoticeEntity merge(AlertNoticeEntity alertNotice); @Transactional void remove(AlertNoticeEntity alertNotice); @Transactional void removeNoticeByDefinitionId(long definitionId); }
AlertDispatchDAO { @RequiresSession public List<AlertNoticeEntity> findAllNotices() { TypedQuery<AlertNoticeEntity> query = entityManagerProvider.get().createNamedQuery( "AlertNoticeEntity.findAll", AlertNoticeEntity.class); return daoUtils.selectList(query); }  @RequiresSession AlertGroupEntity findGroupById(long groupId); @RequiresSession List<AlertGroupEntity> findGroupsById(List<Long> groupIds); @RequiresSession AlertTargetEntity findTargetById(long targetId); @RequiresSession List<AlertTargetEntity> findTargetsById(List<Long> targetIds); @RequiresSession AlertNoticeEntity findNoticeById(long noticeId); @RequiresSession AlertNoticeEntity findNoticeByUuid(String uuid); @RequiresSession List<AlertNoticeEntity> findPendingNotices(); @RequiresSession AlertGroupEntity findGroupByName(long clusterId, String groupName); @RequiresSession AlertTargetEntity findTargetByName(String targetName); @RequiresSession List<AlertGroupEntity> findAllGroups(); @RequiresSession List<AlertGroupEntity> findAllGroups(long clusterId); @RequiresSession List<AlertTargetEntity> findAllTargets(); @RequiresSession List<AlertTargetEntity> findAllGlobalTargets(); @RequiresSession List<AlertGroupEntity> findGroupsByDefinition(
      AlertDefinitionEntity definitionEntity); @RequiresSession AlertGroupEntity findDefaultServiceGroup(long clusterId,
      String serviceName); @RequiresSession List<AlertNoticeEntity> findAllNotices(); @RequiresSession List<AlertNoticeEntity> findAllNotices(AlertNoticeRequest request); @RequiresSession int getNoticesCount(Predicate predicate); @Transactional void createGroups(List<AlertGroupEntity> entities); @Transactional void create(AlertGroupEntity group); @Transactional AlertGroupEntity createDefaultGroup(long clusterId, String serviceName); @Transactional void refresh(AlertGroupEntity alertGroup); @Transactional AlertGroupEntity merge(AlertGroupEntity alertGroup); @Transactional void remove(AlertGroupEntity alertGroup); @Transactional void removeAllGroups(long clusterId); @Transactional void createTargets(List<AlertTargetEntity> entities); @Transactional List<AlertNoticeEntity> createNotices(List<AlertNoticeEntity> entities); @Transactional void create(AlertTargetEntity alertTarget); @Transactional void refresh(AlertTargetEntity alertTarget); @Transactional AlertTargetEntity merge(AlertTargetEntity alertTarget); @Transactional void remove(AlertTargetEntity alertTarget); @Transactional void create(AlertNoticeEntity alertNotice); @Transactional void refresh(AlertNoticeEntity alertNotice); @Transactional AlertNoticeEntity merge(AlertNoticeEntity alertNotice); @Transactional void remove(AlertNoticeEntity alertNotice); @Transactional void removeNoticeByDefinitionId(long definitionId);  }