use of org.opennms.features.topology.plugins.topo.graphml.status.GraphMLScriptVertexStatusProvider in project opennms by OpenNMS.
the class GraphMLVertexStatusProviderIT method testScriptStatusProvider.
@Test
public void testScriptStatusProvider() throws InvalidGraphException {
GraphML graphML = GraphMLReader.read(getClass().getResourceAsStream("/test-graph.xml"));
GraphMLTopologyProvider topologyProvider = new GraphMLTopologyProvider(null, graphML.getGraphs().get(0), new GraphMLServiceAccessor());
GraphMLScriptVertexStatusProvider statusProvider = new GraphMLScriptVertexStatusProvider(topologyProvider.getNamespace(), this.alarmSummaryWrapper, new ScriptEngineManager(), this.serviceAccessor, Paths.get("src", "test", "opennms-home", "etc", "graphml-vertex-status"));
List<VertexRef> vertices = topologyProvider.getVertices().stream().map(eachVertex -> (VertexRef) eachVertex).collect(Collectors.toList());
Assert.assertEquals(4, vertices.size());
Assert.assertEquals(topologyProvider.getNamespace(), statusProvider.getNamespace());
Assert.assertTrue(statusProvider.contributesTo(topologyProvider.getNamespace()));
Map<? extends VertexRef, ? extends Status> statusForVertices = statusProvider.getStatusForVertices(topologyProvider, vertices, new Criteria[0]);
Assert.assertEquals(4, statusForVertices.size());
Assert.assertEquals(ImmutableMap.of(createVertexRef(topologyProvider.getNamespace(), "north"), createStatus(OnmsSeverity.NORMAL, 0), createVertexRef(topologyProvider.getNamespace(), "west"), createStatus(OnmsSeverity.NORMAL, 0), createVertexRef(topologyProvider.getNamespace(), "south"), createStatus(OnmsSeverity.WARNING, 42), createVertexRef(topologyProvider.getNamespace(), "east"), createStatus(OnmsSeverity.CRITICAL, 23)), statusForVertices);
}
Aggregations