Search in sources :

Example 6 with SimpleGraphBuilder

use of org.opennms.features.topology.api.support.SimpleGraphBuilder in project opennms by OpenNMS.

the class D3LayoutTest method getGraphProvider.

@Override
protected GraphProvider getGraphProvider() {
    final SimpleGraphBuilder bldr = new SimpleGraphBuilder("nodes");
    for (int i = 0; i < 100; i++) {
        bldr.vertex("v" + i).vLabel("vertex" + i).vIconKey("server").vTooltip("tooltip").vStyleName("vertex");
    }
    bldr.edge("e1", "v1", "v2").eStyleName("edge").edge("e2", "v1", "v3").eStyleName("edge").edge("e3", "v1", "v4").eStyleName("edge").edge("e4", "v1", "v5").eStyleName("edge").edge("e5", "v1", "v6").eStyleName("edge").edge("e6", "v1", "v7").eStyleName("edge").edge("e7", "v1", "v8").eStyleName("edge").edge("e8", "v1", "v8").eStyleName("edge").edge("e9", "v2", "v8").eStyleName("edge").edge("e10", "v2", "v7").eStyleName("edge").edge("e11", "v3", "v8").eStyleName("edge").edge("e12", "v5", "v8").eStyleName("edge").edge("e13", "v6", "v8").eStyleName("edge").edge("e14", "v7", "v8").eStyleName("edge");
    return bldr.get();
}
Also used : SimpleGraphBuilder(org.opennms.features.topology.api.support.SimpleGraphBuilder) Point(org.opennms.features.topology.api.Point)

Example 7 with SimpleGraphBuilder

use of org.opennms.features.topology.api.support.SimpleGraphBuilder in project opennms by OpenNMS.

the class ManualLayoutAlgorithmTest method verifyLayoutCoordinatesHavePriority.

/*
     * If persisted layout is defined, verify that it has priority.
     */
@Test
public void verifyLayoutCoordinatesHavePriority() {
    final GraphProvider graphProvider = new SimpleGraphBuilder("dummy").vertex("vertex1").vX(1).vY(1).get();
    final ManualTest test = new ManualTest(graphProvider);
    final LayoutEntity persistedLayout = new LayoutEntity();
    int x = 5;
    int y = 5;
    for (VertexRef eachVertex : graphProvider.getVertices()) {
        VertexPositionEntity vertexPositionEntity = new VertexPositionEntity();
        vertexPositionEntity.setVertexRef(LayoutManager.toVertexRefEntity(eachVertex));
        vertexPositionEntity.setPosition(new PointEntity(x++, y++));
        persistedLayout.addVertexPosition(vertexPositionEntity);
    }
    Mockito.when(test.layoutManager.loadLayout(test.graph)).thenReturn(persistedLayout);
    new ManualLayoutAlgorithm(test.layoutManager).updateLayout(test.graph);
    Assert.assertEquals(ImmutableMap.builder().put(new DefaultVertexRef("dummy", "vertex1"), new Point(5, 5)).build(), test.layout.getLocations());
}
Also used : VertexPositionEntity(org.opennms.netmgt.topology.persistence.api.VertexPositionEntity) SimpleGraphBuilder(org.opennms.features.topology.api.support.SimpleGraphBuilder) DefaultVertexRef(org.opennms.features.topology.api.topo.DefaultVertexRef) GraphProvider(org.opennms.features.topology.api.topo.GraphProvider) LayoutEntity(org.opennms.netmgt.topology.persistence.api.LayoutEntity) PointEntity(org.opennms.netmgt.topology.persistence.api.PointEntity) Point(org.opennms.features.topology.api.Point) DefaultVertexRef(org.opennms.features.topology.api.topo.DefaultVertexRef) VertexRef(org.opennms.features.topology.api.topo.VertexRef) Point(org.opennms.features.topology.api.Point) Test(org.junit.Test)

Aggregations

SimpleGraphBuilder (org.opennms.features.topology.api.support.SimpleGraphBuilder)7 Test (org.junit.Test)4 Point (org.opennms.features.topology.api.Point)4 DefaultVertexRef (org.opennms.features.topology.api.topo.DefaultVertexRef)4 Before (org.junit.Before)3 MetaTopologyProvider (org.opennms.features.topology.api.topo.MetaTopologyProvider)3 VertexRef (org.opennms.features.topology.api.topo.VertexRef)3 DefaultTopologyService (org.opennms.features.topology.app.internal.service.DefaultTopologyService)3 SimpleServiceLocator (org.opennms.features.topology.app.internal.service.SimpleServiceLocator)3 GraphProvider (org.opennms.features.topology.api.topo.GraphProvider)2 SimpleMetaTopologyProvider (org.opennms.features.topology.api.topo.SimpleMetaTopologyProvider)2 GridLayoutAlgorithm (org.opennms.features.topology.app.internal.jung.GridLayoutAlgorithm)2 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 IOException (java.io.IOException)1 Collection (java.util.Collection)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1