Remove EncodeConstants.SIZE_OF_{BYTE,SHORT,INT,LONG}_IN_BYTES
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / protocol / serialization / multipart / tablefeatures / ApplySetfieldTablePropertySerializerTest.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 package org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures;
9
10 import static org.junit.Assert.assertEquals;
11
12 import com.google.common.collect.ImmutableList;
13 import org.junit.Test;
14 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatchBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.TableFeaturePropType;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfield;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder;
22
23 public class ApplySetfieldTablePropertySerializerTest extends AbstractTablePropertySerializerTest {
24     @Test
25     public void testSerialize() {
26         final ApplySetfield property = new ApplySetfieldBuilder()
27                 .setApplySetfield(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature
28                         .prop.type.table.feature.prop.type.apply.setfield
29                         .ApplySetfieldBuilder()
30                         .setSetFieldMatch(ImmutableList
31                                 .<SetFieldMatch>builder()
32                                 .add(new SetFieldMatchBuilder()
33                                         .setMatchType(ArpOp.class)
34                                         .setHasMask(false)
35                                         .build())
36                                 .build())
37                         .build())
38                 .build();
39
40         assertProperty(property, out -> {
41             assertEquals(out.readUnsignedShort(), OxmMatchConstants.OPENFLOW_BASIC_CLASS);
42             assertEquals(out.readUnsignedByte(), OxmMatchConstants.ARP_OP << 1);
43             out.skipBytes(Byte.BYTES); // Skip match entry length
44         });
45     }
46
47     @Override
48     protected Class<? extends TableFeaturePropType> getClazz() {
49         return ApplySetfield.class;
50     }
51
52     @Override
53     protected int getType() {
54         return TableFeaturesPropType.OFPTFPTAPPLYSETFIELD.getIntValue();
55     }
56 }