Use ByteBuf.readRetainedSlice()
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / protocol / serialization / instructions / WriteMetadataInstructionSerializerTest.java
1 /*
2  * Copyright (c) 2016 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.instructions;
10
11 import static org.junit.Assert.assertEquals;
12
13 import org.junit.Test;
14 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder;
19 import org.opendaylight.yangtools.yang.common.Uint64;
20
21 public class WriteMetadataInstructionSerializerTest extends AbstractInstructionSerializerTest {
22
23     @Test
24     public void testSerialize() {
25         final Instruction instruction = new WriteMetadataCaseBuilder()
26                 .setWriteMetadata(new WriteMetadataBuilder()
27                         .setMetadata(Uint64.TEN)
28                         .setMetadataMask(Uint64.TEN)
29                         .build())
30                 .build();
31
32         assertInstruction(instruction, out -> {
33             out.skipBytes(InstructionConstants.PADDING_IN_WRITE_METADATA);
34             assertEquals(out.readLong(), 10);
35             assertEquals(out.readLong(), 10);
36         });
37     }
38
39     @Override
40     protected Class<? extends Instruction> getClazz() {
41         return WriteMetadataCase.class;
42     }
43
44     @Override
45     protected int getType() {
46         return InstructionConstants.WRITE_METADATA_TYPE;
47     }
48
49     @Override
50     protected int getLength() {
51         return InstructionConstants.WRITE_METADATA_LENGTH;
52     }
53
54 }