@SuppressWarnings("unchecked") @Test public void onDataChangeTestRemovedPaths() { NodeId childNodeId = mock(NodeId.class); InstanceIdentifier<FlowCapableNode> entryKey = InstanceIdentifier.builder(Nodes.class) .child(Node.class, new NodeKey(childNodeId)) .augmentation(FlowCapableNode.class) .build(); doReturn(new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, entryKey)).when(mockDataTreeModification) .getRootPath(); doReturn(DataObjectModification.ModificationType.DELETE).when(mockModification).getModificationType(); listener.onDataTreeChanged(changeEvent); verify(switchManager).updateSwitch(childNodeId, null); }
@Override public void onDataTreeChanged(Collection<DataTreeModification<FlowCapableNode>> changes) { for (DataTreeModification<FlowCapableNode> change: changes) { DataObjectModification<FlowCapableNode> rootNode = change.getRootNode(); NodeId nodeId = change.getRootPath().getRootIdentifier().firstKeyOf(Node.class, NodeKey.class).getId(); switch (rootNode.getModificationType()) { case SUBTREE_MODIFIED: case WRITE: FlowCapableNode fcNode = rootNode.getDataAfter(); LOG.trace("FlowCapableNode updated. NodeId: {} FlowCapableNode: {}", nodeId.getValue(), fcNode); switchManager.updateSwitch(nodeId, fcNode); break; case DELETE: LOG.trace("FlowCapableNode removed. NodeId: {}", nodeId.getValue()); switchManager.updateSwitch(nodeId, null); break; default: break; } } }
FlowCapableNodeListener implements DataTreeChangeListener<FlowCapableNode>, AutoCloseable { @Override public void onDataTreeChanged(Collection<DataTreeModification<FlowCapableNode>> changes) { for (DataTreeModification<FlowCapableNode> change: changes) { DataObjectModification<FlowCapableNode> rootNode = change.getRootNode(); NodeId nodeId = change.getRootPath().getRootIdentifier().firstKeyOf(Node.class, NodeKey.class).getId(); switch (rootNode.getModificationType()) { case SUBTREE_MODIFIED: case WRITE: FlowCapableNode fcNode = rootNode.getDataAfter(); LOG.trace("FlowCapableNode updated. NodeId: {} FlowCapableNode: {}", nodeId.getValue(), fcNode); switchManager.updateSwitch(nodeId, fcNode); break; case DELETE: LOG.trace("FlowCapableNode removed. NodeId: {}", nodeId.getValue()); switchManager.updateSwitch(nodeId, null); break; default: break; } } } }
FlowCapableNodeListener implements DataTreeChangeListener<FlowCapableNode>, AutoCloseable { @Override public void onDataTreeChanged(Collection<DataTreeModification<FlowCapableNode>> changes) { for (DataTreeModification<FlowCapableNode> change: changes) { DataObjectModification<FlowCapableNode> rootNode = change.getRootNode(); NodeId nodeId = change.getRootPath().getRootIdentifier().firstKeyOf(Node.class, NodeKey.class).getId(); switch (rootNode.getModificationType()) { case SUBTREE_MODIFIED: case WRITE: FlowCapableNode fcNode = rootNode.getDataAfter(); LOG.trace("FlowCapableNode updated. NodeId: {} FlowCapableNode: {}", nodeId.getValue(), fcNode); switchManager.updateSwitch(nodeId, fcNode); break; case DELETE: LOG.trace("FlowCapableNode removed. NodeId: {}", nodeId.getValue()); switchManager.updateSwitch(nodeId, null); break; default: break; } } } FlowCapableNodeListener(DataBroker dataProvider, SwitchManager switchManager); }
FlowCapableNodeListener implements DataTreeChangeListener<FlowCapableNode>, AutoCloseable { @Override public void onDataTreeChanged(Collection<DataTreeModification<FlowCapableNode>> changes) { for (DataTreeModification<FlowCapableNode> change: changes) { DataObjectModification<FlowCapableNode> rootNode = change.getRootNode(); NodeId nodeId = change.getRootPath().getRootIdentifier().firstKeyOf(Node.class, NodeKey.class).getId(); switch (rootNode.getModificationType()) { case SUBTREE_MODIFIED: case WRITE: FlowCapableNode fcNode = rootNode.getDataAfter(); LOG.trace("FlowCapableNode updated. NodeId: {} FlowCapableNode: {}", nodeId.getValue(), fcNode); switchManager.updateSwitch(nodeId, fcNode); break; case DELETE: LOG.trace("FlowCapableNode removed. NodeId: {}", nodeId.getValue()); switchManager.updateSwitch(nodeId, null); break; default: break; } } } FlowCapableNodeListener(DataBroker dataProvider, SwitchManager switchManager); @Override void onDataTreeChanged(Collection<DataTreeModification<FlowCapableNode>> changes); @Override void close(); }
FlowCapableNodeListener implements DataTreeChangeListener<FlowCapableNode>, AutoCloseable { @Override public void onDataTreeChanged(Collection<DataTreeModification<FlowCapableNode>> changes) { for (DataTreeModification<FlowCapableNode> change: changes) { DataObjectModification<FlowCapableNode> rootNode = change.getRootNode(); NodeId nodeId = change.getRootPath().getRootIdentifier().firstKeyOf(Node.class, NodeKey.class).getId(); switch (rootNode.getModificationType()) { case SUBTREE_MODIFIED: case WRITE: FlowCapableNode fcNode = rootNode.getDataAfter(); LOG.trace("FlowCapableNode updated. NodeId: {} FlowCapableNode: {}", nodeId.getValue(), fcNode); switchManager.updateSwitch(nodeId, fcNode); break; case DELETE: LOG.trace("FlowCapableNode removed. NodeId: {}", nodeId.getValue()); switchManager.updateSwitch(nodeId, null); break; default: break; } } } FlowCapableNodeListener(DataBroker dataProvider, SwitchManager switchManager); @Override void onDataTreeChanged(Collection<DataTreeModification<FlowCapableNode>> changes); @Override void close();  }