Replace deprecated initMocks() in openflowplugin-impl 66/99966/2
authorSangwook Ha <sangwook.ha@verizon.com>
Fri, 4 Mar 2022 09:28:51 +0000 (01:28 -0800)
committerRobert Varga <nite@hq.sk>
Fri, 11 Mar 2022 14:22:33 +0000 (14:22 +0000)
initMocks has been deprecated. Use MockitoJUnitRunner instead
and remove unnecessary stubbing in openflowplugin-impl.

JIRA: OPNFLWPLUG-1122
Change-Id: Iaf9843a0d310e85964c440f2e82310bc9ad95fd0
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalRoleServiceImplTest.java

index cbb9c53a953376b08062ac2d60e6ba212e7a9fac..f6f207f83e458d16122a3d20e9e231b774af0608 100644 (file)
@@ -16,9 +16,10 @@ import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
@@ -50,6 +51,7 @@ import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.common.Uint64;
 import org.opendaylight.yangtools.yang.common.Uint8;
 
+@RunWith(MockitoJUnitRunner.class)
 public class SalRoleServiceImplTest {
 
     @Mock
@@ -95,17 +97,11 @@ public class SalRoleServiceImplTest {
 
     @Before
     public void setup() {
-        MockitoAnnotations.initMocks(this);
         Mockito.when(mockDeviceInfo.getNodeId()).thenReturn(testNodeId);
         Mockito.when(mockDeviceInfo.getDatapathId()).thenReturn(Uint64.valueOf(10));
         Uint8 testVersion = Uint8.valueOf(4);
-        Mockito.when(mockFeaturesOutput.getVersion()).thenReturn(testVersion);
-        Mockito.when(mockDeviceContext.getDeviceState()).thenReturn(mockDeviceState);
         Mockito.when(mockDeviceContext.getDeviceInfo()).thenReturn(mockDeviceInfo);
         Mockito.when(mockDeviceContext.getPrimaryConnectionContext()).thenReturn(mockConnectionContext);
-        Mockito.when(mockConnectionContext.getFeatures()).thenReturn(mockFeaturesReply);
-        Mockito.when(mockConnectionContext.getNodeId()).thenReturn(testNodeId);
-        Mockito.when(mockFeaturesReply.getVersion()).thenReturn(testVersion);
         Mockito.when(mockDeviceContext.getMessageSpy()).thenReturn(mockMessageSpy);
         Mockito.when(mockRequestContextStack.<RoleRequestOutput>createRequestContext()).thenReturn(mockRequestContext);
         Mockito.when(mockRequestContext.getXid()).thenReturn(new Xid(TEST_XID));