Update MRI projects for Aluminium
[openflowplugin.git] / applications / forwardingrules-sync / src / test / java / org / opendaylight / openflowplugin / applications / frsync / impl / SimplifiedOperationalListenerTest.java
index 9ba97bfa13b212f5f01b37ff19fa31fd991c3a1f..0a4d143af541aadcd3cd36d2f09758a31d4928cb 100644 (file)
@@ -1,33 +1,32 @@
-/**
+/*
  * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * 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.frsync.impl;
 
-import com.google.common.base.Optional;
 import com.google.common.util.concurrent.Futures;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Collections;
-import java.util.List;
+import java.util.Map;
+import java.util.Optional;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mockito.Matchers;
+import org.mockito.ArgumentMatchers;
 import org.mockito.Mock;
 import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.DataObjectModification;
+import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
+import org.opendaylight.mdsal.binding.api.DataTreeModification;
+import org.opendaylight.mdsal.binding.api.ReadTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.openflowplugin.applications.frsync.SyncReactor;
 import org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeCachedDao;
 import org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeDao;
@@ -42,8 +41,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.Fl
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.snapshot.gathering.status.grouping.SnapshotGatheringStatusEnd;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yangtools.util.concurrent.FluentFutures;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 /**
@@ -63,7 +65,7 @@ public class SimplifiedOperationalListenerTest {
     @Mock
     private SyncReactor reactor;
     @Mock
-    private ReadOnlyTransaction roTx;
+    private ReadTransaction roTx;
     @Mock
     private DataTreeModification<Node> dataTreeModification;
     @Mock
@@ -83,12 +85,12 @@ public class SimplifiedOperationalListenerTest {
     @Mock
     private DeviceMastershipManager deviceMastershipManager;
     @Mock
-    private List nodeConnector;
+    private Map<NodeConnectorKey, NodeConnector> nodeConnector;
     @Mock
     private Node operationalNodeEmpty;
 
     @Before
-    public void setUp() throws Exception {
+    public void setUp() {
         final DataBroker db = Mockito.mock(DataBroker.class);
         final FlowCapableNodeSnapshotDao configSnapshot = new FlowCapableNodeSnapshotDao();
         final FlowCapableNodeSnapshotDao operationalSnapshot = new FlowCapableNodeSnapshotDao();
@@ -102,7 +104,7 @@ public class SimplifiedOperationalListenerTest {
         fcNodePath = nodePath.augmentation(FlowCapableNode.class);
 
         final DataTreeIdentifier<Node> dataTreeIdentifier =
-                new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, nodePath);
+                DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, nodePath);
 
         Mockito.when(db.newReadOnlyTransaction()).thenReturn(roTx);
         Mockito.when(operationalNode.getId()).thenReturn(NODE_ID);
@@ -112,7 +114,7 @@ public class SimplifiedOperationalListenerTest {
     }
 
     @Test
-    public void testDSLogicalType() throws Exception {
+    public void testDSLogicalType() {
         Assert.assertEquals(LogicalDatastoreType.OPERATIONAL, nodeListenerOperational.dsType());
     }
 
@@ -125,7 +127,7 @@ public class SimplifiedOperationalListenerTest {
     }
 
     @Test
-    public void testOnDataTreeChangedDeletePhysical() throws Exception {
+    public void testOnDataTreeChangedDeletePhysical() {
         Mockito.when(operationalModification.getDataBefore()).thenReturn(operationalNode);
         Mockito.when(operationalModification.getDataAfter()).thenReturn(null);
 
@@ -244,8 +246,8 @@ public class SimplifiedOperationalListenerTest {
         operationalUpdate();
         prepareFreshOperational(true);
 
-        Mockito.when(roTx.read(LogicalDatastoreType.CONFIGURATION, fcNodePath))
-                .thenReturn(Futures.immediateCheckedFuture(Optional.absent()));
+        Mockito.doReturn(FluentFutures.immediateFluentFuture(Optional.empty())).when(roTx)
+            .read(LogicalDatastoreType.CONFIGURATION, fcNodePath);
 
         nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
 
@@ -286,11 +288,12 @@ public class SimplifiedOperationalListenerTest {
     private SyncupEntry loadConfigDSAndPrepareSyncupEntry(final FlowCapableNode after,
             final LogicalDatastoreType dsTypeAfter, final FlowCapableNode before,
             final LogicalDatastoreType dsTypeBefore) {
-        Mockito.when(roTx.read(LogicalDatastoreType.CONFIGURATION, fcNodePath))
-                .thenReturn(Futures.immediateCheckedFuture(Optional.of(configNode)));
+
+        Mockito.doReturn(FluentFutures.immediateFluentFuture(Optional.of(configNode))).when(roTx)
+            .read(LogicalDatastoreType.CONFIGURATION, fcNodePath);
         final SyncupEntry syncupEntry = new SyncupEntry(after, dsTypeAfter, before, dsTypeBefore);
-        Mockito.when(reactor.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(syncupEntry)))
-                .thenReturn(Futures.immediateFuture(Boolean.TRUE));
+        Mockito.when(reactor.syncup(ArgumentMatchers.any(),
+                Mockito.eq(syncupEntry))).thenReturn(Futures.immediateFuture(Boolean.TRUE));
         return syncupEntry;
     }
 }