Create common parent for extensions families
[bgpcep.git] / bgp / extensions / mvpn / src / test / java / org / opendaylight / protocol / bgp / mvpn / impl / nlri / InterASIPmsiADHandlerTest.java
diff --git a/bgp/extensions/mvpn/src/test/java/org/opendaylight/protocol/bgp/mvpn/impl/nlri/InterASIPmsiADHandlerTest.java b/bgp/extensions/mvpn/src/test/java/org/opendaylight/protocol/bgp/mvpn/impl/nlri/InterASIPmsiADHandlerTest.java
new file mode 100644 (file)
index 0000000..1a8ce92
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.mvpn.impl.nlri;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.Unpooled;
+import org.junit.Test;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.NlriType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.inter.as.i.pmsi.a.d.grouping.InterAsIPmsiADBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.mvpn.mvpn.choice.InterAsIPmsiADCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.mvpn.mvpn.choice.InterAsIPmsiADCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.RdIpv4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.RouteDistinguisher;
+
+public final class InterASIPmsiADHandlerTest {
+
+    private static final byte[] INTER_AS = new byte[]{
+        0, 1,
+        1, 2, 3, 4, 1, 2,
+        0, 0, 0, 1
+    };
+    private static final byte[] INTER_AS_TYPE_LENGTH = new byte[]{
+        2, 12,
+        0, 1,
+        1, 2, 3, 4, 1, 2,
+        0, 0, 0, 1
+    };
+
+    private final InterAsIPmsiADCase expected = new InterAsIPmsiADCaseBuilder()
+            .setInterAsIPmsiAD(new InterAsIPmsiADBuilder()
+                    .setSourceAs(new AsNumber(1L))
+                    .setRouteDistinguisher(new RouteDistinguisher(new RdIpv4("1.2.3.4:258")))
+                    .build()
+            ).build();
+    private final InterASIPmsiADHandler handler = new InterASIPmsiADHandler();
+
+
+    @Test
+    public void testInterASIPmsiADParser() {
+        assertEquals(this.expected, this.handler.parseMvpn(Unpooled.copiedBuffer(INTER_AS)));
+    }
+
+    @Test
+    public void testInterASIPmsiADSerializer() {
+        assertArrayEquals(INTER_AS_TYPE_LENGTH, ByteArray.getAllBytes(this.handler.serializeMvpn(this.expected)));
+    }
+
+    @Test
+    public void testGetType() {
+        assertEquals(NlriType.InterAsIPmsiAD.getIntValue(), this.handler.getType());
+    }
+
+    @Test
+    public void testGetClazz() {
+        assertEquals(InterAsIPmsiADCase.class, this.handler.getClazz());
+    }
+}
\ No newline at end of file