PathListener implements DataTreeChangeListener<Flow> { protected void onFlowRuleUpdated(InstanceIdentifier<Flow> iid, Flow dataBefore, Flow dataAfter) { if (PathManagerHelper.isFlowRuleDiff(dataBefore, dataAfter)) { LOG.debug("Flow rule changed in SUBTREE_MODIFIED mod: {}.", iid); updater.updateFlowRule(iid.firstKeyOf(Node.class).getId().getValue(), dataBefore, dataAfter); return; } LOG.debug("No change on this flow rule: {}.", iid); return; } PathListener(final PathManagerUpdater updater); @Override void onDataTreeChanged(@Nonnull Collection<DataTreeModification<Flow>> changes);  }
@Test public void testOnFlowRuleUpdated() throws Exception { Collection<DataTreeModification<Flow>> changes = new ArrayList<>(); DataTreeModification<Flow> change0 = mock(DataTreeModification.class); NodeId nodeId0 = new NodeId(new Uri(getRandomId("openflow"))); FlowId flowId0 = new FlowId(new Uri(getRandomId("flow"))); when(change0.getRootPath()).thenReturn(getMockRootPath(new NodeKey(nodeId0), new TableKey(DEFAULT_TABLE_ID), new FlowKey(flowId0))); DataObjectModification<Flow> rootNode0 = getMockRootNode(ModificationType.WRITE, getIpv4DropFlow(flowId0), getIpv4OutputFlow(flowId0, getRandomId("openflow"))); when(change0.getRootNode()).thenReturn(rootNode0); changes.add(change0); DataTreeModification<Flow> change1 = mock(DataTreeModification.class); NodeId nodeId1 = new NodeId(new Uri(getRandomId("openflow"))); FlowId flowId1 = new FlowId(new Uri(getRandomId("flow"))); when(change1.getRootPath()).thenReturn(getMockRootPath(new NodeKey(nodeId1), new TableKey(DEFAULT_TABLE_ID), new FlowKey(flowId1))); DataObjectModification<Flow> rootNode1 = getMockRootNode(ModificationType.SUBTREE_MODIFIED, getIpv4OutputFlow(flowId1, getRandomId("openflow")), getIpv4DropFlow(flowId1)); when(change1.getRootNode()).thenReturn(rootNode1); changes.add(change1); pathListener1.onDataTreeChanged(changes); pathListener2.onDataTreeChanged(changes); }