X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Futil%2FFlowUtilTest.java;h=95f066018b0f9ce8b6a06e4a5dd2cc8534ae10a6;hb=26d73dba20bcdcbe3d97e8b41e6ee8801495569e;hp=dc5034b5f3f876d5636c5a5fbd88f744cae632e5;hpb=0b595be684db641f3cb25f1995de1f1660c07edb;p=openflowplugin.git diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlowUtilTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlowUtilTest.java index dc5034b5f3..95f066018b 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlowUtilTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlowUtilTest.java @@ -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 void checkBatchSuccessOutcomeTransformation( + private static void checkBatchSuccessOutcomeTransformation( final RpcResult output) { Assert.assertTrue(output.isSuccessful()); - Assert.assertEquals(0, output.getResult().getBatchFailedFlowsOutput().size()); + Map failedFlows + = output.getResult().nonnullBatchFailedFlowsOutput(); + Assert.assertEquals(0, failedFlows.size()); Assert.assertEquals(0, output.getErrors().size()); } - private RpcResult> createEmptyBatchOutcome() { + private static RpcResult> createEmptyBatchOutcome() { return RpcResultBuilder .success(Collections.emptyList()) .build(); } - private RpcResult> createBatchOutcomeWithError() { + private static RpcResult> createBatchOutcomeWithError() { return RpcResultBuilder.>failed() .withError(RpcError.ErrorType.APPLICATION, "ut-flowAddFail") .withResult(Collections.singletonList(new BatchFailedFlowsOutputBuilder() .setFlowId(DUMMY_FLOW_ID) + .setBatchOrder(Uint16.ZERO) .build())) .build(); } - private void checkBatchErrorOutcomeTransformation( + private static void checkBatchErrorOutcomeTransformation( final RpcResult 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 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 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 createBarrierFailureOutcome() { + private static RpcResult createBarrierFailureOutcome() { return RpcResultBuilder.failed() .withError(RpcError.ErrorType.APPLICATION, "ut-barrier-error") .build(); } - private RpcResult createAddFlowsBatchSuccessOutput() { + private static RpcResult createAddFlowsBatchSuccessOutput() { return RpcResultBuilder .success(new AddFlowsBatchOutputBuilder() .setBatchFailedFlowsOutput(Collections.emptyList()) @@ -225,7 +236,7 @@ public class FlowUtilTest { .build(); } - private RpcResult createAddFlowsBatchFailureOutcome() { + private static RpcResult createAddFlowsBatchFailureOutcome() { final RpcResult> batchOutcomeWithError = createBatchOutcomeWithError(); return RpcResultBuilder.failed() .withResult(new AddFlowsBatchOutputBuilder()