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