Update MRI projects for Aluminium
[openflowplugin.git] / applications / topology-manager / src / test / java / org / opendaylight / openflowplugin / applications / topology / manager / TerminationPointChangeListenerImplTest.java
index c13514fe21ca438c38bc98136973f31aed852f92..92ab192d3b28864492fb5b40935fe6430b087c24 100644 (file)
@@ -9,14 +9,14 @@ package org.opendaylight.openflowplugin.applications.topology.manager;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
-import static org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType.DELETE;
-import static org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType.WRITE;
+import static org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.DELETE;
+import static org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.WRITE;
 import static org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.assertDeletedIDs;
 import static org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newDestTp;
 import static org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newInvNodeConnKey;
@@ -31,19 +31,18 @@ import static org.opendaylight.openflowplugin.applications.topology.manager.Test
 import static org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.waitForDeletes;
 import static org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.waitForSubmit;
 
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.SettableFuture;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+import java.util.Optional;
 import java.util.concurrent.CountDownLatch;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.mdsal.binding.api.DataTreeModification;
+import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.topology.inventory.rev131030.InventoryNodeConnector;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
@@ -56,6 +55,7 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey;
+import org.opendaylight.yangtools.util.concurrent.FluentFutures;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public class TerminationPointChangeListenerImplTest extends DataTreeChangeListenerBase {
@@ -93,13 +93,11 @@ public class TerminationPointChangeListenerImplTest extends DataTreeChangeListen
         final SettableFuture<Optional<Topology>> readFuture = SettableFuture.create();
         readFuture.set(Optional.of(topology));
         ReadWriteTransaction mockTx1 = mock(ReadWriteTransaction.class);
-        doReturn(Futures.makeChecked(readFuture, ReadFailedException.MAPPER)).when(mockTx1)
-                .read(LogicalDatastoreType.OPERATIONAL, topologyIID);
+        doReturn(FluentFuture.from(readFuture)).when(mockTx1).read(LogicalDatastoreType.OPERATIONAL, topologyIID);
 
         SettableFuture<Optional<Node>> readFutureNode = SettableFuture.create();
         readFutureNode.set(Optional.of(topoNode));
-        doReturn(Futures.makeChecked(readFutureNode, ReadFailedException.MAPPER)).when(mockTx1)
-                .read(LogicalDatastoreType.OPERATIONAL, topoNodeII);
+        doReturn(FluentFuture.from(readFutureNode)).when(mockTx1).read(LogicalDatastoreType.OPERATIONAL, topoNodeII);
 
         final CountDownLatch submitLatch1 = setupStubbedSubmit(mockTx1);
 
@@ -149,13 +147,11 @@ public class TerminationPointChangeListenerImplTest extends DataTreeChangeListen
             };
 
         ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class);
-        doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockTx)
+        doReturn(FluentFutures.immediateFluentFuture(Optional.empty())).when(mockTx)
                 .read(LogicalDatastoreType.OPERATIONAL, topologyIID);
         final CountDownLatch submitLatch = setupStubbedSubmit(mockTx);
 
-        SettableFuture<Optional<Node>> readFutureNode = SettableFuture.create();
-        readFutureNode.set(Optional.of(topoNode));
-        doReturn(Futures.makeChecked(readFutureNode, ReadFailedException.MAPPER)).when(mockTx)
+        doReturn(FluentFutures.immediateFluentFuture(Optional.of(topoNode))).when(mockTx)
                 .read(LogicalDatastoreType.OPERATIONAL, topoNodeII);
 
         CountDownLatch deleteLatch = new CountDownLatch(1);
@@ -201,8 +197,8 @@ public class TerminationPointChangeListenerImplTest extends DataTreeChangeListen
         InstanceIdentifier<TerminationPoint> expTpPath = topologyIID.child(
                 Node.class, new NodeKey(expNodeId)).child(TerminationPoint.class,
                         new TerminationPointKey(expTpId));
-        verify(mockTx).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(expTpPath),
-                mergedNode.capture(), eq(true));
+        verify(mockTx).mergeParentStructureMerge(eq(LogicalDatastoreType.OPERATIONAL), eq(expTpPath),
+                mergedNode.capture());
         assertEquals("getTpId", expTpId, mergedNode.getValue().getTpId());
         InventoryNodeConnector augmentation = mergedNode.getValue().augmentation(
                 InventoryNodeConnector.class);
@@ -227,7 +223,7 @@ public class TerminationPointChangeListenerImplTest extends DataTreeChangeListen
         Topology topology = new TopologyBuilder().setLink(linkList).build();
 
         ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class);
-        doReturn(Futures.immediateCheckedFuture(Optional.of(topology))).when(mockTx)
+        doReturn(FluentFutures.immediateFluentFuture(Optional.of(topology))).when(mockTx)
                 .read(LogicalDatastoreType.OPERATIONAL, topologyIID);
         setupStubbedSubmit(mockTx);
 
@@ -249,8 +245,8 @@ public class TerminationPointChangeListenerImplTest extends DataTreeChangeListen
                 Node.class, new NodeKey(new NodeId("node1"))).child(TerminationPoint.class,
                         new TerminationPointKey(new TpId("tp1")));
 
-        verify(mockTx).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(expTpPath),
-                any(TerminationPoint.class), eq(true));
+        verify(mockTx).mergeParentStructureMerge(eq(LogicalDatastoreType.OPERATIONAL), eq(expTpPath),
+                any(TerminationPoint.class));
 
         assertDeletedIDs(new InstanceIdentifier[]{topologyIID.child(Link.class,
                 linkList.get(0).key())}, deletedLinkIDs);
@@ -272,7 +268,7 @@ public class TerminationPointChangeListenerImplTest extends DataTreeChangeListen
         Topology topology = new TopologyBuilder().setLink(linkList).build();
 
         ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class);
-        doReturn(Futures.immediateCheckedFuture(Optional.of(topology))).when(mockTx)
+        doReturn(FluentFutures.immediateFluentFuture(Optional.of(topology))).when(mockTx)
                 .read(LogicalDatastoreType.OPERATIONAL, topologyIID);
         setupStubbedSubmit(mockTx);
 
@@ -294,8 +290,8 @@ public class TerminationPointChangeListenerImplTest extends DataTreeChangeListen
                 Node.class, new NodeKey(new NodeId("node1"))).child(TerminationPoint.class,
                         new TerminationPointKey(new TpId("tp1")));
 
-        verify(mockTx).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(expTpPath),
-                any(TerminationPoint.class), eq(true));
+        verify(mockTx).mergeParentStructureMerge(eq(LogicalDatastoreType.OPERATIONAL), eq(expTpPath),
+                any(TerminationPoint.class));
 
         assertDeletedIDs(new InstanceIdentifier[]{topologyIID.child(Link.class,
                 linkList.get(0).key())}, deletedLinkIDs);