Search in sources :

Example 1 with VEProviderGraphContainer

use of org.opennms.features.topology.app.internal.VEProviderGraphContainer in project opennms by OpenNMS.

the class AbstractLayoutTest method setUp.

@Before
public void setUp() {
    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");
    final DefaultTopologyService topologyService = new DefaultTopologyService();
    final MetaTopologyProvider metaTopologyProvider = new SimpleMetaTopologyProvider(getGraphProvider());
    topologyService.setServiceLocator(new SimpleServiceLocator(metaTopologyProvider));
    final VEProviderGraphContainer graphContainer = new VEProviderGraphContainer();
    graphContainer.setTopologyService(topologyService);
    graphContainer.setSelectedNamespace(metaTopologyProvider.getDefaultGraphProvider().getNamespace());
    graphContainer.setMetaTopologyId(metaTopologyProvider.getId());
    m_graphContainer = graphContainer;
}
Also used : SimpleMetaTopologyProvider(org.opennms.features.topology.api.topo.SimpleMetaTopologyProvider) MetaTopologyProvider(org.opennms.features.topology.api.topo.MetaTopologyProvider) SimpleGraphBuilder(org.opennms.features.topology.api.support.SimpleGraphBuilder) DefaultTopologyService(org.opennms.features.topology.app.internal.service.DefaultTopologyService) VEProviderGraphContainer(org.opennms.features.topology.app.internal.VEProviderGraphContainer) SimpleServiceLocator(org.opennms.features.topology.app.internal.service.SimpleServiceLocator) SimpleMetaTopologyProvider(org.opennms.features.topology.api.topo.SimpleMetaTopologyProvider) Before(org.junit.Before)

Example 2 with VEProviderGraphContainer

use of org.opennms.features.topology.app.internal.VEProviderGraphContainer in project opennms by OpenNMS.

the class GraphMLSearchProviderTest method canSearchAllSearchProviders.

@Test
public void canSearchAllSearchProviders() throws IOException, InvalidGraphException {
    final GraphMLMetaTopologyProvider metaTopologyProvider = new GraphMLMetaTopologyProvider(new GraphMLServiceAccessor());
    metaTopologyProvider.setTopologyLocation("target/test-classes/test-graph.xml");
    metaTopologyProvider.reload();
    Assert.assertNotNull(metaTopologyProvider.getDefaultGraphProvider());
    List<SearchProvider> searchProviders = metaTopologyProvider.getGraphProviders().stream().map(eachProvider -> new GraphMLSearchProvider(metaTopologyProvider.getRawTopologyProvider(eachProvider.getNamespace()))).collect(Collectors.toList());
    Assert.assertEquals(2, searchProviders.size());
    DefaultTopologyService defaultTopologyService = new DefaultTopologyService();
    defaultTopologyService.setServiceLocator(new SimpleServiceLocator(metaTopologyProvider));
    VEProviderGraphContainer graphContainer = new VEProviderGraphContainer();
    graphContainer.setTopologyService(defaultTopologyService);
    graphContainer.setMetaTopologyId(metaTopologyProvider.getId());
    graphContainer.setSelectedNamespace(metaTopologyProvider.getDefaultGraphProvider().getNamespace());
    OperationContext operationContext = EasyMock.niceMock(OperationContext.class);
    EasyMock.expect(operationContext.getGraphContainer()).andReturn(graphContainer).anyTimes();
    OnmsServiceManager onmsServiceManager = EasyMock.niceMock(OnmsServiceManager.class);
    EasyMock.expect(onmsServiceManager.getServices(SearchProvider.class, null, new Hashtable<>())).andReturn(searchProviders).anyTimes();
    EasyMock.replay(onmsServiceManager, operationContext);
    SearchBox searchBox = new SearchBox(onmsServiceManager, operationContext);
    List<SearchSuggestion> results = searchBox.getQueryResults("North");
    Assert.assertEquals(5, results.size());
}
Also used : IOException(java.io.IOException) Test(org.junit.Test) EasyMock(org.easymock.EasyMock) DefaultTopologyService(org.opennms.features.topology.app.internal.service.DefaultTopologyService) OnmsServiceManager(org.opennms.osgi.OnmsServiceManager) Collectors(java.util.stream.Collectors) SearchBox(org.opennms.features.topology.app.internal.ui.SearchBox) List(java.util.List) OperationContext(org.opennms.features.topology.api.OperationContext) InvalidGraphException(org.opennms.features.graphml.model.InvalidGraphException) SearchSuggestion(org.opennms.features.topology.app.internal.gwt.client.SearchSuggestion) VEProviderGraphContainer(org.opennms.features.topology.app.internal.VEProviderGraphContainer) Assert(org.junit.Assert) SimpleServiceLocator(org.opennms.features.topology.app.internal.service.SimpleServiceLocator) GraphMLGraph(org.opennms.features.graphml.model.GraphMLGraph) GraphMLServiceAccessor(org.opennms.features.topology.plugins.topo.graphml.internal.GraphMLServiceAccessor) Hashtable(java.util.Hashtable) SearchProvider(org.opennms.features.topology.api.topo.SearchProvider) OperationContext(org.opennms.features.topology.api.OperationContext) OnmsServiceManager(org.opennms.osgi.OnmsServiceManager) SearchSuggestion(org.opennms.features.topology.app.internal.gwt.client.SearchSuggestion) DefaultTopologyService(org.opennms.features.topology.app.internal.service.DefaultTopologyService) VEProviderGraphContainer(org.opennms.features.topology.app.internal.VEProviderGraphContainer) Hashtable(java.util.Hashtable) SimpleServiceLocator(org.opennms.features.topology.app.internal.service.SimpleServiceLocator) SearchProvider(org.opennms.features.topology.api.topo.SearchProvider) SearchBox(org.opennms.features.topology.app.internal.ui.SearchBox) GraphMLServiceAccessor(org.opennms.features.topology.plugins.topo.graphml.internal.GraphMLServiceAccessor) Test(org.junit.Test)

Aggregations

VEProviderGraphContainer (org.opennms.features.topology.app.internal.VEProviderGraphContainer)2 DefaultTopologyService (org.opennms.features.topology.app.internal.service.DefaultTopologyService)2 SimpleServiceLocator (org.opennms.features.topology.app.internal.service.SimpleServiceLocator)2 IOException (java.io.IOException)1 Hashtable (java.util.Hashtable)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 EasyMock (org.easymock.EasyMock)1 Assert (org.junit.Assert)1 Before (org.junit.Before)1 Test (org.junit.Test)1 GraphMLGraph (org.opennms.features.graphml.model.GraphMLGraph)1 InvalidGraphException (org.opennms.features.graphml.model.InvalidGraphException)1 OperationContext (org.opennms.features.topology.api.OperationContext)1 SimpleGraphBuilder (org.opennms.features.topology.api.support.SimpleGraphBuilder)1 MetaTopologyProvider (org.opennms.features.topology.api.topo.MetaTopologyProvider)1 SearchProvider (org.opennms.features.topology.api.topo.SearchProvider)1 SimpleMetaTopologyProvider (org.opennms.features.topology.api.topo.SimpleMetaTopologyProvider)1 SearchSuggestion (org.opennms.features.topology.app.internal.gwt.client.SearchSuggestion)1 SearchBox (org.opennms.features.topology.app.internal.ui.SearchBox)1