BUG-4826: Update BGP Evpn yang model 45/37545/4
authorClaudio D. Gasparini <cgaspari@cisco.com>
Wed, 13 Apr 2016 12:15:57 +0000 (14:15 +0200)
committerClaudio D. Gasparini <cgaspari@cisco.com>
Wed, 13 Apr 2016 19:24:00 +0000 (21:24 +0200)
-Update BGP Evpn yang model by inserting a container over
each Evpn Case.
-Make Esi Choice and Evpn Choice manatory.
-Update of EsiModelUtil with new Qnames
-Update of test required by Evpn yang model update.

Change-Id: Ie55365d9694cec0c1be9a6b2b97420a0d0038632
Signed-off-by: Claudio D. Gasparini <cgaspari@cisco.com>
bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/AbstractEsiType.java
bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/EsiModelUtil.java
bgp/evpn/src/main/yang/bgp-evpn.yang
bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/EvpnTestUtil.java [moved from bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/ModelTestUtil.java with 69% similarity]
bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/ASGenParserTest.java
bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/AbstractParserTest.java [deleted file]
bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/ArbitraryParserTest.java
bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/LacpParserTest.java
bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/LanParserTest.java
bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/MacParserTest.java
bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/RouterIdParserTest.java

index b105dee8fbbdea7470a59b3fe3473f529295005b..d986ee6ba016fd15d2bbc31ff787603af1f49202 100644 (file)
@@ -16,7 +16,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.esi.Esi;
 
 abstract class AbstractEsiType implements EsiParser, EsiSerializer {
-    static final int BODY_LENGTH = 9;
+    private static final int BODY_LENGTH = 9;
     static final int ZERO_BYTE = 1;
     static final int MAC_ADDRESS_LENGTH = 6;
 
index 59e841c9b3f69aa599b261b823efa4ab507d6039..d4f8e9d635c078458c0408ebda0427f8227686b7 100644 (file)
@@ -13,21 +13,21 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.Uint24;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.esi.esi.arbitrary._case.Arbitrary;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.esi.esi.arbitrary._case.ArbitraryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.evpn.Evpn;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.evpn.EvpnChoice;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 
 final class EsiModelUtil {
-    static final NodeIdentifier LD_NID = NodeIdentifier.create(QName.create(Evpn.QNAME, "local-discriminator").intern());
-    static final NodeIdentifier ARB_NID = NodeIdentifier.create(QName.create(Evpn.QNAME, "arbitrary").intern());
-    static final NodeIdentifier AS_NID = NodeIdentifier.create(QName.create(Evpn.QNAME, "as").intern());
-    static final NodeIdentifier LACP_MAC_NID = NodeIdentifier.create(QName.create(Evpn.QNAME, "ce-lacp-mac-address").intern());
-    static final NodeIdentifier PK_NID = NodeIdentifier.create(QName.create(Evpn.QNAME, "ce-lacp-port-key").intern());
-    static final NodeIdentifier BRIDGE_MAC_NID = NodeIdentifier.create(QName.create(Evpn.QNAME, "root-bridge-mac-address").intern());
-    static final NodeIdentifier RBP_NID = NodeIdentifier.create(QName.create(Evpn.QNAME, "root-bridge-priority").intern());
-    static final NodeIdentifier SYSTEM_MAC_NID = NodeIdentifier.create(QName.create(Evpn.QNAME, "system-mac-address").intern());
-    static final NodeIdentifier RD_NID = NodeIdentifier.create(QName.create(Evpn.QNAME, "router-id").intern());
+    static final NodeIdentifier LD_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "local-discriminator").intern());
+    static final NodeIdentifier ARB_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "arbitrary").intern());
+    static final NodeIdentifier AS_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "as").intern());
+    static final NodeIdentifier LACP_MAC_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "ce-lacp-mac-address").intern());
+    static final NodeIdentifier PK_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "ce-lacp-port-key").intern());
+    static final NodeIdentifier BRIDGE_MAC_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "root-bridge-mac-address").intern());
+    static final NodeIdentifier RBP_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "root-bridge-priority").intern());
+    static final NodeIdentifier SYSTEM_MAC_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "system-mac-address").intern());
+    static final NodeIdentifier RD_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "router-id").intern());
 
     private EsiModelUtil() {
         throw new UnsupportedOperationException();
@@ -53,11 +53,11 @@ final class EsiModelUtil {
     }
 
     static MacAddress extractLacpMac(final ContainerNode t1) {
-        return (MacAddress) t1.getChild(LACP_MAC_NID).get().getValue();
+        return new MacAddress((String) t1.getChild(LACP_MAC_NID).get().getValue());
     }
 
     static MacAddress extractBrigeMac(final ContainerNode lan) {
-        return (MacAddress) lan.getChild(BRIDGE_MAC_NID).get().getValue();
+        return new MacAddress((String) lan.getChild(BRIDGE_MAC_NID).get().getValue());
     }
 
     static Integer extractBP(final ContainerNode lan) {
@@ -65,15 +65,15 @@ final class EsiModelUtil {
     }
 
     static Uint24 extractUint24LD(final ContainerNode esiVal) {
-        return (Uint24) esiVal.getChild(LD_NID).get().getValue();
+        return new Uint24((Long) esiVal.getChild(LD_NID).get().getValue());
     }
 
     static MacAddress extractSystmeMac(final ContainerNode macGEn) {
-        return (MacAddress) macGEn.getChild(SYSTEM_MAC_NID).get().getValue();
+        return new MacAddress((String) macGEn.getChild(SYSTEM_MAC_NID).get().getValue());
     }
 
     static Ipv4Address extractRD(final ContainerNode t4) {
-        return (Ipv4Address) t4.getChild(RD_NID).get().getValue();
+        return new Ipv4Address((String) t4.getChild(RD_NID).get().getValue());
     }
 
 }
index 4a9b28c294ef7e54db1a09c18a704ba89f8116e8..61cd376bdafe899c62d7b1542717b3b0418d1029 100644 (file)
@@ -120,6 +120,7 @@ module odl-bgp-evpn {
             integer in line format with the most significant octet sent first";
 
         choice esi {
+            mandatory true;
             case arbitrary-case {
                 container arbitrary {
                     description "Type 0 indicates an arbitrary 9-octet ESI
@@ -214,64 +215,65 @@ module odl-bgp-evpn {
     }
 
     grouping ethernet-a-d-route {
-        reference "https://tools.ietf.org/html/rfc7432#section-7.1";
-        description "Ethernet Auto-Discovery (A-D) route";
+        container ethernet-a-d-route {
+            reference "https://tools.ietf.org/html/rfc7432#section-7.1";
+            description "Ethernet Auto-Discovery (A-D) route";
 
-        uses route-distinguisher;
-        uses esi;
-        uses ethernet-tag-id;
-        leaf mpls-label {
-            type netc:mpls-label;
-            mandatory true;
+            uses esi;
+            uses ethernet-tag-id;
+            leaf mpls-label {
+                type netc:mpls-label;
+                mandatory true;
+            }
         }
     }
 
     grouping mac-ip-adv-route {
-        reference "https://tools.ietf.org/html/rfc7432#section-7.2";
-        description "MAC/IP Advertisement route";
+        container mac-ip-adv-route {
+            reference "https://tools.ietf.org/html/rfc7432#section-7.2";
+            description "MAC/IP Advertisement route";
 
-        uses route-distinguisher;
-        uses esi;
-        uses ethernet-tag-id;
-        leaf mac-address {
-            type yang:mac-address;
-            mandatory true;
-        }
-        leaf ip-address {
-            type inet:ip-address;
-        }
-        leaf mpls-label1 {
-            type netc:mpls-label;
-            mandatory true;
-        }
-        leaf mpls-label2 {
-            type netc:mpls-label;
+            uses esi;
+            uses ethernet-tag-id;
+            leaf mac-address {
+                type yang:mac-address;
+                mandatory true;
+            }
+            leaf ip-address {
+                type inet:ip-address;
+            }
+            leaf mpls-label1 {
+                type netc:mpls-label;
+                mandatory true;
+            }
+            leaf mpls-label2 {
+                type netc:mpls-label;
+            }
         }
     }
 
     grouping inc-multi-ethernet-tag-res {
-        reference "https://tools.ietf.org/html/rfc7432#section-7.3";
-        description "Inclusive Multicast Ethernet Tag route";
+        container inc-multi-ethernet-tag-res {
+            reference "https://tools.ietf.org/html/rfc7432#section-7.3";
+            description "Inclusive Multicast Ethernet Tag route";
 
-        uses route-distinguisher;
-        uses ethernet-tag-id;
-        leaf orig-route-ip {
-            type inet:ip-address;
+            uses ethernet-tag-id;
+            leaf orig-route-ip {
+                type inet:ip-address;
+            }
         }
     }
 
     grouping es-route {
-        reference "https://tools.ietf.org/html/rfc7432#section-7.4";
-        description "Ethernet Segment route";
+        container es-route {
+            reference "https://tools.ietf.org/html/rfc7432#section-7.4";
+            description "Ethernet Segment route";
 
-        leaf route-distinguisher {
-            type bgp-t:route-distinguisher;
-            mandatory true;
-        }
-        uses esi;
-        leaf orig-route-ip {
-            type inet:ip-address;
-            mandatory true;
+            uses esi;
+            leaf orig-route-ip {
+                type inet:ip-address;
+                mandatory true;
+            }
         }
     }
 
@@ -381,7 +383,7 @@ module odl-bgp-evpn {
             Extensions [RFC4760] with an Address Family Identifier (AFI) of 25 (L2VPN)
             and a Subsequent Address Family Identifier (SAFI) of 70 (EVPN)";
 
-        choice evpn {
+        choice evpn-choice {
             case ethernet-a-d-route-case {
                 uses ethernet-a-d-route;
             }
@@ -394,7 +396,10 @@ module odl-bgp-evpn {
             case es-route-case {
                 uses es-route;
             }
+            mandatory true;
         }
+
+        uses route-distinguisher;
     }
 
     augment "/bgp-msg:update/bgp-msg:attributes/bgp-mp:mp-reach-nlri/bgp-mp:advertized-routes/bgp-mp:destination-type" {
similarity index 69%
rename from bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/ModelTestUtil.java
rename to bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/EvpnTestUtil.java
index 7531dd402f5dc649a643083aa62dee0a9c225adf..ab969e2c186a6125744cce949afb2cc1e4295e2e 100644 (file)
@@ -8,13 +8,23 @@
 
 package org.opendaylight.protocol.bgp.evpn.impl;
 
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeSchemaAwareBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder;
 
-public final class ModelTestUtil {
+public final class EvpnTestUtil {
+    public static final int VALUE_SIZE = 9;
+    public static final long LD = 33686018;
+    public static final String MAC_MODEL = "f2:0c:dd:80:9f:f7";
+    public static final MacAddress MAC = new MacAddress(MAC_MODEL);
+    public static final long AS_MODEL = 16843009;
+    public static final AsNumber AS_NUMBER = new AsNumber(AS_MODEL);
+    public static final Integer PORT = 514;
+
     public static DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, ContainerNode> createContBuilder(final YangInstanceIdentifier
         .NodeIdentifier nid) {
         return ImmutableContainerNodeSchemaAwareBuilder.create().withNodeIdentifier(nid);
index 99c9b84ab6ae6c6d9c5088183d766209b3e354e7..581f603485b23c88b1a2b68d751f556e05ee3f84 100644 (file)
@@ -9,8 +9,12 @@ package org.opendaylight.protocol.bgp.evpn.impl.esi.types;
 
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
-import static org.opendaylight.protocol.bgp.evpn.impl.ModelTestUtil.createContBuilder;
-import static org.opendaylight.protocol.bgp.evpn.impl.ModelTestUtil.createValueBuilder;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.AS_MODEL;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.AS_NUMBER;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.LD;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.VALUE_SIZE;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.createContBuilder;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.createValueBuilder;
 import static org.opendaylight.protocol.bgp.evpn.impl.esi.types.EsiModelUtil.AS_NID;
 import static org.opendaylight.protocol.bgp.evpn.impl.esi.types.EsiModelUtil.LD_NID;
 
@@ -19,7 +23,6 @@ import io.netty.buffer.Unpooled;
 import org.junit.Before;
 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.rev100924.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.esi.Esi;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.esi.esi.ArbitraryCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.esi.esi.AsGeneratedCase;
@@ -29,12 +32,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 
-public final class ASGenParserTest extends AbstractParserTest {
+public final class ASGenParserTest {
     private static final byte[] VALUE = {(byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x02,
         (byte) 0x02, (byte) 0x00};
     private static final byte[] RESULT = {(byte) 0x05, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x02,
         (byte) 0x02, (byte) 0x00};
-    private static final AsNumber AS = new AsNumber(16843009L);
     private ASGenParser parser;
 
     @Before
@@ -46,20 +48,18 @@ public final class ASGenParserTest extends AbstractParserTest {
     public void parserTest() {
         final ByteBuf buff = Unpooled.buffer(VALUE_SIZE);
 
-        final AsGeneratedCase acb = new AsGeneratedCaseBuilder().setAsGenerated(new AsGeneratedBuilder().setAs(AS)
-            .setLocalDiscriminator(LD).build()).build();
-        this.parser.serializeEsi(acb, buff);
+        final AsGeneratedCase asGen = new AsGeneratedCaseBuilder().setAsGenerated(new AsGeneratedBuilder().setAs(AS_NUMBER).setLocalDiscriminator(LD)
+            .build()).build();
+        this.parser.serializeEsi(asGen, buff);
         assertArrayEquals(RESULT, ByteArray.getAllBytes(buff));
 
         final Esi acResult = this.parser.parseEsi(Unpooled.wrappedBuffer(VALUE));
-        assertEquals(acb, acResult);
+        assertEquals(asGen, acResult);
 
-        final ContainerNode cont = createContBuilder(new NodeIdentifier(AsGenerated.QNAME))
-            .addChild(createValueBuilder(16843009L, AS_NID).build())
-            .addChild(createValueBuilder(LD, LD_NID).build())
-            .build();
+        final ContainerNode cont = createContBuilder(new NodeIdentifier(AsGenerated.QNAME)).addChild(createValueBuilder(AS_MODEL, AS_NID).build())
+            .addChild(createValueBuilder(LD, LD_NID).build()).build();
         final Esi acmResult = this.parser.serializeEsi(cont);
-        assertEquals(acb, acmResult);
+        assertEquals(asGen, acmResult);
     }
 
     @Test(expected = IllegalArgumentException.class)
diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/AbstractParserTest.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/AbstractParserTest.java
deleted file mode 100644 (file)
index 9252ab5..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others.  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.evpn.impl.esi.types;
-
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
-
-abstract class AbstractParserTest {
-    protected static final int VALUE_SIZE = 9;
-    protected static final long LD = 33686018;
-    protected static final MacAddress MAC = new MacAddress("f2:0c:dd:80:9f:f7");
-}
index fcb2c086c678d2fafef3cf6b2d4e63518c812ca2..e7c51472f28f4d26810ea77ff1d7fbcdc96f52e0 100644 (file)
@@ -9,8 +9,9 @@ package org.opendaylight.protocol.bgp.evpn.impl.esi.types;
 
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
-import static org.opendaylight.protocol.bgp.evpn.impl.ModelTestUtil.createContBuilder;
-import static org.opendaylight.protocol.bgp.evpn.impl.ModelTestUtil.createValueBuilder;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.VALUE_SIZE;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.createContBuilder;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.createValueBuilder;
 import static org.opendaylight.protocol.bgp.evpn.impl.esi.types.EsiModelUtil.ARB_NID;
 
 import io.netty.buffer.ByteBuf;
@@ -27,7 +28,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 
-public final class ArbitraryParserTest extends AbstractParserTest {
+public final class ArbitraryParserTest {
     private static final byte[] ARB_VALUE = {(byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,
         (byte) 0x08, (byte) 0x09};
     private static final byte[] ARB_RESULT = {(byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06,
@@ -43,17 +44,17 @@ public final class ArbitraryParserTest extends AbstractParserTest {
     public void parserTest() {
         final ByteBuf buff = Unpooled.buffer(VALUE_SIZE);
 
-        final ArbitraryCase acb = new ArbitraryCaseBuilder().setArbitrary(new ArbitraryBuilder().setArbitrary(ARB_VALUE).build()).build();
-        this.parser.serializeEsi(acb, buff);
+        final ArbitraryCase arbitrary = new ArbitraryCaseBuilder().setArbitrary(new ArbitraryBuilder().setArbitrary(ARB_VALUE).build()).build();
+        this.parser.serializeEsi(arbitrary, buff);
         assertArrayEquals(ARB_RESULT, ByteArray.getAllBytes(buff));
 
         final Esi acResult = this.parser.parseEsi(Unpooled.wrappedBuffer(ARB_VALUE));
-        assertEquals(acb, acResult);
+        assertEquals(arbitrary, acResult);
 
         final ContainerNode cont = createContBuilder(new NodeIdentifier(Arbitrary.QNAME))
             .addChild(createValueBuilder(ARB_VALUE, ARB_NID).build()).build();
         final Esi acmResult = this.parser.serializeEsi(cont);
-        assertEquals(acb, acmResult);
+        assertEquals(arbitrary, acmResult);
     }
 
     @Test(expected = IllegalArgumentException.class)
index 9d0003e5ce6a422cb859ba818be5edefad991790..cffb8b78287eed2bc80fc97da46969bf2d0ac4bb 100644 (file)
@@ -9,8 +9,12 @@ package org.opendaylight.protocol.bgp.evpn.impl.esi.types;
 
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
-import static org.opendaylight.protocol.bgp.evpn.impl.ModelTestUtil.createContBuilder;
-import static org.opendaylight.protocol.bgp.evpn.impl.ModelTestUtil.createValueBuilder;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.MAC;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.MAC_MODEL;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.PORT;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.VALUE_SIZE;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.createContBuilder;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.createValueBuilder;
 import static org.opendaylight.protocol.bgp.evpn.impl.esi.types.EsiModelUtil.LACP_MAC_NID;
 import static org.opendaylight.protocol.bgp.evpn.impl.esi.types.EsiModelUtil.PK_NID;
 
@@ -28,8 +32,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 
-public final class LacpParserTest extends AbstractParserTest {
-    private static final Integer PORT = 514;
+public final class LacpParserTest {
     private static final byte[] VALUE = {(byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02,
         (byte) 0x02, (byte) 0x00};
     private static final byte[] RESULT = {(byte) 0x01, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02,
@@ -45,20 +48,20 @@ public final class LacpParserTest extends AbstractParserTest {
     public void parserTest() {
         final ByteBuf buff = Unpooled.buffer(VALUE_SIZE);
 
-        final LacpAutoGeneratedCase acb = new LacpAutoGeneratedCaseBuilder().setLacpAutoGenerated(new LacpAutoGeneratedBuilder()
+        final LacpAutoGeneratedCase lanAuto = new LacpAutoGeneratedCaseBuilder().setLacpAutoGenerated(new LacpAutoGeneratedBuilder()
             .setCeLacpMacAddress(MAC).setCeLacpPortKey(PORT).build()).build();
-        this.parser.serializeEsi(acb, buff);
+        this.parser.serializeEsi(lanAuto, buff);
         assertArrayEquals(RESULT, ByteArray.getAllBytes(buff));
 
         final Esi acResult = this.parser.parseEsi(Unpooled.wrappedBuffer(VALUE));
-        assertEquals(acb, acResult);
+        assertEquals(lanAuto, acResult);
 
         final ContainerNode cont = createContBuilder( new NodeIdentifier(LacpAutoGenerated.QNAME))
-            .addChild(createValueBuilder(MAC, LACP_MAC_NID).build())
+            .addChild(createValueBuilder(MAC_MODEL, LACP_MAC_NID).build())
             .addChild(createValueBuilder(PORT, PK_NID).build())
             .build();
         final Esi acmResult = this.parser.serializeEsi(cont);
-        assertEquals(acb, acmResult);
+        assertEquals(lanAuto, acmResult);
     }
 
     @Test(expected = IllegalArgumentException.class)
index ee547a47786bc9cc72baa599fa461b93a1d33cdb..cbdf5db65b7e56b66da92aa2cc5cd598188f94f4 100644 (file)
@@ -9,8 +9,11 @@ package org.opendaylight.protocol.bgp.evpn.impl.esi.types;
 
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
-import static org.opendaylight.protocol.bgp.evpn.impl.ModelTestUtil.createContBuilder;
-import static org.opendaylight.protocol.bgp.evpn.impl.ModelTestUtil.createValueBuilder;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.MAC;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.MAC_MODEL;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.VALUE_SIZE;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.createContBuilder;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.createValueBuilder;
 import static org.opendaylight.protocol.bgp.evpn.impl.esi.types.EsiModelUtil.BRIDGE_MAC_NID;
 import static org.opendaylight.protocol.bgp.evpn.impl.esi.types.EsiModelUtil.RBP_NID;
 
@@ -21,7 +24,6 @@ import org.junit.Test;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.esi.Esi;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.esi.esi.ArbitraryCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.esi.esi.LacpAutoGeneratedCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.esi.esi.LanAutoGeneratedCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.esi.esi.LanAutoGeneratedCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.esi.esi.lan.auto.generated._case.LanAutoGenerated;
@@ -32,7 +34,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
 
-public class LanParserTest extends AbstractParserTest {
+public class LanParserTest {
     private static final Integer PRIORITY = 514;
     public static final LanAutoGeneratedCase LAN_AUT_GEN_CASE = new LanAutoGeneratedCaseBuilder().setLanAutoGenerated(new LanAutoGeneratedBuilder()
         .setRootBridgeMacAddress(MAC).setRootBridgePriority(PRIORITY).build()).build();
@@ -56,8 +58,6 @@ public class LanParserTest extends AbstractParserTest {
         final Esi acResult = this.parser.parseEsi(Unpooled.wrappedBuffer(VALUE));
         assertEquals(LAN_AUT_GEN_CASE, acResult);
 
-
-
         final Esi acmResult = this.parser.serializeEsi(createLanCont());
         assertEquals(LAN_AUT_GEN_CASE, acmResult);
     }
@@ -69,14 +69,12 @@ public class LanParserTest extends AbstractParserTest {
 
     public static ChoiceNode createLanChoice() {
         final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> choice = Builders.choiceBuilder();
-        choice.withNodeIdentifier(new NodeIdentifier(LacpAutoGeneratedCase.QNAME));
+        choice.withNodeIdentifier(NodeIdentifier.create(Esi.QNAME));
         return choice.addChild(createLanCont()).build();
     }
 
     private static ContainerNode createLanCont() {
-        return createContBuilder(new NodeIdentifier(LanAutoGenerated.QNAME))
-            .addChild(createValueBuilder(MAC, BRIDGE_MAC_NID).build())
-            .addChild(createValueBuilder(PRIORITY, RBP_NID).build())
-            .build();
+        return createContBuilder(new NodeIdentifier(LanAutoGenerated.QNAME)).addChild(createValueBuilder(MAC_MODEL, BRIDGE_MAC_NID).build())
+            .addChild(createValueBuilder(PRIORITY, RBP_NID).build()).build();
     }
 }
\ No newline at end of file
index 313e864800800df5829dfdbfaf81263d33c203a8..64420e94953524319741aff3a3770ac3a5f7eff0 100644 (file)
@@ -9,8 +9,11 @@ package org.opendaylight.protocol.bgp.evpn.impl.esi.types;
 
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
-import static org.opendaylight.protocol.bgp.evpn.impl.ModelTestUtil.createContBuilder;
-import static org.opendaylight.protocol.bgp.evpn.impl.ModelTestUtil.createValueBuilder;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.MAC;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.MAC_MODEL;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.VALUE_SIZE;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.createContBuilder;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.createValueBuilder;
 import static org.opendaylight.protocol.bgp.evpn.impl.esi.types.EsiModelUtil.LD_NID;
 import static org.opendaylight.protocol.bgp.evpn.impl.esi.types.EsiModelUtil.SYSTEM_MAC_NID;
 
@@ -29,12 +32,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 
-public final class MacParserTest extends AbstractParserTest {
+public final class MacParserTest {
     private static final byte[] VALUE = {(byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02,
         (byte) 0x02, (byte) 0x00};
     private static final byte[] RESULT = {(byte) 0x03, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02,
         (byte) 0x02, (byte) 0x00};
-    private static final Uint24 UINT24_LD = new Uint24(131584L);
+    private static final long UINT24_LD_MODEL = 131584L;
+    private static final Uint24 UINT24_LD = new Uint24(UINT24_LD_MODEL);
     private MacParser parser;
 
     @Before
@@ -46,20 +50,18 @@ public final class MacParserTest extends AbstractParserTest {
     public void parserTest() {
         final ByteBuf buff = Unpooled.buffer(VALUE_SIZE);
 
-        final MacAutoGeneratedCase acb = new MacAutoGeneratedCaseBuilder().setMacAutoGenerated(new MacAutoGeneratedBuilder()
+        final MacAutoGeneratedCase macAuto = new MacAutoGeneratedCaseBuilder().setMacAutoGenerated(new MacAutoGeneratedBuilder()
             .setLocalDiscriminator(UINT24_LD).setSystemMacAddress(MAC).build()).build();
-        this.parser.serializeEsi(acb, buff);
+        this.parser.serializeEsi(macAuto, buff);
         assertArrayEquals(RESULT, ByteArray.getAllBytes(buff));
 
         final Esi acResult = this.parser.parseEsi(Unpooled.wrappedBuffer(VALUE));
-        assertEquals(acb, acResult);
+        assertEquals(macAuto, acResult);
 
-        final ContainerNode cont = createContBuilder(new NodeIdentifier(MacAutoGenerated.QNAME))
-            .addChild(createValueBuilder(MAC, SYSTEM_MAC_NID).build())
-            .addChild(createValueBuilder(UINT24_LD, LD_NID).build())
-            .build();
+        final ContainerNode cont = createContBuilder(new NodeIdentifier(MacAutoGenerated.QNAME)).addChild(createValueBuilder(MAC_MODEL, SYSTEM_MAC_NID).build())
+            .addChild(createValueBuilder(UINT24_LD_MODEL, LD_NID).build()).build();
         final Esi acmResult = this.parser.serializeEsi(cont);
-        assertEquals(acb, acmResult);
+        assertEquals(macAuto, acmResult);
     }
 
     @Test(expected = IllegalArgumentException.class)
index 39ff2808011d323ac53933ce422d49e06f3cae22..66d5bdc4d8735cc96f87709e478ca3e5ded96e19 100644 (file)
@@ -9,8 +9,10 @@ package org.opendaylight.protocol.bgp.evpn.impl.esi.types;
 
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
-import static org.opendaylight.protocol.bgp.evpn.impl.ModelTestUtil.createContBuilder;
-import static org.opendaylight.protocol.bgp.evpn.impl.ModelTestUtil.createValueBuilder;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.LD;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.VALUE_SIZE;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.createContBuilder;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.createValueBuilder;
 import static org.opendaylight.protocol.bgp.evpn.impl.esi.types.EsiModelUtil.LD_NID;
 import static org.opendaylight.protocol.bgp.evpn.impl.esi.types.EsiModelUtil.RD_NID;
 
@@ -32,7 +34,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
 
-public class RouterIdParserTest extends AbstractParserTest {
+public class RouterIdParserTest {
     public static final byte[] RESULT = {(byte) 0x04, (byte) 0x2A, (byte) 0x2A, (byte) 0x2A, (byte) 0x2A, (byte) 0x02, (byte) 0x02, (byte) 0x02,
         (byte) 0x02, (byte) 0x00};
     private static final byte[] VALUE = {(byte) 0x2A, (byte) 0x2A, (byte) 0x2A, (byte) 0x2A, (byte) 0x02, (byte) 0x02, (byte) 0x02,
@@ -40,6 +42,7 @@ public class RouterIdParserTest extends AbstractParserTest {
     private static final Ipv4Address ROUTE_ID = new Ipv4Address("42.42.42.42");
     public static final RouterIdGeneratedCase ROUTE_ID_CASE = new RouterIdGeneratedCaseBuilder().setRouterIdGenerated(new RouterIdGeneratedBuilder()
         .setLocalDiscriminator(LD).setRouterId(ROUTE_ID).build()).build();
+    private static final String ROUTE_ID_MODEL = "42.42.42.42";
     private RouterIdParser parser;
 
     @Before
@@ -69,7 +72,7 @@ public class RouterIdParserTest extends AbstractParserTest {
 
     private static ContainerNode createRouteContainer() {
         return createContBuilder(new NodeIdentifier(RouterIdGenerated.QNAME))
-            .addChild(createValueBuilder(ROUTE_ID, RD_NID).build())
+            .addChild(createValueBuilder(ROUTE_ID_MODEL, RD_NID).build())
             .addChild(createValueBuilder(LD, LD_NID).build())
             .build();
     }