@Test public void testFindNoticeByUuid() throws Exception { List<AlertDefinitionEntity> definitions = createDefinitions(); AlertDefinitionEntity definition = definitions.get(0); AlertHistoryEntity history = new AlertHistoryEntity(); history.setServiceName(definition.getServiceName()); history.setClusterId(m_cluster.getClusterId()); history.setAlertDefinition(definition); history.setAlertLabel("Label"); history.setAlertState(AlertState.OK); history.setAlertText("Alert Text"); history.setAlertTimestamp(System.currentTimeMillis()); m_alertsDao.create(history); AlertTargetEntity target = m_helper.createAlertTarget(); AlertNoticeEntity notice = new AlertNoticeEntity(); notice.setUuid(UUID.randomUUID().toString()); notice.setAlertTarget(target); notice.setAlertHistory(history); notice.setNotifyState(NotificationState.PENDING); m_dao.create(notice); AlertNoticeEntity actual = m_dao.findNoticeByUuid(notice.getUuid()); assertEquals(notice.getNotificationId(), actual.getNotificationId()); assertNull(m_dao.findNoticeByUuid("DEADBEEF")); }
@RequiresSession public AlertNoticeEntity findNoticeByUuid(String uuid) { TypedQuery<AlertNoticeEntity> query = entityManagerProvider.get().createNamedQuery( "AlertNoticeEntity.findByUuid", AlertNoticeEntity.class); query.setParameter("uuid", uuid); return daoUtils.selectOne(query); }
AlertDispatchDAO { @RequiresSession public AlertNoticeEntity findNoticeByUuid(String uuid) { TypedQuery<AlertNoticeEntity> query = entityManagerProvider.get().createNamedQuery( "AlertNoticeEntity.findByUuid", AlertNoticeEntity.class); query.setParameter("uuid", uuid); return daoUtils.selectOne(query); } }
AlertDispatchDAO { @RequiresSession public AlertNoticeEntity findNoticeByUuid(String uuid) { TypedQuery<AlertNoticeEntity> query = entityManagerProvider.get().createNamedQuery( "AlertNoticeEntity.findByUuid", AlertNoticeEntity.class); query.setParameter("uuid", uuid); return daoUtils.selectOne(query); }  }
AlertDispatchDAO { @RequiresSession public AlertNoticeEntity findNoticeByUuid(String uuid) { TypedQuery<AlertNoticeEntity> query = entityManagerProvider.get().createNamedQuery( "AlertNoticeEntity.findByUuid", AlertNoticeEntity.class); query.setParameter("uuid", uuid); return daoUtils.selectOne(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 AlertNoticeEntity findNoticeByUuid(String uuid) { TypedQuery<AlertNoticeEntity> query = entityManagerProvider.get().createNamedQuery( "AlertNoticeEntity.findByUuid", AlertNoticeEntity.class); query.setParameter("uuid", uuid); return daoUtils.selectOne(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);  }