Bump upstreams to 2022.09
[bgpcep.git] / bgp / extensions / flowspec / src / test / java / org / opendaylight / protocol / bgp / flowspec / SimpleFlowspecIpv4NlriParserTest.java
index 1e034c1db87e2e31d7a27faf14d4af4a53fc2ff8..0b80c47fe2b5d972458be25a0a3bdd9bc9df1909 100644 (file)
@@ -205,9 +205,9 @@ public class SimpleFlowspecIpv4NlriParserTest {
 
         final SimpleFlowspecIpv4NlriParser parser = new SimpleFlowspecIpv4NlriParser(SAFI.FLOWSPEC);
 
-        final MpReachNlriBuilder result = new MpReachNlriBuilder();
-        result.setAfi(Ipv4AddressFamily.class);
-        result.setSafi(FlowspecSubsequentAddressFamily.class);
+        final MpReachNlriBuilder result = new MpReachNlriBuilder()
+            .setAfi(Ipv4AddressFamily.VALUE)
+            .setSafi(FlowspecSubsequentAddressFamily.VALUE);
         parser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI), result, null);
 
         final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
@@ -219,15 +219,17 @@ public class SimpleFlowspecIpv4NlriParserTest {
         final ByteBuf buffer = Unpooled.buffer();
         parser.serializeAttribute(new AttributesBuilder()
             .addAugmentation(new AttributesReachBuilder()
-                .setMpReachNlri(mp.setAfi(Ipv4AddressFamily.class).build())
+                .setMpReachNlri(mp.setAfi(Ipv4AddressFamily.VALUE).build())
                 .build())
             .build(), buffer);
         assertArrayEquals(REACHED_NLRI, ByteArray.readAllBytes(buffer));
 
-        assertEquals("all packets to 10.0.1.0/32 AND from 1.2.3.4/32 AND where IP protocol equals to 6 AND where port "
-                + "is greater than or equals to 137 and is less than or equals to 139 or equals to 8080 AND where "
-                + "destination port is greater than 4089 or equals to 179 AND where source port equals to 8080 ",
-                fsParser.stringNlri(flows));
+        assertEquals("""
+            all packets to 10.0.1.0/32 AND from 1.2.3.4/32 AND where IP protocol equals to 6 AND where port \
+            is greater than or equals to 137 and is less than or equals to 139 or equals to 8080 AND where \
+            destination port is greater than 4089 or equals to 179 AND where source port equals to 8080 \
+            """,
+            fsParser.stringNlri(flows));
     }
 
     private static void testFlows(final List<Flowspec> flows, final DestinationPrefixCase destinationPrefix,
@@ -307,9 +309,9 @@ public class SimpleFlowspecIpv4NlriParserTest {
 
         final SimpleFlowspecIpv4NlriParser parser = new SimpleFlowspecIpv4NlriParser(SAFI.FLOWSPEC);
 
-        final MpReachNlriBuilder result = new MpReachNlriBuilder();
-        result.setAfi(Ipv4AddressFamily.class);
-        result.setSafi(FlowspecSubsequentAddressFamily.class);
+        final MpReachNlriBuilder result = new MpReachNlriBuilder()
+            .setAfi(Ipv4AddressFamily.VALUE)
+            .setSafi(FlowspecSubsequentAddressFamily.VALUE);
         parser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI_ADD_PATH), result, constraint);
 
         final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
@@ -321,15 +323,17 @@ public class SimpleFlowspecIpv4NlriParserTest {
         final ByteBuf buffer = Unpooled.buffer();
         parser.serializeAttribute(new AttributesBuilder()
             .addAugmentation(new AttributesReachBuilder()
-                .setMpReachNlri(mp.setAfi(Ipv4AddressFamily.class).build())
+                .setMpReachNlri(mp.setAfi(Ipv4AddressFamily.VALUE).build())
                 .build())
             .build(), buffer);
         assertArrayEquals(REACHED_NLRI_ADD_PATH, ByteArray.readAllBytes(buffer));
 
-        assertEquals("all packets to 10.0.1.0/32 AND from 1.2.3.4/32 AND where IP protocol equals to 6 AND where port "
-                + "is greater than or equals to 137 and is less than or equals to 139 or equals to 8080 AND where "
-                + "destination port is greater than 4089 or equals to 179 AND where source port equals to 8080 ",
-                fsParser.stringNlri(flows));
+        assertEquals("""
+            all packets to 10.0.1.0/32 AND from 1.2.3.4/32 AND where IP protocol equals to 6 AND where port \
+            is greater than or equals to 137 and is less than or equals to 139 or equals to 8080 AND where \
+            destination port is greater than 4089 or equals to 179 AND where source port equals to 8080 \
+            """,
+            fsParser.stringNlri(flows));
     }
 
     private static PortCase createPorts() {
@@ -347,7 +351,6 @@ public class SimpleFlowspecIpv4NlriParserTest {
     @Test
     public void testParseMpUnreachNlri() throws BGPParsingException {
         final List<Flowspec> fs = new ArrayList<>();
-        final MpUnreachNlriBuilder mp = new MpUnreachNlriBuilder();
 
         final FlowspecBuilder builder = new FlowspecBuilder();
 
@@ -375,22 +378,22 @@ public class SimpleFlowspecIpv4NlriParserTest {
         builder.setFlowspecType(fragment);
         fs.add(builder.build());
 
-        mp.setAfi(Ipv4AddressFamily.class).setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
-            new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update
-                .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecCaseBuilder()
-                .setDestinationFlowspecIpv4(
-                    new DestinationFlowspecIpv4Builder()
+        final MpUnreachNlriBuilder mp = new MpUnreachNlriBuilder()
+            .setAfi(Ipv4AddressFamily.VALUE)
+            .setWithdrawnRoutes(new WithdrawnRoutesBuilder()
+                .setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec
+                    .rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+                    .DestinationFlowspecCaseBuilder().setDestinationFlowspecIpv4(new DestinationFlowspecIpv4Builder()
                         .setFlowspec(fs)
-                        .build()
-                ).build()
-            ).build()
-        );
+                        .build())
+                    .build())
+                .build());
 
         final SimpleFlowspecIpv4NlriParser parser = new SimpleFlowspecIpv4NlriParser(SAFI.FLOWSPEC);
 
-        final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder();
-        result.setAfi(Ipv4AddressFamily.class);
-        result.setSafi(FlowspecSubsequentAddressFamily.class);
+        final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder()
+            .setAfi(Ipv4AddressFamily.VALUE)
+            .setSafi(FlowspecSubsequentAddressFamily.VALUE);
         parser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI), result, null);
 
         final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
@@ -408,11 +411,12 @@ public class SimpleFlowspecIpv4NlriParserTest {
             .build(), buffer);
         assertArrayEquals(UNREACHED_NLRI, ByteArray.readAllBytes(buffer));
 
-        assertEquals("all packets where ICMP type is less than 2 or is less than 3 AND where ICMP code is less than 4 "
-                + "or 5 AND where TCP flags is not 1025 or does match 22193 AND where packet length is less than 57005 "
-                + "AND where DSCP is greater than 42 AND where fragment does match 'IS FIRST' 'IS LAST' 'IS A' ",
-                fsParser.stringNlri(flows));
-
+        assertEquals("""
+            all packets where ICMP type is less than 2 or is less than 3 AND where ICMP code is less than 4 \
+            or 5 AND where TCP flags is not 1025 or does match 22193 AND where packet length is less than 57005 \
+            AND where DSCP is greater than 42 AND where fragment does match 'IS FIRST' 'IS LAST' 'IS A' \
+            """,
+            fsParser.stringNlri(flows));
     }
 
     private static FlowspecType createFragment() {
@@ -507,7 +511,7 @@ public class SimpleFlowspecIpv4NlriParserTest {
         builder.setFlowspecType(fragment);
         fs.add(builder.build());
 
-        mp.setAfi(Ipv4AddressFamily.class).setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
+        mp.setAfi(Ipv4AddressFamily.VALUE).setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
             new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update
                 .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecCaseBuilder()
                 .setDestinationFlowspecIpv4(
@@ -521,9 +525,9 @@ public class SimpleFlowspecIpv4NlriParserTest {
 
         final SimpleFlowspecIpv4NlriParser parser = new SimpleFlowspecIpv4NlriParser(SAFI.FLOWSPEC);
 
-        final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder();
-        result.setAfi(Ipv4AddressFamily.class);
-        result.setSafi(FlowspecSubsequentAddressFamily.class);
+        final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder()
+            .setAfi(Ipv4AddressFamily.VALUE)
+            .setSafi(FlowspecSubsequentAddressFamily.VALUE);
         parser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI_ADD_PATH), result, constraint);
 
         final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
@@ -542,11 +546,12 @@ public class SimpleFlowspecIpv4NlriParserTest {
             .build(), buffer);
         assertArrayEquals(UNREACHED_NLRI_ADD_PATH, ByteArray.readAllBytes(buffer));
 
-        assertEquals("all packets where ICMP type is less than 2 or is less than 3 AND where ICMP code is less than 4 "
-                + "or 5 AND where TCP flags is not 1025 or does match 22193 AND where packet length is less than 57005 "
-                + "AND where DSCP is greater than 42 AND where fragment does match 'IS FIRST' 'IS LAST' 'IS A' ",
-                fsParser.stringNlri(flows));
-
+        assertEquals("""
+            all packets where ICMP type is less than 2 or is less than 3 AND where ICMP code is less than 4 \
+            or 5 AND where TCP flags is not 1025 or does match 22193 AND where packet length is less than 57005 \
+            AND where DSCP is greater than 42 AND where fragment does match 'IS FIRST' 'IS LAST' 'IS A' \
+            """,
+            fsParser.stringNlri(flows));
     }
 
     @Test
@@ -909,15 +914,15 @@ public class SimpleFlowspecIpv4NlriParserTest {
     public void testBatchedFlowspecNlri() throws Exception {
         final SimpleFlowspecIpv4NlriParser parser = new SimpleFlowspecIpv4NlriParser(SAFI.FLOWSPEC);
 
-        final MpReachNlriBuilder result = new MpReachNlriBuilder();
-        result.setAfi(Ipv4AddressFamily.class);
-        result.setSafi(FlowspecSubsequentAddressFamily.class);
+        final MpReachNlriBuilder result = new MpReachNlriBuilder()
+            .setAfi(Ipv4AddressFamily.VALUE)
+            .setSafi(FlowspecSubsequentAddressFamily.VALUE);
 
         parser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI_BATCHED), result, null);
         final MpReachNlri nlri = result.build();
 
         final List<Flowspec> flowspecList = ((DestinationFlowspecCase) nlri.getAdvertizedRoutes().getDestinationType())
-                .getDestinationFlowspecIpv4().getFlowspec();
+                .getDestinationFlowspecIpv4().nonnullFlowspec();
         assertEquals(3, flowspecList.size());
         assertEquals("216.58.245.101/32", ((DestinationPrefixCase) flowspecList.get(0).getFlowspecType())
             .getDestinationPrefix().getValue());