Merge "Cleanup use of Guava Function"
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / util / MeterUtilTest.java
index 869f0bb456b1811ca5c80ce791f481c321c15f2c..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),
@@ -73,49 +74,51 @@ public class MeterUtilTest {
         Assert.assertEquals(1, output.getResult().get(0).getBatchOrder().intValue());
     }
 
-    private org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter createBatchMeter(final MeterId meterId) {
+    private org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter createBatchMeter(
+            final MeterId meterId) {
         return new MeterBuilder()
                 .setMeterId(meterId)
                 .build();
     }
 
     @Test
-    public void testMETER_ADD_TRANSFORM__failure() throws Exception {
+    public void testMeterAddTransformFailure() {
         final RpcResult<List<BatchFailedMetersOutput>> input = createBatchOutcomeWithError();
         checkBatchErrorOutcomeTransformation(MeterUtil.METER_ADD_TRANSFORM.apply(input));
     }
 
     @Test
-    public void testMETER_ADD_TRANSFORM__success() throws Exception {
+    public void testMeterAddTransformSuccess() {
         final RpcResult<List<BatchFailedMetersOutput>> input = createEmptyBatchOutcome();
         checkBatchSuccessOutcomeTransformation(MeterUtil.METER_ADD_TRANSFORM.apply(input));
     }
 
     @Test
-    public void testMETER_REMOVE_TRANSFORM__failure() throws Exception {
+    public void testMeterRemoveTransformFailure() {
         final RpcResult<List<BatchFailedMetersOutput>> input = createBatchOutcomeWithError();
         checkBatchErrorOutcomeTransformation(MeterUtil.METER_REMOVE_TRANSFORM.apply(input));
     }
 
     @Test
-    public void testFLOW_REMOVE_TRANSFORM__success() throws Exception {
+    public void testFlowRemoveTransformSuccess() {
         final RpcResult<List<BatchFailedMetersOutput>> input = createEmptyBatchOutcome();
         checkBatchSuccessOutcomeTransformation(MeterUtil.METER_REMOVE_TRANSFORM.apply(input));
     }
 
     @Test
-    public void testFLOW_UPDATE_TRANSFORM__failure() throws Exception {
+    public void testFlowUpdateTransformFailure() {
         final RpcResult<List<BatchFailedMetersOutput>> input = createBatchOutcomeWithError();
         checkBatchErrorOutcomeTransformation(MeterUtil.METER_UPDATE_TRANSFORM.apply(input));
     }
 
     @Test
-    public void testFLOW_UPDATE_TRANSFORM__success() throws Exception {
+    public void testFlowUpdateTransformSuccess() {
         final RpcResult<List<BatchFailedMetersOutput>> input = createEmptyBatchOutcome();
         checkBatchSuccessOutcomeTransformation(MeterUtil.METER_UPDATE_TRANSFORM.apply(input));
     }
 
-    private <T extends BatchMeterOutputListGrouping> void checkBatchSuccessOutcomeTransformation(final RpcResult<T> output) {
+    private <T extends BatchMeterOutputListGrouping> void checkBatchSuccessOutcomeTransformation(
+            final RpcResult<T> output) {
         Assert.assertTrue(output.isSuccessful());
         Assert.assertEquals(0, output.getResult().getBatchFailedMetersOutput().size());
         Assert.assertEquals(0, output.getErrors().size());
@@ -123,7 +126,7 @@ public class MeterUtilTest {
 
     private RpcResult<List<BatchFailedMetersOutput>> createEmptyBatchOutcome() {
         return RpcResultBuilder
-                .<List<BatchFailedMetersOutput>>success(Collections.<BatchFailedMetersOutput>emptyList())
+                .success(Collections.<BatchFailedMetersOutput>emptyList())
                 .build();
     }
 
@@ -136,7 +139,8 @@ public class MeterUtilTest {
                 .build();
     }
 
-    private <T extends BatchMeterOutputListGrouping> void checkBatchErrorOutcomeTransformation(final RpcResult<T> output) {
+    private <T extends BatchMeterOutputListGrouping> void checkBatchErrorOutcomeTransformation(
+            final RpcResult<T> output) {
         Assert.assertFalse(output.isSuccessful());
         Assert.assertEquals(1, output.getResult().getBatchFailedMetersOutput().size());
         Assert.assertEquals(DUMMY_METER_ID, output.getResult().getBatchFailedMetersOutput().get(0).getMeterId());
@@ -145,13 +149,14 @@ 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 = Pair.of(addGroupBatchOutput, barrierOutput);
+        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);
 
         Assert.assertTrue(composite.isSuccessful());
@@ -160,13 +165,14 @@ 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 = Pair.of(addGroupBatchOutput, barrierOutput);
+        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);
 
         Assert.assertFalse(composite.isSuccessful());
@@ -175,13 +181,14 @@ 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 = Pair.of(addGroupBatchOutput, barrierOutput);
+        final RpcResult<SendBarrierOutput> barrierOutput = createBarrierFailureOutcome();
+        final Pair<RpcResult<AddMetersBatchOutput>, RpcResult<SendBarrierOutput>> input =
+                Pair.of(addGroupBatchOutput, barrierOutput);
         final RpcResult<AddMetersBatchOutput> composite = compositeFunction.apply(input);
 
         Assert.assertFalse(composite.isSuccessful());
@@ -190,13 +197,14 @@ 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 = Pair.of(addGroupBatchOutput, barrierOutput);
+        final RpcResult<SendBarrierOutput> barrierOutput = createBarrierFailureOutcome();
+        final Pair<RpcResult<AddMetersBatchOutput>, RpcResult<SendBarrierOutput>> input =
+                Pair.of(addGroupBatchOutput, barrierOutput);
         final RpcResult<AddMetersBatchOutput> composite = compositeFunction.apply(input);
 
         Assert.assertFalse(composite.isSuccessful());
@@ -204,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();
     }
@@ -213,7 +221,7 @@ public class MeterUtilTest {
     private RpcResult<AddMetersBatchOutput> createAddMetersBatchSuccessOutput() {
         return RpcResultBuilder
                 .success(new AddMetersBatchOutputBuilder()
-                        .setBatchFailedMetersOutput(Collections.<BatchFailedMetersOutput>emptyList())
+                        .setBatchFailedMetersOutput(Collections.emptyList())
                         .build())
                 .build();
     }
@@ -227,4 +235,4 @@ public class MeterUtilTest {
                 .withRpcErrors(batchOutcomeWithError.getErrors())
                 .build();
     }
-}
\ No newline at end of file
+}