Search in sources :

Example 6 with AggregateStatusDefinition

use of org.opennms.netmgt.model.AggregateStatusDefinition in project opennms by OpenNMS.

the class DefaultSiteStatusServiceIT method testCreateAggregateStatusUsingBuilding.

@Test
@Transactional
public void testCreateAggregateStatusUsingBuilding() {
    m_databasePopulator.populateDatabase();
    createOutageForNodeInCategory("Routers");
    createOutageForNodeInCategory("Servers");
    Set<AggregateStatusDefinition> defs = new LinkedHashSet<AggregateStatusDefinition>();
    AggregateStatusDefinition definition;
    definition = new AggregateStatusDefinition("Routers", Collections.singleton(new OnmsCategory("Routers")));
    defs.add(definition);
    definition = new AggregateStatusDefinition("Switches", Collections.singleton(new OnmsCategory("Switches")));
    defs.add(definition);
    definition = new AggregateStatusDefinition("Servers", Collections.singleton(new OnmsCategory("Servers")));
    defs.add(definition);
    //        AggregateStatusDefinition definition;
    //        definition = new AggregateStatusDefinition("LB/Router", new HashSet<OnmsCategory>(Arrays.asList(new OnmsCategory[]{ new OnmsCategory("DEV_ROUTER"), new OnmsCategory("DEV_LOADBAL") })));
    //        defs.add(definition);        
    //        definition = new AggregateStatusDefinition("Access Controller", Collections.singleton(new OnmsCategory("DEV_AC")));
    //        defs.add(definition);
    //        definition = new AggregateStatusDefinition("Switches", Collections.singleton(new OnmsCategory("DEV_SWITCH")));
    //        defs.add(definition);
    //        definition = new AggregateStatusDefinition("Access Points", Collections.singleton(new OnmsCategory("DEV_AP")));
    //        defs.add(definition);
    //        definition = new AggregateStatusDefinition("BCPC", Collections.singleton(new OnmsCategory("DEV_BCPC")));
    //        defs.add(definition);
    AggregateStatusView view = new AggregateStatusView();
    view.setName("building");
    view.setColumnName("building");
    view.setColumnValue("HQ");
    view.setStatusDefinitions(defs);
    List<AggregateStatus> aggrStati = new ArrayList<AggregateStatus>(m_aggregateService.createAggregateStatuses(view));
    AggregateStatus status;
    status = aggrStati.get(0);
    assertEquals("Routers", status.getLabel());
    assertEquals(AggregateStatus.NODES_ARE_DOWN, status.getStatus());
    status = aggrStati.get(1);
    assertEquals("Switches", status.getLabel());
    assertEquals(AggregateStatus.ALL_NODES_UP, status.getStatus());
    status = aggrStati.get(2);
    assertEquals("Servers", status.getLabel());
    assertEquals(AggregateStatus.NODES_ARE_DOWN, status.getStatus());
    //        status = aggrStati.get(3);
    //        assertEquals(AggregateStatus.NODES_ARE_DOWN, status.getStatus());
    //        assertEquals(new Integer(6), status.getDownEntityCount());
    //        
    //        status = aggrStati.get(4);
    //        assertEquals(AggregateStatus.ALL_NODES_UP, status.getStatus());
    m_databasePopulator.resetDatabase();
}
Also used : LinkedHashSet(java.util.LinkedHashSet) OnmsCategory(org.opennms.netmgt.model.OnmsCategory) AggregateStatusDefinition(org.opennms.netmgt.model.AggregateStatusDefinition) ArrayList(java.util.ArrayList) AggregateStatus(org.opennms.web.svclayer.model.AggregateStatus) AggregateStatusView(org.opennms.netmgt.model.AggregateStatusView) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

AggregateStatusDefinition (org.opennms.netmgt.model.AggregateStatusDefinition)6 ArrayList (java.util.ArrayList)4 LinkedHashSet (java.util.LinkedHashSet)4 AggregateStatusView (org.opennms.netmgt.model.AggregateStatusView)4 OnmsCategory (org.opennms.netmgt.model.OnmsCategory)4 AggregateStatus (org.opennms.web.svclayer.model.AggregateStatus)4 Test (org.junit.Test)3 OnmsNode (org.opennms.netmgt.model.OnmsNode)3 HashSet (java.util.HashSet)2 RowDef (org.opennms.netmgt.config.siteStatusViews.RowDef)2 View (org.opennms.netmgt.config.siteStatusViews.View)2 Category (org.opennms.netmgt.config.siteStatusViews.Category)1 Transactional (org.springframework.transaction.annotation.Transactional)1