Fix checkstyle
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / protocol / deserialization / multipart / MultipartReplyFlowTableStatsDeserializerTest.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 package org.opendaylight.openflowplugin.impl.protocol.deserialization.multipart;
9
10 import static org.junit.Assert.assertEquals;
11
12 import io.netty.buffer.ByteBuf;
13 import io.netty.buffer.UnpooledByteBufAllocator;
14 import org.junit.Test;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.multipart.reply.multipart.reply.body.MultipartReplyFlowTableStats;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
17
18 public class MultipartReplyFlowTableStatsDeserializerTest extends AbstractMultipartDeserializerTest {
19     private static final byte TABLE_ID = 2;
20     private static final long PACKETS_LOOKEDUP = 1L;
21     private static final long PACKETS_MATCHED = 2L;
22     private static final int ACTIVE_FLOWS = 3;
23     private static final byte PADDING_IN_TABLE_HEADER = 3;
24
25     @Test
26     public void testDeserialize() {
27         ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
28         buffer.writeByte(TABLE_ID);
29         buffer.writeZero(PADDING_IN_TABLE_HEADER);
30         buffer.writeInt(ACTIVE_FLOWS);
31         buffer.writeLong(PACKETS_LOOKEDUP);
32         buffer.writeLong(PACKETS_MATCHED);
33
34         final MultipartReplyFlowTableStats reply = (MultipartReplyFlowTableStats) deserializeMultipart(buffer);
35         assertEquals(TABLE_ID, reply.getFlowTableAndStatisticsMap().get(0).getTableId().getValue().byteValue());
36         assertEquals(ACTIVE_FLOWS, reply.getFlowTableAndStatisticsMap().get(0).getActiveFlows().getValue().intValue());
37         assertEquals(PACKETS_LOOKEDUP, reply.getFlowTableAndStatisticsMap().get(0).getPacketsLookedUp().getValue()
38                 .longValue());
39         assertEquals(PACKETS_MATCHED, reply.getFlowTableAndStatisticsMap().get(0).getPacketsMatched().getValue()
40                 .longValue());
41         assertEquals(0, buffer.readableBytes());
42     }
43
44     @Override
45     protected int getType() {
46         return MultipartType.OFPMPTABLE.getIntValue();
47     }
48 }