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