Update MRI projects for Aluminium
[openflowplugin.git] / applications / topology-manager / src / test / java / org / opendaylight / openflowplugin / applications / topology / manager / FlowCapableTopologyExporterTest.java
index 883d0722f0803bce71b7c06bc8618501a7fb76ba..34ac9ae80678ae7c040968e8be0e1127adccf569 100644 (file)
@@ -5,13 +5,12 @@
  * 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.openflowplugin.applications.topology.manager;
 
 import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.any;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
@@ -24,8 +23,7 @@ import static org.opendaylight.openflowplugin.applications.topology.manager.Test
 import static org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.setupStubbedSubmit;
 import static org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.waitForSubmit;
 
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.Futures;
+import java.util.Optional;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -35,12 +33,11 @@ import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
+import org.opendaylight.mdsal.binding.api.TransactionChain;
+import org.opendaylight.mdsal.binding.api.TransactionChainListener;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkDiscoveredBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkRemovedBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
@@ -51,30 +48,19 @@ 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.TopologyKey;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkKey;
-import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.util.concurrent.FluentFutures;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public class FlowCapableTopologyExporterTest {
 
-    @Mock
-    private DataBroker mockDataBroker;
-
-    @Mock
-    private BindingTransactionChain mockTxChain;
-
     private OperationProcessor processor;
-
     private FlowCapableTopologyExporter exporter;
-
-    private TerminationPointChangeListenerImpl terminationPointListener;
-    private NodeChangeListenerImpl nodeChangeListener;
-
     private InstanceIdentifier<Topology> topologyIID;
-
     private final ExecutorService executor = Executors.newFixedThreadPool(1);
-
     @Mock
-    private AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> mockedDataChangeListener;
+    private DataBroker mockDataBroker;
+    @Mock
+    private TransactionChain mockTxChain;
 
     @Before
     public void setUp() {
@@ -88,9 +74,6 @@ public class FlowCapableTopologyExporterTest {
         topologyIID = InstanceIdentifier.create(NetworkTopology.class)
                 .child(Topology.class, new TopologyKey(new TopologyId("flow:1")));
         exporter = new FlowCapableTopologyExporter(processor, topologyIID);
-        terminationPointListener = new TerminationPointChangeListenerImpl(mockDataBroker, processor);
-        nodeChangeListener = new NodeChangeListenerImpl(mockDataBroker, processor);
-
         executor.execute(processor);
     }
 
@@ -126,9 +109,9 @@ public class FlowCapableTopologyExporterTest {
         waitForSubmit(submitLatch);
 
         ArgumentCaptor<Link> mergedNode = ArgumentCaptor.forClass(Link.class);
-        verify(mockTx).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(topologyIID.child(
+        verify(mockTx).mergeParentStructureMerge(eq(LogicalDatastoreType.OPERATIONAL), eq(topologyIID.child(
                         Link.class, new LinkKey(new LinkId(sourceNodeConnKey.getId())))),
-                mergedNode.capture(), eq(true));
+                mergedNode.capture());
         assertEquals("Source node ID", "sourceNode",
                 mergedNode.getValue().getSource().getSourceNode().getValue());
         assertEquals("Dest TP ID", "sourceTP",
@@ -158,10 +141,11 @@ public class FlowCapableTopologyExporterTest {
                 newDestTp(destNodeConnKey.getId().getValue()));
 
         ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class);
-        CountDownLatch submitLatch = setupStubbedSubmit(mockTx);
+        final CountDownLatch submitLatch = setupStubbedSubmit(mockTx);
         doReturn(mockTx).when(mockTxChain).newReadWriteTransaction();
-        doReturn(Futures.immediateCheckedFuture(Optional.of(link))).when(mockTx).read(LogicalDatastoreType.OPERATIONAL, topologyIID.child(
-                Link.class, new LinkKey(new LinkId(sourceNodeConnKey.getId()))));
+        doReturn(FluentFutures.immediateFluentFuture(Optional.of(link))).when(mockTx)
+                .read(LogicalDatastoreType.OPERATIONAL,
+                      topologyIID.child(Link.class, new LinkKey(new LinkId(sourceNodeConnKey.getId()))));
 
         exporter.onLinkRemoved(new LinkRemovedBuilder().setSource(
                 new NodeConnectorRef(sourceConnID)).setDestination(
@@ -189,10 +173,11 @@ public class FlowCapableTopologyExporterTest {
         InstanceIdentifier<?> destConnID = newNodeConnID(destNodeKey, destNodeConnKey);
 
         ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class);
-        CountDownLatch submitLatch = setupStubbedSubmit(mockTx);
+        final CountDownLatch submitLatch = setupStubbedSubmit(mockTx);
         doReturn(mockTx).when(mockTxChain).newReadWriteTransaction();
-        doReturn(Futures.immediateCheckedFuture(Optional.<Link>absent())).when(mockTx).read(LogicalDatastoreType.OPERATIONAL, topologyIID.child(
-                Link.class, new LinkKey(new LinkId(sourceNodeConnKey.getId()))));
+        doReturn(FluentFutures.immediateFluentFuture(Optional.empty())).when(mockTx)
+                .read(LogicalDatastoreType.OPERATIONAL,
+                      topologyIID.child(Link.class, new LinkKey(new LinkId(sourceNodeConnKey.getId()))));
 
         exporter.onLinkRemoved(new LinkRemovedBuilder().setSource(
                 new NodeConnectorRef(sourceConnID)).setDestination(
@@ -203,5 +188,4 @@ public class FlowCapableTopologyExporterTest {
         verify(mockTx, never()).delete(LogicalDatastoreType.OPERATIONAL, topologyIID.child(
                 Link.class, new LinkKey(new LinkId(sourceNodeConnKey.getId()))));
     }
-
 }