class 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);
    }

}

class TopologyLinkDataChangeHandlerTest {

    @MockitoAnnotations.Mock
    private DataBroker dataBroker;
    @MockitoAnnotations.Mock
    private NetworkGraphService networkGraphService;
    private TopologyLinkDataChangeHandler topologyLinkDataChangeHandler;

    @Test
    public void testRegisterAsDataChangeListener() throws Exception {

        topologyLinkDataChangeHandler.registerAsDataChangeListener();
        verify(dataBroker, times(1)).registerDataTreeChangeListener(any(DataTreeIdentifier.class),
                any(DataTreeChangeListener.class));
    }

}