### Question:
SfcManager implements AutoCloseable, DataTreeChangeListener<ActionInstance> { @Override public void onDataTreeChanged(Collection<DataTreeModification<ActionInstance>> changes) { for (DataTreeModification<ActionInstance> change: changes) { DataObjectModification<ActionInstance> rootNode = change.getRootNode(); final ActionInstance dataBefore = rootNode.getDataBefore(); final ActionInstance dataAfter = rootNode.getDataAfter(); switch (rootNode.getModificationType()) { case SUBTREE_MODIFIED: case WRITE: if (dataBefore == null) { LOG.debug("New ActionInstance created"); executor.execute(new MatchActionDefTask(dataAfter, null, ActionState.ADD)); } else { LOG.debug("ActionInstance updated"); executor.execute(new MatchActionDefTask(dataAfter, dataBefore, ActionState.CHANGE)); } break; case DELETE: LOG.debug("ActionInstance deleted"); executor.execute(new MatchActionDefTask(null, dataBefore, ActionState.DELETE)); break; default: break; } } } SfcManager(DataBroker dataBroker,
                      RpcProviderRegistry rpcRegistry,
                      ExecutorService executor); Set<IpAddress> getSfcSourceIps(); @Override void onDataTreeChanged(Collection<DataTreeModification<ActionInstance>> changes); RenderedServicePathFirstHop getRspFirstHop(String rspName); @Override void close(); static final String SFC_CHAIN_ACTION; static final String SFC_CHAIN_NAME; }### Answer:
@Test public void onDataChangedTestAdd() { doReturn(DataObjectModification.ModificationType.WRITE).when(mockModification).getModificationType(); doReturn(dataObject).when(mockModification).getDataAfter(); manager.onDataTreeChanged(changeEvent); verify(executor).execute(any(Runnable.class)); }
@Test public void onDataChangedTestDelete() { doReturn(DataObjectModification.ModificationType.DELETE).when(mockModification).getModificationType(); doReturn(dataObject).when(mockModification).getDataBefore(); manager.onDataTreeChanged(changeEvent); verify(executor).execute(any(Runnable.class)); }
@Test public void onDataChangedTestChange() { doReturn(DataObjectModification.ModificationType.SUBTREE_MODIFIED).when(mockModification).getModificationType(); doReturn(dataObject).when(mockModification).getDataBefore(); doReturn(dataObject).when(mockModification).getDataAfter(); manager.onDataTreeChanged(changeEvent); verify(executor).execute(any(Runnable.class)); }