Bump upstreams for Silicon
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / util / FlowUtilTest.java
index dc5034b5f3f876d5636c5a5fbd88f744cae632e5..95f066018b0f9ce8b6a06e4a5dd2cc8534ae10a6 100644 (file)
@@ -5,13 +5,13 @@
  * 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.impl.util;
 
-import com.google.common.base.Function;
 import com.google.common.collect.Lists;
 import java.util.Collections;
 import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
 import org.apache.commons.lang3.tuple.Pair;
 import org.junit.Assert;
 import org.junit.Test;
@@ -27,6 +27,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.Bat
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.BatchFlowOutputListGrouping;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutputKey;
 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.nodes.Node;
@@ -35,12 +36,14 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint8;
 
 public class FlowUtilTest {
     public static final NodeId DUMMY_NODE_ID = new NodeId("dummyNodeId");
     public static final FlowId DUMMY_FLOW_ID = new FlowId("dummyFlowId");
     public static final FlowId DUMMY_FLOW_ID_2 = new FlowId("dummyFlowId_2");
-    public static final Short DUMMY_TABLE_ID = 1;
+    public static final Uint8 DUMMY_TABLE_ID = Uint8.ONE;
 
     @Test
     public void testBuildFlowPath() {
@@ -116,33 +119,37 @@ public class FlowUtilTest {
         checkBatchSuccessOutcomeTransformation(FlowUtil.FLOW_UPDATE_TRANSFORM.apply(input));
     }
 
-    private <T extends BatchFlowOutputListGrouping> void checkBatchSuccessOutcomeTransformation(
+    private static <T extends BatchFlowOutputListGrouping> void checkBatchSuccessOutcomeTransformation(
             final RpcResult<T> output) {
         Assert.assertTrue(output.isSuccessful());
-        Assert.assertEquals(0, output.getResult().getBatchFailedFlowsOutput().size());
+        Map<BatchFailedFlowsOutputKey, BatchFailedFlowsOutput> failedFlows
+                = output.getResult().nonnullBatchFailedFlowsOutput();
+        Assert.assertEquals(0, failedFlows.size());
         Assert.assertEquals(0, output.getErrors().size());
     }
 
-    private RpcResult<List<BatchFailedFlowsOutput>> createEmptyBatchOutcome() {
+    private static RpcResult<List<BatchFailedFlowsOutput>> createEmptyBatchOutcome() {
         return RpcResultBuilder
                 .success(Collections.<BatchFailedFlowsOutput>emptyList())
                 .build();
     }
 
-    private RpcResult<List<BatchFailedFlowsOutput>> createBatchOutcomeWithError() {
+    private static RpcResult<List<BatchFailedFlowsOutput>> createBatchOutcomeWithError() {
         return RpcResultBuilder.<List<BatchFailedFlowsOutput>>failed()
                 .withError(RpcError.ErrorType.APPLICATION, "ut-flowAddFail")
                 .withResult(Collections.singletonList(new BatchFailedFlowsOutputBuilder()
                         .setFlowId(DUMMY_FLOW_ID)
+                        .setBatchOrder(Uint16.ZERO)
                         .build()))
                 .build();
     }
 
-    private <T extends BatchFlowOutputListGrouping> void checkBatchErrorOutcomeTransformation(
+    private static <T extends BatchFlowOutputListGrouping> void checkBatchErrorOutcomeTransformation(
             final RpcResult<T> output) {
         Assert.assertFalse(output.isSuccessful());
-        Assert.assertEquals(1, output.getResult().getBatchFailedFlowsOutput().size());
-        Assert.assertEquals(DUMMY_FLOW_ID, output.getResult().getBatchFailedFlowsOutput().get(0).getFlowId());
+        Assert.assertEquals(1, output.getResult().nonnullBatchFailedFlowsOutput().size());
+        Assert.assertEquals(DUMMY_FLOW_ID,
+            output.getResult().nonnullBatchFailedFlowsOutput().values().iterator().next().getFlowId());
 
         Assert.assertEquals(1, output.getErrors().size());
     }
@@ -160,7 +167,9 @@ public class FlowUtilTest {
 
         Assert.assertTrue(composite.isSuccessful());
         Assert.assertEquals(0, composite.getErrors().size());
-        Assert.assertEquals(0, composite.getResult().getBatchFailedFlowsOutput().size());
+        Map<BatchFailedFlowsOutputKey, BatchFailedFlowsOutput> failedFlows
+                = composite.getResult().nonnullBatchFailedFlowsOutput();
+        Assert.assertEquals(0, failedFlows.size());
     }
 
     @Test
@@ -192,7 +201,9 @@ public class FlowUtilTest {
 
         Assert.assertFalse(composite.isSuccessful());
         Assert.assertEquals(1, composite.getErrors().size());
-        Assert.assertEquals(0, composite.getResult().getBatchFailedFlowsOutput().size());
+        Map<BatchFailedFlowsOutputKey, BatchFailedFlowsOutput> failedFlows
+                = composite.getResult().nonnullBatchFailedFlowsOutput();
+        Assert.assertEquals(0, failedFlows.size());
     }
 
     @Test
@@ -211,13 +222,13 @@ public class FlowUtilTest {
         Assert.assertEquals(1, composite.getResult().getBatchFailedFlowsOutput().size());
     }
 
-    private RpcResult<SendBarrierOutput> createBarrierFailureOutcome() {
+    private static RpcResult<SendBarrierOutput> createBarrierFailureOutcome() {
         return RpcResultBuilder.<SendBarrierOutput>failed()
                 .withError(RpcError.ErrorType.APPLICATION, "ut-barrier-error")
                 .build();
     }
 
-    private RpcResult<AddFlowsBatchOutput> createAddFlowsBatchSuccessOutput() {
+    private static RpcResult<AddFlowsBatchOutput> createAddFlowsBatchSuccessOutput() {
         return RpcResultBuilder
                 .success(new AddFlowsBatchOutputBuilder()
                         .setBatchFailedFlowsOutput(Collections.emptyList())
@@ -225,7 +236,7 @@ public class FlowUtilTest {
                 .build();
     }
 
-    private RpcResult<AddFlowsBatchOutput> createAddFlowsBatchFailureOutcome() {
+    private static RpcResult<AddFlowsBatchOutput> createAddFlowsBatchFailureOutcome() {
         final RpcResult<List<BatchFailedFlowsOutput>> batchOutcomeWithError = createBatchOutcomeWithError();
         return RpcResultBuilder.<AddFlowsBatchOutput>failed()
                 .withResult(new AddFlowsBatchOutputBuilder()