Search in sources :

Example 26 with EdgeRef

use of org.opennms.features.topology.api.topo.EdgeRef in project opennms by OpenNMS.

the class LinkdEdgeStatusProviderTest method testGetLldpLinkStatusDown.

@Test
public void testGetLldpLinkStatusDown() {
    EasyMock.expect(m_alarmDao.findMatching(EasyMock.anyObject(org.opennms.core.criteria.Criteria.class))).andReturn(createLldpDownAlarm()).anyTimes();
    List<EdgeRef> edges = getEdgeRefs();
    for (EdgeRef ref : edges) EasyMock.expect(m_edgeProvider.getEdge(ref)).andReturn(getEdgeFromRef(ref)).anyTimes();
    EasyMock.replay(m_alarmDao, m_edgeProvider);
    Map<EdgeRef, Status> statusMap = m_statusProvider.getStatusForEdges(m_edgeProvider, edges, new Criteria[0]);
    assertEquals(8, statusMap.size());
    assertEquals(edges.get(0), new ArrayList<EdgeRef>(statusMap.keySet()).get(0));
    assertEquals(statusMap.get(edges.get(0)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(1)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(2)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(3)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(5)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(6)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(7)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(4)).computeStatus(), "down");
}
Also used : Status(org.opennms.features.topology.api.topo.Status) ArrayList(java.util.ArrayList) EdgeRef(org.opennms.features.topology.api.topo.EdgeRef) Test(org.junit.Test)

Example 27 with EdgeRef

use of org.opennms.features.topology.api.topo.EdgeRef in project opennms by OpenNMS.

the class LinkdEdgeStatusProviderTest method testGetBridgeLinkStatusOneDown.

@Test
public void testGetBridgeLinkStatusOneDown() {
    EasyMock.expect(m_alarmDao.findMatching(EasyMock.anyObject(org.opennms.core.criteria.Criteria.class))).andReturn(createBridgeDownAlarm()).anyTimes();
    List<EdgeRef> edges = getEdgeRefs();
    for (EdgeRef ref : edges) EasyMock.expect(m_edgeProvider.getEdge(ref)).andReturn(getEdgeFromRef(ref)).anyTimes();
    EasyMock.replay(m_alarmDao, m_edgeProvider);
    Map<EdgeRef, Status> statusMap = m_statusProvider.getStatusForEdges(m_edgeProvider, edges, new Criteria[0]);
    assertEquals(8, statusMap.size());
    assertEquals(edges.get(0), new ArrayList<EdgeRef>(statusMap.keySet()).get(0));
    assertEquals(statusMap.get(edges.get(0)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(2)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(3)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(4)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(5)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(6)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(7)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(1)).computeStatus(), "down");
}
Also used : Status(org.opennms.features.topology.api.topo.Status) ArrayList(java.util.ArrayList) EdgeRef(org.opennms.features.topology.api.topo.EdgeRef) Test(org.junit.Test)

Example 28 with EdgeRef

use of org.opennms.features.topology.api.topo.EdgeRef in project opennms by OpenNMS.

the class LinkdEdgeStatusProviderTest method testGetBridgeLinkStatusDesignatedCloudDown.

@Test
public void testGetBridgeLinkStatusDesignatedCloudDown() {
    EasyMock.expect(m_alarmDao.findMatching(EasyMock.anyObject(org.opennms.core.criteria.Criteria.class))).andReturn(createCloudDownAlarm()).anyTimes();
    List<EdgeRef> edges = getEdgeRefs();
    for (EdgeRef ref : edges) EasyMock.expect(m_edgeProvider.getEdge(ref)).andReturn(getEdgeFromRef(ref)).anyTimes();
    EasyMock.replay(m_alarmDao, m_edgeProvider);
    Map<EdgeRef, Status> statusMap = m_statusProvider.getStatusForEdges(m_edgeProvider, edges, new Criteria[0]);
    assertEquals(8, statusMap.size());
    assertEquals(edges.get(0), new ArrayList<EdgeRef>(statusMap.keySet()).get(0));
    assertEquals(statusMap.get(edges.get(1)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(2)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(3)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(4)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(5)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(6)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(7)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(0)).computeStatus(), "down");
}
Also used : Status(org.opennms.features.topology.api.topo.Status) ArrayList(java.util.ArrayList) EdgeRef(org.opennms.features.topology.api.topo.EdgeRef) Test(org.junit.Test)

Example 29 with EdgeRef

use of org.opennms.features.topology.api.topo.EdgeRef in project opennms by OpenNMS.

the class LinkdEdgeStatusProviderTest method testSPC944OspfLinkStatus.

@Test
public void testSPC944OspfLinkStatus() {
    EasyMock.expect(m_alarmDao.findMatching(EasyMock.anyObject(org.opennms.core.criteria.Criteria.class))).andReturn(createChennaiDownAlarm()).anyTimes();
    List<EdgeRef> edges = getEdgeRefs();
    for (EdgeRef ref : edges) EasyMock.expect(m_edgeProvider.getEdge(ref)).andReturn(getEdgeFromRef(ref)).anyTimes();
    EasyMock.replay(m_alarmDao, m_edgeProvider);
    Map<EdgeRef, Status> statusMap = m_statusProvider.getStatusForEdges(m_edgeProvider, edges, new Criteria[0]);
    assertEquals(8, statusMap.size());
    assertEquals(edges.get(0), new ArrayList<EdgeRef>(statusMap.keySet()).get(0));
    assertEquals(statusMap.get(edges.get(0)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(1)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(2)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(3)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(4)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(5)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(6)).computeStatus(), "up");
    assertEquals(statusMap.get(edges.get(7)).computeStatus(), "down");
}
Also used : Status(org.opennms.features.topology.api.topo.Status) ArrayList(java.util.ArrayList) EdgeRef(org.opennms.features.topology.api.topo.EdgeRef) Test(org.junit.Test)

Example 30 with EdgeRef

use of org.opennms.features.topology.api.topo.EdgeRef in project opennms by OpenNMS.

the class VEProviderGraphContainer method unselectElementsWhichAreNotVisibleAnymore.

// we have to find out if each selected vertex/edge is still displayable, if not we deselect it.
private static void unselectElementsWhichAreNotVisibleAnymore(Graph graph, SelectionManager selectionManager) {
    if (selectionManager == null)
        return;
    List<VertexRef> selectedVertexRefs = new ArrayList<>(selectionManager.getSelectedVertexRefs());
    List<VertexRef> newSelectedVertexRefs = new ArrayList<>();
    for (VertexRef eachSelectedVertex : selectedVertexRefs) {
        for (Vertex eachDisplayableVertex : graph.getDisplayVertices()) {
            if (eachDisplayableVertex.getNamespace().equals(eachSelectedVertex.getNamespace()) && eachDisplayableVertex.getId().equals(eachSelectedVertex.getId())) {
                newSelectedVertexRefs.add(eachSelectedVertex);
                break;
            }
        }
    }
    List<EdgeRef> selectedEdgeRefs = new ArrayList<>(selectionManager.getSelectedEdgeRefs());
    List<EdgeRef> newSelectedEdgeRefs = new ArrayList<>();
    for (EdgeRef eachSelectedEdgeRef : selectedEdgeRefs) {
        for (Edge eachDisplayableEdge : graph.getDisplayEdges()) {
            if (eachDisplayableEdge.getNamespace().equals(eachSelectedEdgeRef.getNamespace()) && eachDisplayableEdge.getId().equals(eachSelectedEdgeRef.getId())) {
                newSelectedEdgeRefs.add(eachSelectedEdgeRef);
                break;
            }
        }
    }
    // if the selection changed, inform selectionManager
    if (!newSelectedVertexRefs.equals(selectedVertexRefs)) {
        selectionManager.setSelectedVertexRefs(newSelectedVertexRefs);
    }
    if (!newSelectedEdgeRefs.equals(selectedEdgeRefs)) {
        selectionManager.setSelectedEdgeRefs(newSelectedEdgeRefs);
    }
}
Also used : Vertex(org.opennms.features.topology.api.topo.Vertex) ArrayList(java.util.ArrayList) EdgeRef(org.opennms.features.topology.api.topo.EdgeRef) VertexRef(org.opennms.features.topology.api.topo.VertexRef) Edge(org.opennms.features.topology.api.topo.Edge)

Aggregations

EdgeRef (org.opennms.features.topology.api.topo.EdgeRef)30 VertexRef (org.opennms.features.topology.api.topo.VertexRef)18 Vertex (org.opennms.features.topology.api.topo.Vertex)14 ArrayList (java.util.ArrayList)12 Test (org.junit.Test)12 Edge (org.opennms.features.topology.api.topo.Edge)11 SparseGraph (edu.uci.ics.jung.graph.SparseGraph)10 Status (org.opennms.features.topology.api.topo.Status)10 Point (org.opennms.features.topology.api.Point)9 Dimension (java.awt.Dimension)6 Layout (org.opennms.features.topology.api.Layout)6 FRLayout (edu.uci.ics.jung.algorithms.layout.FRLayout)3 SpringLayout (edu.uci.ics.jung.algorithms.layout.SpringLayout)3 AbstractVertex (org.opennms.features.topology.api.topo.AbstractVertex)3 HashMap (java.util.HashMap)2 Graph (org.opennms.features.topology.api.Graph)2 Predicate (com.google.common.base.Predicate)1 Lists (com.google.common.collect.Lists)1 ISOMLayout (edu.uci.ics.jung.algorithms.layout.ISOMLayout)1 UnweightedShortestPath (edu.uci.ics.jung.algorithms.shortestpath.UnweightedShortestPath)1