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.serialization.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.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.group.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestGroupStats;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestGroupStatsBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
23 public class MultipartRequestGroupStatsSerializerTest extends AbstractSerializerTest {
24 private static final byte PADDING_IN_MULTIPART_REQUEST_GROUP_BODY = 4;
25 private static final long GROUP_ID = 42;
26 private static final MultipartRequestGroupStats BODY = new MultipartRequestGroupStatsBuilder()
27 .setGroupId(new GroupId(GROUP_ID))
30 private MultipartRequestGroupStatsSerializer serializer;
33 protected void init() {
34 serializer = getRegistry().getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID,
35 MultipartRequestGroupStats.class)) ;
39 public void testSerialize() throws Exception {
40 final ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
41 serializer.serialize(BODY, out);
43 assertEquals(out.readUnsignedInt(), GROUP_ID);
44 out.skipBytes(PADDING_IN_MULTIPART_REQUEST_GROUP_BODY);
45 assertEquals(out.readableBytes(), 0);