### Question:
OfOverlayNodeListener implements DataTreeChangeListener<OfOverlayNodeConfig>, AutoCloseable { @Override public void onDataTreeChanged(Collection<DataTreeModification<OfOverlayNodeConfig>> changes) { for (DataTreeModification<OfOverlayNodeConfig> change: changes) { DataObjectModification<OfOverlayNodeConfig> rootNode = change.getRootNode(); NodeId nodeId = change.getRootPath().getRootIdentifier().firstKeyOf(Node.class, NodeKey.class).getId(); switch (rootNode.getModificationType()) { case SUBTREE_MODIFIED: case WRITE: OfOverlayNodeConfig nodeConfig = rootNode.getDataAfter(); LOG.trace("OfOverlayNodeConfig updated. NodeId: {} OfOverlayNodeConfig: {}", nodeId.getValue(), nodeConfig); switchManager.updateSwitchConfig(nodeId, nodeConfig); break; case DELETE: LOG.trace("OfOverlayNodeConfig removed. NodeId: {}", nodeId.getValue()); switchManager.updateSwitchConfig(nodeId, null); break; default: break; } } } OfOverlayNodeListener(DataBroker dataProvider, SwitchManager switchManager); @Override void onDataTreeChanged(Collection<DataTreeModification<OfOverlayNodeConfig>> changes); @Override void close();  }### Answer:
@Test public void onDataChangedTestCreatedData() { doReturn(DataObjectModification.ModificationType.WRITE).when(mockModification).getModificationType(); doReturn(entryValue).when(mockModification).getDataAfter(); listener.onDataTreeChanged(changeEvent); verify(switchManager).updateSwitchConfig(childNodeId, entryValue); }
@Test public void onDataChangedTestUpdatedData() { doReturn(DataObjectModification.ModificationType.SUBTREE_MODIFIED).when(mockModification).getModificationType(); doReturn(entryValue).when(mockModification).getDataAfter(); listener.onDataTreeChanged(changeEvent); verify(switchManager).updateSwitchConfig(childNodeId, entryValue); }
@Test public void onDataChangedTestRemovedPaths() { doReturn(DataObjectModification.ModificationType.DELETE).when(mockModification).getModificationType(); doReturn(entryValue).when(mockModification).getDataBefore(); listener.onDataTreeChanged(changeEvent); verify(switchManager).updateSwitchConfig(childNodeId, null); }