@Test public void testOnDataTreeChanged_remove() throws Exception { Mockito.when(rootNode.getDataBefore()).thenReturn(policy2); Mockito.when(rootNode.getDataAfter()).thenReturn(createVersion(1)); Mockito.when(rootNode.getModificationType()).thenReturn(DataObjectModification.ModificationType.WRITE); Mockito.when(dataTreeModification.getRootNode()).thenReturn(rootNode); listener.onDataTreeChanged(Collections.singleton(dataTreeModification)); Mockito.verify(policyManager).syncPolicy(null, policy2.getConfiguration(), 1); }
@Override public void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<RendererPolicy>> collection) { LOG.debug("renderer policy configuration changed"); for (DataTreeModification<RendererPolicy> rendererPolicyDataTreeModification : collection) { final DataObjectModification<RendererPolicy> rootNode = rendererPolicyDataTreeModification.getRootNode(); final RendererPolicy dataBefore = rootNode.getDataBefore(); final RendererPolicy dataAfter = rootNode.getDataAfter(); Configuration oldConfig = null; Configuration newConfig = null; long version = 0; if (dataBefore != null) { oldConfig = dataBefore.getConfiguration(); } if (dataAfter != null) { newConfig = dataAfter.getConfiguration(); if (dataAfter.getVersion() != null) { version = dataAfter.getVersion(); } } policyManager.syncPolicy(newConfig, oldConfig, version); } }
RendererConfigurationListenerImpl implements ClusteredDataTreeChangeListener<RendererPolicy>, AutoCloseable { @Override public void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<RendererPolicy>> collection) { LOG.debug("renderer policy configuration changed"); for (DataTreeModification<RendererPolicy> rendererPolicyDataTreeModification : collection) { final DataObjectModification<RendererPolicy> rootNode = rendererPolicyDataTreeModification.getRootNode(); final RendererPolicy dataBefore = rootNode.getDataBefore(); final RendererPolicy dataAfter = rootNode.getDataAfter(); Configuration oldConfig = null; Configuration newConfig = null; long version = 0; if (dataBefore != null) { oldConfig = dataBefore.getConfiguration(); } if (dataAfter != null) { newConfig = dataAfter.getConfiguration(); if (dataAfter.getVersion() != null) { version = dataAfter.getVersion(); } } policyManager.syncPolicy(newConfig, oldConfig, version); } } }
RendererConfigurationListenerImpl implements ClusteredDataTreeChangeListener<RendererPolicy>, AutoCloseable { @Override public void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<RendererPolicy>> collection) { LOG.debug("renderer policy configuration changed"); for (DataTreeModification<RendererPolicy> rendererPolicyDataTreeModification : collection) { final DataObjectModification<RendererPolicy> rootNode = rendererPolicyDataTreeModification.getRootNode(); final RendererPolicy dataBefore = rootNode.getDataBefore(); final RendererPolicy dataAfter = rootNode.getDataAfter(); Configuration oldConfig = null; Configuration newConfig = null; long version = 0; if (dataBefore != null) { oldConfig = dataBefore.getConfiguration(); } if (dataAfter != null) { newConfig = dataAfter.getConfiguration(); if (dataAfter.getVersion() != null) { version = dataAfter.getVersion(); } } policyManager.syncPolicy(newConfig, oldConfig, version); } } RendererConfigurationListenerImpl(final DataBroker dataBroker,
                                             final PolicyManager policyManager); }
RendererConfigurationListenerImpl implements ClusteredDataTreeChangeListener<RendererPolicy>, AutoCloseable { @Override public void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<RendererPolicy>> collection) { LOG.debug("renderer policy configuration changed"); for (DataTreeModification<RendererPolicy> rendererPolicyDataTreeModification : collection) { final DataObjectModification<RendererPolicy> rootNode = rendererPolicyDataTreeModification.getRootNode(); final RendererPolicy dataBefore = rootNode.getDataBefore(); final RendererPolicy dataAfter = rootNode.getDataAfter(); Configuration oldConfig = null; Configuration newConfig = null; long version = 0; if (dataBefore != null) { oldConfig = dataBefore.getConfiguration(); } if (dataAfter != null) { newConfig = dataAfter.getConfiguration(); if (dataAfter.getVersion() != null) { version = dataAfter.getVersion(); } } policyManager.syncPolicy(newConfig, oldConfig, version); } } RendererConfigurationListenerImpl(final DataBroker dataBroker,
                                             final PolicyManager policyManager); @Override void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<RendererPolicy>> collection); @Override void close(); }
RendererConfigurationListenerImpl implements ClusteredDataTreeChangeListener<RendererPolicy>, AutoCloseable { @Override public void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<RendererPolicy>> collection) { LOG.debug("renderer policy configuration changed"); for (DataTreeModification<RendererPolicy> rendererPolicyDataTreeModification : collection) { final DataObjectModification<RendererPolicy> rootNode = rendererPolicyDataTreeModification.getRootNode(); final RendererPolicy dataBefore = rootNode.getDataBefore(); final RendererPolicy dataAfter = rootNode.getDataAfter(); Configuration oldConfig = null; Configuration newConfig = null; long version = 0; if (dataBefore != null) { oldConfig = dataBefore.getConfiguration(); } if (dataAfter != null) { newConfig = dataAfter.getConfiguration(); if (dataAfter.getVersion() != null) { version = dataAfter.getVersion(); } } policyManager.syncPolicy(newConfig, oldConfig, version); } } RendererConfigurationListenerImpl(final DataBroker dataBroker,
                                             final PolicyManager policyManager); @Override void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<RendererPolicy>> collection); @Override void close();  }