use of org.opennms.features.topology.plugins.topo.graphml.status.GraphMLEdgeStatus in project opennms by OpenNMS.
the class GraphMLEdgeStatusProviderIT method verify.
@Test
public void verify() throws Exception {
final GraphMLServiceAccessor serviceAccessor = new GraphMLServiceAccessor();
serviceAccessor.setTransactionOperations(transactionOperations);
serviceAccessor.setNodeDao(nodeDao);
serviceAccessor.setSnmpInterfaceDao(snmpInterfaceDao);
serviceAccessor.setMeasurementsService(request -> new QueryResponse());
final GraphMLGraph graph = GraphMLReader.read(getClass().getResourceAsStream("/test-graph2.xml")).getGraphs().get(0);
final GraphMLTopologyProvider topologyProvider = new GraphMLTopologyProvider(null, graph, serviceAccessor);
final GraphMLEdgeStatusProvider provider = new GraphMLEdgeStatusProvider(topologyProvider, new ScriptEngineManager(), serviceAccessor, Paths.get("src", "test", "opennms-home", "etc", "graphml-edge-status"));
assertThat(provider.contributesTo("acme:regions"), is(true));
assertThat(provider.getNamespace(), is("acme:regions"));
// Calculating the status executes some tests defined int the according scripts as a side effect
final EdgeRef edgeRef = topologyProvider.getEdge("acme:regions", "center_north");
final Map<? extends EdgeRef, ? extends Status> status = provider.getStatusForEdges(topologyProvider, ImmutableList.of(edgeRef), new Criteria[0]);
// Checking nodeID creation for vertices with only foreignSource/foreignID set
final VertexRef vertexRef = topologyProvider.getVertex("acme:regions", "west");
assertThat(vertexRef, is(notNullValue()));
assertThat(vertexRef, is(instanceOf(GraphMLVertex.class)));
assertThat(((GraphMLVertex) vertexRef).getNodeID(), is(4));
// Testing status merging from two scripts
assertThat(status, is(notNullValue()));
assertThat(status, is(hasEntry(edgeRef, new GraphMLEdgeStatus().severity(OnmsSeverity.WARNING).style("stroke", "pink").style("stroke-width", "3em"))));
}
Aggregations