2 * Copyright © 2017 Red Hat, Inc. and others.
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
8 package org.opendaylight.genius.mdsalutil.instructions;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertTrue;
13 import java.math.BigInteger;
14 import org.junit.Test;
15 import org.opendaylight.genius.mdsalutil.InstructionInfo;
16 import org.opendaylight.genius.mdsalutil.InstructionType;
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.write.metadata._case.WriteMetadata;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
22 * Test for {@link InstructionWriteMetadata}.
24 public class InstructionWriteMetadataTest {
26 public void backwardsCompatibleInstruction() {
27 verifyInstructionInfo(
28 new InstructionInfo(InstructionType.write_metadata, new BigInteger[] {BigInteger.ONE, BigInteger.TEN}));
32 public void newInstruction() {
33 verifyInstructionInfo(new InstructionWriteMetadata(BigInteger.ONE, BigInteger.TEN));
36 private void verifyInstructionInfo(InstructionInfo instructionInfo) {
37 Instruction instruction = instructionInfo.buildInstruction(2);
38 assertEquals(2, instruction.getKey().getOrder().intValue());
39 assertTrue(instruction.getInstruction() instanceof WriteMetadataCase);
40 WriteMetadataCase writeMetadataCase = (WriteMetadataCase) instruction.getInstruction();
41 WriteMetadata writeMetadata = writeMetadataCase.getWriteMetadata();
42 assertEquals(BigInteger.ONE, writeMetadata.getMetadata());
43 assertEquals(BigInteger.TEN, writeMetadata.getMetadataMask());