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 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;
21 public class WriteMetadataInstructionSerializerTest extends AbstractInstructionSerializerTest {
24 public void testSerialize() {
25 final Instruction instruction = new WriteMetadataCaseBuilder()
26 .setWriteMetadata(new WriteMetadataBuilder()
27 .setMetadata(Uint64.TEN)
28 .setMetadataMask(Uint64.TEN)
32 assertInstruction(instruction, out -> {
33 out.skipBytes(InstructionConstants.PADDING_IN_WRITE_METADATA);
34 assertEquals(out.readLong(), 10);
35 assertEquals(out.readLong(), 10);
40 protected Class<? extends Instruction> getClazz() {
41 return WriteMetadataCase.class;
45 protected int getType() {
46 return InstructionConstants.WRITE_METADATA_TYPE;
50 protected int getLength() {
51 return InstructionConstants.WRITE_METADATA_LENGTH;