Search in sources :

Example 6 with ObjectNameStorageStrategy

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);
}
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 7 with ObjectNameStorageStrategy

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);
}
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 8 with ObjectNameStorageStrategy

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