use of org.opennms.netmgt.model.OnmsResource in project opennms by OpenNMS.
the class GenericIndexResourceTypeTest method testGetResourceByNodeAndIndexGetLabelIndexWithSubIndexBogusArguments.
@Test
public void testGetResourceByNodeAndIndexGetLabelIndexWithSubIndexBogusArguments() {
GenericIndexResourceType rt = new GenericIndexResourceType(m_resourceStorageDao, "foo", "Foo Resource", "${subIndex(absolutely bogus)}", m_storageStrategy);
touch("snmp", "1", "foo", "1.2.3.4", RRD_FILE_NAME);
m_mocks.replayAll();
OnmsResource resource = rt.getChildByName(getNodeResource(1), "1.2.3.4");
m_mocks.verifyAll();
assertNotNull("resource", resource);
assertEquals("resource label", "${subIndex(absolutely bogus)}", resource.getLabel());
}
use of org.opennms.netmgt.model.OnmsResource in project opennms by OpenNMS.
the class GenericIndexResourceTypeTest method testGetResourceByNodeAndIndexGetLabelIndexWithSubStringOfDynamicLength.
@Test
public void testGetResourceByNodeAndIndexGetLabelIndexWithSubStringOfDynamicLength() {
GenericIndexResourceType rt = new GenericIndexResourceType(m_resourceStorageDao, "foo", "Foo Resource", "Easy as ${subIndex(0, n)}", m_storageStrategy);
touch("snmp", "1", "foo", "5.1.2.3.4.5", RRD_FILE_NAME);
m_mocks.replayAll();
OnmsResource resource = rt.getChildByName(getNodeResource(1), "5.1.2.3.4.5");
m_mocks.verifyAll();
assertNotNull("resource", resource);
assertEquals("resource label", "Easy as 1.2.3.4.5", resource.getLabel());
}
use of org.opennms.netmgt.model.OnmsResource in project opennms by OpenNMS.
the class GenericIndexResourceTypeTest method testGetResourceByNodeAndIndexGetLabelIndexWithSubStringAndTwoDisplaySubStringsOfDynamicLengthAndSubStringToEnd.
@Test
public void testGetResourceByNodeAndIndexGetLabelIndexWithSubStringAndTwoDisplaySubStringsOfDynamicLengthAndSubStringToEnd() {
GenericIndexResourceType rt = new GenericIndexResourceType(m_resourceStorageDao, "foo", "Foo Resource", "Easy as ${subIndex(0, 1)} piece of ${string(subIndex(1, n))} or just under ${string(subIndex(n, n))} pieces of ${subIndex(n)}", m_storageStrategy);
touch("snmp", "1", "foo", "1.3.112.105.101.2.80.105.3.1.4.1.5.9", RRD_FILE_NAME);
m_mocks.replayAll();
OnmsResource resource = rt.getChildByName(getNodeResource(1), "1.3.112.105.101.2.80.105.3.1.4.1.5.9");
m_mocks.verifyAll();
assertNotNull("resource", resource);
assertEquals("resource label", "Easy as 1 piece of pie or just under Pi pieces of 3.1.4.1.5.9", resource.getLabel());
}
use of org.opennms.netmgt.model.OnmsResource in project opennms by OpenNMS.
the class GenericIndexResourceTypeTest method testGetResourceByNodeAndIndexGetLabelIndexWithSubIndexEnding.
@Test
public void testGetResourceByNodeAndIndexGetLabelIndexWithSubIndexEnding() {
GenericIndexResourceType rt = new GenericIndexResourceType(m_resourceStorageDao, "foo", "Foo Resource", "${subIndex(0, 3)}", m_storageStrategy);
touch("snmp", "1", "foo", "1.2.3.4", RRD_FILE_NAME);
m_mocks.replayAll();
OnmsResource resource = rt.getChildByName(getNodeResource(1), "1.2.3.4");
m_mocks.verifyAll();
assertNotNull("resource", resource);
assertEquals("resource label", "1.2.3", resource.getLabel());
}
use of org.opennms.netmgt.model.OnmsResource in project opennms by OpenNMS.
the class GenericIndexResourceTypeTest method testGetResourceByNodeAndIndexGetLabelStringAttribute.
@Test
public void testGetResourceByNodeAndIndexGetLabelStringAttribute() throws Exception {
GenericIndexResourceType rt = new GenericIndexResourceType(m_resourceStorageDao, "foo", "Foo Resource", "${stringAttribute}", m_storageStrategy);
File rrd = touch("snmp", "1", "foo", "1", RRD_FILE_NAME);
m_fileAnticipator.tempFile(rrd.getParentFile(), RrdResourceAttributeUtils.STRINGS_PROPERTIES_FILE_NAME, "stringAttribute=hello!!!!");
m_mocks.replayAll();
OnmsResource resource = rt.getChildByName(getNodeResource(1), "1");
m_mocks.verifyAll();
assertNotNull("resource", resource);
assertEquals("resource label", "hello!!!!", resource.getLabel());
}
Aggregations