use of org.opennms.netmgt.model.topology.BroadcastDomain in project opennms by OpenNMS.
the class EnLinkdIT method testDeleteBridgeC.
@Test
public void testDeleteBridgeC() {
ABCTopology topology = new ABCTopology();
NetworkBuilder nb = new NetworkBuilder();
nb.addNode("nodeA").setForeignSource("linkd").setForeignId("nodeA").setSysObjectId("0.0").setSysName("nodeA").setType(NodeType.ACTIVE);
nb.addInterface("10.0.1.1").setIsSnmpPrimary("P").setIsManaged("M");
m_nodeDao.save(nb.getCurrentNode());
nb.addNode("nodeB").setForeignSource("linkd").setForeignId("nodeB").setSysObjectId("0.0").setSysName("nodeB").setType(NodeType.ACTIVE);
nb.addInterface("10.0.1.2").setIsSnmpPrimary("P").setIsManaged("M");
m_nodeDao.save(nb.getCurrentNode());
nb.addNode("nodeC").setForeignSource("linkd").setForeignId("nodeC").setSysObjectId("0.0").setSysName("nodeC").setType(NodeType.ACTIVE);
nb.addInterface("10.0.1.3").setIsSnmpPrimary("P").setIsManaged("M");
m_nodeDao.save(nb.getCurrentNode());
OnmsNode nodeA = m_nodeDao.findByForeignId("linkd", "nodeA");
OnmsNode nodeB = m_nodeDao.findByForeignId("linkd", "nodeB");
OnmsNode nodeC = m_nodeDao.findByForeignId("linkd", "nodeC");
topology.nodeAId = nodeA.getId();
topology.nodeBId = nodeB.getId();
topology.nodeCId = nodeC.getId();
topology.nodeA = nodeA;
topology.nodeB = nodeB;
topology.nodeC = nodeC;
BridgeBridgeLink ablink = new BridgeBridgeLink();
ablink.setNode(nodeA);
ablink.setBridgePort(topology.portAB);
ablink.setDesignatedNode(nodeB);
ablink.setDesignatedPort(topology.portBA);
ablink.setBridgeBridgeLinkLastPollTime(ablink.getBridgeBridgeLinkCreateTime());
m_bridgeBridgeLinkDao.save(ablink);
BridgeBridgeLink bclink = new BridgeBridgeLink();
bclink.setNode(nodeC);
bclink.setBridgePort(topology.portCB);
bclink.setDesignatedNode(nodeB);
bclink.setDesignatedPort(topology.portBC);
bclink.setBridgeBridgeLinkLastPollTime(ablink.getBridgeBridgeLinkCreateTime());
m_bridgeBridgeLinkDao.save(bclink);
BridgeMacLink mac1 = new BridgeMacLink();
mac1.setNode(nodeA);
mac1.setBridgePort(topology.portA);
mac1.setMacAddress(topology.mac1);
mac1.setBridgeMacLinkLastPollTime(mac1.getBridgeMacLinkCreateTime());
m_bridgeMacLinkDao.save(mac1);
BridgeMacLink mac2 = new BridgeMacLink();
mac2.setNode(nodeB);
mac2.setBridgePort(topology.portB);
mac2.setMacAddress(topology.mac2);
mac2.setBridgeMacLinkLastPollTime(mac2.getBridgeMacLinkCreateTime());
m_bridgeMacLinkDao.save(mac2);
BridgeMacLink mac3 = new BridgeMacLink();
mac3.setNode(nodeC);
mac3.setBridgePort(topology.portC);
mac3.setMacAddress(topology.mac3);
mac3.setBridgeMacLinkLastPollTime(mac3.getBridgeMacLinkCreateTime());
m_bridgeMacLinkDao.save(mac3);
m_bridgeMacLinkDao.flush();
m_bridgeBridgeLinkDao.flush();
assertEquals(3, m_bridgeMacLinkDao.countAll());
assertEquals(2, m_bridgeBridgeLinkDao.countAll());
assertNotNull(m_bridgeTopologyDao);
m_linkd.getQueryManager().loadBridgeTopology();
assertEquals(1, m_linkd.getQueryManager().getAllBroadcastDomains().size());
BroadcastDomain nodeAbd = m_linkd.getQueryManager().getBroadcastDomain(nodeA.getId().intValue());
assertNotNull(nodeAbd);
BroadcastDomain nodeBbd = m_linkd.getQueryManager().getBroadcastDomain(nodeB.getId().intValue());
assertNotNull(nodeBbd);
assertEquals(nodeAbd, nodeBbd);
BroadcastDomain nodeCbd = m_linkd.getQueryManager().getBroadcastDomain(nodeC.getId().intValue());
assertNotNull(nodeCbd);
assertEquals(nodeAbd, nodeCbd);
assertTrue(nodeAbd.hasRootBridge());
assertEquals(nodeAbd.getRootBridgeId().intValue(), nodeB.getId().intValue());
assertTrue(nodeAbd.containBridgeId(nodeA.getId()));
assertTrue(nodeAbd.containBridgeId(nodeB.getId()));
assertTrue(nodeAbd.containBridgeId(nodeC.getId()));
nodeAbd.hierarchySetUp(nodeAbd.getBridge(nodeA.getId()));
assertNotNull(nodeAbd.getRootBridgeId());
topology.check(nodeAbd);
m_linkd.deleteNode(nodeC.getId());
assertEquals(1, m_linkd.getQueryManager().getAllBroadcastDomains().size());
BroadcastDomain domain = m_linkd.getQueryManager().getAllBroadcastDomains().iterator().next();
topology.checkAB(domain);
}
Aggregations