2 * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowplugin.impl.protocol.deserialization.multipart;
11 import static org.junit.Assert.assertEquals;
13 import io.netty.buffer.ByteBuf;
14 import io.netty.buffer.UnpooledByteBufAllocator;
15 import org.junit.Test;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.multipart.reply.multipart.reply.body.MultipartReplyQueueStats;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap;
20 public class MultipartReplyQueueStatsDeserializerTest extends AbstractMultipartDeserializerTest {
21 private static final int PORT = 1;
22 private static final int QUEUE_ID = 1;
23 private static final long TRANSMITTED_BYTES = 5L;
24 private static final long TRANSMITTED_PACKETS = 3L;
25 private static final long TRANSMISSON_ERRORS = 9L;
26 private static final int SECOND = 14;
27 private static final int NANOSECOND = 15;
30 public void deserialize() {
31 ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
32 buffer.writeInt(PORT);
33 buffer.writeInt(QUEUE_ID);
34 buffer.writeLong(TRANSMITTED_BYTES);
35 buffer.writeLong(TRANSMITTED_PACKETS);
36 buffer.writeLong(TRANSMISSON_ERRORS);
37 buffer.writeInt(SECOND);
38 buffer.writeInt(NANOSECOND);
40 final MultipartReplyQueueStats reply = (MultipartReplyQueueStats) deserializeMultipart(buffer);
42 final QueueIdAndStatisticsMap queueStats = reply.nonnullQueueIdAndStatisticsMap().values().iterator().next();
44 assertEquals(QUEUE_ID, queueStats.getQueueId().getValue().intValue());
45 assertEquals(TRANSMITTED_BYTES, queueStats.getTransmittedBytes().getValue().longValue());
46 assertEquals(TRANSMITTED_PACKETS, queueStats.getTransmittedPackets().getValue().longValue());
47 assertEquals(TRANSMISSON_ERRORS, queueStats.getTransmissionErrors().getValue().longValue());
48 assertEquals(SECOND, queueStats.getDuration().getSecond().getValue().intValue());
49 assertEquals(NANOSECOND, queueStats.getDuration().getNanosecond().getValue().intValue());
50 assertEquals(0, buffer.readableBytes());
54 protected int getType() {
55 return MultipartType.OFPMPQUEUE.getIntValue();