Merge "Fix warnings in TableFeaturesConvertor"
authormichal rehak <mirehak@cisco.com>
Thu, 28 May 2015 11:02:20 +0000 (11:02 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 28 May 2015 11:02:20 +0000 (11:02 +0000)
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesConvertor.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesConvertorTest.java

index 40f95762f302ab316ac38ff8d8da9193cad567b4..fa93f06e0df936a92db23c2090f96fa215f8ab2d 100644 (file)
@@ -236,7 +236,7 @@ public class TableFeaturesConvertor {
 
     private static void setTableFeatureProperty(ApplySetfieldMiss propType, TableFeaturePropertiesBuilder propBuilder) {
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch> setFieldMatch = null;
-        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.setfield.miss.ApplySetfieldMiss applySetfieldMiss = ((ApplySetfieldMiss) propType).getApplySetfieldMiss();
+        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.setfield.miss.ApplySetfieldMiss applySetfieldMiss = propType.getApplySetfieldMiss();
 
         if (null != applySetfieldMiss) {
             setFieldMatch = applySetfieldMiss.getSetFieldMatch();
@@ -250,7 +250,7 @@ public class TableFeaturesConvertor {
 
     private static void setTableFeatureProperty(ApplySetfield propType, TableFeaturePropertiesBuilder propBuilder) {
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch> setFieldMatch = null;
-        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.setfield.ApplySetfield applySetfield = ((ApplySetfield) propType).getApplySetfield();
+        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.setfield.ApplySetfield applySetfield = propType.getApplySetfield();
 
         if (null != applySetfield) {
             setFieldMatch = applySetfield.getSetFieldMatch();
@@ -264,7 +264,7 @@ public class TableFeaturesConvertor {
 
     private static void setTableFeatureProperty(WriteSetfieldMiss propType, TableFeaturePropertiesBuilder propBuilder) {
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch> setFieldMatch = null;
-        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.setfield.miss.WriteSetfieldMiss writeSetfieldMiss = ((WriteSetfieldMiss) propType).getWriteSetfieldMiss();
+        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.setfield.miss.WriteSetfieldMiss writeSetfieldMiss = propType.getWriteSetfieldMiss();
 
         if (null != writeSetfieldMiss) {
             setFieldMatch = writeSetfieldMiss.getSetFieldMatch();
@@ -278,7 +278,7 @@ public class TableFeaturesConvertor {
 
     private static void setTableFeatureProperty(WriteSetfield propType, TableFeaturePropertiesBuilder propBuilder) {
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch> setFieldMatch = null;
-        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.setfield.WriteSetfield writeSetField = ((WriteSetfield) propType).getWriteSetfield();
+        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.setfield.WriteSetfield writeSetField = propType.getWriteSetfield();
 
         if (null != writeSetField) {
             setFieldMatch = writeSetField.getSetFieldMatch();
@@ -293,7 +293,7 @@ public class TableFeaturesConvertor {
 
     private static void setTableFeatureProperty(Wildcards propType, TableFeaturePropertiesBuilder propBuilder) {
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch> setFieldMatch = null;
-        WildcardSetfield wildcardSetField = ((Wildcards) propType).getWildcardSetfield();
+        WildcardSetfield wildcardSetField = propType.getWildcardSetfield();
 
         if (null != wildcardSetField) {
             setFieldMatch = wildcardSetField.getSetFieldMatch();
@@ -307,7 +307,7 @@ public class TableFeaturesConvertor {
     }
 
     private static void setTableFeatureProperty(Match propType, TableFeaturePropertiesBuilder propBuilder) {
-        MatchSetfield matchSetField = ((Match) propType).getMatchSetfield();
+        MatchSetfield matchSetField = propType.getMatchSetfield();
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch> setFieldMatch = null;
 
         if (null != matchSetField) {
@@ -322,7 +322,7 @@ public class TableFeaturesConvertor {
     }
 
     private static void setTableFeatureProperty(ApplyActionsMiss propType, TableFeaturePropertiesBuilder propBuilder) {
-        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.miss.ApplyActionsMiss applyActionsMiss = ((ApplyActionsMiss) propType)
+        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.miss.ApplyActionsMiss applyActionsMiss = propType
                 .getApplyActionsMiss();
         setActionTableFeatureProperty(
                 propBuilder,
@@ -332,7 +332,7 @@ public class TableFeaturesConvertor {
     }
 
     private static void setTableFeatureProperty(ApplyActions propType, TableFeaturePropertiesBuilder propBuilder) {
-        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.ApplyActions applyActions = ((ApplyActions) propType)
+        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.ApplyActions applyActions = propType
                 .getApplyActions();
         setActionTableFeatureProperty(
                 propBuilder,
@@ -342,7 +342,7 @@ public class TableFeaturesConvertor {
     }
 
     private static void setTableFeatureProperty(WriteActionsMiss propType, TableFeaturePropertiesBuilder propBuilder) {
-        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.miss.WriteActionsMiss writeActionsMiss = ((WriteActionsMiss) propType)
+        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.miss.WriteActionsMiss writeActionsMiss = propType
                 .getWriteActionsMiss();
         setActionTableFeatureProperty(
                 propBuilder,
@@ -352,7 +352,7 @@ public class TableFeaturesConvertor {
     }
 
     private static void setTableFeatureProperty(WriteActions propType, TableFeaturePropertiesBuilder propBuilder) {
-        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.WriteActions writeActions = ((WriteActions) propType)
+        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.WriteActions writeActions = propType
                 .getWriteActions();
         setActionTableFeatureProperty(
                 propBuilder,
@@ -362,28 +362,28 @@ public class TableFeaturesConvertor {
     }
 
     private static void setTableFeatureProperty(NextTableMiss propType, TableFeaturePropertiesBuilder propBuilder) {
-        TablesMiss tables = ((NextTableMiss) propType)
+        TablesMiss tables = propType
                 .getTablesMiss();
         setNextTableFeatureProperty(propBuilder, TableFeaturesPropType.OFPTFPTNEXTTABLESMISS,
                 (tables == null) ? new ArrayList<Short>() : tables.getTableIds());
     }
 
     private static void setTableFeatureProperty(NextTable propType, TableFeaturePropertiesBuilder propBuilder) {
-        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.Tables tables = ((NextTable) propType)
+        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.Tables tables = propType
                 .getTables();
         setNextTableFeatureProperty(propBuilder, TableFeaturesPropType.OFPTFPTNEXTTABLES,
                 (tables == null) ? new ArrayList<Short>() : tables.getTableIds());
     }
 
     private static void setTableFeatureProperty(InstructionsMiss propType, TableFeaturePropertiesBuilder propBuilder) {
-        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.miss.InstructionsMiss instructions = ((InstructionsMiss) propType)
+        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.miss.InstructionsMiss instructions = propType
                 .getInstructionsMiss();
         setInstructionTableFeatureProperty(propBuilder, TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS,
                 (instructions == null) ? new ArrayList<Instruction>() : instructions.getInstruction());
     }
 
     private static void setTableFeatureProperty(Instructions propType, TableFeaturePropertiesBuilder propBuilder) {
-        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.Instructions instructions = ((Instructions) propType)
+        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.Instructions instructions = propType
                 .getInstructions();
         setInstructionTableFeatureProperty(propBuilder, TableFeaturesPropType.OFPTFPTINSTRUCTIONS,
                 (instructions == null) ? new ArrayList<Instruction>() : instructions.getInstruction());
index 30ba6f2a4a13b85c3de006538d8a1eaff5fd5724..9d8e611dba1f3b3652d59e84e70150fc382bc541 100644 (file)
@@ -9,17 +9,17 @@
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
 
 import static org.mockito.Mockito.when;
-
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import junit.framework.TestCase;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mockito.MockitoAnnotations;
+import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
@@ -85,24 +85,24 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table
 @RunWith(MockitoJUnitRunner.class)
 public class TableFeaturesConvertorTest extends TestCase {
 
-    @MockitoAnnotations.Mock
+    @Mock
     private TableFeatures tableFeatures;
     private static final TablePropertiesBuilder tablePropertiesBuilder = new TablePropertiesBuilder();
-    private static final Map<Class<? extends TableFeaturePropType>, Object> augmentationsMap = new HashMap<>();
+    private static final Map<Class<? extends TableFeaturePropType>, TableFeaturePropType> augmentationsMap = new HashMap<>();
     private static final List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction> instructionsList = new ArrayList<>();
     private static final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions = new ArrayList<>();
     private static final List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch> fieldTableFeatures = new ArrayList<>();
 
-    private void setupInstructionsList() {
-        instructionsList.add((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction) new GoToTableCaseBuilder().build());
-        instructionsList.add((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction) new WriteMetadataCaseBuilder().build());
-        instructionsList.add((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction) new WriteActionsCaseBuilder().build());
-        instructionsList.add((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction) new ApplyActionsCaseBuilder().build());
-        instructionsList.add((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction) new ClearActionsCaseBuilder().build());
-        instructionsList.add((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction) new MeterCaseBuilder().build());
+    private static void setupInstructionsList() {
+        instructionsList.add(new GoToTableCaseBuilder().build());
+        instructionsList.add(new WriteMetadataCaseBuilder().build());
+        instructionsList.add(new WriteActionsCaseBuilder().build());
+        instructionsList.add(new ApplyActionsCaseBuilder().build());
+        instructionsList.add(new ClearActionsCaseBuilder().build());
+        instructionsList.add(new MeterCaseBuilder().build());
     }
 
-    private void setupFieldTableFeatures() {
+    private static void setupFieldTableFeatures() {
         SetFieldMatchBuilder setFieldMatchBuilder = new SetFieldMatchBuilder();
         setFieldMatchBuilder.setHasMask(true);
         setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp.class);
@@ -193,7 +193,7 @@ public class TableFeaturesConvertorTest extends TestCase {
         fieldTableFeatures.add(setFieldMatchBuilder.build());
     }
 
-    private void setupActions() {
+    private static void setupActions() {
         org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder _actionBuilder = new ActionBuilder();
 
         OutputActionCaseBuilder outputActionCaseBuilder = new OutputActionCaseBuilder();
@@ -350,13 +350,13 @@ public class TableFeaturesConvertorTest extends TestCase {
 
     }
 
-    private TableProperties getTableProperties() {
+    private static TableProperties getTableProperties() {
         TableFeaturePropertiesBuilder tableFeaturePropertiesBuilder = new TableFeaturePropertiesBuilder();
         List<TableFeatureProperties> tableFeaturePropertieses = new ArrayList<>();
         int counter = 0;
-        for (Map.Entry entry : augmentationsMap.entrySet()) {
+        for (Entry<Class<? extends TableFeaturePropType>, TableFeaturePropType> entry : augmentationsMap.entrySet()) {
             counter++;
-            tableFeaturePropertiesBuilder.setTableFeaturePropType((TableFeaturePropType) entry.getValue());
+            tableFeaturePropertiesBuilder.setTableFeaturePropType(entry.getValue());
             tableFeaturePropertiesBuilder.setOrder(counter);
             tableFeaturePropertieses.add(tableFeaturePropertiesBuilder.build());
         }