Search in sources :

Example 1 with WSManDataCollectionConfigDao

use of org.opennms.netmgt.dao.WSManDataCollectionConfigDao in project opennms by OpenNMS.

the class WSManCollectorComplianceTest method getRequiredBeans.

public Map<String, Object> getRequiredBeans() {
    OnmsNode node = mock(OnmsNode.class, RETURNS_DEEP_STUBS);
    NodeDao nodeDao = mock(NodeDao.class);
    when(nodeDao.get(anyInt())).thenReturn(node);
    Definition agentConfig = new Definition();
    WSManConfigDao wsManConfigDao = mock(WSManConfigDao.class);
    when(wsManConfigDao.getAgentConfig(InetAddrUtils.getLocalHostAddress())).thenReturn(agentConfig);
    WsmanDatacollectionConfig config = new WsmanDatacollectionConfig();
    config.setRrdRepository("target");
    Collection collection = new Collection();
    collection.setRrd(new Rrd());
    WSManDataCollectionConfigDao wsManDataCollectionConfigDao = mock(WSManDataCollectionConfigDao.class);
    when(wsManDataCollectionConfigDao.getCollectionByName(COLLECTION)).thenReturn(collection);
    when(wsManDataCollectionConfigDao.getConfig()).thenReturn(config);
    return new ImmutableMap.Builder<String, Object>().put("nodeDao", nodeDao).put("wsManConfigDao", wsManConfigDao).put("wsManDataCollectionConfigDao", wsManDataCollectionConfigDao).build();
}
Also used : NodeDao(org.opennms.netmgt.dao.api.NodeDao) OnmsNode(org.opennms.netmgt.model.OnmsNode) WsmanDatacollectionConfig(org.opennms.netmgt.config.wsman.WsmanDatacollectionConfig) Rrd(org.opennms.netmgt.config.wsman.Rrd) Definition(org.opennms.netmgt.config.wsman.Definition) Collection(org.opennms.netmgt.config.wsman.Collection) WSManConfigDao(org.opennms.netmgt.dao.WSManConfigDao) WSManDataCollectionConfigDao(org.opennms.netmgt.dao.WSManDataCollectionConfigDao)

Example 2 with WSManDataCollectionConfigDao

use of org.opennms.netmgt.dao.WSManDataCollectionConfigDao in project opennms by OpenNMS.

the class WSManCollectorTest method canSuccesfullyCollectFromGroupWithNoAttributes.

@Test
public void canSuccesfullyCollectFromGroupWithNoAttributes() throws CollectionInitializationException, CollectionException {
    OnmsNode node = mock(OnmsNode.class);
    NodeDao nodeDao = mock(NodeDao.class);
    when(nodeDao.get(0)).thenReturn(node);
    WSManConfigDao configDao = mock(WSManConfigDao.class);
    when(configDao.getAgentConfig(any())).thenReturn(new Definition());
    Collection collection = new Collection();
    WSManDataCollectionConfigDao dataCollectionConfigDao = mock(WSManDataCollectionConfigDao.class);
    when(dataCollectionConfigDao.getCollectionByName("default")).thenReturn(collection);
    WsManCollector collector = new WsManCollector();
    collector.setWSManClientFactory(mock(WSManClientFactory.class));
    collector.setWSManConfigDao(configDao);
    collector.setWSManDataCollectionConfigDao(dataCollectionConfigDao);
    collector.setNodeDao(nodeDao);
    CollectionAgent agent = mock(CollectionAgent.class);
    when(agent.getAddress()).thenReturn(InetAddrUtils.getLocalHostAddress());
    when(agent.getStorageResourcePath()).thenReturn(ResourcePath.get());
    Map<String, Object> collectionParams = Maps.newHashMap();
    collectionParams.put("collection", "default");
    collectionParams.putAll(collector.getRuntimeAttributes(agent, collectionParams));
    CollectionSet collectionSet = collector.collect(agent, collectionParams);
    assertEquals(CollectionStatus.SUCCEEDED, collectionSet.getStatus());
    assertEquals(0, CollectionSetUtils.getAttributesByName(collectionSet).size());
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) Definition(org.opennms.netmgt.config.wsman.Definition) WSManConfigDao(org.opennms.netmgt.dao.WSManConfigDao) WSManClientFactory(org.opennms.core.wsman.WSManClientFactory) CollectionSet(org.opennms.netmgt.collection.api.CollectionSet) NodeDao(org.opennms.netmgt.dao.api.NodeDao) Collection(org.opennms.netmgt.config.wsman.Collection) WSManDataCollectionConfigDao(org.opennms.netmgt.dao.WSManDataCollectionConfigDao) CollectionAgent(org.opennms.netmgt.collection.api.CollectionAgent) Test(org.junit.Test)

Aggregations

Collection (org.opennms.netmgt.config.wsman.Collection)2 Definition (org.opennms.netmgt.config.wsman.Definition)2 WSManConfigDao (org.opennms.netmgt.dao.WSManConfigDao)2 WSManDataCollectionConfigDao (org.opennms.netmgt.dao.WSManDataCollectionConfigDao)2 NodeDao (org.opennms.netmgt.dao.api.NodeDao)2 OnmsNode (org.opennms.netmgt.model.OnmsNode)2 Test (org.junit.Test)1 WSManClientFactory (org.opennms.core.wsman.WSManClientFactory)1 CollectionAgent (org.opennms.netmgt.collection.api.CollectionAgent)1 CollectionSet (org.opennms.netmgt.collection.api.CollectionSet)1 Rrd (org.opennms.netmgt.config.wsman.Rrd)1 WsmanDatacollectionConfig (org.opennms.netmgt.config.wsman.WsmanDatacollectionConfig)1