InstructionInfo redesign: clean up 48/49948/7
authorStephen Kitt <skitt@redhat.com>
Mon, 2 Jan 2017 15:49:07 +0000 (16:49 +0100)
committerStephen Kitt <skitt@redhat.com>
Thu, 26 Jan 2017 13:51:21 +0000 (14:51 +0100)
Once downstream users have upgraded to the new InstructionInfo
descendants, we can remove InstructionType altogether, and turn
InstructionInfo into an interface.

This patch also changes the AbstractActionInfoList descendants to use
composition rather than inheritance.

Change-Id: Ibfe3cc841f6ad89b29d72e7a4243718059d1c1c5
Signed-off-by: Stephen Kitt <skitt@redhat.com>
15 files changed:
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/ActionInfoList.java [moved from mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/AbstractActionInfoList.java with 87% similarity]
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/BucketInfo.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/InstructionInfo.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/InstructionType.java [deleted file]
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/instructions/InstructionApplyActions.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/instructions/InstructionClearActions.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/instructions/InstructionGotoTable.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/instructions/InstructionWriteActions.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/instructions/InstructionWriteMetadata.java
mdsalutil/mdsalutil-api/src/test/java/org/opendaylight/genius/mdsalutil/instructions/InstructionApplyActionsTest.java
mdsalutil/mdsalutil-api/src/test/java/org/opendaylight/genius/mdsalutil/instructions/InstructionClearActionsTest.java
mdsalutil/mdsalutil-api/src/test/java/org/opendaylight/genius/mdsalutil/instructions/InstructionGotoTableTest.java
mdsalutil/mdsalutil-api/src/test/java/org/opendaylight/genius/mdsalutil/instructions/InstructionWriteActionsTest.java
mdsalutil/mdsalutil-api/src/test/java/org/opendaylight/genius/mdsalutil/instructions/InstructionWriteMetadataTest.java
mdsalutil/mdsalutil-api/src/test/java/org/opendaylight/genius/mdsalutil/tests/ActionInfoImmutableTest.java

similarity index 87%
rename from mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/AbstractActionInfoList.java
rename to mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/ActionInfoList.java
index dfc5bcee75fd8a61f8bf7bf7a6740eb46c0b0d24..20455f0dc17f10c472cd5249aefff4aaeaefcc18 100644 (file)
@@ -17,12 +17,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti
  *
  * @author Michael Vorburger
  */
-public abstract class AbstractActionInfoList {
-
+public class ActionInfoList {
     private final List<ActionInfo> actionInfos = new ArrayList<>();
 
-    protected AbstractActionInfoList(List<ActionInfo> actionInfos) {
-        super();
+    public ActionInfoList(List<ActionInfo> actionInfos) {
         if (actionInfos != null) {
             this.actionInfos.addAll(actionInfos);
         }
@@ -47,7 +45,7 @@ public abstract class AbstractActionInfoList {
         if (this == o) return true;
         if (o == null || getClass() != o.getClass()) return false;
 
-        AbstractActionInfoList that = (AbstractActionInfoList) o;
+        ActionInfoList that = (ActionInfoList) o;
 
         return actionInfos != null ? actionInfos.equals(that.actionInfos) : that.actionInfos == null;
     }
@@ -56,4 +54,9 @@ public abstract class AbstractActionInfoList {
     public int hashCode() {
         return actionInfos != null ? actionInfos.hashCode() : 0;
     }
+
+    @Override
+    public String toString() {
+        return "ActionInfoList" + actionInfos.toString();
+    }
 }
index 369ec9ecfc345d76c606376acc1cb33521114e17..1e78667afd4a4945406c5ee105412a71f9f3a1ef 100644 (file)
@@ -13,7 +13,7 @@ import java.util.List;
 import java.util.Objects;
 import org.opendaylight.yangtools.util.EvenMoreObjects;
 
-public class BucketInfo extends AbstractActionInfoList implements Serializable {
+public class BucketInfo extends ActionInfoList implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
index 9050d2c61e397a06b68784b3ab097eda00a74353..1e798f75cca66e301cd30e2ae7c68a6a77a86dd8 100644 (file)
@@ -7,99 +7,9 @@
  */
 package org.opendaylight.genius.mdsalutil;
 
-import com.google.common.base.MoreObjects;
 import java.io.Serializable;
-import java.math.BigInteger;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
-import org.opendaylight.yangtools.util.EvenMoreObjects;
 
-public class InstructionInfo extends AbstractActionInfoList implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    private final InstructionType m_instructionType;
-    private final long[] m_alInstructionValues;
-    private final BigInteger[] m_alBigInstructionValues;
-
-    // This constructor should be used incase of clearAction
-    @Deprecated
-    public InstructionInfo(InstructionType instructionType) {
-        super(null);
-        m_instructionType = instructionType;
-        m_alInstructionValues = null;
-        m_alBigInstructionValues = null;
-    }
-
-    @Deprecated
-    public InstructionInfo(InstructionType instructionType, long[] instructionValues) {
-        super(null);
-        m_instructionType = instructionType;
-        m_alInstructionValues = instructionValues;
-        m_alBigInstructionValues = null;
-    }
-
-    @Deprecated
-    public InstructionInfo(InstructionType instructionType, BigInteger[] instructionValues) {
-        super(null);
-        m_instructionType = instructionType;
-        m_alInstructionValues = null;
-        m_alBigInstructionValues = instructionValues;
-    }
-
-    @Deprecated
-    public InstructionInfo(InstructionType instructionType, List<ActionInfo> actionInfos) {
-        super(actionInfos);
-        m_instructionType = instructionType;
-        m_alInstructionValues = null;
-        m_alBigInstructionValues = null;
-    }
-
-    public Instruction buildInstruction(int instructionKey) {
-        return m_instructionType.buildInstruction(this, instructionKey);
-    }
-
-    public InstructionType getInstructionType() {
-        return m_instructionType;
-    }
-
-    public long[] getInstructionValues() {
-        return m_alInstructionValues;
-    }
-
-    public BigInteger[] getBigInstructionValues() {
-        return m_alBigInstructionValues;
-    }
-
-    @Override
-    public String toString() {
-        return MoreObjects.toStringHelper(this).omitNullValues().add("instructionType", m_instructionType)
-                .add("instructionValues", Arrays.toString(m_alInstructionValues))
-                .add("bigInstructionValues", Arrays.deepToString(m_alBigInstructionValues))
-                .add("actionInfos", getActionInfos()).toString();
-    }
-
-    @Override
-    public int hashCode() {
-        // BEWARE, Caveat Emptor: Array ([]) type fields must use
-        // Arrays.hashCode(). deepHashCode() would have to be used for nested
-        // arrays.
-        return Objects.hash(m_instructionType, Arrays.hashCode(m_alInstructionValues),
-                Arrays.hashCode(m_alBigInstructionValues), getActionInfos());
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        // BEWARE, Caveat Emptor: Array ([]) type fields must use
-        // Arrays.equals(). deepEquals() would have to be used for nested
-        // arrays. Use == only for primitive types; if ever changing
-        // those field types, must change to Objects.equals.
-        return EvenMoreObjects.equalsHelper(this, obj,
-            (self, other) -> Objects.equals(self.m_instructionType, other.m_instructionType)
-                          && Arrays.equals(self.m_alInstructionValues, other.m_alInstructionValues)
-                          && Arrays.equals(self.m_alBigInstructionValues, other.m_alBigInstructionValues)
-                          && Objects.equals(self.getActionInfos(), other.getActionInfos()));
-    }
+public interface InstructionInfo extends Serializable {
+    Instruction buildInstruction(int instructionKey);
 }
diff --git a/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/InstructionType.java b/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/InstructionType.java
deleted file mode 100644 (file)
index 682c0a4..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright © 2016, 2017 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.genius.mdsalutil;
-
-import org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions;
-import org.opendaylight.genius.mdsalutil.instructions.InstructionClearActions;
-import org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable;
-import org.opendaylight.genius.mdsalutil.instructions.InstructionWriteActions;
-import org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
-
-@Deprecated
-public enum InstructionType {
-    @Deprecated
-    apply_actions {
-        @Override
-        public Instruction buildInstruction(InstructionInfo instructionInfo, int instructionKey) {
-            return new InstructionApplyActions(instructionInfo.getActionInfos()).buildInstruction(instructionKey);
-        }
-    },
-
-    @Deprecated
-    goto_table {
-        @Override
-        public Instruction buildInstruction(InstructionInfo instructionInfo, int instructionKey) {
-            return new InstructionGotoTable((short) instructionInfo.getInstructionValues()[0]).buildInstruction(
-                    instructionKey);
-        }
-    },
-
-    @Deprecated
-    write_actions {
-        @Override
-        public Instruction buildInstruction(InstructionInfo instructionInfo, int instructionKey) {
-            return new InstructionWriteActions(instructionInfo.getActionInfos()).buildInstruction(instructionKey);
-        }
-    },
-
-    @Deprecated
-    clear_actions {
-        @Override
-        public Instruction buildInstruction(InstructionInfo instructionInfo, int instructionKey) {
-            return new InstructionClearActions().buildInstruction(instructionKey);
-        }
-    },
-
-    @Deprecated
-    write_metadata {
-        @Override
-        public Instruction buildInstruction(InstructionInfo instructionInfo, int instructionKey) {
-            return new InstructionWriteMetadata(instructionInfo.getBigInstructionValues()[0],
-                    instructionInfo.getBigInstructionValues()[1]).buildInstruction(instructionKey);
-        }
-    };
-
-    @Deprecated
-    public abstract Instruction buildInstruction(InstructionInfo instructionInfo, int instructionKey);
-}
index a5b3bdd18ba954f106dd61139158415f06d8ff68..b7e09ee8785e79173d26a111b087c84a6a70fc84 100644 (file)
@@ -8,9 +8,9 @@
 package org.opendaylight.genius.mdsalutil.instructions;
 
 import java.util.List;
+import org.opendaylight.genius.mdsalutil.ActionInfoList;
 import org.opendaylight.genius.mdsalutil.ActionInfo;
 import org.opendaylight.genius.mdsalutil.InstructionInfo;
-import org.opendaylight.genius.mdsalutil.InstructionType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
@@ -20,9 +20,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru
 /**
  * Apply actions instruction.
  */
-public class InstructionApplyActions extends InstructionInfo {
+public class InstructionApplyActions implements InstructionInfo {
+    private final ActionInfoList actions;
+
     public InstructionApplyActions(List<ActionInfo> actionsInfos) {
-        super(InstructionType.apply_actions, actionsInfos);
+        this.actions = new ActionInfoList(actionsInfos);
     }
 
     @Override
@@ -30,7 +32,7 @@ public class InstructionApplyActions extends InstructionInfo {
         return new InstructionBuilder()
                 .setInstruction(new ApplyActionsCaseBuilder()
                         .setApplyActions(new ApplyActionsBuilder()
-                                .setAction(buildActions())
+                                .setAction(actions.buildActions())
                                 .build()
                         )
                         .build()
@@ -38,4 +40,8 @@ public class InstructionApplyActions extends InstructionInfo {
                 .setKey(new InstructionKey(instructionKey))
                 .build();
     }
+
+    public List<ActionInfo> getActionInfos() {
+        return actions.getActionInfos();
+    }
 }
index c7b58efabcbc9121e6219ed7defbafda3383208c..460141f7f531c13ef94b68bbb523fc40980a0eb7 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.genius.mdsalutil.instructions;
 
 import org.opendaylight.genius.mdsalutil.InstructionInfo;
-import org.opendaylight.genius.mdsalutil.InstructionType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
@@ -17,11 +16,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru
 /**
  * Clear actions instruction.
  */
-public class InstructionClearActions extends InstructionInfo {
-    public InstructionClearActions() {
-        super(InstructionType.clear_actions);
-    }
-
+public class InstructionClearActions implements InstructionInfo {
     @Override
     public Instruction buildInstruction(int instructionKey) {
         return new InstructionBuilder()
index 8815efd23c5b7fe31c3e715577889317be8717ff..a4979df89c79ae482d84911458755a0354f8ea84 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.genius.mdsalutil.instructions;
 
 import org.opendaylight.genius.mdsalutil.InstructionInfo;
-import org.opendaylight.genius.mdsalutil.InstructionType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
@@ -18,11 +17,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru
 /**
  * Goto table instruction.
  */
-public class InstructionGotoTable extends InstructionInfo {
+public class InstructionGotoTable implements InstructionInfo {
     private final short tableId;
 
     public InstructionGotoTable(short tableId) {
-        super(InstructionType.goto_table, new long[] {tableId});
         this.tableId = tableId;
     }
 
index 544641159fd7f804a74e0936da4532fa3c76cd56..b00a8cf5f1142ad72a96913da124d11e9ce12d78 100644 (file)
@@ -9,8 +9,8 @@ package org.opendaylight.genius.mdsalutil.instructions;
 
 import java.util.List;
 import org.opendaylight.genius.mdsalutil.ActionInfo;
+import org.opendaylight.genius.mdsalutil.ActionInfoList;
 import org.opendaylight.genius.mdsalutil.InstructionInfo;
-import org.opendaylight.genius.mdsalutil.InstructionType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.actions._case.WriteActionsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
@@ -20,9 +20,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru
 /**
  * Write actions instruction.
  */
-public class InstructionWriteActions extends InstructionInfo {
+public class InstructionWriteActions implements InstructionInfo {
+    private final ActionInfoList actions;
+
     public InstructionWriteActions(List<ActionInfo> actionInfos) {
-        super(InstructionType.write_actions, actionInfos);
+        this.actions = new ActionInfoList(actionInfos);
     }
 
     @Override
@@ -30,7 +32,7 @@ public class InstructionWriteActions extends InstructionInfo {
         return new InstructionBuilder()
                 .setInstruction(new WriteActionsCaseBuilder()
                         .setWriteActions(new WriteActionsBuilder()
-                                .setAction(buildActions())
+                                .setAction(actions.buildActions())
                                 .build()
                         )
                         .build()
index c46fedd3372ea565abb0aa883e0f56f54980a5a5..167585491e9521f817e84f83fa81155691fbdaba 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.genius.mdsalutil.instructions;
 
 import java.math.BigInteger;
 import org.opendaylight.genius.mdsalutil.InstructionInfo;
-import org.opendaylight.genius.mdsalutil.InstructionType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
@@ -19,12 +18,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru
 /**
  * Write metadata instruction.
  */
-public class InstructionWriteMetadata extends InstructionInfo {
+public class InstructionWriteMetadata implements InstructionInfo {
     private final BigInteger metadata;
     private final BigInteger mask;
 
     public InstructionWriteMetadata(BigInteger metadata, BigInteger mask) {
-        super(InstructionType.write_metadata, new BigInteger[] {metadata, mask});
         this.metadata = metadata;
         this.mask = mask;
     }
index bf6b19096c7403eaf2a82031583628d224a6f374..e6baf48f6773bd5eef8dd094c5ead9e3c367e943 100644 (file)
@@ -14,7 +14,6 @@ import java.util.Collections;
 import java.util.List;
 import org.junit.Test;
 import org.opendaylight.genius.mdsalutil.InstructionInfo;
-import org.opendaylight.genius.mdsalutil.InstructionType;
 import org.opendaylight.genius.mdsalutil.actions.ActionGroup;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
@@ -25,12 +24,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru
  * Test for {@link InstructionApplyActions}.
  */
 public class InstructionApplyActionsTest {
-    @Test
-    public void backwardsCompatibleInstruction() {
-        verifyInstructionInfo(
-                new InstructionInfo(InstructionType.apply_actions, Collections.singletonList(new ActionGroup(1L))));
-    }
-
     @Test
     public void newInstruction() {
         verifyInstructionInfo(new InstructionApplyActions(Collections.singletonList(new ActionGroup(1L))));
index a065f203fdb4650d4467cdd1431d3d648fb2a66c..8b3743c87b400d429e3c86f1c7242abeac0af260 100644 (file)
@@ -12,7 +12,6 @@ import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
 import org.opendaylight.genius.mdsalutil.InstructionInfo;
-import org.opendaylight.genius.mdsalutil.InstructionType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
 
@@ -20,11 +19,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru
  * Test for {@link InstructionClearActions}.
  */
 public class InstructionClearActionsTest {
-    @Test
-    public void backwardsCompatibleInstruction() {
-        verifyInstructionInfo(new InstructionInfo(InstructionType.clear_actions));
-    }
-
     @Test
     public void newInstruction() {
         verifyInstructionInfo(new InstructionClearActions());
index ec0f8cc9b183ad93af4dbb2f4e8f7fe7a1e62ce0..e3f7e48574e30f879681a6e35976766ed8c40478 100644 (file)
@@ -12,7 +12,6 @@ import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
 import org.opendaylight.genius.mdsalutil.InstructionInfo;
-import org.opendaylight.genius.mdsalutil.InstructionType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
 
@@ -20,11 +19,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru
  * Test for {@link InstructionGotoTable}.
  */
 public class InstructionGotoTableTest {
-    @Test
-    public void backwardsCompatibleInstruction() {
-        verifyInstructionInfo(new InstructionInfo(InstructionType.goto_table, new long[] {1L}));
-    }
-
     @Test
     public void newInstruction() {
         verifyInstructionInfo(new InstructionGotoTable((short) 1));
index 09ea2210403ce2de3a32722b6961c76870b476b9..4debc88afc70527e34118a43f7f7a88b4b02d471 100644 (file)
@@ -14,7 +14,6 @@ import java.util.Collections;
 import java.util.List;
 import org.junit.Test;
 import org.opendaylight.genius.mdsalutil.InstructionInfo;
-import org.opendaylight.genius.mdsalutil.InstructionType;
 import org.opendaylight.genius.mdsalutil.actions.ActionGroup;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
@@ -25,12 +24,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru
  * Test for {@link InstructionWriteActions}.
  */
 public class InstructionWriteActionsTest {
-    @Test
-    public void backwardsCompatibleInstruction() {
-        verifyInstructionInfo(
-                new InstructionInfo(InstructionType.write_actions, Collections.singletonList(new ActionGroup(1L))));
-    }
-
     @Test
     public void newInstruction() {
         verifyInstructionInfo(new InstructionWriteActions(Collections.singletonList(new ActionGroup(1L))));
index 582bd4daf55c528ba571fd06abfb4ba203f2f147..a5e420b8aaa013a21e68ae9e16a9d745dc8c7026 100644 (file)
@@ -13,7 +13,6 @@ import static org.junit.Assert.assertTrue;
 import java.math.BigInteger;
 import org.junit.Test;
 import org.opendaylight.genius.mdsalutil.InstructionInfo;
-import org.opendaylight.genius.mdsalutil.InstructionType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadata;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
@@ -22,12 +21,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru
  * Test for {@link InstructionWriteMetadata}.
  */
 public class InstructionWriteMetadataTest {
-    @Test
-    public void backwardsCompatibleInstruction() {
-        verifyInstructionInfo(
-                new InstructionInfo(InstructionType.write_metadata, new BigInteger[] {BigInteger.ONE, BigInteger.TEN}));
-    }
-
     @Test
     public void newInstruction() {
         verifyInstructionInfo(new InstructionWriteMetadata(BigInteger.ONE, BigInteger.TEN));
index ac0059d7c758e9488f1d79ef540e7d29f8bac371..a359616d30477aae4df991102b34ae31c46dc810 100644 (file)
@@ -29,12 +29,15 @@ public class ActionInfoImmutableTest {
         List<ActionInfo> actionInfos = new ArrayList<>();
         actionInfos.add(actionInfo);
         flowEntity.getInstructionInfoList().add(new InstructionApplyActions(actionInfos));
-        assertEquals(27, flowEntity.getInstructionInfoList().get(0).getActionInfos().get(0).getActionKey());
+        assertEquals(27, ((InstructionApplyActions) flowEntity.getInstructionInfoList().get(0)).getActionInfos().get(
+                0).getActionKey());
 
         flowEntity.getFlowBuilder();
-        assertEquals(27, flowEntity.getInstructionInfoList().get(0).getActionInfos().get(0).getActionKey());
+        assertEquals(27, ((InstructionApplyActions) flowEntity.getInstructionInfoList().get(0)).getActionInfos().get(
+                0).getActionKey());
         flowEntity.getFlowBuilder();
-        assertEquals(27, flowEntity.getInstructionInfoList().get(0).getActionInfos().get(0).getActionKey());
+        assertEquals(27, ((InstructionApplyActions) flowEntity.getInstructionInfoList().get(0)).getActionInfos().get(
+                0).getActionKey());
     }
 
 }