AlertsDAO implements Cleanable { @RequiresSession public List<AlertCurrentEntity> findCurrentByService(long clusterId, String serviceName) { TypedQuery<AlertCurrentEntity> query = m_entityManagerProvider.get().createNamedQuery( "AlertCurrentEntity.findByService", AlertCurrentEntity.class); query.setParameter("clusterId", clusterId); query.setParameter("serviceName", serviceName); query.setParameter("inlist", EnumSet.of(Scope.ANY, Scope.SERVICE)); List<AlertCurrentEntity> alerts = m_daoUtils.selectList(query); if (m_configuration.isAlertCacheEnabled()) { alerts = supplementWithCachedAlerts(alerts); } return alerts; } @Inject  AlertsDAO(Configuration configuration); @RequiresSession AlertHistoryEntity findById(long alertId); @RequiresSession List<AlertHistoryEntity> findAll(); @RequiresSession List<AlertHistoryEntity> findAll(long clusterId); @RequiresSession List<AlertHistoryEntity> findAll(long clusterId,
      List<AlertState> alertStates); @RequiresSession List<AlertHistoryEntity> findAll(long clusterId, Date startDate,
      Date endDate); @RequiresSession List<AlertHistoryEntity> findAll(AlertHistoryRequest request); @Transactional List<AlertCurrentEntity> findAll(AlertCurrentRequest request); int getCount(Predicate predicate); @RequiresSession List<AlertCurrentEntity> findCurrent(); @RequiresSession AlertCurrentEntity findCurrentById(long alertId); @RequiresSession List<AlertCurrentEntity> findCurrentByDefinitionId(long definitionId); @RequiresSession List<AlertCurrentEntity> findCurrentByCluster(long clusterId); @RequiresSession AlertSummaryDTO findCurrentCounts(long clusterId, String serviceName, String hostName); @RequiresSession Map<String, AlertSummaryDTO> findCurrentPerHostCounts(long clusterId); @RequiresSession AlertHostSummaryDTO findCurrentHostCounts(long clusterId); @RequiresSession List<AlertCurrentEntity> findCurrentByService(long clusterId,
      String serviceName); AlertCurrentEntity findCurrentByHostAndName(long clusterId, String hostName,
      String alertName); @Transactional void removeByDefinitionId(long definitionId); @Transactional int removeCurrentByHistoryId(long historyId); @Transactional int removeCurrentDisabledAlerts(); @Transactional int removeCurrentByService(long clusterId, String serviceName); @Transactional int removeCurrentByHost(String hostName); @Transactional int removeCurrentByServiceComponentHost(long clusterId, String serviceName,
      String componentName, String hostName); @Transactional void create(AlertHistoryEntity alert); @Transactional void refresh(AlertHistoryEntity alert); @Transactional AlertHistoryEntity merge(AlertHistoryEntity alert); @Transactional void remove(AlertHistoryEntity alert); @Transactional void create(AlertCurrentEntity alert); @Transactional void refresh(AlertCurrentEntity alert); @Transactional AlertCurrentEntity merge(AlertCurrentEntity alert); AlertCurrentEntity merge(AlertCurrentEntity alert, boolean updateCacheOnly); @Transactional void remove(AlertCurrentEntity alert); @RequiresSession AlertSummaryDTO findAggregateCounts(long clusterId, String alertName); AlertCurrentEntity findCurrentByNameNoHost(long clusterId, String alertName); @Transactional void flushCachedEntitiesToJPA(); @Transactional @Override long cleanup(TimeBasedCleanupPolicy policy);  }
@Test public void testFindCurrentByService() { List<AlertCurrentEntity> currentAlerts = m_dao.findCurrent(); int currentAlertExpectedCount = currentAlerts.size(); assertEquals(5, currentAlertExpectedCount); AlertCurrentEntity current = currentAlerts.get(0); AlertHistoryEntity history = current.getAlertHistory(); assertNotNull(history); currentAlerts = m_dao.findCurrentByService(m_cluster.getClusterId(), history.getServiceName()); assertNotNull(currentAlerts); assertEquals(currentAlertExpectedCount, currentAlerts.size()); currentAlerts = m_dao.findCurrentByService(m_cluster.getClusterId(), "foo"); assertNotNull(currentAlerts); assertEquals(0, currentAlerts.size()); }