Merge "Fix checkstyle warnings for impl/protocol test package"
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / protocol / serialization / multipart / tablefeatures / InstructionsMissTablePropertySerializerTest.java
1 /*
2  * Copyright (c) 2017 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.multipart.tablefeatures;
10
11 import static org.junit.Assert.assertEquals;
12
13 import java.util.Collections;
14 import org.junit.Test;
15 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
16 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.TableFeaturePropType;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMiss;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMissBuilder;
23
24 public class InstructionsMissTablePropertySerializerTest extends AbstractTablePropertySerializerTest {
25
26     @Test
27     public void testSerialize() throws Exception {
28         final InstructionsMiss property = new InstructionsMissBuilder()
29                 .setInstructionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight
30                         .table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.miss
31                         .InstructionsMissBuilder()
32                         .setInstruction(Collections.singletonList(new InstructionBuilder()
33                                 .setOrder(0)
34                                 .setInstruction(new ApplyActionsCaseBuilder()
35                                         .build())
36                                 .build()))
37                         .build())
38                 .build();
39
40         assertProperty(property, out -> {
41             assertEquals(out.readUnsignedShort(), InstructionConstants.APPLY_ACTIONS_TYPE);
42             out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); // Skip length of set field action
43         });
44     }
45
46     @Override
47     protected Class<? extends TableFeaturePropType> getClazz() {
48         return InstructionsMiss.class;
49     }
50
51     @Override
52     protected int getType() {
53         return TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS.getIntValue();
54     }
55
56 }