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