Merge "Remove redundant type specifiers"
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / protocol / serialization / actions / SetNwDstActionSerializerTest.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.assertArrayEquals;
12
13 import org.junit.Test;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
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.SetNwDstActionCase;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
21
22 public class SetNwDstActionSerializerTest extends AbstractSetFieldActionSerializerTest {
23
24     @Test
25     public void testSerialize() throws Exception {
26         final Ipv4 address = new Ipv4Builder()
27                 .setIpv4Address(new Ipv4Prefix("192.168.76.2/32"))
28                 .build();
29
30         final Action action = new SetNwDstActionCaseBuilder()
31                 .setSetNwDstAction(new SetNwDstActionBuilder()
32                         .setAddress(address)
33                         .build())
34                 .build();
35
36         assertAction(action, out -> {
37             byte[] addressBytes = new byte[4];
38             out.readBytes(addressBytes);
39             assertArrayEquals(addressBytes, new byte[] { (byte) 192, (byte) 168, 76, 2 });
40         });
41     }
42
43     @Override
44     protected Class<? extends Action> getClazz() {
45         return SetNwDstActionCase.class;
46     }
47
48 }