Bump upstreams
[openflowplugin.git] / openflowjava / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / PortStatusMessageFactoryTest.java
index 362d2fd86f220543c6a08cde8dd5fd4a404ba874..f351f86a186aed3f81465c6d83db19b440d59ff9 100644 (file)
@@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
-import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;
@@ -26,10 +26,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
 
 /**
- * @author giuseppex.petralia@intel.com
+ * Unit tests for PortStatusMessageFactory.
  *
+ * @author giuseppex.petralia@intel.com
  */
 public class PortStatusMessageFactoryTest {
     private OFSerializer<PortStatusMessage> factory;
@@ -43,7 +45,7 @@ public class PortStatusMessageFactoryTest {
         SerializerRegistry registry = new SerializerRegistryImpl();
         registry.init();
         factory = registry
-                .getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, PortStatusMessage.class));
+                .getSerializer(new MessageTypeKey<>(EncodeConstants.OF_VERSION_1_3, PortStatusMessage.class));
     }
 
     @Test
@@ -51,7 +53,7 @@ public class PortStatusMessageFactoryTest {
         PortStatusMessageBuilder builder = new PortStatusMessageBuilder();
         BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
         builder.setReason(PortReason.forValue(1));
-        builder.setPortNo(1L);
+        builder.setPortNo(Uint32.ONE);
         builder.setHwAddr(new MacAddress("94:de:80:a6:61:40"));
         builder.setName("Port name");
         builder.setConfig(new PortConfig(true, false, true, false));
@@ -64,8 +66,8 @@ public class PortStatusMessageFactoryTest {
                 true, false, true, false, true, false));
         builder.setPeerFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false, true,
                 false, true, false, true, false));
-        builder.setCurrSpeed(1234L);
-        builder.setMaxSpeed(1234L);
+        builder.setCurrSpeed(Uint32.valueOf(1234));
+        builder.setMaxSpeed(Uint32.valueOf(1234));
         PortStatusMessage message = builder.build();
 
         ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
@@ -78,7 +80,7 @@ public class PortStatusMessageFactoryTest {
         byte[] address = new byte[6];
         serializedBuffer.readBytes(address);
         Assert.assertEquals("Wrong MacAddress", message.getHwAddr().getValue().toLowerCase(),
-                new MacAddress(ByteBufUtils.macAddressToString(address)).getValue().toLowerCase());
+                IetfYangUtil.macAddressFor(address).getValue().toLowerCase());
         serializedBuffer.skipBytes(PORT_PADDING_2);
         byte[] name = new byte[16];
         serializedBuffer.readBytes(name);
@@ -96,39 +98,39 @@ public class PortStatusMessageFactoryTest {
         Assert.assertEquals("Wrong Max speed", message.getMaxSpeed().longValue(), serializedBuffer.readInt());
     }
 
-    private static PortConfig createPortConfig(long input) {
-        final Boolean _portDown = ((input) & (1 << 0)) > 0;
-        final Boolean _noRecv = ((input) & (1 << 2)) > 0;
-        final Boolean _noFwd = ((input) & (1 << 5)) > 0;
-        final Boolean _noPacketIn = ((input) & (1 << 6)) > 0;
+    private static PortConfig createPortConfig(final long input) {
+        final Boolean _portDown = (input & 1 << 0) > 0;
+        final Boolean _noRecv = (input & 1 << 2) > 0;
+        final Boolean _noFwd = (input & 1 << 5) > 0;
+        final Boolean _noPacketIn = (input & 1 << 6) > 0;
         return new PortConfig(_noFwd, _noPacketIn, _noRecv, _portDown);
     }
 
-    private static PortFeatures createPortFeatures(long input) {
-        final Boolean _10mbHd = ((input) & (1 << 0)) > 0;
-        final Boolean _10mbFd = ((input) & (1 << 1)) > 0;
-        final Boolean _100mbHd = ((input) & (1 << 2)) > 0;
-        final Boolean _100mbFd = ((input) & (1 << 3)) > 0;
-        final Boolean _1gbHd = ((input) & (1 << 4)) > 0;
-        final Boolean _1gbFd = ((input) & (1 << 5)) > 0;
-        final Boolean _10gbFd = ((input) & (1 << 6)) > 0;
-        final Boolean _40gbFd = ((input) & (1 << 7)) > 0;
-        final Boolean _100gbFd = ((input) & (1 << 8)) > 0;
-        final Boolean _1tbFd = ((input) & (1 << 9)) > 0;
-        final Boolean _other = ((input) & (1 << 10)) > 0;
-        final Boolean _copper = ((input) & (1 << 11)) > 0;
-        final Boolean _fiber = ((input) & (1 << 12)) > 0;
-        final Boolean _autoneg = ((input) & (1 << 13)) > 0;
-        final Boolean _pause = ((input) & (1 << 14)) > 0;
-        final Boolean _pauseAsym = ((input) & (1 << 15)) > 0;
+    private static PortFeatures createPortFeatures(final long input) {
+        final Boolean _10mbHd = (input & 1 << 0) > 0;
+        final Boolean _10mbFd = (input & 1 << 1) > 0;
+        final Boolean _100mbHd = (input & 1 << 2) > 0;
+        final Boolean _100mbFd = (input & 1 << 3) > 0;
+        final Boolean _1gbHd = (input & 1 << 4) > 0;
+        final Boolean _1gbFd = (input & 1 << 5) > 0;
+        final Boolean _10gbFd = (input & 1 << 6) > 0;
+        final Boolean _40gbFd = (input & 1 << 7) > 0;
+        final Boolean _100gbFd = (input & 1 << 8) > 0;
+        final Boolean _1tbFd = (input & 1 << 9) > 0;
+        final Boolean _other = (input & 1 << 10) > 0;
+        final Boolean _copper = (input & 1 << 11) > 0;
+        final Boolean _fiber = (input & 1 << 12) > 0;
+        final Boolean _autoneg = (input & 1 << 13) > 0;
+        final Boolean _pause = (input & 1 << 14) > 0;
+        final Boolean _pauseAsym = (input & 1 << 15) > 0;
         return new PortFeatures(_100gbFd, _100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd, _1gbFd, _1gbHd, _1tbFd,
                 _40gbFd, _autoneg, _copper, _fiber, _other, _pause, _pauseAsym);
     }
 
-    private static PortState createPortState(long input) {
-        final Boolean one = ((input) & (1 << 0)) > 0;
-        final Boolean two = ((input) & (1 << 1)) > 0;
-        final Boolean three = ((input) & (1 << 2)) > 0;
+    private static PortState createPortState(final long input) {
+        final Boolean one = (input & 1 << 0) > 0;
+        final Boolean two = (input & 1 << 1) > 0;
+        final Boolean three = (input & 1 << 2) > 0;
         return new PortState(two, one, three);
     }