Merge "Remove redundant type specifiers"
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / protocol / serialization / actions / SetTpDstActionSerializerTest.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.actions;
10
11 import static org.junit.Assert.assertEquals;
12
13 import org.junit.Test;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCase;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCaseBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstActionBuilder;
19
20 public class SetTpDstActionSerializerTest extends AbstractSetFieldActionSerializerTest {
21
22     @Test
23     public void testSerialize() throws Exception {
24         final PortNumber port = new PortNumber(20);
25         final short protocol = 6; // TCP
26
27         final Action action = new SetTpDstActionCaseBuilder()
28                 .setSetTpDstAction(new SetTpDstActionBuilder()
29                         .setPort(port)
30                         .setIpProtocol(protocol)
31                         .build())
32                 .build();
33
34         assertAction(action, out -> assertEquals(Integer.valueOf(out.readUnsignedShort()), port.getValue()));
35     }
36
37     @Override
38     protected Class<? extends Action> getClazz() {
39         return SetTpDstActionCase.class;
40     }
41
42 }