use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc in project openflowplugin by opendaylight.
the class MultipartReplyPortDescDeserializerTest method deserialize.
@Test
public void deserialize() throws Exception {
ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
buffer.writeInt(PORT_NUMBER);
buffer.writeZero(PADDING_IN_PORT_DESC_HEADER_01);
buffer.writeBytes(MAC_ADDRESS);
buffer.writeZero(PADDING_IN_PORT_DESC_HEADER_02);
buffer.writeZero(EncodeConstants.MAX_PORT_NAME_LENGTH);
Map<Integer, Boolean> portMap = new HashMap<>();
portMap.put(0, PORT_CONFIG.isPORTDOWN());
portMap.put(2, PORT_CONFIG.isNORECV());
portMap.put(5, PORT_CONFIG.isNOFWD());
portMap.put(6, PORT_CONFIG.isNOPACKETIN());
buffer.writeInt(ByteBufUtils.fillBitMaskFromMap(portMap));
buffer.writeInt(ByteBufUtils.fillBitMask(0, PS_BLOCKED, PS_LINK_DOWN, PS_LIVE));
buffer.writeInt(ByteBufUtils.fillBitMask(0, CURRENT_FEATURE.isTenMbHd(), CURRENT_FEATURE.isTenMbFd(), CURRENT_FEATURE.isHundredMbHd(), CURRENT_FEATURE.isHundredMbFd(), CURRENT_FEATURE.isOneGbHd(), CURRENT_FEATURE.isOneGbFd(), CURRENT_FEATURE.isTenGbFd(), CURRENT_FEATURE.isFortyGbFd(), CURRENT_FEATURE.isHundredGbFd(), CURRENT_FEATURE.isOneTbFd(), CURRENT_FEATURE.isOther(), CURRENT_FEATURE.isFiber(), CURRENT_FEATURE.isAutoeng(), CURRENT_FEATURE.isCopper(), CURRENT_FEATURE.isPause(), CURRENT_FEATURE.isPauseAsym()));
buffer.writeInt(ADVERTISED_FEATURE);
buffer.writeInt(SUPPORTED_FEATURE);
buffer.writeInt(PEER_FEATURES);
buffer.writeInt(CURRENT_SPEED);
buffer.writeInt(MAXIMUM_SPEED);
final MultipartReplyPortDesc reply = (MultipartReplyPortDesc) deserializeMultipart(buffer);
assertEquals(PORT_NUMBER, reply.getPorts().get(0).getPortNumber().getUint32().intValue());
assertEquals("01:02:03:04:05:06", reply.getPorts().get(0).getHardwareAddress().getValue());
assertEquals(PORT_CONFIG, reply.getPorts().get(0).getConfiguration());
assertEquals(PS_BLOCKED, reply.getPorts().get(0).getState().isBlocked());
assertEquals(PS_LINK_DOWN, reply.getPorts().get(0).getState().isLinkDown());
assertEquals(PS_LIVE, reply.getPorts().get(0).getState().isLive());
assertEquals(CURRENT_FEATURE, reply.getPorts().get(0).getCurrentFeature());
assertEquals(CURRENT_SPEED, reply.getPorts().get(0).getCurrentSpeed().intValue());
assertEquals(MAXIMUM_SPEED, reply.getPorts().get(0).getMaximumSpeed().intValue());
}
Aggregations