TopologyLinkDataChangeHandler implements DataTreeChangeListener<Link> { public ListenerRegistration<TopologyLinkDataChangeHandler> registerAsDataChangeListener() { InstanceIdentifier<Link> linkInstance = InstanceIdentifier.builder(NetworkTopology.class) .child(Topology.class, new TopologyKey(new TopologyId(topologyId))).child(Link.class).build(); return dataBroker.registerDataTreeChangeListener(new DataTreeIdentifier<>( LogicalDatastoreType.OPERATIONAL, linkInstance), this); } TopologyLinkDataChangeHandler(DataBroker dataBroker, NetworkGraphService networkGraphService); void setGraphRefreshDelay(long graphRefreshDelay); void setTopologyId(String topologyId); ListenerRegistration<TopologyLinkDataChangeHandler> registerAsDataChangeListener(); @Override void onDataTreeChanged(Collection<DataTreeModification<Link>> changes);  }
@Test public void testRegisterAsDataChangeListener() throws Exception { topologyLinkDataChangeHandler.registerAsDataChangeListener(); verify(dataBroker, times(1)).registerDataTreeChangeListener(any(DataTreeIdentifier.class), any(DataTreeChangeListener.class)); }