import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
import static org.opendaylight.protocol.bgp.flowspec.SimpleFlowspecIpv4NlriParserTest.PATH_ID;
-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.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.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
+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.Ipv6Prefix;
-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.FlowspecSubsequentAddressFamily;
-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.FragmentCase;
-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.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.group.ipv6.flowspec.flowspec.type.DestinationIpv6PrefixCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.group.ipv6.flowspec.flowspec.type.DestinationIpv6PrefixCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.group.ipv6.flowspec.flowspec.type.FlowLabelCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.group.ipv6.flowspec.flowspec.type.NextHeaderCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.group.ipv6.flowspec.flowspec.type.NextHeaderCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.group.ipv6.flowspec.flowspec.type.SourceIpv6PrefixCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.group.ipv6.flowspec.flowspec.type.SourceIpv6PrefixCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.group.ipv6.flowspec.flowspec.type.flow.label._case.FlowLabel;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.group.ipv6.flowspec.flowspec.type.flow.label._case.FlowLabelBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.group.ipv6.flowspec.flowspec.type.next.header._case.NextHeaders;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.group.ipv6.flowspec.flowspec.type.next.header._case.NextHeadersBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.ipv6.DestinationFlowspecIpv6Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.ipv6.route.FlowspecRoute;
-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.Ipv6AddressFamily;
+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.FlowspecSubsequentAddressFamily;
+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.FragmentCase;
+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.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.group.ipv6.flowspec.flowspec.type.DestinationIpv6PrefixCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.group.ipv6.flowspec.flowspec.type.DestinationIpv6PrefixCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.group.ipv6.flowspec.flowspec.type.FlowLabelCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.group.ipv6.flowspec.flowspec.type.NextHeaderCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.group.ipv6.flowspec.flowspec.type.NextHeaderCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.group.ipv6.flowspec.flowspec.type.SourceIpv6PrefixCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.group.ipv6.flowspec.flowspec.type.SourceIpv6PrefixCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.group.ipv6.flowspec.flowspec.type.flow.label._case.FlowLabel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.group.ipv6.flowspec.flowspec.type.flow.label._case.FlowLabelBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.group.ipv6.flowspec.flowspec.type.next.header._case.NextHeaders;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.group.ipv6.flowspec.flowspec.type.next.header._case.NextHeadersBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.ipv6.DestinationFlowspecIpv6Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.ipv6.route.FlowspecRoute;
+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.Ipv6AddressFamily;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint8;
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.DataContainerNodeAttrBuilder;
+@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class SimpleFlowspecIpv6NlriParserTest {
private static final NodeIdentifier NEXT_HEADER_NID = new NodeIdentifier(NextHeaders.QNAME);
private static final NodeIdentifier FLOW_LABEL_NID = new NodeIdentifier(FlowLabel.QNAME);
private PeerSpecificParserConstraint constraint;
@Mock
private MultiPathSupport muliPathSupport;
- private final SimpleFlowspecExtensionProviderContext flowspecContext = new SimpleFlowspecExtensionProviderContext();
- private final FlowspecActivator fsa = new FlowspecActivator(this.flowspecContext);
- private final SimpleFlowspecIpv6NlriParser fsParser = new SimpleFlowspecIpv6NlriParser(
- this.flowspecContext.getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV6,
- SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC));
+ private final SimpleFlowspecIpv6NlriParser fsParser = new SimpleFlowspecIpv6NlriParser(SAFI.FLOWSPEC);
private static final byte[] REACHED_NLRI = new byte[] {
0x13,
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
- Mockito.doReturn(Optional.of(this.muliPathSupport)).when(this.constraint).getPeerConstraint(Mockito.any());
- Mockito.doReturn(true).when(this.muliPathSupport).isTableTypeSupported(Mockito.any());
+ doReturn(Optional.of(muliPathSupport)).when(constraint).getPeerConstraint(any());
+ doReturn(true).when(muliPathSupport).isTableTypeSupported(any());
}
@Test
builder.setFlowspecType(sourcePrefix);
fs.add(builder.build());
- final List<NextHeaders> nextheaders = Lists.newArrayList(new NextHeadersBuilder().setOp(
- new NumericOperand(false, true, true, false, false)).setValue((short) 6).build());
+ final List<NextHeaders> nextheaders = List.of(new NextHeadersBuilder().setOp(
+ new NumericOperand(false, true, true, false, false)).setValue(Uint8.valueOf(6)).build());
final NextHeaderCase headersCase = new NextHeaderCaseBuilder().setNextHeaders(nextheaders).build();
builder.setFlowspecType(headersCase);
fs.add(builder.build());
mp.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn
- .opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.mp.reach.nlri.advertized.routes
+ .opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update.attributes.mp.reach.nlri.advertized.routes
.destination.type.DestinationFlowspecIpv6CaseBuilder()
.setDestinationFlowspecIpv6(
new DestinationFlowspecIpv6Builder()
final MpReachNlriBuilder result = new MpReachNlriBuilder();
result.setAfi(Ipv6AddressFamily.class);
result.setSafi(FlowspecSubsequentAddressFamily.class);
- this.fsParser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI), result, null);
+ fsParser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI), result, null);
- final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec
- .rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type
+ final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
+ .bgp.flowspec.rev200120.update.attributes.mp.reach.nlri.advertized.routes.destination.type
.DestinationFlowspecIpv6Case) result.getAdvertizedRoutes().getDestinationType())
.getDestinationFlowspecIpv6().getFlowspec();
assertEquals(3, flows.size());
assertEquals(headersCase, flows.get(2).getFlowspecType());
final ByteBuf buffer = Unpooled.buffer();
- this.fsParser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes1.class,
- new Attributes1Builder().setMpReachNlri(mp.setAfi(Ipv6AddressFamily.class).build()).build()).build(),
- buffer);
+ fsParser.serializeAttribute(new AttributesBuilder()
+ .addAugmentation(new AttributesReachBuilder()
+ .setMpReachNlri(mp.setAfi(Ipv6AddressFamily.class).build())
+ .build())
+ .build(), buffer);
assertArrayEquals(REACHED_NLRI, ByteArray.readAllBytes(buffer));
assertEquals("all packets to 102:304:500::/40 AND from 102:304:600::/40 AND where next header equals to 6 ",
- this.fsParser.stringNlri(flows));
+ fsParser.stringNlri(flows));
}
@Test
builder.setFlowspecType(sourcePrefix);
fs.add(builder.build());
- final List<NextHeaders> nextheaders = Lists.newArrayList(new NextHeadersBuilder().setOp(
- new NumericOperand(false, true, true, false, false)).setValue((short) 6).build());
+ final List<NextHeaders> nextheaders = List.of(new NextHeadersBuilder().setOp(
+ new NumericOperand(false, true, true, false, false)).setValue(Uint8.valueOf(6)).build());
final NextHeaderCase headersCase = new NextHeaderCaseBuilder().setNextHeaders(nextheaders).build();
builder.setFlowspecType(headersCase);
fs.add(builder.build());
mp.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn
- .opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.mp.reach.nlri.advertized.routes
+ .opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update.attributes.mp.reach.nlri.advertized.routes
.destination.type.DestinationFlowspecIpv6CaseBuilder()
.setDestinationFlowspecIpv6(
new DestinationFlowspecIpv6Builder()
final MpReachNlriBuilder result = new MpReachNlriBuilder();
result.setAfi(Ipv6AddressFamily.class);
result.setSafi(FlowspecSubsequentAddressFamily.class);
- this.fsParser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI_ADD_PATH), result, this.constraint);
+ fsParser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI_ADD_PATH), result, constraint);
- final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec
- .rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type
+ final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
+ .bgp.flowspec.rev200120.update.attributes.mp.reach.nlri.advertized.routes.destination.type
.DestinationFlowspecIpv6Case) result.getAdvertizedRoutes().getDestinationType())
.getDestinationFlowspecIpv6().getFlowspec();
assertEquals(3, flows.size());
assertEquals(headersCase, flows.get(2).getFlowspecType());
final ByteBuf buffer = Unpooled.buffer();
- this.fsParser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes1.class,
- new Attributes1Builder().setMpReachNlri(mp.setAfi(Ipv6AddressFamily.class).build()).build()).build(),
- buffer);
+ fsParser.serializeAttribute(new AttributesBuilder()
+ .addAugmentation(new AttributesReachBuilder()
+ .setMpReachNlri(mp.setAfi(Ipv6AddressFamily.class).build())
+ .build())
+ .build(), buffer);
assertArrayEquals(REACHED_NLRI_ADD_PATH, ByteArray.readAllBytes(buffer));
assertEquals("all packets to 102:304:500::/40 AND from 102:304:600::/40 AND where next header equals to 6 ",
- this.fsParser.stringNlri(flows));
+ fsParser.stringNlri(flows));
}
@Test
fs.add(builder.build());
mp.setAfi(Ipv6AddressFamily.class).setWithdrawnRoutes(new WithdrawnRoutesBuilder().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.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecIpv6CaseBuilder()
.setDestinationFlowspecIpv6(
new DestinationFlowspecIpv6Builder()
final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder();
result.setAfi(Ipv6AddressFamily.class);
result.setSafi(FlowspecSubsequentAddressFamily.class);
- this.fsParser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI), result, null);
+ fsParser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI), result, null);
- final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec
- .rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
+ .bgp.flowspec.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
.DestinationFlowspecIpv6Case) result.getWithdrawnRoutes().getDestinationType())
.getDestinationFlowspecIpv6().getFlowspec();
assertEquals(2, flows.size());
assertEquals(label, flows.get(1).getFlowspecType());
final ByteBuf buffer = Unpooled.buffer();
- this.fsParser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes2.class,
- new Attributes2Builder().setMpUnreachNlri(mp.build()).build()).build(), buffer);
+ fsParser.serializeAttribute(new AttributesBuilder()
+ .addAugmentation(new AttributesUnreachBuilder().setMpUnreachNlri(mp.build()).build())
+ .build(), buffer);
assertArrayEquals(UNREACHED_NLRI, ByteArray.readAllBytes(buffer));
assertEquals("all packets where fragment does match 'IS FIRST' 'IS LAST' 'IS A' AND where flow label equals to "
- + "16777222 or equals to 258 ", this.fsParser.stringNlri(flows));
+ + "16777222 or equals to 258 ", fsParser.stringNlri(flows));
}
private static FragmentCase 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 createLabel() {
- final List<FlowLabel> labels = new ArrayList<>(2);
- labels.add(new FlowLabelBuilder().setOp(new NumericOperand(false, false, true, false, false))
- .setValue(16777222L).build());
- labels.add(new FlowLabelBuilder().setOp(new NumericOperand(false, true, true, false, false))
- .setValue(258L).build());
+ final List<FlowLabel> labels = List.of(
+ new FlowLabelBuilder().setOp(new NumericOperand(false, false, true, false, false))
+ .setValue(Uint32.valueOf(16777222)).build(),
+ new FlowLabelBuilder().setOp(new NumericOperand(false, true, true, false, false))
+ .setValue(Uint32.valueOf(258)).build());
return new FlowLabelCaseBuilder().setFlowLabel(labels).build();
}
fs.add(builder.build());
mp.setAfi(Ipv6AddressFamily.class).setWithdrawnRoutes(new WithdrawnRoutesBuilder().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.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecIpv6CaseBuilder()
.setDestinationFlowspecIpv6(
new DestinationFlowspecIpv6Builder()
final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder();
result.setAfi(Ipv6AddressFamily.class);
result.setSafi(FlowspecSubsequentAddressFamily.class);
- this.fsParser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI_ADD_PATH), result, this.constraint);
+ fsParser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI_ADD_PATH), result, constraint);
- final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec
- .rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
+ .bgp.flowspec.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
.DestinationFlowspecIpv6Case) result.getWithdrawnRoutes().getDestinationType())
.getDestinationFlowspecIpv6().getFlowspec();
assertEquals(2, flows.size());
assertEquals(label, flows.get(1).getFlowspecType());
final ByteBuf buffer = Unpooled.buffer();
- this.fsParser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes2.class,
- new Attributes2Builder().setMpUnreachNlri(mp.build()).build()).build(), buffer);
+ fsParser.serializeAttribute(new AttributesBuilder()
+ .addAugmentation(new AttributesUnreachBuilder().setMpUnreachNlri(mp.build()).build())
+ .build(), buffer);
assertArrayEquals(UNREACHED_NLRI_ADD_PATH, ByteArray.readAllBytes(buffer));
assertEquals("all packets where fragment does match 'IS FIRST' 'IS LAST' 'IS A' AND where flow label equals to "
- + "16777222 or equals to 258 ", this.fsParser.stringNlri(flows));
+ + "16777222 or equals to 258 ", fsParser.stringNlri(flows));
}
@Test
public void testExtractFlowspecFragments() {
- final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> entry =
+ final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> entry =
Builders.mapEntryBuilder();
- entry.withNodeIdentifier(new NodeIdentifierWithPredicates(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry));
+ entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry));
entry.withChild(Builders.unkeyedListBuilder()
.withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID)
.withChild(Builders.unkeyedListEntryBuilder()
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.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(AbstractFlowspecNlriParser.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> expectedValue = new ArrayList<>();
- expectedValue.add(expectedFS.build());
- assertEquals(expectedValue, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
public void testExtractFlowspecNextHeaders() {
- final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> entry =
+ final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> entry =
Builders.mapEntryBuilder();
- entry.withNodeIdentifier(new NodeIdentifierWithPredicates(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry));
+ entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry));
entry.withChild(Builders.unkeyedListBuilder()
.withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID)
.withChild(Builders.unkeyedListEntryBuilder()
.withChild(Builders.unkeyedListBuilder().withNodeIdentifier(NEXT_HEADER_NID)
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(NEXT_HEADER_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.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(AbstractFlowspecNlriParser.VALUE_NID)
- .withValue((short) 100).build()).build())
+ .withValue(Uint8.valueOf(100)).build()).build())
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(NEXT_HEADER_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE)).build())
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID)
- .withValue((short) 200).build()).build())
+ .withValue(Uint8.valueOf(200)).build()).build())
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(NEXT_HEADER_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.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(AbstractFlowspecNlriParser.VALUE_NID)
- .withValue((short) 210).build()).build())
+ .withValue(Uint8.valueOf(210)).build()).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
- expectedFS.setFlowspecType(new NextHeaderCaseBuilder().setNextHeaders(Lists.newArrayList(
- new NextHeadersBuilder().setValue((short) 100).setOp(new NumericOperand(true, true, false, false, false))
- .build(),
- new NextHeadersBuilder().setValue((short) 200).setOp(new NumericOperand(true, false, false, false, false))
- .build(),
- new NextHeadersBuilder().setValue((short) 210).setOp(new NumericOperand(true, true, true, false, false))
- .build())).build());
- final List<Flowspec> expectedValue = new ArrayList<>();
- expectedValue.add(expectedFS.build());
- assertEquals(expectedValue, this.fsParser.extractFlowspec(entry.build()));
+ expectedFS.setFlowspecType(new NextHeaderCaseBuilder().setNextHeaders(List.of(
+ new NextHeadersBuilder().setValue(Uint8.valueOf(100))
+ .setOp(new NumericOperand(true, true, false, false, false)).build(),
+ new NextHeadersBuilder().setValue(Uint8.valueOf(200))
+ .setOp(new NumericOperand(true, false, false, false, false)).build(),
+ new NextHeadersBuilder().setValue(Uint8.valueOf(210))
+ .setOp(new NumericOperand(true, true, true, false, false)).build()))
+ .build());
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
public void testExtractFlowspecFlowLabels() {
- final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> entry =
+ final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> entry =
Builders.mapEntryBuilder();
- entry.withNodeIdentifier(new NodeIdentifierWithPredicates(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry));
+ entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry));
entry.withChild(Builders.unkeyedListBuilder()
.withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID)
.withChild(Builders.unkeyedListEntryBuilder()
.withChild(Builders.unkeyedListBuilder().withNodeIdentifier(FLOW_LABEL_NID)
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(FLOW_LABEL_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.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(AbstractFlowspecNlriParser.VALUE_NID)
- .withValue(100L).build()).build())
+ .withValue(Uint32.valueOf(100)).build()).build())
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(FLOW_LABEL_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE)).build())
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID)
- .withValue(200L).build()).build())
+ .withValue(Uint32.valueOf(200)).build()).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
- expectedFS.setFlowspecType(new FlowLabelCaseBuilder().setFlowLabel(Lists.newArrayList(
- new FlowLabelBuilder().setValue(100L).setOp(new NumericOperand(true, true, false, false, false)).build(),
- new FlowLabelBuilder().setValue(200L).setOp(new NumericOperand(true, false, false, false, false)).build()))
+ expectedFS.setFlowspecType(new FlowLabelCaseBuilder().setFlowLabel(List.of(
+ new FlowLabelBuilder().setValue(Uint32.valueOf(100))
+ .setOp(new NumericOperand(true, true, false, false, false)).build(),
+ new FlowLabelBuilder().setValue(Uint32.valueOf(200))
+ .setOp(new NumericOperand(true, false, false, false, false)).build()))
.build());
- final List<Flowspec> expectedValue = new ArrayList<>();
- expectedValue.add(expectedFS.build());
- assertEquals(expectedValue, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
public void testExtractFlowspecDestPrefix() {
- final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> entry =
+ final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> entry =
Builders.mapEntryBuilder();
- entry.withNodeIdentifier(new NodeIdentifierWithPredicates(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry));
+ entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry));
entry.withChild(Builders.unkeyedListBuilder()
.withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID)
.withChild(Builders.unkeyedListEntryBuilder()
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new DestinationIpv6PrefixCaseBuilder().setDestinationPrefix(
new Ipv6Prefix("102:304:500::/40")).build());
- final List<Flowspec> expectedValue = new ArrayList<>();
- expectedValue.add(expectedFS.build());
- assertEquals(expectedValue, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
public void testExtractFlowspecSourcePrefix() {
- final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> entry =
+ final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> entry =
Builders.mapEntryBuilder();
- entry.withNodeIdentifier(new NodeIdentifierWithPredicates(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry));
+ entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry));
entry.withChild(Builders.unkeyedListBuilder()
.withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID)
.withChild(Builders.unkeyedListEntryBuilder()
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new SourceIpv6PrefixCaseBuilder().setSourcePrefix(
new Ipv6Prefix("102:304:600::/40")).build());
- final List<Flowspec> expectedValue = new ArrayList<>();
- expectedValue.add(expectedFS.build());
- assertEquals(expectedValue, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
}