Merge "Cleanup use of Guava Function"
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / util / MeterUtilTest.java
index a83eaab74b42b15f17bc94b0fc94c29d4d205ea3..7fa7ebcb02fae15ef3bc12af822d8cd866a999a2 100644 (file)
@@ -17,6 +17,7 @@ import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierOutput;
 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;
@@ -43,7 +44,7 @@ public class MeterUtilTest {
     private static final MeterId DUMMY_METER_ID_2 = new MeterId(43L);
 
     @Test
-    public void testBuildGroupPath() throws Exception {
+    public void testBuildGroupPath() {
         final InstanceIdentifier<Node> nodePath = InstanceIdentifier
                 .create(Nodes.class)
                 .child(Node.class, new NodeKey(DUMMY_NODE_ID));
@@ -55,7 +56,7 @@ public class MeterUtilTest {
     }
 
     @Test
-    public void testCreateCumulatingFunction() throws Exception {
+    public void testCreateCumulatingFunction() {
         final Function<List<RpcResult<String>>, RpcResult<List<BatchFailedMetersOutput>>> function =
                 MeterUtil.createCumulativeFunction(Lists.newArrayList(
                         createBatchMeter(DUMMY_METER_ID),
@@ -81,37 +82,37 @@ public class MeterUtilTest {
     }
 
     @Test
-    public void testMeterAddTransformFailure() throws Exception {
+    public void testMeterAddTransformFailure() {
         final RpcResult<List<BatchFailedMetersOutput>> input = createBatchOutcomeWithError();
         checkBatchErrorOutcomeTransformation(MeterUtil.METER_ADD_TRANSFORM.apply(input));
     }
 
     @Test
-    public void testMeterAddTransformSuccess() throws Exception {
+    public void testMeterAddTransformSuccess() {
         final RpcResult<List<BatchFailedMetersOutput>> input = createEmptyBatchOutcome();
         checkBatchSuccessOutcomeTransformation(MeterUtil.METER_ADD_TRANSFORM.apply(input));
     }
 
     @Test
-    public void testMeterRemoveTransformFailure() throws Exception {
+    public void testMeterRemoveTransformFailure() {
         final RpcResult<List<BatchFailedMetersOutput>> input = createBatchOutcomeWithError();
         checkBatchErrorOutcomeTransformation(MeterUtil.METER_REMOVE_TRANSFORM.apply(input));
     }
 
     @Test
-    public void testFlowRemoveTransformSuccess() throws Exception {
+    public void testFlowRemoveTransformSuccess() {
         final RpcResult<List<BatchFailedMetersOutput>> input = createEmptyBatchOutcome();
         checkBatchSuccessOutcomeTransformation(MeterUtil.METER_REMOVE_TRANSFORM.apply(input));
     }
 
     @Test
-    public void testFlowUpdateTransformFailure() throws Exception {
+    public void testFlowUpdateTransformFailure() {
         final RpcResult<List<BatchFailedMetersOutput>> input = createBatchOutcomeWithError();
         checkBatchErrorOutcomeTransformation(MeterUtil.METER_UPDATE_TRANSFORM.apply(input));
     }
 
     @Test
-    public void testFlowUpdateTransformSuccess() throws Exception {
+    public void testFlowUpdateTransformSuccess() {
         final RpcResult<List<BatchFailedMetersOutput>> input = createEmptyBatchOutcome();
         checkBatchSuccessOutcomeTransformation(MeterUtil.METER_UPDATE_TRANSFORM.apply(input));
     }
@@ -125,7 +126,7 @@ public class MeterUtilTest {
 
     private RpcResult<List<BatchFailedMetersOutput>> createEmptyBatchOutcome() {
         return RpcResultBuilder
-                .<List<BatchFailedMetersOutput>>success(Collections.<BatchFailedMetersOutput>emptyList())
+                .success(Collections.<BatchFailedMetersOutput>emptyList())
                 .build();
     }
 
@@ -148,13 +149,13 @@ public class MeterUtilTest {
     }
 
     @Test
-    public void testCreateComposingFunction_success_success() throws Exception {
-        final Function<Pair<RpcResult<AddMetersBatchOutput>, RpcResult<Void>>, RpcResult<AddMetersBatchOutput>>
-                compositeFunction = MeterUtil.createComposingFunction();
+    public void testCreateComposingFunction_success_success() {
+        final Function<Pair<RpcResult<AddMetersBatchOutput>, RpcResult<SendBarrierOutput>>,
+                RpcResult<AddMetersBatchOutput>> compositeFunction = MeterUtil.createComposingFunction();
 
         final RpcResult<AddMetersBatchOutput> addGroupBatchOutput = createAddMetersBatchSuccessOutput();
-        final RpcResult<Void> barrierOutput = RpcResultBuilder.<Void>success().build();
-        final Pair<RpcResult<AddMetersBatchOutput>, RpcResult<Void>> input =
+        final RpcResult<SendBarrierOutput> barrierOutput = RpcResultBuilder.<SendBarrierOutput>success().build();
+        final Pair<RpcResult<AddMetersBatchOutput>, RpcResult<SendBarrierOutput>> input =
                 Pair.of(addGroupBatchOutput, barrierOutput);
         final RpcResult<AddMetersBatchOutput> composite = compositeFunction.apply(input);
 
@@ -164,13 +165,13 @@ public class MeterUtilTest {
     }
 
     @Test
-    public void testCreateComposingFunction_failure_success() throws Exception {
-        final Function<Pair<RpcResult<AddMetersBatchOutput>, RpcResult<Void>>, RpcResult<AddMetersBatchOutput>>
-                compositeFunction = MeterUtil.createComposingFunction();
+    public void testCreateComposingFunction_failure_success() {
+        final Function<Pair<RpcResult<AddMetersBatchOutput>, RpcResult<SendBarrierOutput>>,
+                RpcResult<AddMetersBatchOutput>> compositeFunction = MeterUtil.createComposingFunction();
 
         final RpcResult<AddMetersBatchOutput> addGroupBatchOutput = createAddMetersBatchFailureOutcome();
-        final RpcResult<Void> barrierOutput = RpcResultBuilder.<Void>success().build();
-        final Pair<RpcResult<AddMetersBatchOutput>, RpcResult<Void>> input =
+        final RpcResult<SendBarrierOutput> barrierOutput = RpcResultBuilder.<SendBarrierOutput>success().build();
+        final Pair<RpcResult<AddMetersBatchOutput>, RpcResult<SendBarrierOutput>> input =
                 Pair.of(addGroupBatchOutput, barrierOutput);
         final RpcResult<AddMetersBatchOutput> composite = compositeFunction.apply(input);
 
@@ -180,13 +181,13 @@ public class MeterUtilTest {
     }
 
     @Test
-    public void testCreateComposingFunction_success_failure() throws Exception {
-        final Function<Pair<RpcResult<AddMetersBatchOutput>, RpcResult<Void>>, RpcResult<AddMetersBatchOutput>>
-                compositeFunction = MeterUtil.createComposingFunction();
+    public void testCreateComposingFunction_success_failure() {
+        final Function<Pair<RpcResult<AddMetersBatchOutput>, RpcResult<SendBarrierOutput>>,
+                RpcResult<AddMetersBatchOutput>> compositeFunction = MeterUtil.createComposingFunction();
 
         final RpcResult<AddMetersBatchOutput> addGroupBatchOutput = createAddMetersBatchSuccessOutput();
-        final RpcResult<Void> barrierOutput = createBarrierFailureOutcome();
-        final Pair<RpcResult<AddMetersBatchOutput>, RpcResult<Void>> input =
+        final RpcResult<SendBarrierOutput> barrierOutput = createBarrierFailureOutcome();
+        final Pair<RpcResult<AddMetersBatchOutput>, RpcResult<SendBarrierOutput>> input =
                 Pair.of(addGroupBatchOutput, barrierOutput);
         final RpcResult<AddMetersBatchOutput> composite = compositeFunction.apply(input);
 
@@ -196,13 +197,13 @@ public class MeterUtilTest {
     }
 
     @Test
-    public void testCreateComposingFunction_failure_failure() throws Exception {
-        final Function<Pair<RpcResult<AddMetersBatchOutput>, RpcResult<Void>>, RpcResult<AddMetersBatchOutput>>
-                compositeFunction = MeterUtil.createComposingFunction();
+    public void testCreateComposingFunction_failure_failure() {
+        final Function<Pair<RpcResult<AddMetersBatchOutput>, RpcResult<SendBarrierOutput>>,
+                RpcResult<AddMetersBatchOutput>> compositeFunction = MeterUtil.createComposingFunction();
 
         final RpcResult<AddMetersBatchOutput> addGroupBatchOutput = createAddMetersBatchFailureOutcome();
-        final RpcResult<Void> barrierOutput = createBarrierFailureOutcome();
-        final Pair<RpcResult<AddMetersBatchOutput>, RpcResult<Void>> input =
+        final RpcResult<SendBarrierOutput> barrierOutput = createBarrierFailureOutcome();
+        final Pair<RpcResult<AddMetersBatchOutput>, RpcResult<SendBarrierOutput>> input =
                 Pair.of(addGroupBatchOutput, barrierOutput);
         final RpcResult<AddMetersBatchOutput> composite = compositeFunction.apply(input);
 
@@ -211,8 +212,8 @@ public class MeterUtilTest {
         Assert.assertEquals(1, composite.getResult().getBatchFailedMetersOutput().size());
     }
 
-    private RpcResult<Void> createBarrierFailureOutcome() {
-        return RpcResultBuilder.<Void>failed()
+    private RpcResult<SendBarrierOutput> createBarrierFailureOutcome() {
+        return RpcResultBuilder.<SendBarrierOutput>failed()
                 .withError(RpcError.ErrorType.APPLICATION, "ut-barrier-error")
                 .build();
     }
@@ -220,7 +221,7 @@ public class MeterUtilTest {
     private RpcResult<AddMetersBatchOutput> createAddMetersBatchSuccessOutput() {
         return RpcResultBuilder
                 .success(new AddMetersBatchOutputBuilder()
-                        .setBatchFailedMetersOutput(Collections.<BatchFailedMetersOutput>emptyList())
+                        .setBatchFailedMetersOutput(Collections.emptyList())
                         .build())
                 .build();
     }
@@ -234,4 +235,4 @@ public class MeterUtilTest {
                 .withRpcErrors(batchOutcomeWithError.getErrors())
                 .build();
     }
-}
\ No newline at end of file
+}