Merge "OPNFLWPLUG-1062 Include additional LLDP fields in liblldp"
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / protocol / serialization / actions / SetDlDstActionSerializerTest.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.openflowjava.util.ByteBufUtils;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCase;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCaseBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstActionBuilder;
20
21 public class SetDlDstActionSerializerTest extends AbstractSetFieldActionSerializerTest {
22
23     @Test
24     public void testSerialize() {
25         final MacAddress address = new MacAddress("00:01:02:03:04:05");
26
27         final Action action = new SetDlDstActionCaseBuilder()
28                 .setSetDlDstAction(new SetDlDstActionBuilder()
29                         .setAddress(address)
30                         .build())
31                 .build();
32
33         assertAction(action, out -> {
34             byte[] addressBytes = new byte[6];
35             out.readBytes(addressBytes);
36             assertEquals(new MacAddress(ByteBufUtils.macAddressToString(addressBytes)).getValue(), address.getValue());
37         });
38     }
39
40     @Override
41     protected Class<? extends Action> getClazz() {
42         return SetDlDstActionCase.class;
43     }
44
45 }