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();
}
Aggregations