Neon MRI changes
[lispflowmapping.git] / mappingservice / southbound / src / test / java / org / opendaylight / lispflowmapping / southbound / LispSouthboundRpcTest.java
index 0f1ce81cd9ebc7631c6836e5f8a18cf962f81e4d..bc0ffd22033aa32aef20238567c95371d1856780 100644 (file)
@@ -12,12 +12,13 @@ import static org.junit.Assert.assertEquals;
 import com.google.common.collect.Lists;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
+
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.InjectMocks;
 import org.mockito.Mock;
 import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.opendaylight.lispflowmapping.lisp.serializer.MapNotifySerializer;
 import org.opendaylight.lispflowmapping.lisp.serializer.MapRegisterSerializer;
 import org.opendaylight.lispflowmapping.lisp.serializer.MapReplySerializer;
@@ -25,11 +26,9 @@ import org.opendaylight.lispflowmapping.lisp.serializer.MapRequestSerializer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MessageType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotify;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container
-        .MappingRecordBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list
-        .MappingRecordItemBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregistermessage.MapRegister;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregistermessage.MapRegisterBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReply;
@@ -38,7 +37,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.ma
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestmessage.MapRequestBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.GetStatsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.GetStatsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.ResetStatsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.ResetStatsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapNotifyInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapRegisterInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapReplyInput;
@@ -61,9 +63,6 @@ public class LispSouthboundRpcTest {
 
     /**
      * Tests {@link LispSouthboundRPC#sendMapNotify} method.
-     *
-     * @throws ExecutionException
-     * @throws InterruptedException
      */
     @Test
     public void sendMapNotifyTest_inputNotNull() throws ExecutionException, InterruptedException {
@@ -83,9 +82,6 @@ public class LispSouthboundRpcTest {
 
     /**
      * Tests {@link LispSouthboundRPC#sendMapNotify} method with null input.
-     *
-     * @throws ExecutionException
-     * @throws InterruptedException
      */
     @Test
     public void sendMapNotifyTest_nullInput() throws ExecutionException, InterruptedException {
@@ -97,9 +93,6 @@ public class LispSouthboundRpcTest {
 
     /**
      * Tests {@link LispSouthboundRPC#sendMapReply} method.
-     *
-     * @throws ExecutionException
-     * @throws InterruptedException
      */
     @Test
     public void sendMapReplyTest_inputNotNull() throws ExecutionException, InterruptedException {
@@ -119,9 +112,6 @@ public class LispSouthboundRpcTest {
 
     /**
      * Tests {@link LispSouthboundRPC#sendMapReply} method with null input.
-     *
-     * @throws ExecutionException
-     * @throws InterruptedException
      */
     @Test
     public void sendMapReplyTest_nullInput() throws ExecutionException, InterruptedException {
@@ -133,9 +123,6 @@ public class LispSouthboundRpcTest {
 
     /**
      * Tests {@link LispSouthboundRPC#sendMapRequest} method.
-     *
-     * @throws ExecutionException
-     * @throws InterruptedException
      */
     @Test
     public void sendMapRequestTest_inputNotNull() throws ExecutionException, InterruptedException {
@@ -155,9 +142,6 @@ public class LispSouthboundRpcTest {
 
     /**
      * Tests {@link LispSouthboundRPC#sendMapRequest} method with null input.
-     *
-     * @throws ExecutionException
-     * @throws InterruptedException
      */
     @Test
     public void sendMapRequestTest_nullInput() throws ExecutionException, InterruptedException {
@@ -169,9 +153,6 @@ public class LispSouthboundRpcTest {
 
     /**
      * Tests {@link LispSouthboundRPC#sendMapRegister} method.
-     *
-     * @throws ExecutionException
-     * @throws InterruptedException
      */
     @Test
     public void sendMapRegisterTest_inputNotNull() throws ExecutionException, InterruptedException {
@@ -191,9 +172,6 @@ public class LispSouthboundRpcTest {
 
     /**
      * Tests {@link LispSouthboundRPC#sendMapRegister} method with null input.
-     *
-     * @throws ExecutionException
-     * @throws InterruptedException
      */
     @Test
     public void sendMapRegisterTest_nullInput() throws ExecutionException, InterruptedException {
@@ -205,18 +183,16 @@ public class LispSouthboundRpcTest {
 
     /**
      * Tests {@link LispSouthboundRPC#getStats} method.
-     *
-     * @throws ExecutionException
-     * @throws InterruptedException
      */
     @Test
     public void getStatsTest() throws ExecutionException, InterruptedException {
-        final LispSouthboundStats stats = new LispSouthboundStats();
+        final ConcurrentLispSouthboundStats stats = new ConcurrentLispSouthboundStats();
         incrementAll(stats);
         Mockito.when(lispSouthboundPlugin.getStats()).thenReturn(stats);
 
         // result
-        final ControlMessageStats resultStats = lispSouthboundRPC.getStats().get().getResult().getControlMessageStats();
+        final ControlMessageStats resultStats = lispSouthboundRPC.getStats(
+                Mockito.mock(GetStatsInput.class)).get().getResult().getControlMessageStats();
 
         assertEquals(stats.getRx()[0], (long) resultStats.getControlMessage().get(0).getRxCount());
         assertEquals(stats.getRx()[1], (long) resultStats.getControlMessage().get(1).getRxCount());
@@ -230,9 +206,6 @@ public class LispSouthboundRpcTest {
 
     /**
      * Tests {@link LispSouthboundRPC#getStats} method with null stats.
-     *
-     * @throws ExecutionException
-     * @throws InterruptedException
      */
     @Test
     public void getStatsTest_withNullStats() throws ExecutionException, InterruptedException {
@@ -240,7 +213,8 @@ public class LispSouthboundRpcTest {
 
         Mockito.when(lispSouthboundPlugin.getStats()).thenReturn(null);
 
-        final Future<RpcResult<GetStatsOutput>> resultFuture = lispSouthboundRPC.getStats();
+        final Future<RpcResult<GetStatsOutput>> resultFuture = lispSouthboundRPC.getStats(
+                Mockito.mock(GetStatsInput.class));
         final RpcResult<GetStatsOutput> rpcResult = resultFuture.get();
 
         assertEquals(RPC_RESULT_ERROR.isSuccessful(), rpcResult.isSuccessful());
@@ -249,17 +223,15 @@ public class LispSouthboundRpcTest {
 
     /**
      * Tests {@link LispSouthboundRPC#resetStats} method.
-     *
-     * @throws ExecutionException
-     * @throws InterruptedException
      */
     @Test
     public void resetStatsTest() throws ExecutionException, InterruptedException {
-        final LispSouthboundStats stats = new LispSouthboundStats();
+        final ConcurrentLispSouthboundStats stats = new ConcurrentLispSouthboundStats();
         incrementAll(stats);
         Mockito.when(lispSouthboundPlugin.getStats()).thenReturn(stats);
 
-        assertEquals(RPC_RESULT_SUCCESS.isSuccessful(), lispSouthboundRPC.resetStats().get().isSuccessful());
+        assertEquals(RPC_RESULT_SUCCESS.isSuccessful(), lispSouthboundRPC.resetStats(
+                Mockito.mock(ResetStatsInput.class)).get().isSuccessful());
 
         for (long rx : stats.getRx()) {
             assertEquals(0, rx);
@@ -268,9 +240,6 @@ public class LispSouthboundRpcTest {
 
     /**
      * Tests {@link LispSouthboundRPC#resetStats} method with null stats.
-     *
-     * @throws ExecutionException
-     * @throws InterruptedException
      */
     @Test
     public void resetStatsTest_withNullStats() throws ExecutionException, InterruptedException {
@@ -278,8 +247,9 @@ public class LispSouthboundRpcTest {
 
         Mockito.when(lispSouthboundPlugin.getStats()).thenReturn(null);
 
-        final Future<RpcResult<Void>> resultFuture = lispSouthboundRPC.resetStats();
-        final RpcResult<Void> rpcResult = resultFuture.get();
+        final Future<RpcResult<ResetStatsOutput>> resultFuture = lispSouthboundRPC.resetStats(
+                Mockito.mock(ResetStatsInput.class));
+        final RpcResult<ResetStatsOutput> rpcResult = resultFuture.get();
 
         assertEquals(RPC_RESULT_ERROR.isSuccessful(), rpcResult.isSuccessful());
         assertEquals(expectedMsg, rpcResult.getErrors().iterator().next().getMessage());
@@ -305,7 +275,7 @@ public class LispSouthboundRpcTest {
                 .setMappingRecordItem(Lists.newArrayList(getDefaultMappingRecordItem()));
     }
 
-    private static void incrementAll(LispSouthboundStats stats) {
+    private static void incrementAll(ConcurrentLispSouthboundStats stats) {
         for (MessageType type : MessageType.values()) {
             stats.incrementRx(type.getIntValue());
         }