use of org.opennms.netmgt.model.PrefabGraph in project opennms by OpenNMS.
the class PropertiesGraphDaoIT method testGetName.
@Test
public void testGetName() {
PrefabGraph bits = m_graphs.get("mib2.bits").getObject();
;
assertEquals("getName", "mib2.bits", bits.getName());
}
use of org.opennms.netmgt.model.PrefabGraph in project opennms by OpenNMS.
the class PropertiesGraphDaoIT method testGetPrefabGraphsForResource.
@Test
public void testGetPrefabGraphsForResource() {
MockResourceType resourceType = new MockResourceType();
resourceType.setName("interface");
HashSet<OnmsAttribute> attributes = new HashSet<OnmsAttribute>(0);
attributes.add(new RrdGraphAttribute("ifInOctets", "", ""));
attributes.add(new RrdGraphAttribute("ifOutOctets", "", ""));
attributes.add(new ExternalValueAttribute("ifSpeed", ""));
OnmsResource resource = new OnmsResource("node", "1", resourceType, attributes, ResourcePath.get("foo"));
PrefabGraph[] graphs = m_dao.getPrefabGraphsForResource(resource);
assertEquals("prefab graph array size", 1, graphs.length);
assertEquals("prefab graph[0] name", "mib2.bits", graphs[0].getName());
}
use of org.opennms.netmgt.model.PrefabGraph in project opennms by OpenNMS.
the class PropertiesGraphDaoIT method testPrefabGraphPartlyBorkedConfig.
/**
* Test that we can load a partly borked config file (i.e. if one graph is incorrectly specified,
* we load as many of the rest as we can).
* The borked'ness we can tolerate does not include poor double quoting which confuses the underlying
* Java properties parser, but misspelled property names should only affect the graph in question.
*
* NB: It should still complain with an Error log. Should there be an event as well?
* @throws Exception
*/
@Test
public void testPrefabGraphPartlyBorkedConfig() throws Exception {
//We're expecting an ERROR log, and will be most disappointed if
// we don't get it. Turn off the default check in runTest
m_testSpecificLoggingTest = true;
PropertiesGraphDao dao = createPropertiesGraphDao(s_emptyMap, s_emptyMap);
dao.loadProperties("foo", new ByteArrayInputStream(s_partlyBorkedPrefab.getBytes(StandardCharsets.UTF_8)));
//We expect to be able to get a mib2.HCbits, and a mib2.discards, but no mib2.bits
try {
PrefabGraph mib2bits = dao.getPrefabGraph("mib2.bits");
fail("Should have thrown an ObjectRetrievalFailureException retrieving graph " + mib2bits);
} catch (ObjectRetrievalFailureException e) {
}
PrefabGraph mib2HCbits = dao.getPrefabGraph("mib2.HCbits");
assertNotNull(mib2HCbits);
PrefabGraph mib2Discards = dao.getPrefabGraph("mib2.discards");
assertNotNull(mib2Discards);
}
use of org.opennms.netmgt.model.PrefabGraph in project opennms by OpenNMS.
the class PropertiesGraphDaoIT method testGetCommand.
@Test
public void testGetCommand() {
String expectedCommand = "--title=\"Bits In/Out\" " + "DEF:octIn={rrd1}:ifInOctets:AVERAGE " + "DEF:octOut={rrd2}:ifOutOctets:AVERAGE " + "CDEF:bitsIn=octIn,8,* " + "CDEF:bitsOut=octOut,8,* " + "CDEF:totBits=octIn,octOut,+,8,* " + "AREA:totBits#00ff00:\"Total\" " + "GPRINT:totBits:AVERAGE:\" Avg \\: %8.2lf %s\\n\" " + "LINE2:bitsIn#0000ff:\"Bits In\" " + "GPRINT:bitsIn:AVERAGE:\" Avg \\: %8.2lf %s\" " + "GPRINT:bitsIn:MIN:\"Min \\: %8.2lf %s\" " + "GPRINT:bitsIn:MAX:\"Max \\: %8.2lf %s\\n\" " + "LINE2:bitsOut#ff0000:\"Bits Out\" " + "GPRINT:bitsOut:AVERAGE:\"Avg \\: %8.2lf %s\" " + "GPRINT:bitsOut:MIN:\"Min \\: %8.2lf %s\" " + "GPRINT:bitsOut:MAX:\"Max \\: %8.2lf %s\\n\"";
PrefabGraph bits = m_graphs.get("mib2.bits").getObject();
;
assertEquals("getCommand", expectedCommand, bits.getCommand());
}
use of org.opennms.netmgt.model.PrefabGraph in project opennms by OpenNMS.
the class PropertiesGraphDaoIT method testOneType.
@Test
public void testOneType() throws Exception {
PropertiesGraphDao dao = createPropertiesGraphDao(s_emptyMap, s_emptyMap);
ByteArrayInputStream in = new ByteArrayInputStream(s_responsePrefab.getBytes());
dao.loadProperties("response", in);
PrefabGraphTypeDao type = dao.findPrefabGraphTypeDaoByName("response");
assertNotNull("could not get response prefab graph type", type);
PrefabGraph graph = type.getQuery("icmp");
assertNotNull("could not get icmp response prefab graph type", graph);
assertNotNull("graph type list should not be null", graph.getTypes());
assertEquals("graph type was not specified the list should be empty", 1, graph.getTypes().length);
assertEquals("graph type 1", "responseTime", graph.getTypes()[0]);
assertTrue("should have responseTime type", graph.hasMatchingType("responseTime"));
assertFalse("should not have distributedStatus type", graph.hasMatchingType("distributedStatus"));
assertTrue("should have responseTime or distributedStatus type", graph.hasMatchingType("responseTime", "distributedStatus"));
}
Aggregations