Increased unit test coverage for keys
[openflowjava.git] / openflow-protocol-api / src / test / java / org / opendaylight / openflowjava / protocol / api / keys / MatchEntrySerializerKeyTest.java
index 5e79712df9515680487733b492d89b89cdb93792..576c446f0e9a3d661aed547e45a5f31b312f9467 100644 (file)
@@ -53,6 +53,8 @@ public class MatchEntrySerializerKeyTest {
                 null, InPhyPort.class);\r
         Assert.assertFalse("Wrong equals", key1.equals(key2));\r
         Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());\r
+        key2.setExperimenterId(42L);\r
+        Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());\r
     }\r
     \r
     /**\r
@@ -78,8 +80,28 @@ public class MatchEntrySerializerKeyTest {
         key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, null, InPort.class);\r
         key1.setExperimenterId(expId2);\r
         Assert.assertFalse("Wrong equal by oxmClass", key1.equals(key2));\r
+        key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, null, InPort.class);\r
+        key2.setExperimenterId(expId2);\r
+        Assert.assertTrue("Wrong equal by oxmClass", key1.equals(key2));\r
         key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, null);\r
         key1.setExperimenterId(expId2);\r
         Assert.assertFalse("Wrong equal by oxmField", key1.equals(key2));\r
+        key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, null);\r
+        key2.setExperimenterId(expId2);\r
+        Assert.assertTrue("Wrong equal by oxmField", key1.equals(key2));\r
+    }\r
+\r
+    /**\r
+     * Test MatchEntrySerializerKey toString()\r
+     */\r
+    @Test\r
+    public void testToString(){\r
+        MatchEntrySerializerKey<?, ?> key1;\r
+        key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class);\r
+\r
+        Assert.assertEquals("Wrong toString()", "msgVersion: 4 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight"\r
+                + ".openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries oxm_class: org.opendaylight.yang.gen.v1.urn"\r
+                + ".opendaylight.openflow.oxm.rev130731.OpenflowBasicClass oxm_field: org.opendaylight.yang.gen.v1.urn"\r
+                + ".opendaylight.openflow.oxm.rev130731.InPort experimenterID: null", key1.toString());\r
     }\r
 }
\ No newline at end of file