Search in sources :

Example 1 with ObjectNameStorageStrategy

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);
}
Also used : ObjectNameStorageStrategy(org.opennms.netmgt.collection.support.ObjectNameStorageStrategy) ArrayList(java.util.ArrayList) Parameter(org.opennms.netmgt.config.datacollection.Parameter) Test(org.junit.Test)

Example 2 with ObjectNameStorageStrategy

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);
}
Also used : ObjectNameStorageStrategy(org.opennms.netmgt.collection.support.ObjectNameStorageStrategy) CollectionResource(org.opennms.netmgt.collection.api.CollectionResource) ResourcePath(org.opennms.netmgt.model.ResourcePath) ArrayList(java.util.ArrayList) Parameter(org.opennms.netmgt.config.datacollection.Parameter) Test(org.junit.Test)

Example 3 with ObjectNameStorageStrategy

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);
}
Also used : ObjectNameStorageStrategy(org.opennms.netmgt.collection.support.ObjectNameStorageStrategy) CollectionResource(org.opennms.netmgt.collection.api.CollectionResource) ResourcePath(org.opennms.netmgt.model.ResourcePath) ArrayList(java.util.ArrayList) Parameter(org.opennms.netmgt.config.datacollection.Parameter) Test(org.junit.Test)

Example 4 with ObjectNameStorageStrategy

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);
}
Also used : ObjectNameStorageStrategy(org.opennms.netmgt.collection.support.ObjectNameStorageStrategy) CollectionResource(org.opennms.netmgt.collection.api.CollectionResource) ResourcePath(org.opennms.netmgt.model.ResourcePath) ArrayList(java.util.ArrayList) Parameter(org.opennms.netmgt.config.datacollection.Parameter) Test(org.junit.Test)

Example 5 with ObjectNameStorageStrategy

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);
}
Also used : ObjectNameStorageStrategy(org.opennms.netmgt.collection.support.ObjectNameStorageStrategy) Parameter(org.opennms.netmgt.config.datacollection.Parameter) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 ObjectNameStorageStrategy (org.opennms.netmgt.collection.support.ObjectNameStorageStrategy)8 Parameter (org.opennms.netmgt.config.datacollection.Parameter)8 ArrayList (java.util.ArrayList)7 CollectionResource (org.opennms.netmgt.collection.api.CollectionResource)4 ResourcePath (org.opennms.netmgt.model.ResourcePath)4