Fix most bgp-parser-impl checkstyle
[bgpcep.git] / bgp / parser-impl / src / test / java / org / opendaylight / protocol / bgp / parser / impl / message / update / extended / communities / OpaqueEcHandlerTest.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. 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.protocol.bgp.parser.impl.message.update.extended.communities;
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.protocol.bgp.parser.BGPDocumentedException;
15 import org.opendaylight.protocol.bgp.parser.BGPParsingException;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.ExtendedCommunity;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.OpaqueExtendedCommunityCase;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.OpaqueExtendedCommunityCaseBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.opaque.extended.community._case.OpaqueExtendedCommunityBuilder;
20
21 public class OpaqueEcHandlerTest {
22     private static final byte[] INPUT = {
23         21, 45, 5, 4, 3, 1
24     };
25
26     @Test
27     public void testHandler() throws BGPDocumentedException, BGPParsingException {
28         final OpaqueEcHandler handler = new OpaqueEcHandler();
29         final OpaqueExtendedCommunityCase expected = new OpaqueExtendedCommunityCaseBuilder()
30                 .setOpaqueExtendedCommunity(new OpaqueExtendedCommunityBuilder()
31                     .setValue(new byte[] { 21, 45, 5, 4, 3, 1 }).build()).build();
32
33         final ExtendedCommunity exComm = handler.parseExtendedCommunity(Unpooled.copiedBuffer(INPUT));
34         Assert.assertEquals(expected, exComm);
35
36         final ByteBuf output = Unpooled.buffer(INPUT.length);
37         handler.serializeExtendedCommunity(expected, output);
38         Assert.assertArrayEquals(INPUT, output.array());
39     }
40 }