From 0b1daa34f49ab93e08b5be06b50424c81efd0c82 Mon Sep 17 00:00:00 2001 From: Martin Sunal Date: Thu, 24 Jul 2014 00:17:22 +0200 Subject: [PATCH] Corrected equals & hashcode methods in extension keys - corrected equals & hashcode methods in keys - tests for equals & hashcode methods in keys Signed-off-by: Martin Sunal --- .../api/extensibility/MessageCodeKey.java | 4 +- .../api/extensibility/MessageTypeKey.java | 7 +- .../api/keys/ActionDeserializerKey.java | 10 ++- .../api/keys/ActionSerializerKey.java | 14 +++- .../api/keys/InstructionDeserializerKey.java | 10 ++- .../api/keys/InstructionSerializerKey.java | 24 ++++--- .../api/keys/MatchEntryDeserializerKey.java | 11 +++- .../api/keys/MatchEntrySerializerKey.java | 17 +++-- .../ExperimenterActionDeserializerKey.java | 30 +-------- .../ExperimenterActionSerializerKey.java | 39 +---------- ...xperimenterInstructionDeserializerKey.java | 30 +-------- .../ExperimenterInstructionSerializerKey.java | 40 +----------- .../api/keys/extensibility/KeysTest.java | 65 +++++++++++++++++++ 13 files changed, 152 insertions(+), 149 deletions(-) create mode 100644 openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/extensibility/KeysTest.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java index b850eae9..86d5a4d1 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java @@ -34,6 +34,7 @@ public class MessageCodeKey { int result = 1; result = prime * result + ((clazz == null) ? 0 : clazz.hashCode()); result = prime * result + msgType; + result = prime * result + msgVersion; return result; } @@ -43,7 +44,7 @@ public class MessageCodeKey { return true; if (obj == null) return false; - if (getClass() != obj.getClass()) + if (!(obj instanceof MessageCodeKey)) return false; MessageCodeKey other = (MessageCodeKey) obj; if (clazz == null) { @@ -62,4 +63,5 @@ public class MessageCodeKey { public String toString() { return "msgVersion: " + msgVersion + " objectClass: " + clazz.getName() + " msgType: " + msgType; } + } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKey.java index 0ece4c61..d5d303e4 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKey.java @@ -38,7 +38,8 @@ public class MessageTypeKey { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((msgType == null) ? 0 : msgType.getName().hashCode()); + result = prime * result + ((msgType == null) ? 0 : msgType.hashCode()); + result = prime * result + msgVersion; return result; } @@ -48,13 +49,13 @@ public class MessageTypeKey { return true; if (obj == null) return false; - if (getClass() != obj.getClass()) + if (!(obj instanceof MessageTypeKey)) return false; MessageTypeKey other = (MessageTypeKey) obj; if (msgType == null) { if (other.msgType != null) return false; - } else if (!other.msgType.getName().equals(msgType.getName())) + } else if (!msgType.equals(other.msgType)) return false; if (msgVersion != other.msgVersion) return false; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java index d329e7ef..db17b3b5 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java @@ -29,13 +29,21 @@ public class ActionDeserializerKey extends MessageCodeKey { this.experimenterId = experimenterId; } + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + return result; + } + @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; - if (getClass() != obj.getClass()) + if (!(obj instanceof ActionDeserializerKey)) return false; ActionDeserializerKey other = (ActionDeserializerKey) obj; if (experimenterId == null) { diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java index 623bdea4..38b8cd49 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java @@ -33,16 +33,24 @@ public class ActionSerializerKey extends MessageTypeKey this.experimenterId = experimenterId; } + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((actionType == null) ? 0 : actionType.hashCode()); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + return result; + } + @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; - if (getClass() != obj.getClass()) + if (!(obj instanceof ActionSerializerKey)) return false; - @SuppressWarnings("rawtypes") - ActionSerializerKey other = (ActionSerializerKey) obj; + ActionSerializerKey other = (ActionSerializerKey) obj; if (actionType == null) { if (other.actionType != null) return false; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java index 95a5715b..91f8977a 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java @@ -29,13 +29,21 @@ public class InstructionDeserializerKey extends MessageCodeKey { this.experimenterId = experimenterId; } + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + return result; + } + @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; - if (getClass() != obj.getClass()) + if (!(obj instanceof InstructionDeserializerKey)) return false; InstructionDeserializerKey other = (InstructionDeserializerKey) obj; if (experimenterId == null) { diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java index 738156a0..899568dc 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java @@ -35,26 +35,34 @@ public class InstructionSerializerKey this.experimenterId = experimenterId; } + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + result = prime * result + ((instructionType == null) ? 0 : instructionType.hashCode()); + return result; + } + @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; - if (getClass() != obj.getClass()) - return false; - @SuppressWarnings("rawtypes") - InstructionSerializerKey other = (InstructionSerializerKey) obj; - if (instructionType == null) { - if (other.instructionType != null) - return false; - } else if (!instructionType.equals(other.instructionType)) + if (!(obj instanceof InstructionSerializerKey)) return false; + InstructionSerializerKey other = (InstructionSerializerKey) obj; if (experimenterId == null) { if (other.experimenterId != null) return false; } else if (!experimenterId.equals(other.experimenterId)) return false; + if (instructionType == null) { + if (other.instructionType != null) + return false; + } else if (!instructionType.equals(other.instructionType)) + return false; return true; } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java index bf703561..593ca8d6 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java @@ -16,7 +16,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm. * @author michal.polkorab * */ -public class MatchEntryDeserializerKey extends MessageCodeKey +public final class MatchEntryDeserializerKey extends MessageCodeKey implements ExperimenterDeserializerKey { private int oxmField; @@ -40,6 +40,15 @@ public class MatchEntryDeserializerKey extends MessageCodeKey this.experimenterId = experimenterId; } + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + result = prime * result + oxmField; + return result; + } + @Override public boolean equals(Object obj) { if (this == obj) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java index 8ceb7ccb..c7f07f62 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java @@ -19,8 +19,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm. * @param oxm_class (see specification) * @param oxm_field (see specification) */ -public class MatchEntrySerializerKey - extends MessageTypeKey implements ExperimenterSerializerKey{ +public final class MatchEntrySerializerKey + extends MessageTypeKey implements ExperimenterSerializerKey { private Class oxmClass; private Class oxmField; @@ -46,6 +46,16 @@ public class MatchEntrySerializerKey other = (MatchEntrySerializerKey) obj; if (experimenterId == null) { if (other.experimenterId != null) return false; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java index 1b21379e..b700f04b 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java @@ -8,46 +8,22 @@ package org.opendaylight.openflowjava.protocol.api.keys.experimenter; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; /** * @author michal.polkorab * */ -public class ExperimenterActionDeserializerKey extends MessageCodeKey +public final class ExperimenterActionDeserializerKey extends ActionDeserializerKey implements ExperimenterDeserializerKey { - private Long experimenterId; /** * @param version protocol wire version * @param experimenterId experimenter / vendor ID */ public ExperimenterActionDeserializerKey(short version, Long experimenterId) { - super(version, EncodeConstants.EXPERIMENTER_VALUE, Action.class); - this.experimenterId = experimenterId; + super(version, EncodeConstants.EXPERIMENTER_VALUE, experimenterId); } - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - ExperimenterActionDeserializerKey other = (ExperimenterActionDeserializerKey) obj; - if (experimenterId == null) { - if (other.experimenterId != null) - return false; - } else if (!experimenterId.equals(other.experimenterId)) - return false; - return true; - } - - @Override - public String toString() { - return super.toString() + " experimenterID: " + experimenterId; - } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java index 23e4640c..989e1ba7 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java @@ -8,54 +8,21 @@ package org.opendaylight.openflowjava.protocol.api.keys.experimenter; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; /** * @author michal.polkorab */ -public class ExperimenterActionSerializerKey extends MessageTypeKey +public final class ExperimenterActionSerializerKey extends ActionSerializerKey implements ExperimenterSerializerKey { - private Class actionType; - private Long experimenterId; - /** * @param msgVersion protocol wire version * @param experimenterId experimenter / vendor ID */ public ExperimenterActionSerializerKey(short msgVersion, Long experimenterId) { - super(msgVersion, Action.class); - this.actionType = Experimenter.class; - this.experimenterId = experimenterId; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - ExperimenterActionSerializerKey other = (ExperimenterActionSerializerKey) obj; - if (actionType == null) { - if (other.actionType != null) - return false; - } else if (!actionType.equals(other.actionType)) - return false; - if (experimenterId == null) { - if (other.experimenterId != null) - return false; - } else if (!experimenterId.equals(other.experimenterId)) - return false; - return true; + super(msgVersion, Experimenter.class, experimenterId); } - @Override - public String toString() { - return super.toString() + " action type: " + actionType.getName() + " experimenterID: " + experimenterId; - } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java index 12270310..cfe99569 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java @@ -8,46 +8,22 @@ package org.opendaylight.openflowjava.protocol.api.keys.experimenter; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; /** * @author michal.polkorab * */ -public class ExperimenterInstructionDeserializerKey extends MessageCodeKey +public final class ExperimenterInstructionDeserializerKey extends InstructionDeserializerKey implements ExperimenterDeserializerKey { - private Long experimenterId; /** * @param version protocol wire version * @param experimenterId */ public ExperimenterInstructionDeserializerKey(short version, Long experimenterId) { - super(version, EncodeConstants.EXPERIMENTER_VALUE, Instruction.class); - this.experimenterId = experimenterId; + super(version, EncodeConstants.EXPERIMENTER_VALUE, experimenterId); } - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - ExperimenterInstructionDeserializerKey other = (ExperimenterInstructionDeserializerKey) obj; - if (experimenterId == null) { - if (other.experimenterId != null) - return false; - } else if (!experimenterId.equals(other.experimenterId)) - return false; - return true; - } - - @Override - public String toString() { - return super.toString() + " experimenterID: " + experimenterId; - } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKey.java index 0a4541b1..28201506 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKey.java @@ -8,55 +8,21 @@ package org.opendaylight.openflowjava.protocol.api.keys.experimenter; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; /** * @author michal.polkorab */ -public class ExperimenterInstructionSerializerKey extends MessageTypeKey +public final class ExperimenterInstructionSerializerKey extends InstructionSerializerKey implements ExperimenterSerializerKey { - private Class instructionType; - private Long experimenterId; - /** * @param msgVersion protocol wire version * @param experimenterId experimenter / vendor ID */ public ExperimenterInstructionSerializerKey(short msgVersion, Long experimenterId) { - super(msgVersion, Instruction.class); - this.instructionType = Experimenter.class; - this.experimenterId = experimenterId; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - ExperimenterInstructionSerializerKey other = (ExperimenterInstructionSerializerKey) obj; - if (instructionType == null) { - if (other.instructionType != null) - return false; - } else if (!instructionType.equals(other.instructionType)) - return false; - if (experimenterId == null) { - if (other.experimenterId != null) - return false; - } else if (!experimenterId.equals(other.experimenterId)) - return false; - return true; + super(msgVersion, Experimenter.class, experimenterId); } - @Override - public String toString() { - return super.toString() + " instructionType type: " + instructionType.getName() - + " vendorID: " + experimenterId; - } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/extensibility/KeysTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/extensibility/KeysTest.java new file mode 100644 index 00000000..9b4cf744 --- /dev/null +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/extensibility/KeysTest.java @@ -0,0 +1,65 @@ +package org.opendaylight.openflowjava.protocol.api.keys.extensibility; + +import junit.framework.Assert; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; + +/** + * @author michal.polkorab + */ +public class KeysTest { + + /** + * Testing equals() and hashcode() methods of extension deserializer's keys + */ + @Test + public void testEqualsAndHashcodeOfDeserializerKeys() { + ActionDeserializerKey actionDeserializerKey = new ActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, + EncodeConstants.EXPERIMENTER_VALUE, 1L); + ExperimenterActionDeserializerKey experimenterActionDeserializerKey = new ExperimenterActionDeserializerKey( + EncodeConstants.OF13_VERSION_ID, 1L); + Assert.assertEquals(actionDeserializerKey, experimenterActionDeserializerKey); + Assert.assertEquals(actionDeserializerKey.hashCode(), experimenterActionDeserializerKey.hashCode()); + + InstructionDeserializerKey instructionDeserializerKey = new InstructionDeserializerKey( + EncodeConstants.OF13_VERSION_ID, EncodeConstants.EXPERIMENTER_VALUE, 1L); + ExperimenterInstructionDeserializerKey experimenterInstructionDeserializerKey = new ExperimenterInstructionDeserializerKey( + EncodeConstants.OF13_VERSION_ID, 1L); + Assert.assertEquals(instructionDeserializerKey, experimenterInstructionDeserializerKey); + Assert.assertEquals(instructionDeserializerKey.hashCode(), experimenterInstructionDeserializerKey.hashCode()); + + + } + + /** + * Testing equals() and hashcode() methods of extension serializer's keys + */ + @Test + public void testEqualsAndHashcodeOfActionDeserializerKeys() { + ActionSerializerKey actionSerializerKey = new ActionSerializerKey<>( + EncodeConstants.OF13_VERSION_ID, Experimenter.class, 1L); + ExperimenterActionSerializerKey experimenterActionSerializerKey = new ExperimenterActionSerializerKey( + EncodeConstants.OF13_VERSION_ID, 1L); + Assert.assertEquals(actionSerializerKey, experimenterActionSerializerKey); + Assert.assertEquals(actionSerializerKey.hashCode(), experimenterActionSerializerKey.hashCode()); + + InstructionSerializerKey instructionSerializerKey = new InstructionSerializerKey<>( + EncodeConstants.OF13_VERSION_ID, + org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter.class, + 1L); + ExperimenterInstructionSerializerKey experimenterInstructionSerializerKey = new ExperimenterInstructionSerializerKey(EncodeConstants.OF13_VERSION_ID, 1L); + Assert.assertEquals(instructionSerializerKey, experimenterInstructionSerializerKey); + Assert.assertEquals(instructionSerializerKey.hashCode(), experimenterInstructionSerializerKey.hashCode()); + } + +} -- 2.36.6