YANG revision dates mass-update
[bgpcep.git] / bgp / extensions / mvpn / src / test / java / org / opendaylight / protocol / bgp / mvpn / impl / nlri / InterASIPmsiADHandlerTest.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.mvpn.impl.nlri;
9
10 import static org.junit.Assert.assertArrayEquals;
11 import static org.junit.Assert.assertEquals;
12
13 import io.netty.buffer.Unpooled;
14 import org.junit.Test;
15 import org.opendaylight.protocol.util.ByteArray;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev200120.NlriType;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev200120.inter.as.i.pmsi.a.d.grouping.InterAsIPmsiADBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev200120.mvpn.mvpn.choice.InterAsIPmsiADCase;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev200120.mvpn.mvpn.choice.InterAsIPmsiADCaseBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.RdIpv4;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.RouteDistinguisher;
23 import org.opendaylight.yangtools.yang.common.Uint32;
24
25 public final class InterASIPmsiADHandlerTest {
26
27     private static final byte[] INTER_AS = new byte[]{
28         0, 1,
29         1, 2, 3, 4, 1, 2,
30         0, 0, 0, 1
31     };
32     private static final byte[] INTER_AS_TYPE_LENGTH = new byte[]{
33         2, 12,
34         0, 1,
35         1, 2, 3, 4, 1, 2,
36         0, 0, 0, 1
37     };
38
39     private final InterAsIPmsiADCase expected = new InterAsIPmsiADCaseBuilder()
40             .setInterAsIPmsiAD(new InterAsIPmsiADBuilder()
41                     .setSourceAs(new AsNumber(Uint32.ONE))
42                     .setRouteDistinguisher(new RouteDistinguisher(new RdIpv4("1.2.3.4:258")))
43                     .build()
44             ).build();
45     private final InterASIPmsiADHandler handler = new InterASIPmsiADHandler();
46
47
48     @Test
49     public void testInterASIPmsiADParser() {
50         assertEquals(this.expected, this.handler.parseMvpn(Unpooled.copiedBuffer(INTER_AS)));
51     }
52
53     @Test
54     public void testInterASIPmsiADSerializer() {
55         assertArrayEquals(INTER_AS_TYPE_LENGTH, ByteArray.getAllBytes(this.handler.serializeMvpn(this.expected)));
56     }
57
58     @Test
59     public void testGetType() {
60         assertEquals(NlriType.InterAsIPmsiAD.getIntValue(), this.handler.getType());
61     }
62
63     @Test
64     public void testGetClazz() {
65         assertEquals(InterAsIPmsiADCase.class, this.handler.getClazz());
66     }
67 }