use of org.opennms.netmgt.collection.support.ObjectNameStorageStrategy in project opennms by OpenNMS.
the class ObjectNameStorageStrategyTest method testSetEmptyParameters.
@Test(expected = IllegalArgumentException.class)
public void testSetEmptyParameters() {
List<org.opennms.netmgt.collection.api.Parameter> params = new ArrayList<>();
ObjectNameStorageStrategy instance = new ObjectNameStorageStrategy();
instance.setParameters(params);
}
use of org.opennms.netmgt.collection.support.ObjectNameStorageStrategy in project opennms by OpenNMS.
the class ObjectNameStorageStrategyTest method testQuotedKeyValues.
@Test
public void testQuotedKeyValues() {
ResourcePath parentResource = ResourcePath.get("1");
CollectionResource resource = new MockCollectionResource(parentResource, "d:k1=\"ab\",k2=\"cd\",k3=\"v3\"", "");
List<org.opennms.netmgt.collection.api.Parameter> params = new ArrayList<>();
Parameter p = new Parameter("index-format", "${domain}-${k1}-${k2}-${k3}");
params.add(p);
ObjectNameStorageStrategy instance = new ObjectNameStorageStrategy();
instance.setParameters(params);
String expResult = "d-ab-cd-v3";
String result = instance.getResourceNameFromIndex(resource);
assertEquals(expResult, result);
}
use of org.opennms.netmgt.collection.support.ObjectNameStorageStrategy in project opennms by OpenNMS.
the class ObjectNameStorageStrategyTest method testGetResourceNameFromIndexCleanOutput.
@Test
public void testGetResourceNameFromIndexCleanOutput() {
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<>();
params.add(new Parameter("index-format", "${ObjectName.toString()}"));
params.add(new Parameter("clean-output", "true"));
ObjectNameStorageStrategy instance = new ObjectNameStorageStrategy();
instance.setParameters(params);
String expResult = "java.lang_typeMemoryPool,nameSurvivor_Space";
String result = instance.getResourceNameFromIndex(resource);
assertEquals(expResult, result);
}
use of org.opennms.netmgt.collection.support.ObjectNameStorageStrategy in project opennms by OpenNMS.
the class ObjectNameStorageStrategyTest method testGetResourceNameFromIndex.
@Test
public void testGetResourceNameFromIndex() {
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<>();
params.add(new Parameter("index-format", "${ObjectName.toString()}"));
ObjectNameStorageStrategy instance = new ObjectNameStorageStrategy();
instance.setParameters(params);
String expResult = "java.lang:type=MemoryPool,name=Survivor Space";
String result = instance.getResourceNameFromIndex(resource);
assertEquals(expResult, result);
}
use of org.opennms.netmgt.collection.support.ObjectNameStorageStrategy in project opennms by OpenNMS.
the class ObjectNameStorageStrategyTest method testSetNullParameters.
@Test(expected = IllegalArgumentException.class)
public void testSetNullParameters() {
List<org.opennms.netmgt.collection.api.Parameter> params = null;
ObjectNameStorageStrategy instance = new ObjectNameStorageStrategy();
instance.setParameters(params);
}
Aggregations