Search in sources :

Example 6 with OnmsDistPoller

use of org.opennms.netmgt.model.OnmsDistPoller in project opennms by OpenNMS.

the class TrapSinkModuleTest method testEqualsAndHashCode.

@Test
public void testEqualsAndHashCode() throws Exception {
    SinkModule<Message, Message> mockModule = Mockito.mock(SinkModule.class);
    Mockito.when(mockModule.getId()).thenReturn("id");
    OnmsDistPoller distPollerMock = Mockito.mock(OnmsDistPoller.class);
    TrapdConfig config = new TrapdConfigBean();
    final TrapSinkModule module = new TrapSinkModule(config, distPollerMock);
    Assert.assertEquals(module, module);
    Assert.assertEquals(module.hashCode(), module.hashCode());
    final TrapSinkModule other = new TrapSinkModule(config, distPollerMock);
    Assert.assertEquals(module, other);
    Assert.assertEquals(module.hashCode(), other.hashCode());
    Assert.assertNotEquals(module, mockModule);
    Assert.assertNotEquals(module.hashCode(), mockModule.hashCode());
}
Also used : Message(org.opennms.core.ipc.sink.api.Message) OnmsDistPoller(org.opennms.netmgt.model.OnmsDistPoller) TrapdConfig(org.opennms.netmgt.config.TrapdConfig) Test(org.junit.Test)

Example 7 with OnmsDistPoller

use of org.opennms.netmgt.model.OnmsDistPoller in project opennms by OpenNMS.

the class ProvisionerIT method setUp.

@Before
public void setUp() throws Exception {
    if (m_distPollerDao.findAll().size() == 0) {
        OnmsDistPoller distPoller = new OnmsDistPoller(DistPollerDao.DEFAULT_DIST_POLLER_ID);
        distPoller.setLabel("localhost");
        distPoller.setLocation(MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID);
        distPoller.setType(OnmsMonitoringSystem.TYPE_OPENNMS);
        m_distPollerDao.save(distPoller);
    }
    SnmpPeerFactory.setInstance(m_snmpPeerFactory);
    assertTrue(m_snmpPeerFactory instanceof ProxySnmpAgentConfigFactory);
    // ensure this property is unset for tests and set it only in tests that need it
    System.getProperties().remove("org.opennms.provisiond.enableDeletionOfRequisitionedEntities");
    m_eventAnticipator = m_mockEventIpcManager.getEventAnticipator();
    m_provisioner.start();
    m_foreignSource = new ForeignSource();
    m_foreignSource.setName("imported:");
    m_foreignSource.setScanInterval(Duration.standardDays(1));
    final PluginConfig policy = new PluginConfig("setCategory", NodeCategorySettingPolicy.class.getName());
    policy.addParameter("category", "TestCategory");
    policy.addParameter("label", "localhost");
    m_foreignSource.addPolicy(policy);
    m_foreignSourceRepository = new MockForeignSourceRepository();
    m_foreignSourceRepository.save(m_foreignSource);
    final ForeignSource emptyForeignSource = new ForeignSource();
    emptyForeignSource.setName("empty");
    emptyForeignSource.setScanInterval(Duration.standardDays(1));
    m_foreignSourceRepository.save(emptyForeignSource);
    final ForeignSource snmpForeignSource = new ForeignSource();
    snmpForeignSource.setName("snmp");
    snmpForeignSource.setScanInterval(Duration.standardDays(1));
    final PluginConfig snmpDetector = new PluginConfig("SNMP", SnmpDetector.class.getName());
    snmpForeignSource.addDetector(snmpDetector);
    m_foreignSourceRepository.save(snmpForeignSource);
    m_foreignSourceRepository.flush();
    m_provisionService.setForeignSourceRepository(m_foreignSourceRepository);
    // make sure node scan scheduler is running initially
    getScanExecutor().resume();
    getScheduledExecutor().pause();
}
Also used : PluginConfig(org.opennms.netmgt.provision.persist.foreignsource.PluginConfig) ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource) NodeCategorySettingPolicy(org.opennms.netmgt.provision.persist.policies.NodeCategorySettingPolicy) OnmsDistPoller(org.opennms.netmgt.model.OnmsDistPoller) SnmpDetector(org.opennms.netmgt.provision.detector.snmp.SnmpDetector) ProxySnmpAgentConfigFactory(org.opennms.core.test.snmp.ProxySnmpAgentConfigFactory) MockForeignSourceRepository(org.opennms.netmgt.provision.persist.MockForeignSourceRepository) Before(org.junit.Before)

Example 8 with OnmsDistPoller

use of org.opennms.netmgt.model.OnmsDistPoller in project opennms by OpenNMS.

the class BlueprintDistPollerDaoMinionIT method testDistPollerDao.

@Test
public void testDistPollerDao() throws Exception {
    DistPollerDao dao = getOsgiService(DistPollerDao.class);
    assertEquals(1, dao.countAll());
    // Test get()
    OnmsDistPoller poller = dao.get(DistPollerDao.DEFAULT_DIST_POLLER_ID);
    assertNotNull(poller);
    assertEquals(DistPollerDao.DEFAULT_DIST_POLLER_ID, poller.getId());
    assertEquals(DistPollerDao.DEFAULT_DIST_POLLER_ID, poller.getLabel());
    assertEquals(LOCATION, poller.getLocation());
    assertEquals(OnmsMonitoringSystem.TYPE_MINION, poller.getType());
    // Test whoami()
    poller = dao.whoami();
    assertNotNull(poller);
    assertEquals(DistPollerDao.DEFAULT_DIST_POLLER_ID, poller.getId());
    assertEquals(DistPollerDao.DEFAULT_DIST_POLLER_ID, poller.getLabel());
    assertEquals(LOCATION, poller.getLocation());
    assertEquals(OnmsMonitoringSystem.TYPE_MINION, poller.getType());
}
Also used : DistPollerDao(org.opennms.netmgt.dao.api.DistPollerDao) OnmsDistPoller(org.opennms.netmgt.model.OnmsDistPoller) Test(org.junit.Test) CamelBlueprintTest(org.opennms.core.test.camel.CamelBlueprintTest)

Example 9 with OnmsDistPoller

use of org.opennms.netmgt.model.OnmsDistPoller in project opennms by OpenNMS.

the class MockDistPollerDao method whoami.

@Override
public OnmsDistPoller whoami() {
    final OnmsDistPoller defaultDistPoller = get(DEFAULT_DIST_POLLER_ID);
    if (defaultDistPoller != null) {
        return defaultDistPoller;
    }
    final OnmsDistPoller whoami = new OnmsDistPoller();
    whoami.setId(DEFAULT_DIST_POLLER_ID);
    whoami.setLabel("localhost");
    whoami.setLocation(MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID);
    return whoami;
}
Also used : OnmsDistPoller(org.opennms.netmgt.model.OnmsDistPoller)

Example 10 with OnmsDistPoller

use of org.opennms.netmgt.model.OnmsDistPoller in project opennms by OpenNMS.

the class DistPollerDaoIT method testCreate.

@Test
@Transactional
public void testCreate() {
    OnmsDistPoller distPoller = new OnmsDistPoller("otherpoller");
    distPoller.setLabel("otherpoller");
    distPoller.setLocation(MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID);
    distPoller.setType(OnmsMonitoringSystem.TYPE_OPENNMS);
    getDistPollerDao().save(distPoller);
}
Also used : OnmsDistPoller(org.opennms.netmgt.model.OnmsDistPoller) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

OnmsDistPoller (org.opennms.netmgt.model.OnmsDistPoller)11 Test (org.junit.Test)6 OnmsEvent (org.opennms.netmgt.model.OnmsEvent)4 Transactional (org.springframework.transaction.annotation.Transactional)4 Before (org.junit.Before)3 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)3 Date (java.util.Date)2 JUnitTemporaryDatabase (org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)2 AlarmDao (org.opennms.netmgt.dao.api.AlarmDao)2 MockForeignSourceRepository (org.opennms.netmgt.provision.persist.MockForeignSourceRepository)2 ForeignSource (org.opennms.netmgt.provision.persist.foreignsource.ForeignSource)2 PluginConfig (org.opennms.netmgt.provision.persist.foreignsource.PluginConfig)2 ArrayList (java.util.ArrayList)1 Message (org.opennms.core.ipc.sink.api.Message)1 CamelBlueprintTest (org.opennms.core.test.camel.CamelBlueprintTest)1 ProxySnmpAgentConfigFactory (org.opennms.core.test.snmp.ProxySnmpAgentConfigFactory)1 Criteria (org.opennms.features.topology.api.topo.Criteria)1 SearchCriteria (org.opennms.features.topology.api.topo.SearchCriteria)1 SearchResult (org.opennms.features.topology.api.topo.SearchResult)1 AlarmProvider (org.opennms.features.topology.app.internal.AlarmProvider)1