Search in sources :

Example 1 with VertexListener

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

the class EnhancedLinkdTopologyProviderTest method testTopoProviderSetParent.

@Test
public void testTopoProviderSetParent() {
    VertexRef vertexId1 = addVertexToTopr();
    VertexRef vertexId2 = addVertexToTopr();
    final AtomicInteger eventsReceived = new AtomicInteger(0);
    m_topologyProvider.addVertexListener(new VertexListener() {

        @Override
        public void vertexSetChanged(VertexProvider provider, Collection<? extends Vertex> added, Collection<? extends Vertex> update, Collection<String> removedVertexIds) {
            eventsReceived.incrementAndGet();
        }

        @Override
        public void vertexSetChanged(VertexProvider provider) {
            eventsReceived.incrementAndGet();
        }
    });
    Vertex groupId = m_topologyProvider.addGroup("Test Group", "groupIcon.jpg");
    assertEquals(1, eventsReceived.get());
    eventsReceived.set(0);
    m_topologyProvider.setParent(vertexId1, groupId);
    m_topologyProvider.setParent(vertexId2, groupId);
    assertEquals(2, eventsReceived.get());
}
Also used : Vertex(org.opennms.features.topology.api.topo.Vertex) AbstractVertex(org.opennms.features.topology.api.topo.AbstractVertex) SimpleLeafVertex(org.opennms.features.topology.api.topo.SimpleLeafVertex) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) VertexProvider(org.opennms.features.topology.api.topo.VertexProvider) DefaultVertexRef(org.opennms.features.topology.api.topo.DefaultVertexRef) VertexRef(org.opennms.features.topology.api.topo.VertexRef) VertexListener(org.opennms.features.topology.api.topo.VertexListener) Test(org.junit.Test)

Aggregations

AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Test (org.junit.Test)1 AbstractVertex (org.opennms.features.topology.api.topo.AbstractVertex)1 DefaultVertexRef (org.opennms.features.topology.api.topo.DefaultVertexRef)1 SimpleLeafVertex (org.opennms.features.topology.api.topo.SimpleLeafVertex)1 Vertex (org.opennms.features.topology.api.topo.Vertex)1 VertexListener (org.opennms.features.topology.api.topo.VertexListener)1 VertexProvider (org.opennms.features.topology.api.topo.VertexProvider)1 VertexRef (org.opennms.features.topology.api.topo.VertexRef)1