Search in sources :

Example 6 with ResourceType

use of org.opennms.netmgt.collection.api.ResourceType in project opennms by OpenNMS.

the class JMXCollectorTest method collectJvmMbeansWithWildCard.

@Test
public void collectJvmMbeansWithWildCard() {
    final Map<String, Object> parms = new HashMap<String, Object>();
    parms.put(ParameterName.COLLECTION.toString(), "collectBasicJvmValues");
    parms.putAll(jmxCollector.getRuntimeAttributes(collectionAgent, parms));
    CollectionSet collectionSet = jmxCollector.collect(collectionAgent, parms);
    assertEquals("Collection of jvm values failed", CollectionStatus.SUCCEEDED, collectionSet.getStatus());
    ResourceType rt = mock(ResourceType.class, RETURNS_DEEP_STUBS);
    when(rt.getName()).thenReturn("jvm");
    when(rt.getStorageStrategy().getClazz()).thenReturn(MockStorageStrategy.class.getCanonicalName());
    when(rt.getPersistenceSelectorStrategy().getClazz()).thenReturn(MockPersistenceSelectorStrategy.class.getCanonicalName());
    ResourceTypeMapper.getInstance().setResourceTypeMapper((name) -> rt);
    Map<String, Map<String, CollectionAttribute>> attributesByNameByGroup = CollectionSetUtils.getAttributesByNameByGroup(collectionSet);
    // 2 attributes from the defined Numeric attributes and 3 string
    // attributes, domain, type, name
    assertEquals(5, attributesByNameByGroup.get("java_lang_type_GarbageCollector_name__").size());
    Map<String, CollectionAttribute> attributes = attributesByNameByGroup.get("java_lang_type_GarbageCollector_name__");
    CollectionAttribute attribute1 = attributes.get("domain");
    CollectionAttribute attribute2 = attributes.get("type");
    assertEquals("java.lang", attribute1.getStringValue());
    assertEquals("GarbageCollector", attribute2.getStringValue());
}
Also used : CollectionAttribute(org.opennms.netmgt.collection.api.CollectionAttribute) HashMap(java.util.HashMap) ResourceType(org.opennms.netmgt.collection.api.ResourceType) HashMap(java.util.HashMap) Map(java.util.Map) CollectionSet(org.opennms.netmgt.collection.api.CollectionSet) JmxTest(org.opennms.netmgt.collectd.jmxhelper.JmxTest) Test(org.junit.Test)

Aggregations

ResourceType (org.opennms.netmgt.collection.api.ResourceType)6 GenericTypeResource (org.opennms.netmgt.collection.support.builder.GenericTypeResource)4 DeferredGenericTypeResource (org.opennms.netmgt.collection.support.builder.DeferredGenericTypeResource)3 NodeLevelResource (org.opennms.netmgt.collection.support.builder.NodeLevelResource)3 Date (java.util.Date)2 CollectionAgent (org.opennms.netmgt.collection.api.CollectionAgent)2 CollectionSet (org.opennms.netmgt.collection.api.CollectionSet)2 CollectionSetBuilder (org.opennms.netmgt.collection.support.builder.CollectionSetBuilder)2 InterfaceLevelResource (org.opennms.netmgt.collection.support.builder.InterfaceLevelResource)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Test (org.junit.Test)1 Parameters (org.junit.runners.Parameterized.Parameters)1 JmxTest (org.opennms.netmgt.collectd.jmxhelper.JmxTest)1 CollectionAttribute (org.opennms.netmgt.collection.api.CollectionAttribute)1 CollectionResource (org.opennms.netmgt.collection.api.CollectionResource)1 ResourcePath (org.opennms.netmgt.model.ResourcePath)1