コード例 #1
0
 @Test
 @Transactional
 public void testSortOnNodeLabel() {
   Criteria criteria = new Criteria(OnmsAlarm.class);
   criteria.setAliases(Arrays.asList(new Alias[] {new Alias("node", "node", JoinType.LEFT_JOIN)}));
   criteria.setOrders(Arrays.asList(new Order[] {Order.asc("node.label")}));
   m_alarmDao.findMatching(criteria);
 }
コード例 #2
0
  @Test
  @Transactional
  public void testSave() {
    OnmsEvent event = new OnmsEvent();
    event.setEventLog("Y");
    event.setEventDisplay("Y");
    event.setEventCreateTime(new Date());
    event.setDistPoller(m_distPollerDao.load("localhost"));
    event.setEventTime(new Date());
    event.setEventSeverity(new Integer(7));
    event.setEventUei("uei://org/opennms/test/EventDaoTest");
    event.setEventSource("test");
    m_eventDao.save(event);

    OnmsNode node = m_nodeDao.findAll().iterator().next();

    OnmsAlarm alarm = new OnmsAlarm();

    alarm.setNode(node);
    alarm.setUei(event.getEventUei());
    alarm.setSeverityId(event.getEventSeverity());
    alarm.setFirstEventTime(event.getEventTime());
    alarm.setLastEvent(event);
    alarm.setCounter(1);
    alarm.setDistPoller(m_distPollerDao.load("localhost"));

    m_alarmDao.save(alarm);
    // It works we're so smart! hehe

    OnmsAlarm newAlarm = m_alarmDao.load(alarm.getId());
    assertEquals("uei://org/opennms/test/EventDaoTest", newAlarm.getUei());
    assertEquals(alarm.getLastEvent().getId(), newAlarm.getLastEvent().getId());

    Collection<OnmsAlarm> alarms;
    Criteria criteria = new Criteria(OnmsAlarm.class);
    criteria.addRestriction(new EqRestriction("node.id", node.getId()));
    alarms = m_alarmDao.findMatching(criteria);
    assertEquals(1, alarms.size());
    newAlarm = alarms.iterator().next();
    assertEquals("uei://org/opennms/test/EventDaoTest", newAlarm.getUei());
    assertEquals(alarm.getLastEvent().getId(), newAlarm.getLastEvent().getId());
  }
コード例 #3
0
  @Test
  public void testGetOspfLinkStatusDown() {
    EasyMock.expect(
            m_alarmDao.findMatching(EasyMock.anyObject(org.opennms.core.criteria.Criteria.class)))
        .andReturn(createDownAlarm());
    EasyMock.expect(
            m_ospfLinkDao.findMatching(EasyMock.<org.opennms.core.criteria.Criteria>anyObject()))
        .andReturn(createOspfLinks());

    EasyMock.replay(m_alarmDao, m_ospfLinkDao);

    List<EdgeRef> edges = createEdges();
    Map<EdgeRef, Status> statusMap =
        m_statusProvider.getStatusForEdges(m_edgeProvider, edges, new Criteria[0]);

    assertEquals(1, statusMap.size());
    assertEquals(edges.get(0), new ArrayList<EdgeRef>(statusMap.keySet()).get(0));
    Status status = statusMap.get(edges.get(0));
    assertEquals("down", status.computeStatus());
  }