Create common parent for extensions families
[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.rev180417.NlriType;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.inter.as.i.pmsi.a.d.grouping.InterAsIPmsiADBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.mvpn.mvpn.choice.InterAsIPmsiADCase;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.mvpn.mvpn.choice.InterAsIPmsiADCaseBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.RdIpv4;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.RouteDistinguisher;
23
24 public final class InterASIPmsiADHandlerTest {
25
26     private static final byte[] INTER_AS = new byte[]{
27         0, 1,
28         1, 2, 3, 4, 1, 2,
29         0, 0, 0, 1
30     };
31     private static final byte[] INTER_AS_TYPE_LENGTH = new byte[]{
32         2, 12,
33         0, 1,
34         1, 2, 3, 4, 1, 2,
35         0, 0, 0, 1
36     };
37
38     private final InterAsIPmsiADCase expected = new InterAsIPmsiADCaseBuilder()
39             .setInterAsIPmsiAD(new InterAsIPmsiADBuilder()
40                     .setSourceAs(new AsNumber(1L))
41                     .setRouteDistinguisher(new RouteDistinguisher(new RdIpv4("1.2.3.4:258")))
42                     .build()
43             ).build();
44     private final InterASIPmsiADHandler handler = new InterASIPmsiADHandler();
45
46
47     @Test
48     public void testInterASIPmsiADParser() {
49         assertEquals(this.expected, this.handler.parseMvpn(Unpooled.copiedBuffer(INTER_AS)));
50     }
51
52     @Test
53     public void testInterASIPmsiADSerializer() {
54         assertArrayEquals(INTER_AS_TYPE_LENGTH, ByteArray.getAllBytes(this.handler.serializeMvpn(this.expected)));
55     }
56
57     @Test
58     public void testGetType() {
59         assertEquals(NlriType.InterAsIPmsiAD.getIntValue(), this.handler.getType());
60     }
61
62     @Test
63     public void testGetClazz() {
64         assertEquals(InterAsIPmsiADCase.class, this.handler.getClazz());
65     }
66 }