Migrate openflowplugim-impl tests to uint types
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / protocol / serialization / actions / SetTpSrcActionSerializerTest.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 package org.opendaylight.openflowplugin.impl.protocol.serialization.actions;
9
10 import static org.junit.Assert.assertEquals;
11
12 import org.junit.Test;
13 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCase;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCaseBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcActionBuilder;
18 import org.opendaylight.yangtools.yang.common.Uint16;
19 import org.opendaylight.yangtools.yang.common.Uint8;
20
21 public class SetTpSrcActionSerializerTest extends AbstractSetFieldActionSerializerTest {
22
23     @Test
24     public void testSerialize() {
25         final PortNumber port = new PortNumber(Uint16.valueOf(20));
26         final short protocol = 6; // TCP
27
28         final Action action = new SetTpSrcActionCaseBuilder()
29                 .setSetTpSrcAction(new SetTpSrcActionBuilder()
30                         .setPort(port)
31                         .setIpProtocol(Uint8.valueOf(protocol))
32                         .build())
33                 .build();
34
35         assertAction(action, out -> assertEquals(Uint16.valueOf(out.readUnsignedShort()), port.getValue()));
36     }
37
38     @Override
39     protected Class<? extends Action> getClazz() {
40         return SetTpSrcActionCase.class;
41     }
42
43 }