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());
}
Aggregations