Fix most bgp-parser-spi checkstyle violations
[bgpcep.git] / bgp / parser-spi / src / test / java / org / opendaylight / protocol / bgp / parser / spi / extended / community / Inet4SpecificExtendedCommunityCommonUtilTest.java
1 /*
2  * Copyright (c) 2018 AT&T Intellectual Property. 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.protocol.bgp.parser.spi.extended.community;
9
10 import io.netty.buffer.ByteBuf;
11 import io.netty.buffer.Unpooled;
12 import org.junit.Assert;
13 import org.junit.Test;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.inet4.specific.extended.community.common.Inet4SpecificExtendedCommunityCommon;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.inet4.specific.extended.community.common.Inet4SpecificExtendedCommunityCommonBuilder;
17
18 public class Inet4SpecificExtendedCommunityCommonUtilTest {
19     private static final byte[] INPUT = {
20         12, 51, 2, 5, 21, 45
21     };
22
23     @Test
24     public void testHandle() {
25         final Inet4SpecificExtendedCommunityCommon expected = new Inet4SpecificExtendedCommunityCommonBuilder()
26                 .setGlobalAdministrator(new Ipv4Address("12.51.2.5"))
27                 .setLocalAdministrator(new byte[]{21, 45}).build();
28
29         final Inet4SpecificExtendedCommunityCommon exComm = Inet4SpecificExtendedCommunityCommonUtil
30                 .parseCommon(Unpooled.copiedBuffer(INPUT));
31         Assert.assertEquals(expected, exComm);
32
33         final ByteBuf output = Unpooled.buffer(INPUT.length);
34         Inet4SpecificExtendedCommunityCommonUtil.serializeCommon(expected, output);
35         Assert.assertArrayEquals(INPUT, output.array());
36     }
37 }