Merge "Remove redundant exception declarations"
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / protocol / deserialization / multipart / MultipartReplyFlowAggregateStatsDeserializerTest.java
1 /**
2  * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.openflowplugin.impl.protocol.deserialization.multipart;
10
11 import static org.junit.Assert.assertEquals;
12
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.flow.statistics.rev130819.multipart.reply.multipart.reply.body.MultipartReplyFlowAggregateStats;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
18
19 public class MultipartReplyFlowAggregateStatsDeserializerTest extends AbstractMultipartDeserializerTest {
20     private static final long PACKET_COUNT = 6L;
21     private static final long BYTE_COUNT = 256L;
22     private static final int FLOW_COUNT = 3;
23     private static final byte PADDING_IN_MULTIPART_REPLY_HEADER = 4;
24
25     @Test
26     public void testDeserialize() {
27         ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
28         buffer.writeLong(PACKET_COUNT);
29         buffer.writeLong(BYTE_COUNT);
30         buffer.writeInt(FLOW_COUNT);
31         buffer.writeZero(PADDING_IN_MULTIPART_REPLY_HEADER);
32
33         final MultipartReplyFlowAggregateStats reply = (MultipartReplyFlowAggregateStats) deserializeMultipart(buffer);
34         assertEquals(PACKET_COUNT, reply.getPacketCount().getValue().longValue());
35         assertEquals(BYTE_COUNT, reply.getByteCount().getValue().longValue());
36         assertEquals(FLOW_COUNT, reply.getFlowCount().getValue().intValue());
37         assertEquals(0, buffer.readableBytes());
38     }
39
40     @Override
41     protected int getType() {
42         return MultipartType.OFPMPAGGREGATE.getIntValue();
43     }
44 }