@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)); }
@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 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 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); }
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(); }
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();  }