2 * Copyright (c) 2016 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.instructions;
11 import static org.junit.Assert.assertEquals;
13 import java.math.BigInteger;
14 import org.junit.Test;
15 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder;
21 public class WriteMetadataInstructionSerializerTest extends AbstractInstructionSerializerTest {
24 public void testSerialize() {
25 final long metadata = 10L;
26 final long metadataMask = 10L;
28 final Instruction instruction = new WriteMetadataCaseBuilder()
29 .setWriteMetadata(new WriteMetadataBuilder()
30 .setMetadata(BigInteger.valueOf(metadata))
31 .setMetadataMask(BigInteger.valueOf(metadataMask))
35 assertInstruction(instruction, out -> {
36 out.skipBytes(InstructionConstants.PADDING_IN_WRITE_METADATA);
37 assertEquals(out.readLong(), metadata);
38 assertEquals(out.readLong(), metadataMask);
43 protected Class<? extends Instruction> getClazz() {
44 return WriteMetadataCase.class;
48 protected int getType() {
49 return InstructionConstants.WRITE_METADATA_TYPE;
53 protected int getLength() {
54 return InstructionConstants.WRITE_METADATA_LENGTH;