use of org.opennms.netmgt.collection.support.ObjectNameStorageStrategy in project opennms by OpenNMS.
the class ObjectNameStorageStrategyTest method testGetResourceNameFromIndex2.
@Test
public void testGetResourceNameFromIndex2() {
ResourcePath parentResource = ResourcePath.get("1");
CollectionResource resource = new MockCollectionResource(parentResource, "java.lang:type=MemoryPool,name=Survivor Space", "");
List<org.opennms.netmgt.collection.api.Parameter> params = new ArrayList<>();
Parameter p = new Parameter("index-format", "${domain}");
params.add(p);
ObjectNameStorageStrategy instance = new ObjectNameStorageStrategy();
instance.setParameters(params);
String expResult = "java.lang";
String result = instance.getResourceNameFromIndex(resource);
assertEquals(expResult, result);
params.clear();
p.setValue("${type}");
params.add(p);
instance.setParameters(params);
expResult = "MemoryPool";
result = instance.getResourceNameFromIndex(resource);
assertEquals(expResult, result);
params.clear();
p.setValue("${name}");
params.add(p);
instance.setParameters(params);
expResult = "Survivor Space";
result = instance.getResourceNameFromIndex(resource);
assertEquals(expResult, result);
params.clear();
p.setValue("${domain}:type=${type},name=${name}");
params.add(p);
instance.setParameters(params);
expResult = "java.lang:type=MemoryPool,name=Survivor Space";
result = instance.getResourceNameFromIndex(resource);
assertEquals(expResult, result);
}
use of org.opennms.netmgt.collection.support.ObjectNameStorageStrategy in project opennms by OpenNMS.
the class ObjectNameStorageStrategyTest method testSetValidParameters.
@Test()
public void testSetValidParameters() {
List<org.opennms.netmgt.collection.api.Parameter> params = new ArrayList<>();
params.add(new Parameter("index-format", "${ObjectName.toString()}"));
ObjectNameStorageStrategy instance = new ObjectNameStorageStrategy();
instance.setParameters(params);
}
use of org.opennms.netmgt.collection.support.ObjectNameStorageStrategy in project opennms by OpenNMS.
the class ObjectNameStorageStrategyTest method testSetInvalidParameters.
@Test(expected = IllegalArgumentException.class)
public void testSetInvalidParameters() {
List<org.opennms.netmgt.collection.api.Parameter> params = new ArrayList<>();
params.add(new Parameter("SERVICE", "svc"));
ObjectNameStorageStrategy instance = new ObjectNameStorageStrategy();
instance.setParameters(params);
}
Aggregations