Search in sources :

Example 6 with IpInterfaceDao

use of org.opennms.netmgt.dao.api.IpInterfaceDao in project opennms by OpenNMS.

the class CollectableServiceTest method createCollectableService.

private void createCollectableService() throws CollectionInitializationException, IOException {
    // Mock it all!
    OnmsIpInterface iface = mock(OnmsIpInterface.class, RETURNS_DEEP_STUBS);
    IpInterfaceDao ifaceDao = mock(IpInterfaceDao.class);
    spec = mock(CollectionSpecification.class);
    scheduler = mock(Scheduler.class);
    SchedulingCompletedFlag schedulingCompletedFlag = mock(SchedulingCompletedFlag.class);
    PlatformTransactionManager transMgr = mock(PlatformTransactionManager.class);
    RrdPersisterFactory persisterFactory = new RrdPersisterFactory();
    persisterFactory.setRrdStrategy(rrdStrategy);
    ResourceStorageDao resourceStorageDao = mock(ResourceStorageDao.class);
    // Disable thresholding
    Map<String, Object> paramsMap = new HashMap<>();
    paramsMap.put("thresholding-enabled", Boolean.FALSE.toString());
    ServiceParameters params = new ServiceParameters(paramsMap);
    when(iface.getNode().getId()).thenReturn(1);
    when(spec.getServiceParameters()).thenReturn(params);
    when(spec.getRrdRepository(any())).thenReturn(createRrdRepository());
    when(ifaceDao.load(any())).thenReturn(iface);
    when(iface.getIpAddress()).thenReturn(InetAddrUtils.getLocalHostAddress());
    service = new CollectableService(iface, ifaceDao, spec, scheduler, schedulingCompletedFlag, transMgr, persisterFactory, resourceStorageDao);
}
Also used : ResourceStorageDao(org.opennms.netmgt.dao.api.ResourceStorageDao) HashMap(java.util.HashMap) Scheduler(org.opennms.netmgt.scheduler.Scheduler) CollectionSpecification(org.opennms.netmgt.collection.core.CollectionSpecification) PlatformTransactionManager(org.springframework.transaction.PlatformTransactionManager) IpInterfaceDao(org.opennms.netmgt.dao.api.IpInterfaceDao) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) RrdPersisterFactory(org.opennms.netmgt.collection.persistence.rrd.RrdPersisterFactory) ServiceParameters(org.opennms.netmgt.collection.api.ServiceParameters) SchedulingCompletedFlag(org.opennms.netmgt.collectd.Collectd.SchedulingCompletedFlag)

Aggregations

IpInterfaceDao (org.opennms.netmgt.dao.api.IpInterfaceDao)6 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)6 PlatformTransactionManager (org.springframework.transaction.PlatformTransactionManager)6 Test (org.junit.Test)4 OnmsNode (org.opennms.netmgt.model.OnmsNode)4 HashMap (java.util.HashMap)3 MockPlatformTransactionManager (org.opennms.core.test.MockPlatformTransactionManager)3 CollectionAgent (org.opennms.netmgt.collection.api.CollectionAgent)3 DefaultCollectionAgent (org.opennms.netmgt.collection.core.DefaultCollectionAgent)3 CollectionSet (org.opennms.netmgt.collection.api.CollectionSet)2 ServiceCollector (org.opennms.netmgt.collection.api.ServiceCollector)2 ServiceParameters (org.opennms.netmgt.collection.api.ServiceParameters)2 TreeMap (java.util.TreeMap)1 Before (org.junit.Before)1 MockRpcClientFactory (org.opennms.core.rpc.mock.MockRpcClientFactory)1 SchedulingCompletedFlag (org.opennms.netmgt.collectd.Collectd.SchedulingCompletedFlag)1 AttributeGroupType (org.opennms.netmgt.collection.api.AttributeGroupType)1 CollectionSpecification (org.opennms.netmgt.collection.core.CollectionSpecification)1 CollectionAgentDTO (org.opennms.netmgt.collection.dto.CollectionAgentDTO)1 RrdPersisterFactory (org.opennms.netmgt.collection.persistence.rrd.RrdPersisterFactory)1