Search in sources :

Example 1 with TestNodeProvider

use of org.opennms.features.topology.plugins.topo.asset.util.TestNodeProvider in project opennms by OpenNMS.

the class AssetGraphGeneratorTest method verifyGenerationWithNoHierarchies.

@Test
public void verifyGenerationWithNoHierarchies() throws InvalidGraphException, FileNotFoundException {
    // Generate
    final GeneratorConfig config = new GeneratorConfig();
    config.setProviderId("asset");
    config.setLabel("testgraph");
    config.setPreferredLayout("Grid Layout");
    // empty layers
    config.setLayerHierarchies(new ArrayList<>());
    // empty filters
    config.setFilters(new ArrayList<>());
    final AssetGraphGenerator assetGraphGenerator = new AssetGraphGenerator(new TestNodeProvider());
    final GraphML graphML = assetGraphGenerator.generateGraphs(config);
    // Verify
    assertEquals(1, graphML.getGraphs().size());
}
Also used : TestNodeProvider(org.opennms.features.topology.plugins.topo.asset.util.TestNodeProvider) GraphML(org.opennms.features.graphml.model.GraphML) Test(org.junit.Test)

Example 2 with TestNodeProvider

use of org.opennms.features.topology.plugins.topo.asset.util.TestNodeProvider in project opennms by OpenNMS.

the class AssetGraphGeneratorTest method verifyGenerationWithLayersPopulated.

@Test
public void verifyGenerationWithLayersPopulated() throws InvalidGraphException, FileNotFoundException {
    // Generate
    final GeneratorConfig config = new GeneratorConfig();
    config.setProviderId("asset");
    config.setLabel("testgraph");
    config.setPreferredLayout("Grid Layout");
    config.setLayerHierarchies(Lists.newArrayList(NodeParamLabels.ASSET_REGION, NodeParamLabels.ASSET_BUILDING, NodeParamLabels.ASSET_RACK));
    // empty filters
    config.setFilters(new ArrayList<>());
    final AssetGraphGenerator assetGraphGenerator = new AssetGraphGenerator(new TestNodeProvider());
    final GraphML generatedGraphML = assetGraphGenerator.generateGraphs(config);
    // Verify Region layer
    Assert.assertEquals(2, generatedGraphML.getGraph(config.getProviderId() + ":" + NodeParamLabels.ASSET_REGION).getNodes().size());
    Assert.assertEquals(9, generatedGraphML.getGraph(config.getProviderId() + ":" + NodeParamLabels.ASSET_BUILDING).getNodes().size());
    Assert.assertEquals(17, generatedGraphML.getGraph(config.getProviderId() + ":" + NodeParamLabels.ASSET_RACK).getNodes().size());
    // for debug generate file
    GraphMLWriter.write(generatedGraphML, new File("target/verifyGenerationWithLayersPopulatedGenerated.graphml"));
    // verify total graph
    GraphML expectedGraphML = GraphMLReader.read(getClass().getResourceAsStream(GRAPHML_TEST_TOPOLOGY_FILE_NAME));
    assertEquals(expectedGraphML, generatedGraphML);
}
Also used : TestNodeProvider(org.opennms.features.topology.plugins.topo.asset.util.TestNodeProvider) GraphML(org.opennms.features.graphml.model.GraphML) File(java.io.File) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 GraphML (org.opennms.features.graphml.model.GraphML)2 TestNodeProvider (org.opennms.features.topology.plugins.topo.asset.util.TestNodeProvider)2 File (java.io.File)1