Clean up mdsal-netconf-notification
[netconf.git] / netconf / mdsal-netconf-notification / src / test / java / org / opendaylight / netconf / mdsal / notification / impl / OperationalDatastoreListenerTest.java
index efd2a5c73bb218cd6bfc07d8aad13c9406ffea79..254489d4bb7932892b00a22c2ced18aad6721b1c 100644 (file)
@@ -5,7 +5,6 @@
  * 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.netconf.mdsal.notification.impl;
 
 import static org.junit.Assert.assertEquals;
@@ -14,48 +13,50 @@ import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.verify;
 
 import java.util.Collection;
-import javax.annotation.Nonnull;
-import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
+import org.opendaylight.mdsal.binding.api.DataTreeModification;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.ChildOf;
+import org.opendaylight.yangtools.yang.binding.DataRoot;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
+@RunWith(MockitoJUnitRunner.StrictStubs.class)
 public class OperationalDatastoreListenerTest {
-
     @Mock
     private DataBroker dataBroker;
-
-    @Before
-    public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
-    }
+    @Captor
+    private ArgumentCaptor<DataTreeIdentifier<?>> argumentId;
 
     @Test
     public void testDataStoreListener() {
-        final InstanceIdentifier<DataObject> instanceIdentifier = InstanceIdentifier.create(DataObject.class);
-        final DataTreeIdentifier<DataObject> testId =
-                DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, instanceIdentifier);
+        final InstanceIdentifier<TestInterface> instanceIdentifier = InstanceIdentifier.create(TestInterface.class);
 
-        final OperationalDatastoreListener<DataObject> op =
-                new OperationalDatastoreListener<DataObject>(instanceIdentifier) {
+        final var op = new OperationalDatastoreListener<>(instanceIdentifier) {
             @Override
-            public void onDataTreeChanged(@Nonnull final Collection collection) {
+            public void onDataTreeChanged(final Collection<DataTreeModification<TestInterface>> collection) {
+                // no-op
             }
         };
         doReturn(null).when(dataBroker).registerDataTreeChangeListener(any(), any());
 
-        ArgumentCaptor<DataTreeIdentifier> argumentId = ArgumentCaptor.forClass(DataTreeIdentifier.class);
         op.registerOnChanges(dataBroker);
         verify(dataBroker).registerDataTreeChangeListener(argumentId.capture(), any());
 
-        assertEquals(testId, argumentId.getValue());
-
+        assertEquals(DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, instanceIdentifier),
+            argumentId.getValue());
     }
 
+    interface TestInterface extends ChildOf<DataRoot> {
+        @Override
+        default Class<TestInterface> implementedInterface() {
+            return TestInterface.class;
+        }
+    }
 }