Adopt odlparent-10.0.0/yangtools-8.0.0-SNAPSHOT
[mdsal.git] / dom / mdsal-dom-broker / src / test / java / org / opendaylight / mdsal / dom / broker / DOMDataTreeListenerTest.java
index 3d378ca5e3f212eace85006d2a9c3865b70160e1..39947d728bf1b907cadc95283bf20d64015c25b1 100644 (file)
@@ -19,7 +19,6 @@ import com.google.common.util.concurrent.ForwardingExecutorService;
 import com.google.common.util.concurrent.ListeningExecutorService;
 import com.google.common.util.concurrent.MoreExecutors;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutionException;
@@ -35,7 +34,6 @@ import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
-import org.opendaylight.mdsal.dom.broker.util.TestModel;
 import org.opendaylight.mdsal.dom.spi.store.DOMStore;
 import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
@@ -46,11 +44,11 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
+import org.opendaylight.yangtools.yang.data.tree.api.ModificationType;
 
 public class DOMDataTreeListenerTest extends AbstractDatastoreTest {
 
@@ -137,10 +135,10 @@ public class DOMDataTreeListenerTest extends AbstractDatastoreTest {
         latch.await(5, TimeUnit.SECONDS);
 
         assertEquals(1, listener.getReceivedChanges().size());
-        final Collection<DataTreeCandidate> changes = listener.getReceivedChanges().get(0);
+        final List<DataTreeCandidate> changes = listener.getReceivedChanges().get(0);
         assertEquals(1, changes.size());
 
-        final DataTreeCandidate candidate = changes.iterator().next();
+        final DataTreeCandidate candidate = changes.get(0);
         assertNotNull(candidate);
         final DataTreeCandidateNode candidateRoot = candidate.getRootNode();
         checkChange(null, TEST_CONTAINER, ModificationType.WRITE, candidateRoot);
@@ -169,10 +167,10 @@ public class DOMDataTreeListenerTest extends AbstractDatastoreTest {
         latch.await(5, TimeUnit.SECONDS);
 
         assertEquals(2, listener.getReceivedChanges().size());
-        Collection<DataTreeCandidate> changes = listener.getReceivedChanges().get(0);
+        List<DataTreeCandidate> changes = listener.getReceivedChanges().get(0);
         assertEquals(1, changes.size());
 
-        DataTreeCandidate candidate = changes.iterator().next();
+        DataTreeCandidate candidate = changes.get(0);
         assertNotNull(candidate);
         DataTreeCandidateNode candidateRoot = candidate.getRootNode();
         checkChange(null, TEST_CONTAINER, ModificationType.WRITE, candidateRoot);
@@ -180,7 +178,7 @@ public class DOMDataTreeListenerTest extends AbstractDatastoreTest {
         changes = listener.getReceivedChanges().get(1);
         assertEquals(1, changes.size());
 
-        candidate = changes.iterator().next();
+        candidate = changes.get(0);
         assertNotNull(candidate);
         candidateRoot = candidate.getRootNode();
         checkChange(TEST_CONTAINER, TEST_CONTAINER_2, ModificationType.WRITE, candidateRoot);
@@ -210,10 +208,10 @@ public class DOMDataTreeListenerTest extends AbstractDatastoreTest {
         latch.await(5, TimeUnit.SECONDS);
 
         assertEquals(2, listener.getReceivedChanges().size());
-        Collection<DataTreeCandidate> changes = listener.getReceivedChanges().get(0);
+        List<DataTreeCandidate> changes = listener.getReceivedChanges().get(0);
         assertEquals(1, changes.size());
 
-        DataTreeCandidate candidate = changes.iterator().next();
+        DataTreeCandidate candidate = changes.get(0);
         assertNotNull(candidate);
         DataTreeCandidateNode candidateRoot = candidate.getRootNode();
         checkChange(null, TEST_CONTAINER, ModificationType.WRITE, candidateRoot);
@@ -221,7 +219,7 @@ public class DOMDataTreeListenerTest extends AbstractDatastoreTest {
         changes = listener.getReceivedChanges().get(1);
         assertEquals(1, changes.size());
 
-        candidate = changes.iterator().next();
+        candidate = changes.get(0);
         assertNotNull(candidate);
         candidateRoot = candidate.getRootNode();
         checkChange(TEST_CONTAINER, null, ModificationType.DELETE, candidateRoot);
@@ -251,10 +249,10 @@ public class DOMDataTreeListenerTest extends AbstractDatastoreTest {
         latch.await(5, TimeUnit.SECONDS);
 
         assertEquals(2, listener.getReceivedChanges().size());
-        Collection<DataTreeCandidate> changes = listener.getReceivedChanges().get(0);
+        List<DataTreeCandidate> changes = listener.getReceivedChanges().get(0);
         assertEquals(1, changes.size());
 
-        DataTreeCandidate candidate = changes.iterator().next();
+        DataTreeCandidate candidate = changes.get(0);
         assertNotNull(candidate);
         DataTreeCandidateNode candidateRoot = candidate.getRootNode();
         checkChange(null, TEST_CONTAINER, ModificationType.WRITE, candidateRoot);
@@ -262,7 +260,7 @@ public class DOMDataTreeListenerTest extends AbstractDatastoreTest {
         changes = listener.getReceivedChanges().get(1);
         assertEquals(1, changes.size());
 
-        candidate = changes.iterator().next();
+        candidate = changes.get(0);
         assertNotNull(candidate);
         candidateRoot = candidate.getRootNode();
         checkChange(TEST_CONTAINER, TEST_CONTAINER_2, ModificationType.SUBTREE_MODIFIED, candidateRoot);
@@ -295,10 +293,10 @@ public class DOMDataTreeListenerTest extends AbstractDatastoreTest {
         latch.await(1, TimeUnit.SECONDS);
 
         assertEquals(2, listener.getReceivedChanges().size());
-        Collection<DataTreeCandidate> changes = listener.getReceivedChanges().get(0);
+        List<DataTreeCandidate> changes = listener.getReceivedChanges().get(0);
         assertEquals(1, changes.size());
 
-        DataTreeCandidate candidate = changes.iterator().next();
+        DataTreeCandidate candidate = changes.get(0);
         assertNotNull(candidate);
         DataTreeCandidateNode candidateRoot = candidate.getRootNode();
         checkChange(null, OUTER_LIST, ModificationType.WRITE, candidateRoot);
@@ -306,7 +304,7 @@ public class DOMDataTreeListenerTest extends AbstractDatastoreTest {
         changes = listener.getReceivedChanges().get(1);
         assertEquals(1, changes.size());
 
-        candidate = changes.iterator().next();
+        candidate = changes.get(0);
         assertNotNull(candidate);
         candidateRoot = candidate.getRootNode();
         checkChange(OUTER_LIST, OUTER_LIST_2, ModificationType.WRITE, candidateRoot);
@@ -356,10 +354,10 @@ public class DOMDataTreeListenerTest extends AbstractDatastoreTest {
         latch.await(5, TimeUnit.SECONDS);
 
         assertEquals(2, listener.getReceivedChanges().size());
-        Collection<DataTreeCandidate> changes = listener.getReceivedChanges().get(0);
+        List<DataTreeCandidate> changes = listener.getReceivedChanges().get(0);
         assertEquals(1, changes.size());
 
-        DataTreeCandidate candidate = changes.iterator().next();
+        DataTreeCandidate candidate = changes.get(0);
         assertNotNull(candidate);
         DataTreeCandidateNode candidateRoot = candidate.getRootNode();
         checkChange(null, OUTER_LIST, ModificationType.WRITE, candidateRoot);
@@ -367,7 +365,7 @@ public class DOMDataTreeListenerTest extends AbstractDatastoreTest {
         changes = listener.getReceivedChanges().get(1);
         assertEquals(1, changes.size());
 
-        candidate = changes.iterator().next();
+        candidate = changes.get(0);
         assertNotNull(candidate);
         candidateRoot = candidate.getRootNode();
         checkChange(OUTER_LIST, listAfter, ModificationType.SUBTREE_MODIFIED, candidateRoot);
@@ -418,8 +416,7 @@ public class DOMDataTreeListenerTest extends AbstractDatastoreTest {
     }
 
     static class TestDataTreeListener implements DOMDataTreeChangeListener {
-
-        private final List<Collection<DataTreeCandidate>> receivedChanges = new ArrayList<>();
+        private final List<List<DataTreeCandidate>> receivedChanges = new ArrayList<>();
         private final CountDownLatch latch;
 
         TestDataTreeListener(final CountDownLatch latch) {
@@ -427,12 +424,17 @@ public class DOMDataTreeListenerTest extends AbstractDatastoreTest {
         }
 
         @Override
-        public void onDataTreeChanged(final Collection<DataTreeCandidate> changes) {
+        public void onDataTreeChanged(final List<DataTreeCandidate> changes) {
             receivedChanges.add(changes);
             latch.countDown();
         }
 
-        public List<Collection<DataTreeCandidate>> getReceivedChanges() {
+        @Override
+        public void onInitialData() {
+            // noop
+        }
+
+        List<List<DataTreeCandidate>> getReceivedChanges() {
             return receivedChanges;
         }
     }