Bump upstreams to 2022.09
[bgpcep.git] / bgp / extensions / evpn / src / test / java / org / opendaylight / protocol / bgp / evpn / impl / nlri / EvpnNlriParserTest.java
index a02598f9c46def9f9a4ba7e7d1ee94cad3854aed..f72fae8715619f142765ee4cb804867617595c52 100644 (file)
@@ -13,16 +13,12 @@ import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.RD;
 import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.RD_MODEL;
 import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.createValueBuilder;
 import static org.opendaylight.protocol.bgp.evpn.impl.nlri.NlriModelUtil.RD_NID;
-import static org.opendaylight.protocol.bgp.evpn.spi.pojo.SimpleEvpnNlriRegistryTest.EVPN_NID;
+import static org.opendaylight.protocol.bgp.evpn.impl.nlri.SimpleEvpnNlriRegistryTest.EVPN_NID;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
-import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
-import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.protocol.bgp.evpn.impl.esi.types.ESIActivator;
 import org.opendaylight.protocol.bgp.parser.BGPParsingException;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.EvpnSubsequentAddressFamily;
@@ -32,69 +28,63 @@ 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.rev200120.evpn.destination.EvpnDestinationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationEvpnCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.update.attributes.mp.reach.nlri.advertized.routes.destination.type.destination.evpn._case.DestinationEvpnBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpReachNlriBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpUnreachNlri;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpUnreachNlriBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.reach.nlri.AdvertizedRoutes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.reach.nlri.AdvertizedRoutesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.unreach.nlri.WithdrawnRoutes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.unreach.nlri.WithdrawnRoutesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.MpReachNlriBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.mp.reach.nlri.AdvertizedRoutes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.mp.reach.nlri.AdvertizedRoutesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlriBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.mp.unreach.nlri.WithdrawnRoutes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.mp.unreach.nlri.WithdrawnRoutesBuilder;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
+import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUnkeyedListEntryNodeBuilder;
 
 public class EvpnNlriParserTest {
     private static final NodeIdentifier EVPN_CHOICE_NID = new NodeIdentifier(EvpnChoice.QNAME);
-    private List<EvpnDestination> dest;
-    private EvpnNlriParser parser;
 
-    private static ChoiceNode createMACIpAdvChoice() {
-        final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> choice = Builders.choiceBuilder();
-        choice.withNodeIdentifier(EVPN_CHOICE_NID);
-        return choice.addChild(MACIpAdvRParserTest.createMacIpCont()).build();
-    }
+    private final List<EvpnDestination> dest = List.of(new EvpnDestinationBuilder()
+        .setRouteDistinguisher(RD)
+        .setEvpnChoice(IncMultEthTagRParserTest.createIncMultiCase()).build());
+    private final EvpnNlriParser parser = new EvpnNlriParser();
 
-    @Before
-    public void setUp() {
-        ESIActivator.registerEsiTypeParsers(new ArrayList<>());
-        NlriActivator.registerNlriParsers(new ArrayList<>());
-        this.dest = Collections.singletonList(new EvpnDestinationBuilder()
-                .setRouteDistinguisher(RD)
-                .setEvpnChoice(IncMultEthTagRParserTest.createIncMultiCase()).build());
-        this.parser = new EvpnNlriParser();
+    private static ChoiceNode createMACIpAdvChoice() {
+        return Builders.choiceBuilder()
+            .withNodeIdentifier(EVPN_CHOICE_NID)
+            .addChild(MACIpAdvRParserTest.createMacIpCont())
+            .build();
     }
 
     @Test
     public void testSerializeNlri() {
         final ByteBuf buffer = Unpooled.buffer();
-        EvpnNlriParser.serializeNlri(this.dest, buffer);
+        EvpnNlriParser.serializeNlri(dest, buffer);
         assertArrayEquals(IncMultEthTagRParserTest.RESULT, ByteArray.getAllBytes(buffer));
 
     }
 
     @Test
     public void testMpUnreach() throws BGPParsingException {
-        final MpUnreachNlriBuilder mpReach = new MpUnreachNlriBuilder();
-        mpReach.setAfi(L2vpnAddressFamily.class);
-        mpReach.setSafi(EvpnSubsequentAddressFamily.class);
-        this.parser.parseNlri(Unpooled.wrappedBuffer(IncMultEthTagRParserTest.RESULT), mpReach, null);
+        final MpUnreachNlriBuilder mpReach = new MpUnreachNlriBuilder()
+            .setAfi(L2vpnAddressFamily.VALUE)
+            .setSafi(EvpnSubsequentAddressFamily.VALUE);
+        parser.parseNlri(Unpooled.wrappedBuffer(IncMultEthTagRParserTest.RESULT), mpReach, null);
         assertEquals(createUnreach(), mpReach.build());
     }
 
     private MpUnreachNlri createUnreach() {
-        final MpUnreachNlriBuilder mpReachExpected = new MpUnreachNlriBuilder();
-        mpReachExpected.setAfi(L2vpnAddressFamily.class);
-        mpReachExpected.setSafi(EvpnSubsequentAddressFamily.class);
+        final MpUnreachNlriBuilder mpReachExpected = new MpUnreachNlriBuilder()
+            .setAfi(L2vpnAddressFamily.VALUE)
+            .setSafi(EvpnSubsequentAddressFamily.VALUE);
         final WithdrawnRoutes wd = new WithdrawnRoutesBuilder().setDestinationType(
             new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.update
                 .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCaseBuilder()
                 .setDestinationEvpn(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
                     .bgp.evpn.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
                     .destination.evpn._case.DestinationEvpnBuilder()
-                    .setEvpnDestination(this.dest).build())
+                    .setEvpnDestination(dest).build())
                 .build())
             .build();
         return mpReachExpected.setWithdrawnRoutes(wd).build();
@@ -102,16 +92,16 @@ public class EvpnNlriParserTest {
 
     @Test
     public void testMpReach() throws BGPParsingException {
-        final MpReachNlriBuilder mpReach = new MpReachNlriBuilder();
-        mpReach.setAfi(L2vpnAddressFamily.class);
-        mpReach.setSafi(EvpnSubsequentAddressFamily.class);
-        this.parser.parseNlri(Unpooled.wrappedBuffer(IncMultEthTagRParserTest.RESULT), mpReach, null);
+        final MpReachNlriBuilder mpReach = new MpReachNlriBuilder()
+            .setAfi(L2vpnAddressFamily.VALUE)
+            .setSafi(EvpnSubsequentAddressFamily.VALUE);
+        parser.parseNlri(Unpooled.wrappedBuffer(IncMultEthTagRParserTest.RESULT), mpReach, null);
 
-        final MpReachNlriBuilder mpReachExpected = new MpReachNlriBuilder();
-        mpReachExpected.setAfi(L2vpnAddressFamily.class);
-        mpReachExpected.setSafi(EvpnSubsequentAddressFamily.class);
+        final MpReachNlriBuilder mpReachExpected = new MpReachNlriBuilder()
+            .setAfi(L2vpnAddressFamily.VALUE)
+            .setSafi(EvpnSubsequentAddressFamily.VALUE);
         final AdvertizedRoutes wd = new AdvertizedRoutesBuilder().setDestinationType(new DestinationEvpnCaseBuilder()
-                .setDestinationEvpn(new DestinationEvpnBuilder().setEvpnDestination(this.dest).build())
+                .setDestinationEvpn(new DestinationEvpnBuilder().setEvpnDestination(dest).build())
                 .build()).build();
         mpReachExpected.setAdvertizedRoutes(wd);
         assertEquals(mpReachExpected.build(), mpReach.build());
@@ -120,14 +110,14 @@ public class EvpnNlriParserTest {
     @Test
     public void testNullMpReachNlri() throws BGPParsingException {
         final MpReachNlriBuilder mpb = new MpReachNlriBuilder();
-        this.parser.parseNlri(Unpooled.buffer(), mpb, null);
+        parser.parseNlri(Unpooled.buffer(), mpb, null);
         assertEquals(new MpReachNlriBuilder().build(), mpb.build());
     }
 
     @Test
     public void testNullMpUnReachNlri() throws BGPParsingException {
         final MpUnreachNlriBuilder mpb = new MpUnreachNlriBuilder();
-        this.parser.parseNlri(Unpooled.buffer(), mpb, null);
+        parser.parseNlri(Unpooled.buffer(), mpb, null);
         assertEquals(new MpUnreachNlriBuilder().build(), mpb.build());
     }