Expose a List of changes in DOMDataTreeChangeListener 47/109847/9
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 18 Jan 2024 19:14:29 +0000 (20:14 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 19 Jan 2024 04:24:35 +0000 (05:24 +0100)
The collection of changes needs to be considered to be ordered. This
patch codifies that by using a List. This has the up side of making it
easier to access first/last item as well as to navigate around.

Change-Id: If747e0000f8a9bb33d934b84c0c078d56d4c6126
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-api/src/main/java/org/opendaylight/mdsal/binding/api/DataChangeListenerAdapter.java
binding/mdsal-binding-api/src/main/java/org/opendaylight/mdsal/binding/api/DataListenerAdapter.java
binding/mdsal-binding-api/src/main/java/org/opendaylight/mdsal/binding/api/DataTreeChangeListener.java
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/BindingDOMDataTreeChangeServiceAdapterTest.java
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/Bug4513Test.java
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/DataTreeChangeListenerTest.java
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/Mdsal298Test.java
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/test/AbstractDataTreeChangeListenerTest.java

index 364fa59e0f730e67bf0a0557dae84ea0dfe80121..53895f7a20bb40094fe96c2436de521031ef8df0 100644 (file)
@@ -10,8 +10,7 @@ package org.opendaylight.mdsal.binding.api;
 import static java.util.Objects.requireNonNull;
 
 import com.google.common.collect.ForwardingObject;
-import com.google.common.collect.Iterables;
-import java.util.Collection;
+import java.util.List;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 
 final class DataChangeListenerAdapter<T extends DataObject> extends ForwardingObject
@@ -23,9 +22,9 @@ final class DataChangeListenerAdapter<T extends DataObject> extends ForwardingOb
     }
 
     @Override
-    public void onDataTreeChanged(final Collection<DataTreeModification<T>> changes) {
-        delegate.dataChanged(changes.iterator().next().getRootNode().dataBefore(),
-            Iterables.getLast(changes).getRootNode().dataAfter());
+    public void onDataTreeChanged(final List<DataTreeModification<T>> changes) {
+        delegate.dataChanged(changes.get(0).getRootNode().dataBefore(),
+            changes.get(changes.size() - 1).getRootNode().dataAfter());
     }
 
     @Override
index b12fbc82a1d2bd51b7a406002c8f36d27109d3fb..8d6dc87f52582cd0191e3a2eaed98660a1b98449 100644 (file)
@@ -10,8 +10,7 @@ package org.opendaylight.mdsal.binding.api;
 import static java.util.Objects.requireNonNull;
 
 import com.google.common.collect.ForwardingObject;
-import com.google.common.collect.Iterables;
-import java.util.Collection;
+import java.util.List;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 
 final class DataListenerAdapter<T extends DataObject> extends ForwardingObject
@@ -23,8 +22,8 @@ final class DataListenerAdapter<T extends DataObject> extends ForwardingObject
     }
 
     @Override
-    public void onDataTreeChanged(final Collection<DataTreeModification<T>> changes) {
-        delegate.dataChangedTo(Iterables.getLast(changes).getRootNode().dataAfter());
+    public void onDataTreeChanged(final List<DataTreeModification<T>> changes) {
+        delegate.dataChangedTo(changes.get(changes.size() - 1).getRootNode().dataAfter());
     }
 
     @Override
index 3c6c43c2946def05e89b98c4153d5423746daa1e..c9d4a351be1ab0ef119b00e530823638bf2cf11c 100644 (file)
@@ -7,53 +7,49 @@
  */
 package org.opendaylight.mdsal.binding.api;
 
-import java.util.Collection;
+import java.util.List;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 
 /**
- * Interface implemented by classes interested in receiving notifications about
- * data tree changes. It provides a cursor-based view of the change, which has potentially
- * lower overhead and allow more flexible consumption of change event.
+ * Interface implemented by classes interested in receiving notifications about changes to a data tree. It provides
+ * a cursor-based view of the change, which has potentially lower overhead and allow more flexible consumption of change
+ * events.
  */
 public interface DataTreeChangeListener<T extends DataObject> {
     /**
-     * Invoked when there was data change for the supplied path, which was used
-     * to register this listener.
+     * Invoked when there was data change for the supplied path, which was used to register this listener.
      *
      * <p>
-     * This method may be also invoked during registration of the listener if
-     * there is any pre-existing data in the conceptual data tree for supplied
-     * path. This initial event will contain all pre-existing data as created.
+     * This method may be also invoked during registration of the listener if there is any pre-existing data in the
+     * conceptual data tree for supplied path. This initial event will contain all pre-existing data as created.
      *
      * <p>
      * Note: If there is no pre-existing data, the method {@link #onInitialData} will be invoked.
      *
      * <p>
-     * A data change event may be triggered spuriously, e.g. such that data before
-     * and after compare as equal. Implementations of this interface are expected
-     * to recover from such events. Event producers are expected to exert reasonable
-     * effort to suppress such events.
+     * A data change event may be triggered spuriously, e.g. such that data before and after compare as equal.
+     * Implementations of this interface are expected to recover from such events. Event producers are expected to exert
+     * reasonable effort to suppress such events.
      *
      *<p>
-     * In other words, it is completely acceptable to observe
-     * a {@link DataObjectModification}, while the state observed before and
-     * after- data items compare as equal.
+     * In other words, it is completely acceptable to observe a {@link DataObjectModification}, while the state observed
+     * before and after- data items compare as equal.
      *
-     * @param changes Collection of change events, may not be null or empty.
+     * @param changes List of change events, may not be null or empty.
      */
-    void onDataTreeChanged(@NonNull Collection<DataTreeModification<T>> changes);
+    void onDataTreeChanged(@NonNull List<DataTreeModification<T>> changes);
 
     /**
-     * Invoked only once during registration of the listener if there was no data in the conceptual data tree
-     * for the supplied path, which was used to register this listener, and after this
-     * {@link #onDataTreeChanged(Collection)} would always be invoked for data changes.
+     * Invoked only once during registration of the listener if there was no data in the conceptual data tree for the
+     * supplied path, which was used to register this listener, and after this {@link #onDataTreeChanged(List)} would
+     * always be invoked for data changes.
      *
      * <p>
-     * Default implementation does nothing and is appropriate for users who do not care about ascertaining
-     * initial state.
+     * Default implementation does nothing and is appropriate for users who do not care about ascertaining initial
+     * state.
      */
-    // FIXME: 8.0.0: this method should be non-default
+    // FIXME: 14.0.0: this method should be non-default
     default void onInitialData() {
         //no-op
     }
index 42a8d2e959554a9bb24ff5d737a27f69c06418db..1a00a5169315305b7a36292e22e52dd677b4b167 100644 (file)
@@ -15,7 +15,7 @@ import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.reset;
 import static org.mockito.Mockito.verify;
 
-import java.util.Collection;
+import java.util.List;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -33,7 +33,7 @@ import org.opendaylight.mdsal.dom.api.DOMDataBroker.DataTreeChangeExtension;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
@@ -53,9 +53,8 @@ public class BindingDOMDataTreeChangeServiceAdapterTest {
     @Mock
     private BindingDOMCodecServices services;
 
-    @SuppressWarnings("rawtypes")
     @Mock
-    private ListenerRegistration mockDOMReg;
+    private Registration mockDOMReg;
 
     @Before
     public void setUp() {
@@ -94,14 +93,14 @@ public class BindingDOMDataTreeChangeServiceAdapterTest {
 
     private static final class TestClusteredDataTreeChangeListener implements ClusteredDataTreeChangeListener<Top> {
         @Override
-        public void onDataTreeChanged(final Collection<DataTreeModification<Top>> changes) {
+        public void onDataTreeChanged(final List<DataTreeModification<Top>> changes) {
             // No-op
         }
     }
 
     private static final class TestDataTreeChangeListener implements DataTreeChangeListener<Top> {
         @Override
-        public void onDataTreeChanged(final Collection<DataTreeModification<Top>> changes) {
+        public void onDataTreeChanged(final List<DataTreeModification<Top>> changes) {
             // No-op
         }
     }
index d9355986d08bbca6c45677aa579963be00e8333f..2bed1fc742c56bb823b3b8406e40301307bac239 100644 (file)
@@ -11,7 +11,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.Mockito.timeout;
 import static org.mockito.Mockito.verify;
 
-import java.util.Collection;
+import java.util.List;
 import org.junit.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.ArgumentCaptor;
@@ -40,23 +40,23 @@ class Bug4513Test extends AbstractDataBrokerTest {
     @Mock
     private DataTreeChangeListener<ListItem> listener;
     @Captor
-    private ArgumentCaptor<Collection<DataTreeModification<ListItem>>> captor;
+    private ArgumentCaptor<List<DataTreeModification<ListItem>>> captor;
 
     @Test
     void testDataTreeChangeListener() {
         final var dataBroker = getDataBroker();
 
         final var wildCard = InstanceIdentifier.builder(ListenerTest.class).child(ListItem.class).build();
-        final var reg = dataBroker.registerDataTreeChangeListener(
-                DataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL, wildCard), listener);
+        try (var reg = dataBroker.registerDataTreeChangeListener(
+                DataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL, wildCard), listener)) {
+            final var item = writeListItem();
 
-        final var item = writeListItem();
+            verify(listener, timeout(100)).onDataTreeChanged(captor.capture());
 
-        verify(listener, timeout(100)).onDataTreeChanged(captor.capture());
-
-        final var mods = captor.getValue();
-        assertEquals(1, mods.size());
-        assertEquals(item, mods.iterator().next().getRootNode().getDataAfter());
+            final var mods = captor.getValue();
+            assertEquals(1, mods.size());
+            assertEquals(item, mods.get(0).getRootNode().dataAfter());
+        }
     }
 
     private ListItem writeListItem() {
index 58a61e2078dd8d376438ec3d5aaa9f985ba72a1d..e2e03620b2481b6a4a52d8661a8c610e938941ac 100644 (file)
@@ -22,6 +22,7 @@ import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
 import com.google.common.util.concurrent.SettableFuture;
 import java.util.Collection;
+import java.util.List;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
 import org.junit.Test;
@@ -62,17 +63,15 @@ public class DataTreeChangeListenerTest extends AbstractDataBrokerTest {
     private BindingDOMDataBrokerAdapter dataBrokerImpl;
 
     private static final class EventCapturingListener<T extends DataObject> implements DataTreeChangeListener<T> {
-
-        private SettableFuture<Collection<DataTreeModification<T>>> futureChanges = SettableFuture.create();
+        private SettableFuture<List<DataTreeModification<T>>> futureChanges = SettableFuture.create();
 
         @Override
-        public void onDataTreeChanged(final Collection<DataTreeModification<T>> changes) {
+        public void onDataTreeChanged(final List<DataTreeModification<T>> changes) {
             futureChanges.set(changes);
-
         }
 
         Collection<DataTreeModification<T>> nextEvent() throws Exception {
-            final Collection<DataTreeModification<T>> result = futureChanges.get(200,TimeUnit.MILLISECONDS);
+            final var result = futureChanges.get(200,TimeUnit.MILLISECONDS);
             futureChanges = SettableFuture.create();
             return result;
         }
index 258eacee00aceeca46e4d5b68d556273b0192afa..794a3eeb9d8cfc8f8528ef5b51527d58d5a3fccd 100644 (file)
@@ -8,15 +8,13 @@
 package org.opendaylight.mdsal.binding.dom.adapter;
 
 import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.anyCollection;
+import static org.mockito.ArgumentMatchers.anyList;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.reset;
 import static org.mockito.Mockito.verify;
 import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION;
 
-import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
 import org.junit.Test;
@@ -105,38 +103,38 @@ public class Mdsal298Test extends AbstractDataBrokerTest {
                 .build());
         domTx.commit().get();
 
-        final var captor = ArgumentCaptor.forClass(Collection.class);
+        final var captor = ArgumentCaptor.forClass(List.class);
         verify(listener).onDataTreeChanged(captor.capture());
-        Collection<DataTreeModification<Container>> capture = captor.getValue();
+        List<DataTreeModification<Container>> capture = captor.getValue();
         assertEquals(1, capture.size());
 
-        final DataTreeModification<Container> change = capture.iterator().next();
+        final DataTreeModification<Container> change = capture.get(0);
         assertEquals(CONTAINER_TID, change.getRootPath());
         final DataObjectModification<Container> changedContainer = change.getRootNode();
-        assertEquals(new NodeStep<>(Container.class), changedContainer.getIdentifier());
-        assertEquals(ModificationType.SUBTREE_MODIFIED, changedContainer.getModificationType());
+        assertEquals(new NodeStep<>(Container.class), changedContainer.step());
+        assertEquals(ModificationType.SUBTREE_MODIFIED, changedContainer.modificationType());
 
-        final Container containerAfter = changedContainer.getDataAfter();
+        final Container containerAfter = changedContainer.dataAfter();
         assertEquals(new ContainerBuilder()
             .setKeyed(List.of(
                 new KeyedBuilder().setFoo("foo").withKey(new KeyedKey("foo")).build(),
                 new KeyedBuilder().setFoo("bar").withKey(new KeyedKey("bar")).build()))
             .build(), containerAfter);
 
-        final Collection<? extends DataObjectModification<?>> changedChildren = changedContainer.getModifiedChildren();
+        final var changedChildren = changedContainer.modifiedChildren();
         assertEquals(2, changedChildren.size());
 
-        final Iterator<? extends DataObjectModification<?>> it = changedChildren.iterator();
+        final var it = changedChildren.iterator();
         final DataObjectModification<?> changedChild1 = it.next();
-        assertEquals(ModificationType.WRITE, changedChild1.getModificationType());
-        assertEquals(List.of(), changedChild1.getModifiedChildren());
-        final Keyed child1After = (Keyed) changedChild1.getDataAfter();
+        assertEquals(ModificationType.WRITE, changedChild1.modificationType());
+        assertEquals(List.of(), changedChild1.modifiedChildren());
+        final Keyed child1After = (Keyed) changedChild1.dataAfter();
         assertEquals("foo", child1After.getFoo());
 
         final DataObjectModification<?> changedChild2 = it.next();
-        assertEquals(ModificationType.WRITE, changedChild2.getModificationType());
-        assertEquals(List.of(), changedChild2.getModifiedChildren());
-        final Keyed child2After = (Keyed) changedChild2.getDataAfter();
+        assertEquals(ModificationType.WRITE, changedChild2.modificationType());
+        assertEquals(List.of(), changedChild2.modifiedChildren());
+        final Keyed child2After = (Keyed) changedChild2.dataAfter();
         assertEquals("bar", child2After.getFoo());
     }
 
@@ -160,25 +158,25 @@ public class Mdsal298Test extends AbstractDataBrokerTest {
                 .build());
         domTx.commit().get();
 
-        final var captor = ArgumentCaptor.forClass(Collection.class);
+        final var captor = ArgumentCaptor.forClass(List.class);
         verify(listener).onDataTreeChanged(captor.capture());
-        Collection<DataTreeModification<Container>> capture = captor.getValue();
+        List<DataTreeModification<Container>> capture = captor.getValue();
         assertEquals(1, capture.size());
 
-        final DataTreeModification<Container> change = capture.iterator().next();
+        final DataTreeModification<Container> change = capture.get(0);
         assertEquals(CONTAINER_TID, change.getRootPath());
         final DataObjectModification<Container> changedContainer = change.getRootNode();
-        assertEquals(new NodeStep<>(Container.class), changedContainer.getIdentifier());
-        assertEquals(ModificationType.WRITE, changedContainer.getModificationType());
+        assertEquals(new NodeStep<>(Container.class), changedContainer.step());
+        assertEquals(ModificationType.WRITE, changedContainer.modificationType());
 
-        final Container containerAfter = changedContainer.getDataAfter();
+        final Container containerAfter = changedContainer.dataAfter();
         assertEquals(new ContainerBuilder()
                 .setUnkeyed(List.of(
                     new UnkeyedBuilder().setFoo("foo").build(),
                     new UnkeyedBuilder().setFoo("bar").build()))
                 .build(), containerAfter);
 
-        final Collection<? extends DataObjectModification<?>> changedChildren = changedContainer.getModifiedChildren();
+        final var changedChildren = changedContainer.modifiedChildren();
         assertEquals(0, changedChildren.size());
     }
 
@@ -186,31 +184,30 @@ public class Mdsal298Test extends AbstractDataBrokerTest {
     public void testChoiceDataTreeModificationAddressable() throws InterruptedException, ExecutionException {
         final DataTreeChangeListener<WithChoice> listener = assertWrittenWithChoice();
 
-        doNothing().when(listener).onDataTreeChanged(anyCollection());
+        doNothing().when(listener).onDataTreeChanged(anyList());
 
         final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
         writeTx.put(CONFIGURATION, ADDRESSABLE_CASE, new AddressableBuilder().build());
         writeTx.commit().get();
 
-        final var captor = ArgumentCaptor.forClass(Collection.class);
+        final var captor = ArgumentCaptor.forClass(List.class);
         verify(listener).onDataTreeChanged(captor.capture());
-        Collection<DataTreeModification<WithChoice>> capture = captor.getValue();
+        List<DataTreeModification<WithChoice>> capture = captor.getValue();
         assertEquals(1, capture.size());
 
         final DataTreeModification<WithChoice> choiceChange = capture.iterator().next();
         assertEquals(CHOICE_CONTAINER_TID, choiceChange.getRootPath());
         final DataObjectModification<WithChoice> changedContainer = choiceChange.getRootNode();
-        assertEquals(ModificationType.SUBTREE_MODIFIED, changedContainer.getModificationType());
-        assertEquals(new NodeStep<>(WithChoice.class), changedContainer.getIdentifier());
+        assertEquals(ModificationType.SUBTREE_MODIFIED, changedContainer.modificationType());
+        assertEquals(new NodeStep<>(WithChoice.class), changedContainer.step());
 
-        final Collection<? extends DataObjectModification<?>> choiceChildren = changedContainer.getModifiedChildren();
+        final var choiceChildren = changedContainer.modifiedChildren();
         assertEquals(1, choiceChildren.size());
 
-        final DataObjectModification<Addressable> changedCase = (DataObjectModification<Addressable>) choiceChildren
-                .iterator().next();
-        assertEquals(ModificationType.WRITE, changedCase.getModificationType());
-        assertEquals(new NodeStep<>(Addressable.class), changedCase.getIdentifier());
-        assertEquals(new AddressableBuilder().build(), changedCase.getDataAfter());
+        final var changedCase = (DataObjectModification<Addressable>) choiceChildren.iterator().next();
+        assertEquals(ModificationType.WRITE, changedCase.modificationType());
+        assertEquals(new NodeStep<>(Addressable.class), changedCase.step());
+        assertEquals(new AddressableBuilder().build(), changedCase.dataAfter());
     }
 
     @Test
@@ -218,32 +215,31 @@ public class Mdsal298Test extends AbstractDataBrokerTest {
         final DataTreeChangeListener<AddressableCont> listener = assertWrittenContainer(AddressableCont.QNAME,
             AddressableCont.class, new AddressableContBuilder().build());
 
-        doNothing().when(listener).onDataTreeChanged(anyCollection());
+        doNothing().when(listener).onDataTreeChanged(anyList());
 
         final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
         writeTx.put(CONFIGURATION, ADDRESSABLE_CONTAINER.child(AddressableChild.class),
             new AddressableChildBuilder().build());
         writeTx.commit().get();
 
-        final var captor = ArgumentCaptor.forClass(Collection.class);
+        final var captor = ArgumentCaptor.forClass(List.class);
         verify(listener).onDataTreeChanged(captor.capture());
-        Collection<DataTreeModification<AddressableCont>> capture = captor.getValue();
+        final List<DataTreeModification<AddressableCont>> capture = captor.getValue();
         assertEquals(1, capture.size());
 
         final DataTreeModification<AddressableCont> contChange = capture.iterator().next();
         assertEquals(ADDRESSABLE_CONTAINER_TID, contChange.getRootPath());
         final DataObjectModification<AddressableCont> changedContainer = contChange.getRootNode();
-        assertEquals(ModificationType.SUBTREE_MODIFIED, changedContainer.getModificationType());
-        assertEquals(new NodeStep<>(AddressableCont.class), changedContainer.getIdentifier());
+        assertEquals(ModificationType.SUBTREE_MODIFIED, changedContainer.modificationType());
+        assertEquals(new NodeStep<>(AddressableCont.class), changedContainer.step());
 
-        final Collection<? extends DataObjectModification<?>> contChildren = changedContainer.getModifiedChildren();
+        final var contChildren = changedContainer.modifiedChildren();
         assertEquals(1, contChildren.size());
 
-        final DataObjectModification<Addressable> changedChild = (DataObjectModification<Addressable>) contChildren
-                .iterator().next();
-        assertEquals(ModificationType.WRITE, changedChild.getModificationType());
-        assertEquals(new NodeStep<>(AddressableChild.class), changedChild.getIdentifier());
-        assertEquals(new AddressableChildBuilder().build(), changedChild.getDataAfter());
+        final var changedChild = (DataObjectModification<Addressable>) contChildren.iterator().next();
+        assertEquals(ModificationType.WRITE, changedChild.modificationType());
+        assertEquals(new NodeStep<>(AddressableChild.class), changedChild.step());
+        assertEquals(new AddressableChildBuilder().build(), changedChild.dataAfter());
     }
 
     @Test
@@ -251,7 +247,7 @@ public class Mdsal298Test extends AbstractDataBrokerTest {
         final DataTreeChangeListener<UnaddressableCont> listener = assertWrittenContainer(UnaddressableCont.QNAME,
             UnaddressableCont.class, new UnaddressableContBuilder().build());
 
-        doNothing().when(listener).onDataTreeChanged(anyCollection());
+        doNothing().when(listener).onDataTreeChanged(anyList());
 
         final DOMDataTreeWriteTransaction domTx = getDomBroker().newWriteOnlyTransaction();
         domTx.put(CONFIGURATION, YangInstanceIdentifier.of(UNADDRESSABLE_CONTAINER_NID)
@@ -259,18 +255,18 @@ public class Mdsal298Test extends AbstractDataBrokerTest {
             ImmutableNodes.leafNode(BAZ_QNAME, "baz"));
         domTx.commit().get();
 
-        final var captor = ArgumentCaptor.forClass(Collection.class);
+        final var captor = ArgumentCaptor.forClass(List.class);
         verify(listener).onDataTreeChanged(captor.capture());
-        Collection<DataTreeModification<UnaddressableCont>> capture = captor.getValue();
+        List<DataTreeModification<UnaddressableCont>> capture = captor.getValue();
         assertEquals(1, capture.size());
 
         final DataTreeModification<UnaddressableCont> contChange = capture.iterator().next();
         assertEquals(UNADDRESSABLE_CONTAINER_TID, contChange.getRootPath());
         final DataObjectModification<UnaddressableCont> changedContainer = contChange.getRootNode();
-        assertEquals(ModificationType.WRITE, changedContainer.getModificationType());
-        assertEquals(new NodeStep<>(UnaddressableCont.class), changedContainer.getIdentifier());
+        assertEquals(ModificationType.WRITE, changedContainer.modificationType());
+        assertEquals(new NodeStep<>(UnaddressableCont.class), changedContainer.step());
 
-        final Collection<? extends DataObjectModification<?>> contChildren = changedContainer.getModifiedChildren();
+        final var contChildren = changedContainer.modifiedChildren();
         assertEquals(0, contChildren.size());
     }
 
@@ -278,7 +274,7 @@ public class Mdsal298Test extends AbstractDataBrokerTest {
     public void testChoiceDataTreeModificationUnaddressable() throws InterruptedException, ExecutionException {
         final DataTreeChangeListener<WithChoice> listener = assertWrittenWithChoice();
 
-        doNothing().when(listener).onDataTreeChanged(anyCollection());
+        doNothing().when(listener).onDataTreeChanged(anyList());
 
         final DOMDataTreeWriteTransaction domTx = getDomBroker().newWriteOnlyTransaction();
         domTx.put(CONFIGURATION, YangInstanceIdentifier.of(CHOICE_CONTAINER_NID).node(Foo.QNAME),
@@ -291,20 +287,20 @@ public class Mdsal298Test extends AbstractDataBrokerTest {
                 .build());
         domTx.commit().get();
 
-        final var captor = ArgumentCaptor.forClass(Collection.class);
+        final var captor = ArgumentCaptor.forClass(List.class);
         verify(listener).onDataTreeChanged(captor.capture());
-        Collection<DataTreeModification<WithChoice>> capture = captor.getValue();
+        List<DataTreeModification<WithChoice>> capture = captor.getValue();
         assertEquals(1, capture.size());
 
-        final DataTreeModification<WithChoice> choiceChange = capture.iterator().next();
+        final DataTreeModification<WithChoice> choiceChange = capture.get(0);
         assertEquals(CHOICE_CONTAINER_TID, choiceChange.getRootPath());
         final DataObjectModification<WithChoice> changedContainer = choiceChange.getRootNode();
 
         // Should be write
-        assertEquals(ModificationType.WRITE, changedContainer.getModificationType());
-        assertEquals(new NodeStep<>(WithChoice.class), changedContainer.getIdentifier());
+        assertEquals(ModificationType.WRITE, changedContainer.modificationType());
+        assertEquals(new NodeStep<>(WithChoice.class), changedContainer.step());
 
-        final Collection<? extends DataObjectModification<?>> choiceChildren = changedContainer.getModifiedChildren();
+        final var choiceChildren = changedContainer.modifiedChildren();
         assertEquals(0, choiceChildren.size());
     }
 
@@ -312,7 +308,7 @@ public class Mdsal298Test extends AbstractDataBrokerTest {
             final Class<T> bindingClass, final T expected)
             throws InterruptedException, ExecutionException {
         final DataTreeChangeListener<T> listener = mock(DataTreeChangeListener.class);
-        doNothing().when(listener).onDataTreeChanged(anyCollection());
+        doNothing().when(listener).onDataTreeChanged(anyList());
 
         final DataTreeIdentifier<T> dti = DataTreeIdentifier.of(CONFIGURATION, InstanceIdentifier.create(bindingClass));
         getDataBroker().registerDataTreeChangeListener(dti, listener);
@@ -322,32 +318,32 @@ public class Mdsal298Test extends AbstractDataBrokerTest {
             ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(qname)).build());
         domTx.commit().get();
 
-        final var captor = ArgumentCaptor.forClass(Collection.class);
+        final var captor = ArgumentCaptor.forClass(List.class);
         verify(listener).onDataTreeChanged(captor.capture());
-        Collection<DataTreeModification<T>> capture = captor.getValue();
+        List<DataTreeModification<T>> capture = captor.getValue();
         assertEquals(1, capture.size());
 
         final DataTreeModification<T> change = capture.iterator().next();
         assertEquals(dti, change.getRootPath());
         final DataObjectModification<T> changedContainer = change.getRootNode();
-        assertEquals(ModificationType.WRITE, changedContainer.getModificationType());
-        assertEquals(new NodeStep<>(bindingClass), changedContainer.getIdentifier());
+        assertEquals(ModificationType.WRITE, changedContainer.modificationType());
+        assertEquals(new NodeStep<>(bindingClass), changedContainer.step());
 
-        final T containerAfter = changedContainer.getDataAfter();
+        final T containerAfter = changedContainer.dataAfter();
         assertEquals(expected, containerAfter);
 
         // No further modifications should occur
-        assertEquals(List.of(), changedContainer.getModifiedChildren());
+        assertEquals(List.of(), changedContainer.modifiedChildren());
 
         reset(listener);
-        doNothing().when(listener).onDataTreeChanged(anyCollection());
+        doNothing().when(listener).onDataTreeChanged(anyList());
         return listener;
     }
 
     private DataTreeChangeListener<WithChoice> assertWrittenWithChoice() throws InterruptedException,
             ExecutionException {
         final DataTreeChangeListener<WithChoice> listener = mock(DataTreeChangeListener.class);
-        doNothing().when(listener).onDataTreeChanged(anyCollection());
+        doNothing().when(listener).onDataTreeChanged(anyList());
         getDataBroker().registerDataTreeChangeListener(CHOICE_CONTAINER_TID, listener);
 
         final DOMDataTreeWriteTransaction domTx = getDomBroker().newWriteOnlyTransaction();
@@ -357,25 +353,25 @@ public class Mdsal298Test extends AbstractDataBrokerTest {
             .build());
         domTx.commit().get();
 
-        final var captor = ArgumentCaptor.forClass(Collection.class);
+        final var captor = ArgumentCaptor.forClass(List.class);
         verify(listener).onDataTreeChanged(captor.capture());
-        Collection<DataTreeModification<WithChoice>> capture = captor.getValue();
+        List<DataTreeModification<WithChoice>> capture = captor.getValue();
         assertEquals(1, capture.size());
 
         final DataTreeModification<WithChoice> change = capture.iterator().next();
         assertEquals(CHOICE_CONTAINER_TID, change.getRootPath());
         final DataObjectModification<WithChoice> changedContainer = change.getRootNode();
-        assertEquals(ModificationType.WRITE, changedContainer.getModificationType());
-        assertEquals(new NodeStep<>(WithChoice.class), changedContainer.getIdentifier());
+        assertEquals(ModificationType.WRITE, changedContainer.modificationType());
+        assertEquals(new NodeStep<>(WithChoice.class), changedContainer.step());
 
-        final WithChoice containerAfter = changedContainer.getDataAfter();
+        final WithChoice containerAfter = changedContainer.dataAfter();
         assertEquals(new WithChoiceBuilder().build(), containerAfter);
 
         // No further modifications should occur
-        assertEquals(List.of(), changedContainer.getModifiedChildren());
+        assertEquals(List.of(), changedContainer.modifiedChildren());
 
         reset(listener);
-        doNothing().when(listener).onDataTreeChanged(anyCollection());
+        doNothing().when(listener).onDataTreeChanged(anyList());
 
         return listener;
     }
index 274ca6eeaca5d552cdcdaeaa1b2dfe2bbcf613fa..e2b4887f836c2ed88ca2f83f76457538c085bbe3 100644 (file)
@@ -14,8 +14,8 @@ import com.google.common.base.Stopwatch;
 import com.google.common.util.concurrent.Uninterruptibles;
 import java.util.ArrayDeque;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.Deque;
+import java.util.List;
 import java.util.Objects;
 import java.util.concurrent.TimeUnit;
 import org.eclipse.jdt.annotation.NonNull;
@@ -90,7 +90,7 @@ public class AbstractDataTreeChangeListenerTest extends AbstractConcurrentDataBr
         private boolean synced;
 
         @Override
-        public synchronized void onDataTreeChanged(final Collection<DataTreeModification<T>> changes) {
+        public synchronized void onDataTreeChanged(final List<DataTreeModification<T>> changes) {
             accumulatedChanges.addAll(changes);
             synced = true;
         }