OPNFLWPLUG-1032: Neon-MRI: Bump odlparent, yangtools, mdsal
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / services / sal / SalFlowsBatchServiceImplTest.java
index bea9d1c9d8ceba148e3309442b402ebaef11db3b..e5f9b77e5c70b01eb3dfa85f562f9d62d4fb6573 100644 (file)
@@ -17,9 +17,9 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
+import org.mockito.ArgumentMatchers;
 import org.mockito.Captor;
 import org.mockito.InOrder;
-import org.mockito.Matchers;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
@@ -36,6 +36,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.Upda
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.FlowCapableTransactionService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.AddFlowsBatchInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.AddFlowsBatchInputBuilder;
@@ -76,7 +77,8 @@ public class SalFlowsBatchServiceImplTest {
 
     public static final NodeId NODE_ID = new NodeId("ut-dummy-node");
     public static final NodeKey NODE_KEY = new NodeKey(NODE_ID);
-    public static final NodeRef NODE_REF = new NodeRef(InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY));
+    public static final NodeRef NODE_REF =
+            new NodeRef(InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY));
 
     @Mock
     private SalFlowService salFlowService;
@@ -97,8 +99,8 @@ public class SalFlowsBatchServiceImplTest {
     public void setUp() throws Exception {
         salFlowsBatchService = new SalFlowsBatchServiceImpl(salFlowService, transactionService);
 
-        Mockito.when(transactionService.sendBarrier(Matchers.<SendBarrierInput>any()))
-                .thenReturn(RpcResultBuilder.<Void>success().buildFuture());
+        Mockito.when(transactionService.sendBarrier(ArgumentMatchers.<SendBarrierInput>any()))
+                .thenReturn(RpcResultBuilder.<SendBarrierOutput>success().buildFuture());
     }
 
     @After
@@ -108,7 +110,7 @@ public class SalFlowsBatchServiceImplTest {
 
     @Test
     public void testRemoveFlowsBatch_success() throws Exception {
-        Mockito.when(salFlowService.removeFlow(Matchers.<RemoveFlowInput>any()))
+        Mockito.when(salFlowService.removeFlow(ArgumentMatchers.<RemoveFlowInput>any()))
                 .thenReturn(RpcResultBuilder.success(new RemoveFlowOutputBuilder().build())
                         .buildFuture());
 
@@ -139,12 +141,12 @@ public class SalFlowsBatchServiceImplTest {
         Assert.assertEquals(42, allValues.get(0).getPriority().longValue());
         Assert.assertEquals(43, allValues.get(1).getPriority().longValue());
 
-        inOrder.verify(transactionService).sendBarrier(Matchers.<SendBarrierInput>any());
+        inOrder.verify(transactionService).sendBarrier(ArgumentMatchers.<SendBarrierInput>any());
     }
 
     @Test
     public void testRemoveFlowsBatch_failed() throws Exception {
-        Mockito.when(salFlowService.removeFlow(Matchers.<RemoveFlowInput>any()))
+        Mockito.when(salFlowService.removeFlow(ArgumentMatchers.<RemoveFlowInput>any()))
                 .thenReturn(RpcResultBuilder.<RemoveFlowOutput>failed()
                         .withError(RpcError.ErrorType.APPLICATION, "flow-remove-fail-1")
                         .buildFuture());
@@ -176,7 +178,7 @@ public class SalFlowsBatchServiceImplTest {
         Assert.assertEquals(42, allValues.get(0).getPriority().longValue());
         Assert.assertEquals(43, allValues.get(1).getPriority().longValue());
 
-        inOrder.verify(transactionService).sendBarrier(Matchers.<SendBarrierInput>any());
+        inOrder.verify(transactionService).sendBarrier(ArgumentMatchers.<SendBarrierInput>any());
     }
 
     private static BatchAddFlows createEmptyBatchAddFlow(final String flowIdValue, final int priority) {
@@ -209,7 +211,7 @@ public class SalFlowsBatchServiceImplTest {
 
     @Test
     public void testAddFlowsBatch_success() throws Exception {
-        Mockito.when(salFlowService.addFlow(Matchers.<AddFlowInput>any()))
+        Mockito.when(salFlowService.addFlow(ArgumentMatchers.<AddFlowInput>any()))
                 .thenReturn(RpcResultBuilder.success(new AddFlowOutputBuilder().build()).buildFuture());
 
         final AddFlowsBatchInput input = new AddFlowsBatchInputBuilder()
@@ -233,13 +235,14 @@ public class SalFlowsBatchServiceImplTest {
         Assert.assertEquals(42, allValues.get(0).getPriority().longValue());
         Assert.assertEquals(43, allValues.get(1).getPriority().longValue());
 
-        inOrder.verify(transactionService).sendBarrier(Matchers.<SendBarrierInput>any());
+        inOrder.verify(transactionService).sendBarrier(ArgumentMatchers.<SendBarrierInput>any());
     }
 
     @Test
     public void testAddFlowsBatch_failed() throws Exception {
-        Mockito.when(salFlowService.addFlow(Matchers.<AddFlowInput>any()))
-                .thenReturn(RpcResultBuilder.<AddFlowOutput>failed().withError(RpcError.ErrorType.APPLICATION, "ut-groupAddError")
+        Mockito.when(salFlowService.addFlow(ArgumentMatchers.<AddFlowInput>any()))
+                .thenReturn(RpcResultBuilder
+                        .<AddFlowOutput>failed().withError(RpcError.ErrorType.APPLICATION, "ut-groupAddError")
                         .buildFuture());
 
         final AddFlowsBatchInput input = new AddFlowsBatchInputBuilder()
@@ -255,8 +258,10 @@ public class SalFlowsBatchServiceImplTest {
         Assert.assertTrue(resultFuture.isDone());
         Assert.assertFalse(resultFuture.get().isSuccessful());
         Assert.assertEquals(2, resultFuture.get().getResult().getBatchFailedFlowsOutput().size());
-        Assert.assertEquals(FLOW_ID_VALUE_1, resultFuture.get().getResult().getBatchFailedFlowsOutput().get(0).getFlowId().getValue());
-        Assert.assertEquals(FLOW_ID_VALUE_2, resultFuture.get().getResult().getBatchFailedFlowsOutput().get(1).getFlowId().getValue());
+        Assert.assertEquals(FLOW_ID_VALUE_1,
+                resultFuture.get().getResult().getBatchFailedFlowsOutput().get(0).getFlowId().getValue());
+        Assert.assertEquals(FLOW_ID_VALUE_2,
+                resultFuture.get().getResult().getBatchFailedFlowsOutput().get(1).getFlowId().getValue());
         Assert.assertEquals(2, resultFuture.get().getErrors().size());
 
         final InOrder inOrder = Mockito.inOrder(salFlowService, transactionService);
@@ -267,12 +272,12 @@ public class SalFlowsBatchServiceImplTest {
         Assert.assertEquals(42, allValues.get(0).getPriority().longValue());
         Assert.assertEquals(43, allValues.get(1).getPriority().longValue());
 
-        inOrder.verify(transactionService).sendBarrier(Matchers.<SendBarrierInput>any());
+        inOrder.verify(transactionService).sendBarrier(ArgumentMatchers.<SendBarrierInput>any());
     }
 
     @Test
     public void testUpdateFlowsBatch_success() throws Exception {
-        Mockito.when(salFlowService.updateFlow(Matchers.<UpdateFlowInput>any()))
+        Mockito.when(salFlowService.updateFlow(ArgumentMatchers.<UpdateFlowInput>any()))
                 .thenReturn(RpcResultBuilder.success(new UpdateFlowOutputBuilder().build()).buildFuture());
 
         final UpdateFlowsBatchInput input = new UpdateFlowsBatchInputBuilder()
@@ -298,13 +303,14 @@ public class SalFlowsBatchServiceImplTest {
         Assert.assertEquals(44, allValues.get(1).getOriginalFlow().getPriority().longValue());
         Assert.assertEquals(45, allValues.get(1).getUpdatedFlow().getPriority().longValue());
 
-        inOrder.verify(transactionService).sendBarrier(Matchers.<SendBarrierInput>any());
+        inOrder.verify(transactionService).sendBarrier(ArgumentMatchers.<SendBarrierInput>any());
     }
 
     @Test
     public void testUpdateFlowsBatch_failure() throws Exception {
-        Mockito.when(salFlowService.updateFlow(Matchers.<UpdateFlowInput>any()))
-                .thenReturn(RpcResultBuilder.<UpdateFlowOutput>failed().withError(RpcError.ErrorType.APPLICATION, "ut-flowUpdateError")
+        Mockito.when(salFlowService.updateFlow(ArgumentMatchers.<UpdateFlowInput>any()))
+                .thenReturn(RpcResultBuilder.<UpdateFlowOutput>failed()
+                        .withError(RpcError.ErrorType.APPLICATION, "ut-flowUpdateError")
                         .buildFuture());
 
         final UpdateFlowsBatchInput input = new UpdateFlowsBatchInputBuilder()
@@ -321,8 +327,10 @@ public class SalFlowsBatchServiceImplTest {
         Assert.assertFalse(resultFuture.get().isSuccessful());
         Assert.assertFalse(resultFuture.get().isSuccessful());
         Assert.assertEquals(2, resultFuture.get().getResult().getBatchFailedFlowsOutput().size());
-        Assert.assertEquals(FLOW_ID_VALUE_1, resultFuture.get().getResult().getBatchFailedFlowsOutput().get(0).getFlowId().getValue());
-        Assert.assertEquals(FLOW_ID_VALUE_2, resultFuture.get().getResult().getBatchFailedFlowsOutput().get(1).getFlowId().getValue());
+        Assert.assertEquals(FLOW_ID_VALUE_1,
+                resultFuture.get().getResult().getBatchFailedFlowsOutput().get(0).getFlowId().getValue());
+        Assert.assertEquals(FLOW_ID_VALUE_2,
+                resultFuture.get().getResult().getBatchFailedFlowsOutput().get(1).getFlowId().getValue());
         Assert.assertEquals(2, resultFuture.get().getErrors().size());
 
         final InOrder inOrder = Mockito.inOrder(salFlowService, transactionService);
@@ -334,6 +342,6 @@ public class SalFlowsBatchServiceImplTest {
         Assert.assertEquals(44, allValues.get(1).getOriginalFlow().getPriority().longValue());
         Assert.assertEquals(45, allValues.get(1).getUpdatedFlow().getPriority().longValue());
 
-        inOrder.verify(transactionService).sendBarrier(Matchers.<SendBarrierInput>any());
+        inOrder.verify(transactionService).sendBarrier(ArgumentMatchers.<SendBarrierInput>any());
     }
 }