Update MRI upstreams for Phosphorus
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / protocol / serialization / actions / SetNwTosActionSerializerTest.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.openflowplugin.openflow.md.util.ActionUtil;
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.SetNwTosActionCase;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCaseBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder;
18
19 public class SetNwTosActionSerializerTest extends AbstractSetFieldActionSerializerTest {
20     @Test
21     public void testSerialize() {
22         final int tos = 10;
23
24         final Action action = new SetNwTosActionCaseBuilder()
25                 .setSetNwTosAction(new SetNwTosActionBuilder().setTos(10).build())
26                 .build();
27
28         assertAction(action, out -> assertEquals(out.readUnsignedByte(), ActionUtil.tosToDscp((short) tos).toJava()));
29     }
30
31     @Override
32     protected Class<? extends Action> getClazz() {
33         return SetNwTosActionCase.class;
34     }
35 }