### Question:
ClassifierDefinitionListener implements ClusteredDataTreeChangeListener<ClassifierDefinition>, AutoCloseable { @Override public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<ClassifierDefinition>> changes) { for (DataTreeModification<ClassifierDefinition> change : changes) { DataObjectModification<ClassifierDefinition> rootNode = change.getRootNode(); switch (rootNode.getModificationType()) { case WRITE: case SUBTREE_MODIFIED: ClassifierDefinition classifierDefinitionAfter = checkNotNull(rootNode.getDataAfter()); Classifier ourClassifier = SubjectFeatures.getClassifier(classifierDefinitionAfter.getId()); if (ourClassifier != null) { SupportedClassifierDefinition supportedClassifierDefinition = createSupportedClassifierDefinition(ourClassifier); WriteTransaction wTx = dataProvider.newWriteOnlyTransaction(); wTx.put(LogicalDatastoreType.OPERATIONAL, RENDERER_CAPABILITIES_IID .child(SupportedClassifierDefinition.class, supportedClassifierDefinition.getKey()), supportedClassifierDefinition, true); Futures.addCallback(wTx.submit(), logDebugResult(supportedClassifierDefinition.getKey(), PUT), MoreExecutors.directExecutor()); } break; case DELETE: ClassifierDefinition classifierDefinitionBefore = checkNotNull(rootNode.getDataBefore()); ourClassifier = SubjectFeatures.getClassifier(classifierDefinitionBefore.getId()); if (ourClassifier != null) { SupportedClassifierDefinitionKey supportedClassifierDefinitionKey = new SupportedClassifierDefinitionKey(ourClassifier.getId()); WriteTransaction wTx = dataProvider.newWriteOnlyTransaction(); wTx.delete(LogicalDatastoreType.OPERATIONAL, RENDERER_CAPABILITIES_IID .child(SupportedClassifierDefinition.class, supportedClassifierDefinitionKey)); Futures.addCallback(wTx.submit(), logDebugResult(supportedClassifierDefinitionKey, DELETED), MoreExecutors.directExecutor()); } break; } } } ClassifierDefinitionListener(DataBroker dataProvider); @Override void onDataTreeChanged(@Nonnull Collection<DataTreeModification<ClassifierDefinition>> 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(SupportedClassifierDefinition.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(SupportedClassifierDefinition.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)); }