-/*\r
- * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-\r
-package org.opendaylight.openflowjava.protocol.api.keys;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class InstructionSerializerKeyTest {\r
-\r
- /**\r
- * Test InstructionSerializerKey equals and hashCode\r
- */\r
- @Test\r
- public void test() {\r
- InstructionSerializerKey<?> key1 =\r
- new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L);\r
- InstructionSerializerKey<?> key2 =\r
- new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L);\r
- Assert.assertTrue("Wrong equals", key1.equals(key2));\r
- Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode());\r
- key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, null);\r
- Assert.assertFalse("Wrong equals", key1.equals(key2));\r
- Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());\r
- key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L);\r
- Assert.assertFalse("Wrong equals", key1.equals(key2));\r
- Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());\r
- key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, WriteActions.class, 42L);\r
- Assert.assertFalse("Wrong equals", key1.equals(key2));\r
- Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());\r
- key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 55L);\r
- Assert.assertFalse("Wrong equals", key1.equals(key2));\r
- Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());\r
- key2 = new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, ApplyActions.class, 42L);\r
- Assert.assertFalse("Wrong equals", key1.equals(key2));\r
- Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());\r
- }\r
+/*
+ * Copyright (c) 2014 Pantheon Technologies s.r.o. 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.openflowjava.protocol.api.keys;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class InstructionSerializerKeyTest {
+
+ /**
+ * Test InstructionSerializerKey equals and hashCode
+ */
+ @Test
+ public void test() {
+ InstructionSerializerKey<?> key1 =
+ new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L);
+ InstructionSerializerKey<?> key2 =
+ new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L);
+ Assert.assertTrue("Wrong equals", key1.equals(key2));
+ Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode());
+ key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, null);
+ Assert.assertFalse("Wrong equals", key1.equals(key2));
+ Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
+ key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L);
+ Assert.assertFalse("Wrong equals", key1.equals(key2));
+ Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
+ key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, WriteActions.class, 42L);
+ Assert.assertFalse("Wrong equals", key1.equals(key2));
+ Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
+ key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 55L);
+ Assert.assertFalse("Wrong equals", key1.equals(key2));
+ Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
+ key2 = new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, ApplyActions.class, 42L);
+ Assert.assertFalse("Wrong equals", key1.equals(key2));
+ Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
+ }
+
+ /**
+ * Test InstructionSerializerKey equals - additional test
+ */
+ @Test
+ public void testEquals(){
+ InstructionSerializerKey<?> key1 =
+ new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L);
+ InstructionSerializerKey<?> key2 =
+ new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L);
+
+ Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1));
+ Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object()));
+
+ key1 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, null);
+ Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2));
+
+ key1 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L);
+ key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L);
+ Assert.assertTrue("Wrong equal by instructionType.", key1.equals(key2));
+ }
+
+ /**
+ * Test InstructionSerializerKey toString()
+ */
+ @Test
+ public void testToString(){
+ InstructionSerializerKey<?> key1 =
+ new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L);
+
+ Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight"
+ + ".openflow.common.instruction.rev130731.instructions.grouping.Instruction"
+ + " instructionType type: org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
+ + ".instruction.rev130731.ApplyActions vendorID: 42", key1.toString());
+ }