Clean up List-related warnings in bgp-parser-impl tests
[bgpcep.git] / bgp / parser-impl / src / test / java / org / opendaylight / protocol / bgp / parser / impl / RouteRefreshCapabilityHandlerTest.java
1 /*
2  * Copyright (c) 2016 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;
9
10 import static org.junit.Assert.assertEquals;
11
12 import io.netty.buffer.ByteBuf;
13 import io.netty.buffer.Unpooled;
14 import org.junit.Test;
15 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
16 import org.opendaylight.protocol.bgp.parser.BGPParsingException;
17 import org.opendaylight.protocol.bgp.parser.impl.message.open.RouteRefreshCapabilityHandler;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParameters;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParametersBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1Builder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.RouteRefreshCapabilityBuilder;
22
23 public class RouteRefreshCapabilityHandlerTest {
24
25     private static final RouteRefreshCapabilityHandler HANDLER = new RouteRefreshCapabilityHandler();
26
27     private static final byte[] WRONG_BYTES = new byte[] {1, 2};
28     private static final byte[] OK_BYTES = new byte[] {0};
29     private static final byte[] CAP_BYTES = new byte[] {2, 0};
30
31     @Test
32     public void testRRCapHandler() throws BGPDocumentedException, BGPParsingException {
33         final CParameters expectedParams = new CParametersBuilder()
34                 .addAugmentation(new CParameters1Builder()
35                     .setRouteRefreshCapability(new RouteRefreshCapabilityBuilder().build())
36                     .build())
37                 .build();
38         assertEquals(expectedParams, HANDLER.parseCapability(Unpooled.copiedBuffer(OK_BYTES)));
39         assertEquals(expectedParams, HANDLER.parseCapability(Unpooled.copiedBuffer(WRONG_BYTES)));
40
41         final ByteBuf byteAggregator = Unpooled.buffer(2);
42         HANDLER.serializeCapability(expectedParams, byteAggregator);
43         assertEquals(Unpooled.copiedBuffer(CAP_BYTES), byteAggregator);
44
45         final CParameters missingCap = new CParametersBuilder()
46                 .addAugmentation(new CParameters1Builder().setRouteRefreshCapability(null).build())
47                 .build();
48         final ByteBuf byteAggregator2 = Unpooled.buffer(0);
49         HANDLER.serializeCapability(missingCap, byteAggregator2);
50         assertEquals(Unpooled.copiedBuffer(new byte[]{}), byteAggregator2);
51     }
52 }