Search in sources :

Example 16 with OnmsResource

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());
}
Also used : OnmsResource(org.opennms.netmgt.model.OnmsResource) Test(org.junit.Test)

Example 17 with OnmsResource

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());
}
Also used : OnmsResource(org.opennms.netmgt.model.OnmsResource) Test(org.junit.Test)

Example 18 with OnmsResource

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());
}
Also used : OnmsResource(org.opennms.netmgt.model.OnmsResource) Test(org.junit.Test)

Example 19 with OnmsResource

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());
}
Also used : OnmsResource(org.opennms.netmgt.model.OnmsResource) Test(org.junit.Test)

Example 20 with OnmsResource

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());
}
Also used : OnmsResource(org.opennms.netmgt.model.OnmsResource) File(java.io.File) Test(org.junit.Test)

Aggregations

OnmsResource (org.opennms.netmgt.model.OnmsResource)143 Test (org.junit.Test)54 OnmsAttribute (org.opennms.netmgt.model.OnmsAttribute)40 MockResourceType (org.opennms.netmgt.mock.MockResourceType)31 OnmsNode (org.opennms.netmgt.model.OnmsNode)28 RrdGraphAttribute (org.opennms.netmgt.model.RrdGraphAttribute)23 File (java.io.File)22 ResourcePath (org.opennms.netmgt.model.ResourcePath)19 ArrayList (java.util.ArrayList)14 HashSet (java.util.HashSet)14 PrefabGraph (org.opennms.netmgt.model.PrefabGraph)12 HashMap (java.util.HashMap)11 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)11 ResourceId (org.opennms.netmgt.model.ResourceId)11 Date (java.util.Date)10 Source (org.opennms.netmgt.measurements.model.Source)8 LinkedList (java.util.LinkedList)7 FetchResults (org.opennms.netmgt.measurements.api.FetchResults)7 ExternalValueAttribute (org.opennms.netmgt.model.ExternalValueAttribute)7 ModelAndView (org.springframework.web.servlet.ModelAndView)7