Ejemplo n.º 1
0
  public void setUpMock() {

    EasyMock.expect(m_nodeDao.getAllLabelsById());
    EasyMock.expectLastCall().andReturn(getNodeLabelsById()).anyTimes();

    for (int i = 1; i < 9; i++) {
      EasyMock.expect(m_nodeDao.get(i)).andReturn(getNode(i)).anyTimes();
      EasyMock.expect(m_snmpInterfaceDao.findByNodeIdAndIfIndex(i, -1)).andReturn(null).anyTimes();
      EasyMock.expect(m_ipInterfaceDao.findPrimaryInterfaceByNodeId(i))
          .andReturn(getNode(i).getPrimaryInterface())
          .anyTimes();
      EasyMock.expect(m_ipInterfaceDao.findByNodeId(i))
          .andReturn(getList(getNode(i).getIpInterfaces()))
          .anyTimes();
    }

    EasyMock.replay(m_nodeDao);
    EasyMock.replay(m_snmpInterfaceDao);
    EasyMock.replay(m_ipInterfaceDao);
  }
Ejemplo n.º 2
0
  public void resetDatabase() {
    LOG.debug("==== DatabasePopulator Reset ====");
    for (final DataLinkInterface iface : m_dataLinkInterfaceDao.findAll()) {
      m_dataLinkInterfaceDao.delete(iface);
    }
    for (final OnmsOutage outage : m_outageDao.findAll()) {
      m_outageDao.delete(outage);
    }
    for (final OnmsUserNotification not : m_userNotificationDao.findAll()) {
      m_userNotificationDao.delete(not);
    }
    for (final OnmsNotification not : m_notificationDao.findAll()) {
      m_notificationDao.delete(not);
    }
    for (final OnmsAlarm alarm : m_alarmDao.findAll()) {
      m_alarmDao.delete(alarm);
    }
    for (final OnmsEvent event : m_eventDao.findAll()) {
      m_eventDao.delete(event);
    }
    for (final OnmsSnmpInterface iface : m_snmpInterfaceDao.findAll()) {
      m_snmpInterfaceDao.delete(iface);
    }
    for (final OnmsIpInterface iface : m_ipInterfaceDao.findAll()) {
      m_ipInterfaceDao.delete(iface);
    }
    for (final OnmsNode node : m_nodeDao.findAll()) {
      m_nodeDao.delete(node);
    }
    for (final OnmsServiceType service : m_serviceTypeDao.findAll()) {
      m_serviceTypeDao.delete(service);
    }

    LOG.debug("= DatabasePopulatorExtension Reset Starting =");
    for (Extension eachExtension : extensions) {
      DaoSupport daoSupport = eachExtension.getDaoSupport();
      OnmsDao dao =
          daoSupport != null && daoSupport.getDaoClass() != null
              ? lookupDao(daoSupport.getDaoClass())
              : null;

      eachExtension.onShutdown(this, dao);
      if (dao != null) {
        dao.flush();
      }
    }
    LOG.debug("= DatabasePopulatorExtension Reset Finished =");

    m_dataLinkInterfaceDao.flush();
    m_outageDao.flush();
    m_userNotificationDao.flush();
    m_notificationDao.flush();
    m_alarmDao.flush();
    m_eventDao.flush();
    m_snmpInterfaceDao.flush();
    m_ipInterfaceDao.flush();
    m_nodeDao.flush();
    m_serviceTypeDao.flush();

    LOG.debug("==== DatabasePopulator Reset Finished ====");
  }