Search in sources :

Example 1 with PrefabGraphTypeDao

use of org.opennms.netmgt.dao.support.PropertiesGraphDao.PrefabGraphTypeDao in project opennms by OpenNMS.

the class PropertiesGraphDaoIT method testNoType.

@Test
public void testNoType() throws Exception {
    PropertiesGraphDao dao = createPropertiesGraphDao(s_emptyMap, s_emptyMap);
    String ourConfig = s_responsePrefab.replaceAll("report.icmp.type=responseTime", "");
    ByteArrayInputStream in = new ByteArrayInputStream(ourConfig.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", 0, graph.getTypes().length);
    assertFalse("should not have responseTime type", graph.hasMatchingType("responseTime"));
}
Also used : PrefabGraph(org.opennms.netmgt.model.PrefabGraph) ByteArrayInputStream(java.io.ByteArrayInputStream) PrefabGraphTypeDao(org.opennms.netmgt.dao.support.PropertiesGraphDao.PrefabGraphTypeDao) Test(org.junit.Test)

Example 2 with PrefabGraphTypeDao

use of org.opennms.netmgt.dao.support.PropertiesGraphDao.PrefabGraphTypeDao 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"));
}
Also used : PrefabGraph(org.opennms.netmgt.model.PrefabGraph) ByteArrayInputStream(java.io.ByteArrayInputStream) PrefabGraphTypeDao(org.opennms.netmgt.dao.support.PropertiesGraphDao.PrefabGraphTypeDao) Test(org.junit.Test)

Example 3 with PrefabGraphTypeDao

use of org.opennms.netmgt.dao.support.PropertiesGraphDao.PrefabGraphTypeDao in project opennms by OpenNMS.

the class PropertiesGraphDaoIT method testTwoTypes.

@Test
public void testTwoTypes() throws Exception {
    PropertiesGraphDao dao = createPropertiesGraphDao(s_emptyMap, s_emptyMap);
    String ourConfig = s_responsePrefab.replaceAll("report.icmp.type=responseTime", "report.icmp.type=responseTime, distributedStatus");
    ByteArrayInputStream in = new ByteArrayInputStream(ourConfig.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 should not be null", graph.getTypes());
    assertEquals("graph type count", 2, graph.getTypes().length);
    assertEquals("graph type 1", "responseTime", graph.getTypes()[0]);
    assertEquals("graph type 2", "distributedStatus", graph.getTypes()[1]);
    assertTrue("should have responseTime type", graph.hasMatchingType("responseTime"));
    assertTrue("should have distributedStatus type", graph.hasMatchingType("distributedStatus"));
}
Also used : PrefabGraph(org.opennms.netmgt.model.PrefabGraph) ByteArrayInputStream(java.io.ByteArrayInputStream) PrefabGraphTypeDao(org.opennms.netmgt.dao.support.PropertiesGraphDao.PrefabGraphTypeDao) Test(org.junit.Test)

Example 4 with PrefabGraphTypeDao

use of org.opennms.netmgt.dao.support.PropertiesGraphDao.PrefabGraphTypeDao in project opennms by OpenNMS.

the class PropertiesGraphDaoITCase method setUp.

@Before
public void setUp() throws Exception {
    MockLogAppender.setupLogging(true);
    m_dao = createPropertiesGraphDao(s_emptyMap, s_emptyMap);
    ByteArrayInputStream in = new ByteArrayInputStream(s_prefab.getBytes());
    m_dao.loadProperties("performance", in);
    PrefabGraphTypeDao type = m_dao.findPrefabGraphTypeDaoByName("performance");
    assertNotNull("could not get performance prefab graph type", type);
    m_graphs = type.getReportMap();
    assertNotNull("report map shouldn't be null", m_graphs);
    m_fileAnticipator = new FileAnticipator();
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) FileAnticipator(org.opennms.test.FileAnticipator) PrefabGraphTypeDao(org.opennms.netmgt.dao.support.PropertiesGraphDao.PrefabGraphTypeDao) Before(org.junit.Before)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)4 PrefabGraphTypeDao (org.opennms.netmgt.dao.support.PropertiesGraphDao.PrefabGraphTypeDao)4 Test (org.junit.Test)3 PrefabGraph (org.opennms.netmgt.model.PrefabGraph)3 Before (org.junit.Before)1 FileAnticipator (org.opennms.test.FileAnticipator)1