Remove redundant exception declarations
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / protocol / serialization / multipart / MultipartRequestPortStatsSerializerTest.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.serialization.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.openflowjava.protocol.api.keys.MessageTypeKey;
17 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
18 import org.opendaylight.openflowplugin.impl.protocol.serialization.AbstractSerializerTest;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.multipart.request.multipart.request.body.MultipartRequestPortStats;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.multipart.request.multipart.request.body.MultipartRequestPortStatsBuilder;
22
23 public class MultipartRequestPortStatsSerializerTest extends AbstractSerializerTest {
24     private static final byte PADDING_IN_MULTIPART_REQUEST_PORTSTATS_BODY = 4;
25     private static final long PORT = 42;
26     private static final MultipartRequestPortStats BODY = new MultipartRequestPortStatsBuilder()
27             .setNodeConnectorId(new NodeConnectorId("openflow:1:" + PORT))
28             .build();
29
30     private MultipartRequestPortStatsSerializer serializer;
31
32     @Override
33     protected void init() {
34         serializer = getRegistry().getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID,
35                 MultipartRequestPortStats.class));
36     }
37
38     @Test
39     public void testSerialize() {
40         final ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
41         serializer.serialize(BODY, out);
42
43         assertEquals(out.readUnsignedInt(), PORT);
44         out.skipBytes(PADDING_IN_MULTIPART_REQUEST_PORTSTATS_BODY);
45         assertEquals(out.readableBytes(), 0);
46     }
47
48 }