ClassifierRspsUpdateListener extends AbstractDataTreeChangeListener<RenderedServicePath> { @Override protected void update(RenderedServicePath originalRsp, RenderedServicePath updatedRsp) { if (LOG.isDebugEnabled()) { LOG.debug("update - old rspId: {}; new rspId: {}", originalRsp, updatedRsp); } Optional<DpnIdType> originalDataplaneId = dataGetter.getFirstHopDataplaneId(originalRsp); Optional<DpnIdType> updatedDataplaneId = dataGetter.getFirstHopDataplaneId(updatedRsp); if (originalDataplaneId.isPresent() && updatedDataplaneId.isPresent() && !originalDataplaneId.get().equals(updatedDataplaneId.get())) { LOG.info("update - First SF of RSP [{}] *moved*. Old DPNID: {}; New DPNID: {}", originalRsp.getPathId(), originalDataplaneId.get(), updatedDataplaneId.get()); RspName theRspName = originalRsp.getName(); openflowWriter.deleteRspFlows(originalRsp.getPathId()); openflowWriter.deleteFlowSet(); List<Acl> theAcls = updateDataGetter.filterAclsByRspName(theRspName); theAcls.forEach(acl -> { List<SclServiceFunctionForwarder> theClassifierObjects = updateDataGetter.filterClassifierNodesByAclName(acl.getAclName()); theClassifierObjects.forEach(classifier -> { List<FlowDetails> allFlows = classifierProcessor.processClassifier(classifier, acl, updatedRsp); if(!allFlows.isEmpty()) { LOG.debug("update - Flows generated; gonna write them into the DS "); openflowWriter.writeFlows(allFlows); openflowWriter.flushFlows(); } }); }); } } ClassifierRspsUpdateListener(DataBroker theDataBroker,
                                        ClassifierRspUpdateProcessor theClassifierProcessor,
                                        SfcOfFlowWriterInterface theOpenflowWriter,
                                        ClassifierRspUpdateDataGetter theUpdateDataGetter,
                                        LogicalClassifierDataGetter theDataGetter); @Override void close();  }
@Test public void testUpdateRsp() { theUpdateListener.update(oldRsp, newRsp); Mockito.verify(theOpenflowWriter).deleteRspFlows(oldRsp.getPathId()); Mockito.verify(theOpenflowWriter).deleteFlowSet(); Mockito.verify(theClassifierProcessor).processClassifier(theClassifier, theAcl, newRsp); }