import static org.mockito.Mockito.doReturn;
import static org.opendaylight.bgp.concepts.RouteDistinguisherUtil.extractRouteDistinguisher;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Optional;
+import java.util.Set;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.opendaylight.bgp.concepts.RouteDistinguisherUtil;
+import org.opendaylight.protocol.bgp.flowspec.FlowspecTypeRegistries.SAFI;
import org.opendaylight.protocol.bgp.flowspec.handlers.AbstractNumericOperandParser;
import org.opendaylight.protocol.bgp.flowspec.handlers.AbstractOperandParser;
import org.opendaylight.protocol.bgp.flowspec.handlers.BitmaskOperandParser;
import org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.BitmaskOperand;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.Dscp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.FlowspecL3vpnSubsequentAddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.Fragment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.NumericOperand;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.Flowspec;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.FlowspecBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.FlowspecType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.DestinationPortCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.DscpCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.FragmentCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.IcmpCodeCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.IcmpTypeCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.PacketLengthCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.PacketLengthCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.PortCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.PortCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.SourcePortCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.TcpFlagsCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.TcpFlagsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.destination.port._case.DestinationPorts;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.destination.port._case.DestinationPortsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.dscp._case.Dscps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.dscp._case.DscpsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.fragment._case.Fragments;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.fragment._case.FragmentsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.icmp.code._case.Codes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.icmp.code._case.CodesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.icmp.type._case.Types;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.icmp.type._case.TypesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.packet.length._case.PacketLengths;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.packet.length._case.PacketLengthsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.port._case.Ports;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.port._case.PortsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.source.port._case.SourcePorts;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.source.port._case.SourcePortsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.tcp.flags._case.TcpFlags;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.tcp.flags._case.TcpFlagsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.group.ipv4.flowspec.flowspec.type.DestinationPrefixCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.group.ipv4.flowspec.flowspec.type.DestinationPrefixCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.group.ipv4.flowspec.flowspec.type.ProtocolIpCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.group.ipv4.flowspec.flowspec.type.SourcePrefixCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.group.ipv4.flowspec.flowspec.type.SourcePrefixCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.group.ipv4.flowspec.flowspec.type.protocol.ip._case.ProtocolIps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.group.ipv4.flowspec.flowspec.type.protocol.ip._case.ProtocolIpsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.ipv4.route.FlowspecRoute;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.destination.ipv4.DestinationFlowspecL3vpnIpv4;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.destination.ipv4.DestinationFlowspecL3vpnIpv4Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.AttributesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.Attributes1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.Attributes1Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.Attributes2;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.Attributes2Builder;
-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.MpUnreachNlriBuilder;
-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.WithdrawnRoutesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.RouteDistinguisher;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.RouteDistinguisherBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.BitmaskOperand;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.Dscp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.FlowspecL3vpnSubsequentAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.Fragment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.NumericOperand;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.Flowspec;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.FlowspecBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.FlowspecType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.DestinationPortCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.DscpCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.FragmentCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.IcmpCodeCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.IcmpTypeCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.PacketLengthCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.PacketLengthCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.PortCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.PortCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.SourcePortCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.TcpFlagsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.TcpFlagsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.destination.port._case.DestinationPorts;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.destination.port._case.DestinationPortsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.dscp._case.Dscps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.dscp._case.DscpsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.fragment._case.Fragments;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.fragment._case.FragmentsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.code._case.Codes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.code._case.CodesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.type._case.Types;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.type._case.TypesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.packet.length._case.PacketLengths;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.packet.length._case.PacketLengthsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.port._case.Ports;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.port._case.PortsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.source.port._case.SourcePorts;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.source.port._case.SourcePortsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.tcp.flags._case.TcpFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.tcp.flags._case.TcpFlagsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.group.ipv4.flowspec.flowspec.type.DestinationPrefixCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.group.ipv4.flowspec.flowspec.type.DestinationPrefixCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.group.ipv4.flowspec.flowspec.type.ProtocolIpCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.group.ipv4.flowspec.flowspec.type.SourcePrefixCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.group.ipv4.flowspec.flowspec.type.SourcePrefixCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.group.ipv4.flowspec.flowspec.type.protocol.ip._case.ProtocolIps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.group.ipv4.flowspec.flowspec.type.protocol.ip._case.ProtocolIpsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.ipv4.route.FlowspecRoute;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.l3vpn.destination.ipv4.DestinationFlowspecL3vpnIpv4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.l3vpn.destination.ipv4.DestinationFlowspecL3vpnIpv4Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.PathId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesReachBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesUnreachBuilder;
+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.AdvertizedRoutesBuilder;
+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.WithdrawnRoutesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.RouteDistinguisher;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.Uint16;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
+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.ImmutableNodes;
+@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class FlowspecL3vpnIpv4NlriParserTest {
-
private static final NodeIdentifier RD_NID = new NodeIdentifier(QName.create(Flowspec.QNAME.getNamespace(),
Flowspec.QNAME.getRevision(), "route-distinguisher"));
private static final NodeIdentifier PROTOCOL_IP_NID = new NodeIdentifier(ProtocolIps.QNAME);
0x0c, (byte) 0x81, (byte) 0x0e
};
- private final SimpleFlowspecExtensionProviderContext flowspecContext = new SimpleFlowspecExtensionProviderContext();
- private final FlowspecActivator fsa = new FlowspecActivator(this.flowspecContext);
- private final FlowspecL3vpnIpv4NlriParser fsParser = new FlowspecL3vpnIpv4NlriParser(
- this.flowspecContext.getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV4,
- SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC_VPN));
+ private final FlowspecL3vpnIpv4NlriParser fsParser = new FlowspecL3vpnIpv4NlriParser(SAFI.FLOWSPEC_VPN);
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
- doReturn(Optional.of(this.muliPathSupport)).when(this.constraint).getPeerConstraint(any());
- doReturn(true).when(this.muliPathSupport).isTableTypeSupported(any());
+ doReturn(Optional.of(muliPathSupport)).when(constraint).getPeerConstraint(any());
+ doReturn(true).when(muliPathSupport).isTableTypeSupported(any());
}
@Test
builder.setFlowspecType(sps);
fs.add(builder.build());
- final FlowspecL3vpnIpv4NlriParser parser = new FlowspecL3vpnIpv4NlriParser(
- this.flowspecContext.getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV4,
- SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC_VPN));
+ final FlowspecL3vpnIpv4NlriParser parser = new FlowspecL3vpnIpv4NlriParser(SAFI.FLOWSPEC_VPN);
- final MpReachNlriBuilder result = new MpReachNlriBuilder();
- result.setAfi(Ipv4AddressFamily.class);
- result.setSafi(FlowspecL3vpnSubsequentAddressFamily.class);
+ final MpReachNlriBuilder result = new MpReachNlriBuilder()
+ .setAfi(Ipv4AddressFamily.VALUE)
+ .setSafi(FlowspecL3vpnSubsequentAddressFamily.VALUE);
parser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI), result, null);
final DestinationFlowspecL3vpnIpv4 flowspecDst = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
- .yang.bgp.flowspec.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type
+ .yang.bgp.flowspec.rev200120.update.attributes.mp.reach.nlri.advertized.routes.destination.type
.DestinationFlowspecL3vpnIpv4Case) result.getAdvertizedRoutes().getDestinationType())
.getDestinationFlowspecL3vpnIpv4();
final List<Flowspec> flows = flowspecDst.getFlowspec();
mp.setAdvertizedRoutes(
new AdvertizedRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update
.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecL3vpnIpv4CaseBuilder()
.setDestinationFlowspecL3vpnIpv4(
new DestinationFlowspecL3vpnIpv4Builder()
);
final ByteBuf buffer = Unpooled.buffer();
- parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes1.class,
- new Attributes1Builder().setMpReachNlri(mp.setAfi(Ipv4AddressFamily.class).build()).build()).build(),
- buffer);
+ parser.serializeAttribute(new AttributesBuilder()
+ .addAugmentation(new AttributesReachBuilder()
+ .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 ",
- this.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(
}
private static FlowspecType createSps() {
- final List<SourcePorts> sports = Lists.newArrayList(new SourcePortsBuilder().setOp(
+ final List<SourcePorts> sports = List.of(new SourcePortsBuilder().setOp(
new NumericOperand(false, true, true, false, false)).setValue(Uint16.valueOf(8080)).build());
return new SourcePortCaseBuilder().setSourcePorts(sports).build();
}
private static FlowspecType createProts() {
- final List<ProtocolIps> protocols = Lists.newArrayList(new ProtocolIpsBuilder().setOp(
+ final List<ProtocolIps> protocols = List.of(new ProtocolIpsBuilder().setOp(
new NumericOperand(false, true, true, false, false)).setValue(Uint8.valueOf(6)).build());
return new ProtocolIpCaseBuilder().setProtocolIps(protocols).build();
}
private static FlowspecType createDps() {
- final List<DestinationPorts> destports = Lists.newArrayList(
+ final List<DestinationPorts> destports = List.of(
new DestinationPortsBuilder().setOp(new NumericOperand(false, false, false, true, false))
.setValue(Uint16.valueOf(4089)).build(),
new DestinationPortsBuilder().setOp(new NumericOperand(false, true, true, false, false))
builder.setFlowspecType(sps);
fs.add(builder.build());
- final FlowspecL3vpnIpv4NlriParser parser = new FlowspecL3vpnIpv4NlriParser(
- this.flowspecContext.getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV4,
- SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC_VPN));
+ final FlowspecL3vpnIpv4NlriParser parser = new FlowspecL3vpnIpv4NlriParser(SAFI.FLOWSPEC_VPN);
- final MpReachNlriBuilder result = new MpReachNlriBuilder();
- result.setAfi(Ipv4AddressFamily.class);
- result.setSafi(FlowspecL3vpnSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI_ADD_PATH), result, this.constraint);
+ final MpReachNlriBuilder result = new MpReachNlriBuilder()
+ .setAfi(Ipv4AddressFamily.VALUE)
+ .setSafi(FlowspecL3vpnSubsequentAddressFamily.VALUE);
+ parser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI_ADD_PATH), result, constraint);
final DestinationFlowspecL3vpnIpv4 flowspecDst = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
- .yang.bgp.flowspec.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type
+ .yang.bgp.flowspec.rev200120.update.attributes.mp.reach.nlri.advertized.routes.destination.type
.DestinationFlowspecL3vpnIpv4Case) result.getAdvertizedRoutes().getDestinationType())
.getDestinationFlowspecL3vpnIpv4();
final List<Flowspec> flows = flowspecDst.getFlowspec();
mp.setAdvertizedRoutes(
new AdvertizedRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update
.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecL3vpnIpv4CaseBuilder()
.setDestinationFlowspecL3vpnIpv4(
new DestinationFlowspecL3vpnIpv4Builder()
);
final ByteBuf buffer = Unpooled.buffer();
- parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes1.class,
- new Attributes1Builder().setMpReachNlri(mp.setAfi(Ipv4AddressFamily.class).build()).build()).build(),
- buffer);
+ parser.serializeAttribute(new AttributesBuilder()
+ .addAugmentation(new AttributesReachBuilder()
+ .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 ",
- this.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() {
- final List<Ports> ports = Lists.newArrayList(
+ final List<Ports> ports = List.of(
new PortsBuilder().setOp(new NumericOperand(false, false, true, true, false)).setValue(Uint16.valueOf(137))
.build(),
new PortsBuilder().setOp(new NumericOperand(true, false, true, false, true)).setValue(Uint16.valueOf(139))
builder.setFlowspecType(fragment);
fs.add(builder.build());
- final FlowspecL3vpnIpv4NlriParser parser = new FlowspecL3vpnIpv4NlriParser(
- this.flowspecContext.getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV4,
- SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC_VPN));
+ final FlowspecL3vpnIpv4NlriParser parser = new FlowspecL3vpnIpv4NlriParser(SAFI.FLOWSPEC_VPN);
- final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder();
- result.setAfi(Ipv4AddressFamily.class);
- result.setSafi(FlowspecL3vpnSubsequentAddressFamily.class);
+ final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder()
+ .setAfi(Ipv4AddressFamily.VALUE)
+ .setSafi(FlowspecL3vpnSubsequentAddressFamily.VALUE);
parser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI), result, null);
DestinationFlowspecL3vpnIpv4 flowspecDst = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
- .bgp.flowspec.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .bgp.flowspec.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
.DestinationFlowspecL3vpnIpv4Case) result.getWithdrawnRoutes().getDestinationType())
.getDestinationFlowspecL3vpnIpv4();
final List<Flowspec> flows = flowspecDst.getFlowspec();
final RouteDistinguisher rd = flowspecDst.getRouteDistinguisher();
- mp.setAfi(Ipv4AddressFamily.class).setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update
+ 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.DestinationFlowspecL3vpnIpv4CaseBuilder()
.setDestinationFlowspecL3vpnIpv4(
new DestinationFlowspecL3vpnIpv4Builder()
);
final ByteBuf buffer = Unpooled.buffer();
- parser.serializeNlri(new Object[] {rd, flows}, null, buffer);
+ parser.serializeNlri(rd, flows, null, buffer);
assertArrayEquals(UNREACHED_NLRI, ByteArray.readAllBytes(buffer));
- parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes2.class,
- new Attributes2Builder().setMpUnreachNlri(mp.build()).build()).build(), buffer);
+ parser.serializeAttribute(new AttributesBuilder()
+ .addAugmentation(new AttributesUnreachBuilder().setMpUnreachNlri(mp.build()).build())
+ .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' ",
- this.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() {
- final List<Fragments> fragments = Lists.newArrayList(new FragmentsBuilder().setOp(
+ final List<Fragments> fragments = List.of(new FragmentsBuilder().setOp(
new BitmaskOperand(false, true, true, false)).setValue(new Fragment(false, true, true, true)).build());
return new FragmentCaseBuilder().setFragments(fragments).build();
}
private static FlowspecType createDscp() {
- final List<Dscps> dscps = Lists.newArrayList(new DscpsBuilder().setOp(
+ final List<Dscps> dscps = List.of(new DscpsBuilder().setOp(
new NumericOperand(false, true, false, true, false)).setValue(new Dscp(Uint8.valueOf(42))).build());
return new DscpCaseBuilder().setDscps(dscps).build();
}
private static PacketLengthCase createPackets() {
- final List<PacketLengths> packets = Lists.newArrayList(new PacketLengthsBuilder().setOp(
+ final List<PacketLengths> packets = List.of(new PacketLengthsBuilder().setOp(
new NumericOperand(false, true, false, false, true)).setValue(Uint16.valueOf(57005)).build());
return new PacketLengthCaseBuilder().setPacketLengths(packets).build();
}
private static TcpFlagsCase createTcp() {
- final List<TcpFlags> flags = Lists.newArrayList(
+ final List<TcpFlags> flags = List.of(
new TcpFlagsBuilder().setOp(new BitmaskOperand(false, false, false, true)).setValue(Uint16.valueOf(1025))
.build(),
new TcpFlagsBuilder().setOp(new BitmaskOperand(false, true, true, false)).setValue(Uint16.valueOf(22193))
}
private static FlowspecType createIcmpCode() {
- final List<Codes> codes = Lists.newArrayList(
+ final List<Codes> codes = List.of(
new CodesBuilder().setOp(new NumericOperand(false, false, false, false, true)).setValue(Uint8.valueOf(4))
.build(),
new CodesBuilder().setOp(new NumericOperand(false, true, false, false, false)).setValue(Uint8.valueOf(5))
}
private static FlowspecType createIcmpType() {
- final List<Types> types = Lists.newArrayList(
+ final List<Types> types = List.of(
new TypesBuilder().setOp(new NumericOperand(false, false, false, false, true)).setValue(Uint8.TWO)
.build(),
new TypesBuilder().setOp(new NumericOperand(false, true, false, false, true)).setValue(Uint8.valueOf(3))
builder.setFlowspecType(fragment);
fs.add(builder.build());
- final FlowspecL3vpnIpv4NlriParser parser = new FlowspecL3vpnIpv4NlriParser(
- this.flowspecContext.getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV4,
- SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC_VPN));
+ final FlowspecL3vpnIpv4NlriParser parser = new FlowspecL3vpnIpv4NlriParser(SAFI.FLOWSPEC_VPN);
- final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder();
- result.setAfi(Ipv4AddressFamily.class);
- result.setSafi(FlowspecL3vpnSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI_ADD_PATH), result, this.constraint);
+ final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder()
+ .setAfi(Ipv4AddressFamily.VALUE)
+ .setSafi(FlowspecL3vpnSubsequentAddressFamily.VALUE);
+ parser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI_ADD_PATH), result, constraint);
DestinationFlowspecL3vpnIpv4 flowspecDst = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
- .bgp.flowspec.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .bgp.flowspec.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
.DestinationFlowspecL3vpnIpv4Case) result.getWithdrawnRoutes().getDestinationType())
.getDestinationFlowspecL3vpnIpv4();
final List<Flowspec> flows = flowspecDst.getFlowspec();
final RouteDistinguisher rd = flowspecDst.getRouteDistinguisher();
- mp.setAfi(Ipv4AddressFamily.class).setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update
+ 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.DestinationFlowspecL3vpnIpv4CaseBuilder()
.setDestinationFlowspecL3vpnIpv4(
new DestinationFlowspecL3vpnIpv4Builder()
);
final ByteBuf buffer = Unpooled.buffer();
- parser.serializeNlri(new Object[] {rd, flows}, PATH_ID, buffer);
+ parser.serializeNlri(rd, flows, PATH_ID, buffer);
assertArrayEquals(UNREACHED_NLRI_ADD_PATH, ByteArray.readAllBytes(buffer));
- parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes2.class,
- new Attributes2Builder().setMpUnreachNlri(mp.build()).build()).build(), buffer);
+ parser.serializeAttribute(new AttributesBuilder()
+ .addAugmentation(new AttributesUnreachBuilder().setMpUnreachNlri(mp.build()).build())
+ .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' ",
- this.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
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new DestinationPrefixCaseBuilder().setDestinationPrefix(
new Ipv4Prefix("127.0.0.5/32")).build());
- final List<Flowspec> expected = new ArrayList<>();
- expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
.build());
final List<Flowspec> expected = new ArrayList<>();
expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(expected, fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListBuilder().withNodeIdentifier(PROTOCOL_IP_NID)
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.END_OF_LIST_VALUE,
+ .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE,
AbstractOperandParser.AND_BIT_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.VALUE_NID)
.withValue(Uint8.valueOf(100)).build()).build())
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE)).build())
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.VALUE_NID)
.withValue(Uint8.valueOf(200)).build()).build())
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.END_OF_LIST_VALUE,
+ .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE,
AbstractOperandParser.AND_BIT_VALUE, AbstractNumericOperandParser.EQUALS_VALUE))
.build())
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.VALUE_NID)
final FlowspecBuilder expectedFS = new FlowspecBuilder()
.setFlowspecType(new ProtocolIpCaseBuilder()
- .setProtocolIps(Lists.newArrayList(new ProtocolIpsBuilder()
+ .setProtocolIps(List.of(new ProtocolIpsBuilder()
.setValue(Uint8.valueOf(100))
.setOp(new NumericOperand(true, true, false, false, false))
.build(), new ProtocolIpsBuilder()
.setOp(new NumericOperand(true, true, true, false, false))
.build()))
.build());
- final List<Flowspec> expected = new ArrayList<>();
- expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.PORTS_NID)
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.END_OF_LIST_VALUE,
+ .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE,
AbstractOperandParser.AND_BIT_VALUE, AbstractNumericOperandParser.LESS_THAN_VALUE))
.build())
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.VALUE_NID)
final FlowspecBuilder expectedFS = new FlowspecBuilder()
.setFlowspecType(new PortCaseBuilder()
- .setPorts(Lists.newArrayList(new PortsBuilder()
+ .setPorts(List.of(new PortsBuilder()
.setValue(Uint16.valueOf(100))
.setOp(new NumericOperand(true, true, false, false, true))
.build()))
.build());
final List<Flowspec> expected = new ArrayList<>();
expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(expected, fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.END_OF_LIST_VALUE,
+ .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE,
AbstractNumericOperandParser.EQUALS_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID)
.withValue(Uint16.valueOf(1024)).build()).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new DestinationPortCaseBuilder()
- .setDestinationPorts(Lists.newArrayList(new DestinationPortsBuilder()
+ .setDestinationPorts(List.of(new DestinationPortsBuilder()
.setValue(Uint16.valueOf(1024))
.setOp(new NumericOperand(false, true, true, false, false))
.build()))
.build());
final List<Flowspec> expected = new ArrayList<>();
expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(expected, fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE,
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE,
AbstractOperandParser.END_OF_LIST_VALUE, AbstractNumericOperandParser.EQUALS_VALUE,
AbstractNumericOperandParser.GREATER_THAN_VALUE,
AbstractNumericOperandParser.LESS_THAN_VALUE)).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new SourcePortCaseBuilder()
- .setSourcePorts(Lists.newArrayList(new SourcePortsBuilder()
+ .setSourcePorts(List.of(new SourcePortsBuilder()
.setValue(Uint16.valueOf(8080))
.setOp(new NumericOperand(true, true, true, true, true))
.build()))
.build());
final List<Flowspec> expected = new ArrayList<>();
expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(expected, fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE,
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE,
AbstractOperandParser.END_OF_LIST_VALUE, AbstractNumericOperandParser.EQUALS_VALUE,
AbstractNumericOperandParser.GREATER_THAN_VALUE,
AbstractNumericOperandParser.LESS_THAN_VALUE)).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new IcmpTypeCaseBuilder()
- .setTypes(Lists.newArrayList(new TypesBuilder()
+ .setTypes(List.of(new TypesBuilder()
.setValue(Uint8.valueOf(22))
.setOp(new NumericOperand(true, true, true, true, true))
.build()))
.build());
final List<Flowspec> expected = new ArrayList<>();
expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(expected, fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
- .withValue(Collections.emptySet()).build())
+ .withValue(Set.of()).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.VALUE_NID)
.withValue(Uint8.valueOf(23)).build()).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new IcmpCodeCaseBuilder()
- .setCodes(Lists.newArrayList(new CodesBuilder()
+ .setCodes(List.of(new CodesBuilder()
.setValue(Uint8.valueOf(23))
.setOp(new NumericOperand(false, false, false, false, false))
.build()))
.build());
- final List<Flowspec> expected = new ArrayList<>();
- expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE,
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE,
AbstractOperandParser.END_OF_LIST_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.VALUE_NID)
.withValue(Uint16.valueOf(99)).build()).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
- expectedFS.setFlowspecType(new TcpFlagsCaseBuilder().setTcpFlags(Lists.newArrayList(new TcpFlagsBuilder()
+ expectedFS.setFlowspecType(new TcpFlagsCaseBuilder().setTcpFlags(List.of(new TcpFlagsBuilder()
.setValue(Uint16.valueOf(99)).setOp(new BitmaskOperand(true, true, false, false)).build())).build());
final List<Flowspec> expected = new ArrayList<>();
expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(expected, fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE,
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE,
AbstractNumericOperandParser.GREATER_THAN_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.VALUE_NID)
.withValue(Uint16.valueOf(101)).build()).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
- expectedFS.setFlowspecType(new PacketLengthCaseBuilder().setPacketLengths(Lists.newArrayList(
+ expectedFS.setFlowspecType(new PacketLengthCaseBuilder().setPacketLengths(List.of(
new PacketLengthsBuilder().setValue(Uint16.valueOf(101)).setOp(
new NumericOperand(true, false, false, true, false)).build())).build());
- final List<Flowspec> expected = new ArrayList<>();
- expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE,
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE,
AbstractOperandParser.END_OF_LIST_VALUE,
AbstractNumericOperandParser.GREATER_THAN_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.VALUE_NID)
.withValue(Uint8.valueOf(15)).build()).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
- expectedFS.setFlowspecType(new DscpCaseBuilder().setDscps(Lists.newArrayList(new DscpsBuilder().setValue(
+ expectedFS.setFlowspecType(new DscpCaseBuilder().setDscps(List.of(new DscpsBuilder().setValue(
new Dscp(Uint8.valueOf(15))).setOp(new NumericOperand(true, true, false, true, false)).build())).build());
- final List<Flowspec> expected = new ArrayList<>();
- expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE,
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE,
AbstractOperandParser.END_OF_LIST_VALUE, BitmaskOperandParser.MATCH_VALUE,
BitmaskOperandParser.NOT_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.VALUE_NID)
- .withValue(Sets.newHashSet(AbstractFlowspecNlriParser.DO_NOT_VALUE,
+ .withValue(Set.of(AbstractFlowspecNlriParser.DO_NOT_VALUE,
AbstractFlowspecNlriParser.FIRST_VALUE, AbstractFlowspecNlriParser.IS_A_VALUE,
AbstractFlowspecNlriParser.LAST_VALUE)).build()).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
- expectedFS.setFlowspecType(new FragmentCaseBuilder().setFragments(Lists.newArrayList(new FragmentsBuilder()
+ expectedFS.setFlowspecType(new FragmentCaseBuilder().setFragments(List.of(new FragmentsBuilder()
.setValue(new Fragment(true, true, true, true)).setOp(new BitmaskOperand(true, true, true, true)).build()))
.build());
- final List<Flowspec> expected = new ArrayList<>();
- expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
public void testExtractFlowspecRouteDistinguisher() {
- final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> entry =
- Builders.mapEntryBuilder();
- entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry));
- entry.withChild(
- Builders.leafBuilder()
- .withNodeIdentifier(RD_NID)
- .withValue(
- RouteDistinguisherBuilder.getDefaultInstance(ROUTE_DISTINGUISHER)
- ).build()
- );
-
- RouteDistinguisher rd = RouteDistinguisherBuilder.getDefaultInstance(ROUTE_DISTINGUISHER);
- assertEquals(rd, extractRouteDistinguisher(entry.build(), AbstractFlowspecL3vpnNlriParser.RD_NID));
+ assertEquals(RouteDistinguisherUtil.parseRouteDistinguisher(ROUTE_DISTINGUISHER),
+ extractRouteDistinguisher(Builders.mapEntryBuilder()
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, "foo"))
+ .withChild(ImmutableNodes.leafNode(RD_NID, ROUTE_DISTINGUISHER))
+ .build(), AbstractFlowspecL3vpnNlriParser.RD_NID));
}
}