Remove redundant exception declarations
[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 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;
20
21 public class WriteMetadataInstructionSerializerTest extends AbstractInstructionSerializerTest {
22
23     @Test
24     public void testSerialize() {
25         final long metadata = 10L;
26         final long metadataMask = 10L;
27
28         final Instruction instruction = new WriteMetadataCaseBuilder()
29                 .setWriteMetadata(new WriteMetadataBuilder()
30                         .setMetadata(BigInteger.valueOf(metadata))
31                         .setMetadataMask(BigInteger.valueOf(metadataMask))
32                         .build())
33                 .build();
34
35         assertInstruction(instruction, out -> {
36             out.skipBytes(InstructionConstants.PADDING_IN_WRITE_METADATA);
37             assertEquals(out.readLong(), metadata);
38             assertEquals(out.readLong(), metadataMask);
39         });
40     }
41
42     @Override
43     protected Class<? extends Instruction> getClazz() {
44         return WriteMetadataCase.class;
45     }
46
47     @Override
48     protected int getType() {
49         return InstructionConstants.WRITE_METADATA_TYPE;
50     }
51
52     @Override
53     protected int getLength() {
54         return InstructionConstants.WRITE_METADATA_LENGTH;
55     }
56
57 }