Merge "Fix ExperimenterActionSerializerKey initializer use"
authorArunprakash D <d.arunprakash@ericsson.com>
Wed, 22 Jul 2020 08:51:02 +0000 (08:51 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 22 Jul 2020 08:51:02 +0000 (08:51 +0000)
openflowjava/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdMeterSubTypeSerializerKey.java
openflowjava/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java
openflowjava/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java
openflowjava/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java

index 2fa5775fce0ebb375c01b3c7357b2a49efcf4558..e6ad13e06e0f9206267bdef45161b49dfc9ef5fd 100755 (executable)
@@ -52,7 +52,7 @@ public class ExperimenterIdMeterSubTypeSerializerKey<T extends DataContainer> ex
         if (getClass() != obj.getClass()) {
             return false;
         }
-        ExperimenterIdMeterSubTypeSerializerKey other = (ExperimenterIdMeterSubTypeSerializerKey) obj;
+        ExperimenterIdMeterSubTypeSerializerKey<?> other = (ExperimenterIdMeterSubTypeSerializerKey<?>) obj;
         if (meterSubType == null) {
             if (other.meterSubType != null) {
                 return false;
index 376394a2f4ce03180b0a200bbc4ddc72dfe184ea..bba05c74948825eabf00c8b062e47bc6506c9df6 100644 (file)
@@ -5,7 +5,6 @@
  * 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;
@@ -21,6 +20,8 @@ import org.opendaylight.yangtools.yang.common.Uint32;
  * @author michal.polkorab
  */
 public class ActionSerializerKeyTest {
+    private static final Uint32 FORTY_TWO = Uint32.valueOf(42);
+    private static final Uint32 FIFTY_FIVE = Uint32.valueOf(55);
 
     /**
      * Test ActionSerializerKey equals and hashCode.
@@ -28,9 +29,9 @@ public class ActionSerializerKeyTest {
     @Test
     public void test() {
         ActionSerializerKey<CopyTtlInCase> key1 =
-                new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlInCase.class, 42L);
+                new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlInCase.class, FORTY_TWO);
         ActionSerializerKey<?> key2 =
-                new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlInCase.class, 42L);
+                new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlInCase.class, FORTY_TWO);
         Assert.assertTrue("Wrong equals", key1.equals(key2));
         Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode());
         key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlInCase.class, (Uint32) null);
@@ -39,13 +40,13 @@ public class ActionSerializerKeyTest {
         key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, (Uint32) null);
         Assert.assertFalse("Wrong equals", key1.equals(key2));
         Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
-        key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlOutCase.class, 42L);
+        key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlOutCase.class, FORTY_TWO);
         Assert.assertFalse("Wrong equals", key1.equals(key2));
         Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
-        key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlInCase.class, 55L);
+        key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlInCase.class, FIFTY_FIVE);
         Assert.assertFalse("Wrong equals", key1.equals(key2));
         Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
-        key2 = new ActionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, CopyTtlInCase.class, 55L);
+        key2 = new ActionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, CopyTtlInCase.class, FIFTY_FIVE);
         Assert.assertFalse("Wrong equals", key1.equals(key2));
         Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
     }
@@ -55,14 +56,14 @@ public class ActionSerializerKeyTest {
      */
     @Test
     public void testEquals() {
-        ActionSerializerKey<?> key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L);
+        ActionSerializerKey<?> key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, FORTY_TWO);
         ActionSerializerKey<?> key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID,
-                CopyTtlInCase.class, 42L);
+                CopyTtlInCase.class, FORTY_TWO);
 
         Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1));
         Assert.assertFalse("Wrong equal by actionType", key1.equals(key2));
 
-        key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L);
+        key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, FORTY_TWO);
         Assert.assertTrue("Wrong equal by action type", key1.equals(key2));
         key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID,  CopyTtlInCase.class, (Uint32) null);
         Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2));
@@ -76,7 +77,7 @@ public class ActionSerializerKeyTest {
     @Test
     public void testToString() {
         ActionSerializerKey<CopyTtlInCase> key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID,
-                CopyTtlInCase.class, 42L);
+                CopyTtlInCase.class, FORTY_TWO);
 
         Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn"
                 + ".opendaylight.openflow.common.action.rev150203.actions.grouping.Action action type:"
index 0e393fbb0b22ec2e07e5d086e14af1827f7635ca..350a91a5bc7ff27e321d8fb9571e8ae8d7bd6ae4 100644 (file)
@@ -15,6 +15,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.ExperimenterActionSubType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+import org.opendaylight.yangtools.yang.common.Uint32;
 
 /**
  * Unit tests for keys.
@@ -57,9 +58,9 @@ public class KeysTest {
     @Test
     public void testEqualsAndHashcodeOfActionDeserializerKeys() {
         ActionSerializerKey<ExperimenterIdCase> actionSerializerKey = new ActionSerializerKey<>(
-                EncodeConstants.OF13_VERSION_ID, ExperimenterIdCase.class, 1L);
+                EncodeConstants.OF13_VERSION_ID, ExperimenterIdCase.class, Uint32.ONE);
         ExperimenterActionSerializerKey experimenterActionSerializerKey = new ExperimenterActionSerializerKey(
-                EncodeConstants.OF13_VERSION_ID, 1L, ExpSubType.class);
+                EncodeConstants.OF13_VERSION_ID,  Uint32.ONE, ExpSubType.class);
         Assert.assertFalse(actionSerializerKey.equals(experimenterActionSerializerKey));
         Assert.assertFalse(experimenterActionSerializerKey.equals(actionSerializerKey));
 
index b4464f6dc3198b29b69be6f4d6932c06082814de..734625c00c5d8b29577c9d9f44a3a98b24a4209c 100644 (file)
@@ -5,7 +5,6 @@
  * 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.experimenter;
 
 import org.junit.Assert;
@@ -21,6 +20,8 @@ import org.opendaylight.yangtools.yang.common.Uint32;
  * @author michal.polkorab
  */
 public class ExperimenterActionSerializerKeyTest {
+    private static final Uint32 FORTY_TWO = Uint32.valueOf(42);
+    private static final Uint32 FIFTY_FIVE = Uint32.valueOf(55);
 
     /**
      * Test ExperimenterActionSerializerKey equals and hashCode.
@@ -28,24 +29,24 @@ public class ExperimenterActionSerializerKeyTest {
     @Test
     public void test() {
         ExperimenterActionSerializerKey key1 =
-                new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class);
+                new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, FORTY_TWO, TestSubType.class);
         ExperimenterActionSerializerKey key2 =
-                new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class);
+                new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, FORTY_TWO, TestSubType.class);
         Assert.assertTrue("Wrong equals", key1.equals(key2));
         Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode());
-        key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF13_VERSION_ID, 42L, TestSubType.class);
+        key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF13_VERSION_ID, FORTY_TWO, TestSubType.class);
         Assert.assertFalse("Wrong equals", key1.equals(key2));
         Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
         key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, (Uint32) null, TestSubType.class);
         Assert.assertFalse("Wrong equals", key1.equals(key2));
         Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
-        key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L, TestSubType.class);
+        key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, FIFTY_FIVE, TestSubType.class);
         Assert.assertFalse("Wrong equals", key1.equals(key2));
         Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
-        key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L, null);
+        key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, FIFTY_FIVE, null);
         Assert.assertFalse("Wrong equals", key1.equals(key2));
         Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
-        key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L, TestSubType2.class);
+        key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, FIFTY_FIVE, TestSubType2.class);
         Assert.assertFalse("Wrong equals", key1.equals(key2));
         Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
     }
@@ -57,11 +58,11 @@ public class ExperimenterActionSerializerKeyTest {
     public void testEquals() {
         ExperimenterActionSerializerKey key1;
         ExperimenterActionSerializerKey key2;
-        key1 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, null);
+        key1 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, FORTY_TWO, null);
         Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1));
-        key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType2.class);
+        key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, FORTY_TWO, TestSubType2.class);
         Assert.assertFalse("Wrong equal by actionSubType.", key1.equals(key2));
-        key1 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class);
+        key1 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, FORTY_TWO, TestSubType.class);
         Assert.assertFalse("Wrong equal by actionSubType.", key1.equals(key2));
     }
 
@@ -73,6 +74,4 @@ public class ExperimenterActionSerializerKeyTest {
     private interface TestSubType2 extends ExperimenterActionSubType {
         // empty class - only used in test for comparation
     }
-
-
 }