-/*\r
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-\r
-package org.opendaylight.groupbasedpolicy.renderer.ofoverlay.statistics;\r
-\r
-import static org.mockito.Mockito.mock;\r
-import static org.mockito.Mockito.spy;\r
-import static org.mockito.Mockito.times;\r
-import static org.mockito.Mockito.verify;\r
-import static org.mockito.Mockito.when;\r
-\r
-import java.util.Set;\r
-import java.util.concurrent.ScheduledExecutorService;\r
-\r
-import com.google.common.collect.ImmutableSet;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;\r
-import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;\r
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;\r
-import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;\r
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;\r
-import org.opendaylight.groupbasedpolicy.api.StatisticsManager;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.ofoverlay.rev140528.OfOverlayConfig;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.ofoverlay.rev140528.sflow.values.SflowClientSettings;\r
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;\r
-\r
-public class SflowClientSettingsListenerTest {\r
-\r
- private SflowClientSettingsListener listener;\r
- private DataObjectModification<SflowClientSettings> rootNode;\r
- private Set<DataTreeModification<SflowClientSettings>> changes;\r
-\r
- private InstanceIdentifier<SflowClientSettings> rootIdentifier;\r
-\r
- @SuppressWarnings("unchecked")\r
- @Before\r
- public void init() {\r
- DataBroker dataProvider = mock(DataBroker.class);\r
-\r
- StatisticsManager ofStatisticsManager = mock(StatisticsManager.class);\r
- ScheduledExecutorService executor = mock(ScheduledExecutorService.class);\r
- listener = spy(new SflowClientSettingsListener(dataProvider, executor, ofStatisticsManager));\r
-\r
- SflowClientSettings sflowClientSettings = mock(SflowClientSettings.class);\r
-\r
- rootNode = mock(DataObjectModification.class);\r
- rootIdentifier = InstanceIdentifier.builder(OfOverlayConfig.class).child(SflowClientSettings.class).build();\r
- DataTreeIdentifier<SflowClientSettings> rootPath =\r
- new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, rootIdentifier);\r
-\r
- DataTreeModification<SflowClientSettings> change = mock(DataTreeModification.class);\r
-\r
- when(change.getRootNode()).thenReturn(rootNode);\r
- when(change.getRootPath()).thenReturn(rootPath);\r
-\r
- changes = ImmutableSet.of(change);\r
-\r
- when(rootNode.getDataBefore()).thenReturn(sflowClientSettings);\r
- when(rootNode.getDataAfter()).thenReturn(sflowClientSettings);\r
- }\r
-\r
- @Test\r
- public void testOnWrite() {\r
- when(rootNode.getModificationType()).thenReturn(DataObjectModification.ModificationType.WRITE);\r
-\r
- listener.onDataTreeChanged(changes);\r
-\r
- verify(listener).onWrite(rootNode, rootIdentifier);\r
- }\r
-\r
- @Test\r
- public void testOnDelete() {\r
- when(rootNode.getModificationType()).thenReturn(DataObjectModification.ModificationType.DELETE);\r
-\r
- listener.onDataTreeChanged(changes);\r
-\r
- verify(listener).onDelete(rootNode, rootIdentifier);\r
- }\r
-\r
- @Test\r
- public void testOnSubtreeModified() {\r
- when(rootNode.getModificationType()).thenReturn(DataObjectModification.ModificationType.SUBTREE_MODIFIED);\r
-\r
- // first call will initialize uninitialized dependencies;\r
- // second call will call #close on them\r
- listener.onDataTreeChanged(changes);\r
- listener.onDataTreeChanged(changes);\r
- verify(listener, times(2)).onSubtreeModified(rootNode, rootIdentifier);\r
- }\r
-\r
-}\r
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.ofoverlay.statistics;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.Set;
+import java.util.concurrent.ScheduledExecutorService;
+
+import com.google.common.collect.ImmutableSet;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.groupbasedpolicy.api.StatisticsManager;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.ofoverlay.rev140528.OfOverlayConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.ofoverlay.rev140528.sflow.values.SflowClientSettings;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class SflowClientSettingsListenerTest {
+
+ private SflowClientSettingsListener listener;
+ private DataObjectModification<SflowClientSettings> rootNode;
+ private Set<DataTreeModification<SflowClientSettings>> changes;
+
+ private InstanceIdentifier<SflowClientSettings> rootIdentifier;
+
+ @SuppressWarnings("unchecked")
+ @Before
+ public void init() {
+ DataBroker dataProvider = mock(DataBroker.class);
+
+ StatisticsManager ofStatisticsManager = mock(StatisticsManager.class);
+ ScheduledExecutorService executor = mock(ScheduledExecutorService.class);
+ listener = spy(new SflowClientSettingsListener(dataProvider, executor, ofStatisticsManager));
+
+ SflowClientSettings sflowClientSettings = mock(SflowClientSettings.class);
+
+ rootNode = mock(DataObjectModification.class);
+ rootIdentifier = InstanceIdentifier.builder(OfOverlayConfig.class).child(SflowClientSettings.class).build();
+ DataTreeIdentifier<SflowClientSettings> rootPath =
+ new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, rootIdentifier);
+
+ DataTreeModification<SflowClientSettings> change = mock(DataTreeModification.class);
+
+ when(change.getRootNode()).thenReturn(rootNode);
+ when(change.getRootPath()).thenReturn(rootPath);
+
+ changes = ImmutableSet.of(change);
+
+ when(rootNode.getDataBefore()).thenReturn(sflowClientSettings);
+ when(rootNode.getDataAfter()).thenReturn(sflowClientSettings);
+ }
+
+ @Test
+ public void testOnWrite() {
+ when(rootNode.getModificationType()).thenReturn(DataObjectModification.ModificationType.WRITE);
+
+ listener.onDataTreeChanged(changes);
+
+ verify(listener).onWrite(rootNode, rootIdentifier);
+ }
+
+ @Test
+ public void testOnDelete() {
+ when(rootNode.getModificationType()).thenReturn(DataObjectModification.ModificationType.DELETE);
+
+ listener.onDataTreeChanged(changes);
+
+ verify(listener).onDelete(rootNode, rootIdentifier);
+ }
+
+ @Test
+ public void testOnSubtreeModified() {
+ when(rootNode.getModificationType()).thenReturn(DataObjectModification.ModificationType.SUBTREE_MODIFIED);
+
+ // first call will initialize uninitialized dependencies;
+ // second call will call #close on them
+ listener.onDataTreeChanged(changes);
+ listener.onDataTreeChanged(changes);
+ verify(listener, times(2)).onSubtreeModified(rootNode, rootIdentifier);
+ }
+
+}