### Question:
ActionDefinitionListener implements ClusteredDataTreeChangeListener<ActionDefinition>, AutoCloseable { @Override public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<ActionDefinition>> changes) { for (DataTreeModification<ActionDefinition> change : changes) { DataObjectModification<ActionDefinition> rootNode = change.getRootNode(); switch (rootNode.getModificationType()) { case WRITE: case SUBTREE_MODIFIED: ActionDefinition actionDefinitionAfter = checkNotNull(rootNode.getDataAfter()); Action ourAction = SubjectFeatures.getAction(actionDefinitionAfter.getId()); if (ourAction != null) { SupportedActionDefinition supportedActionDefinition = createSupportedActionDefinition(ourAction); WriteTransaction wTx = dataProvider.newWriteOnlyTransaction(); wTx.put(LogicalDatastoreType.OPERATIONAL, CAPABILITIES_IID .child(SupportedActionDefinition.class, supportedActionDefinition.getKey()), supportedActionDefinition, true); Futures.addCallback(wTx.submit(), logDebugResult(supportedActionDefinition.getKey(), PUT), MoreExecutors .directExecutor()); } break; case DELETE: ActionDefinition actionDefinitionBefore = checkNotNull(rootNode.getDataBefore()); ourAction = SubjectFeatures.getAction(actionDefinitionBefore.getId()); if (ourAction != null) { SupportedActionDefinitionKey supportedActionDefinitionKey = new SupportedActionDefinitionKey(ourAction.getId()); WriteTransaction wTx = dataProvider.newWriteOnlyTransaction(); wTx.delete(LogicalDatastoreType.OPERATIONAL, CAPABILITIES_IID.child(SupportedActionDefinition.class, supportedActionDefinitionKey)); Futures.addCallback(wTx.submit(), logDebugResult(supportedActionDefinitionKey, DELETED), MoreExecutors.directExecutor()); } break; } } } ActionDefinitionListener(DataBroker dataProvider); @Override void onDataTreeChanged(@Nonnull Collection<DataTreeModification<ActionDefinition>> changes); @Override void close();  }### Answer:
@Test public void testOnDataTreeChanged_Write() { when(rootNode.getModificationType()).thenReturn(DataObjectModification.ModificationType.WRITE); WriteTransaction wt = resetTransaction(); listener.onDataTreeChanged(changes); verify(wt).put(eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class), any(SupportedActionDefinition.class), eq(true)); }
@Test public void testOnDataTreeChanged_SubtreeModified() { when(rootNode.getModificationType()).thenReturn(DataObjectModification.ModificationType.SUBTREE_MODIFIED); WriteTransaction wt = resetTransaction(); listener.onDataTreeChanged(changes); verify(wt).put(eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class), any(SupportedActionDefinition.class), eq(true)); }
@Test public void testOnDataTreeChanged_Delete() { when(rootNode.getModificationType()).thenReturn(DataObjectModification.ModificationType.DELETE); WriteTransaction wt = resetTransaction(); listener.onDataTreeChanged(changes); verify(wt).delete(eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class)); }