### Question:
IosXeCapableNodeListenerImpl implements ClusteredDataTreeChangeListener<Node>, AutoCloseable { @Override public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<Node>> changes) { printTraceStart(LOG); for (DataTreeModification<Node> modification : changes) { DataObjectModification<Node> rootNode = modification.getRootNode(); Node dataAfter = rootNode.getDataAfter(); Node dataBefore = rootNode.getDataBefore(); nodeManager.syncNodes(dataAfter, dataBefore); } } IosXeCapableNodeListenerImpl(final DataBroker dataBroker, final NodeManager nodeManager); @Override void onDataTreeChanged(@Nonnull Collection<DataTreeModification<Node>> changes); @Override void close();  }### Answer:
@Test public void testOnDataTreeChanged_add() throws Exception { final Node topologyNode = createNetworkTopologyNode("topology-node-id-1"); Mockito.when(dataTreeModification.getRootNode()).thenReturn(rootNode); Mockito.when(rootNode.getDataBefore()).thenReturn(topologyNode); Mockito.when(rootNode.getDataAfter()).thenReturn(null); listener.onDataTreeChanged(Collections.singleton(dataTreeModification)); Mockito.verify(nodeManager).syncNodes(null, topologyNode); }
@Test public void testOnDataTreeChanged_update() throws Exception { final Node topologyNodeBefore = createNetworkTopologyNode("topology-node-id-1"); final Node topologyNodeAfter = createNetworkTopologyNode("topology-node-id-2"); Mockito.when(dataTreeModification.getRootNode()).thenReturn(rootNode); Mockito.when(rootNode.getDataBefore()).thenReturn(topologyNodeBefore); Mockito.when(rootNode.getDataAfter()).thenReturn(topologyNodeAfter); listener.onDataTreeChanged(Collections.singleton(dataTreeModification)); Mockito.verify(nodeManager).syncNodes(topologyNodeAfter, topologyNodeBefore); }
@Test public void testOnDataTreeChanged_remove() throws Exception { final Node topologyNode = createNetworkTopologyNode("topology-node-id-2"); Mockito.when(dataTreeModification.getRootNode()).thenReturn(rootNode); Mockito.when(rootNode.getDataBefore()).thenReturn(null); Mockito.when(rootNode.getDataAfter()).thenReturn(topologyNode); listener.onDataTreeChanged(Collections.singleton(dataTreeModification)); Mockito.verify(nodeManager).syncNodes(topologyNode, null); }