From 825b440c264ef1f524a5eac8c133d0d99e03c392 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 1 Mar 2024 18:08:05 +0100 Subject: [PATCH] Modernize bgp-flowspec Migrate users of deprecated methods. Change-Id: I76b6444b4e07dc2ecdbbc6eb3b7b8dbfadf10814 Signed-off-by: Robert Varga --- bgp/extensions/flowspec/pom.xml | 2 +- .../FlowspecL3vpnIpv4NlriParserTest.java | 311 +++++++++--------- .../FlowspecL3vpnIpv6NlriParserTest.java | 143 ++++---- .../SimpleFlowspecIpv4NlriParserTest.java | 301 ++++++++--------- .../SimpleFlowspecIpv6NlriParserTest.java | 141 ++++---- 5 files changed, 434 insertions(+), 464 deletions(-) diff --git a/bgp/extensions/flowspec/pom.xml b/bgp/extensions/flowspec/pom.xml index 3ea5f84550..e234b78cb2 100644 --- a/bgp/extensions/flowspec/pom.xml +++ b/bgp/extensions/flowspec/pom.xml @@ -60,7 +60,7 @@ org.opendaylight.yangtools - yang-data-impl + yang-data-spi test diff --git a/bgp/extensions/flowspec/src/test/java/org/opendaylight/protocol/bgp/flowspec/FlowspecL3vpnIpv4NlriParserTest.java b/bgp/extensions/flowspec/src/test/java/org/opendaylight/protocol/bgp/flowspec/FlowspecL3vpnIpv4NlriParserTest.java index 6adb7eb1f1..18cd35acac 100644 --- a/bgp/extensions/flowspec/src/test/java/org/opendaylight/protocol/bgp/flowspec/FlowspecL3vpnIpv4NlriParserTest.java +++ b/bgp/extensions/flowspec/src/test/java/org/opendaylight/protocol/bgp/flowspec/FlowspecL3vpnIpv4NlriParserTest.java @@ -100,10 +100,7 @@ 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.ImmutableNodes; +import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes; @RunWith(MockitoJUnitRunner.StrictStubs.class) public class FlowspecL3vpnIpv4NlriParserTest { @@ -592,17 +589,18 @@ public class FlowspecL3vpnIpv4NlriParserTest { @Test public void testExtractFlowspecDestPrefix() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.DEST_PREFIX_NID) - .withValue("127.0.0.5/32").build()).build()).build()).build()); + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.DEST_PREFIX_NID, "127.0.0.5/32")) + .build()) + .build()) + .build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); expectedFS.setFlowspecType(new DestinationPrefixCaseBuilder().setDestinationPrefix( @@ -612,17 +610,18 @@ public class FlowspecL3vpnIpv4NlriParserTest { @Test public void testExtractFlowspecSourcePrefix() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.SOURCE_PREFIX_NID) - .withValue("127.0.0.6/32").build()).build()).build()).build()); + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.SOURCE_PREFIX_NID, "127.0.0.6/32")) + .build()) + .build()) + .build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); expectedFS.setFlowspecType(new SourcePrefixCaseBuilder().setSourcePrefix(new Ipv4Prefix("127.0.0.6/32")) @@ -634,34 +633,34 @@ public class FlowspecL3vpnIpv4NlriParserTest { @Test public void testExtractFlowspecProtocolIps() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.unkeyedListBuilder().withNodeIdentifier(PROTOCOL_IP_NID) - .withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID) - .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(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(Set.of(AbstractOperandParser.END_OF_LIST_VALUE, - AbstractOperandParser.AND_BIT_VALUE, AbstractNumericOperandParser.EQUALS_VALUE)) - .build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.VALUE_NID) - .withValue(Uint8.valueOf(240)).build()).build()) + .withChild(ImmutableNodes.newUnkeyedListBuilder().withNodeIdentifier(PROTOCOL_IP_NID) + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID) + .withChild(ImmutableNodes.leafNode(FlowspecL3vpnIpv4NlriParser.OP_NID, Set.of( + AbstractOperandParser.END_OF_LIST_VALUE, AbstractOperandParser.AND_BIT_VALUE))) + .withChild( + ImmutableNodes.leafNode(FlowspecL3vpnIpv4NlriParser.VALUE_NID, Uint8.valueOf(100))) + .build()) + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID) + .withChild(ImmutableNodes.leafNode(FlowspecL3vpnIpv4NlriParser.OP_NID, + Set.of(AbstractOperandParser.AND_BIT_VALUE))) + .withChild( + ImmutableNodes.leafNode(FlowspecL3vpnIpv4NlriParser.VALUE_NID, Uint8.valueOf(200))) + .build()) + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID) + .withChild(ImmutableNodes.leafNode(FlowspecL3vpnIpv4NlriParser.OP_NID, Set.of( + AbstractOperandParser.END_OF_LIST_VALUE, AbstractOperandParser.AND_BIT_VALUE, + AbstractNumericOperandParser.EQUALS_VALUE))) + .withChild( + ImmutableNodes.leafNode(FlowspecL3vpnIpv4NlriParser.VALUE_NID, Uint8.valueOf(240))) + .build()) .build()).build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder() @@ -682,23 +681,23 @@ public class FlowspecL3vpnIpv4NlriParserTest { @Test public void testExtractFlowspecPorts() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.unkeyedListBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.PORTS_NID) - .withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID) - .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE, - AbstractOperandParser.AND_BIT_VALUE, AbstractNumericOperandParser.LESS_THAN_VALUE)) - .build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.VALUE_NID) - .withValue(Uint16.valueOf(100)).build()).build()) + .withChild(ImmutableNodes.newUnkeyedListBuilder() + .withNodeIdentifier(AbstractFlowspecNlriParser.PORTS_NID) + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID) + .withChild(ImmutableNodes.leafNode(FlowspecL3vpnIpv4NlriParser.OP_NID, Set.of( + AbstractOperandParser.END_OF_LIST_VALUE, AbstractOperandParser.AND_BIT_VALUE, + AbstractNumericOperandParser.LESS_THAN_VALUE))) + .withChild( + ImmutableNodes.leafNode(FlowspecL3vpnIpv4NlriParser.VALUE_NID, Uint16.valueOf(100))) + .build()) .build()).build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder() @@ -715,24 +714,23 @@ public class FlowspecL3vpnIpv4NlriParserTest { @Test public void testExtractFlowspecDestinationPorts() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.unkeyedListBuilder() + .withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.DEST_PORT_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .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()) + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.OP_NID, Set.of( + AbstractOperandParser.END_OF_LIST_VALUE, AbstractNumericOperandParser.EQUALS_VALUE))) + .withChild( + ImmutableNodes.leafNode(AbstractFlowspecNlriParser.VALUE_NID, Uint16.valueOf(1024))) + .build()) .build()).build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); expectedFS.setFlowspecType(new DestinationPortCaseBuilder() @@ -748,26 +746,26 @@ public class FlowspecL3vpnIpv4NlriParserTest { @Test public void testExtractFlowspecSourcePorts() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.unkeyedListBuilder() + .withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.SOURCE_PORT_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID) - .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE, - AbstractOperandParser.END_OF_LIST_VALUE, AbstractNumericOperandParser.EQUALS_VALUE, - AbstractNumericOperandParser.GREATER_THAN_VALUE, - AbstractNumericOperandParser.LESS_THAN_VALUE)).build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.VALUE_NID) - .withValue(Uint16.valueOf(8080)).build()).build()) + .withChild(ImmutableNodes.leafNode(FlowspecL3vpnIpv4NlriParser.OP_NID, Set.of( + AbstractOperandParser.AND_BIT_VALUE, AbstractOperandParser.END_OF_LIST_VALUE, + AbstractNumericOperandParser.EQUALS_VALUE, + AbstractNumericOperandParser.GREATER_THAN_VALUE, + AbstractNumericOperandParser.LESS_THAN_VALUE))) + .withChild( + ImmutableNodes.leafNode(FlowspecL3vpnIpv4NlriParser.VALUE_NID, Uint16.valueOf(8080))) + .build()) .build()).build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); expectedFS.setFlowspecType(new SourcePortCaseBuilder() @@ -783,26 +781,26 @@ public class FlowspecL3vpnIpv4NlriParserTest { @Test public void testExtractFlowspecSourceTypes() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.unkeyedListBuilder() + .withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.ICMP_TYPE_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID) - .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE, - AbstractOperandParser.END_OF_LIST_VALUE, AbstractNumericOperandParser.EQUALS_VALUE, - AbstractNumericOperandParser.GREATER_THAN_VALUE, - AbstractNumericOperandParser.LESS_THAN_VALUE)).build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.VALUE_NID) - .withValue(Uint8.valueOf(22)).build()).build()) + .withChild(ImmutableNodes.leafNode(FlowspecL3vpnIpv4NlriParser.OP_NID, Set.of( + AbstractOperandParser.AND_BIT_VALUE, AbstractOperandParser.END_OF_LIST_VALUE, + AbstractNumericOperandParser.EQUALS_VALUE, + AbstractNumericOperandParser.GREATER_THAN_VALUE, + AbstractNumericOperandParser.LESS_THAN_VALUE))) + .withChild( + ImmutableNodes.leafNode(FlowspecL3vpnIpv4NlriParser.VALUE_NID, Uint8.valueOf(22))) + .build()) .build()).build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); expectedFS.setFlowspecType(new IcmpTypeCaseBuilder() @@ -818,23 +816,22 @@ public class FlowspecL3vpnIpv4NlriParserTest { @Test public void testExtractFlowspecSourceCodes() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.unkeyedListBuilder() + .withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.ICMP_CODE_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID) - .withValue(Set.of()).build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.VALUE_NID) - .withValue(Uint8.valueOf(23)).build()).build()) + .withChild(ImmutableNodes.leafNode(FlowspecL3vpnIpv4NlriParser.OP_NID, Set.of())) + .withChild( + ImmutableNodes.leafNode(FlowspecL3vpnIpv4NlriParser.VALUE_NID, Uint8.valueOf(23))) + .build()) .build()).build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); expectedFS.setFlowspecType(new IcmpCodeCaseBuilder() @@ -848,24 +845,23 @@ public class FlowspecL3vpnIpv4NlriParserTest { @Test public void testExtractFlowspecSourceTcpFlags() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.unkeyedListBuilder() + .withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.TCP_FLAGS_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID) - .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()) + .withChild(ImmutableNodes.leafNode(FlowspecL3vpnIpv4NlriParser.OP_NID, Set.of( + AbstractOperandParser.AND_BIT_VALUE, AbstractOperandParser.END_OF_LIST_VALUE))) + .withChild( + ImmutableNodes.leafNode(FlowspecL3vpnIpv4NlriParser.VALUE_NID, Uint16.valueOf(99))) + .build()) .build()).build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); expectedFS.setFlowspecType(new TcpFlagsCaseBuilder().setTcpFlags(List.of(new TcpFlagsBuilder() @@ -877,24 +873,23 @@ public class FlowspecL3vpnIpv4NlriParserTest { @Test public void testExtractFlowspecPacketLengths() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.unkeyedListBuilder() + .withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.PACKET_LENGTHS_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID) - .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()) + .withChild(ImmutableNodes.leafNode(FlowspecL3vpnIpv4NlriParser.OP_NID, Set.of( + AbstractOperandParser.AND_BIT_VALUE, AbstractNumericOperandParser.GREATER_THAN_VALUE))) + .withChild( + ImmutableNodes.leafNode(FlowspecL3vpnIpv4NlriParser.VALUE_NID, Uint16.valueOf(101))) + .build()) .build()).build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); expectedFS.setFlowspecType(new PacketLengthCaseBuilder().setPacketLengths(List.of( @@ -905,24 +900,24 @@ public class FlowspecL3vpnIpv4NlriParserTest { @Test public void testExtractFlowspecDscps() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.unkeyedListBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.DSCP_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListBuilder() + .withNodeIdentifier(AbstractFlowspecNlriParser.DSCP_NID) + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID) - .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()) + .withChild(ImmutableNodes.leafNode(FlowspecL3vpnIpv4NlriParser.OP_NID, Set.of( + AbstractOperandParser.AND_BIT_VALUE, AbstractOperandParser.END_OF_LIST_VALUE, + AbstractNumericOperandParser.GREATER_THAN_VALUE))) + .withChild( + ImmutableNodes.leafNode(FlowspecL3vpnIpv4NlriParser.VALUE_NID, Uint8.valueOf(15))) + .build()) .build()).build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); expectedFS.setFlowspecType(new DscpCaseBuilder().setDscps(List.of(new DscpsBuilder().setValue( @@ -932,27 +927,25 @@ public class FlowspecL3vpnIpv4NlriParserTest { @Test public void testExtractFlowspecFragments() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.unkeyedListBuilder() + .withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FRAGMENT_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID) - .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(Set.of(AbstractFlowspecNlriParser.DO_NOT_VALUE, - AbstractFlowspecNlriParser.FIRST_VALUE, AbstractFlowspecNlriParser.IS_A_VALUE, - AbstractFlowspecNlriParser.LAST_VALUE)).build()).build()) + .withChild(ImmutableNodes.leafNode(FlowspecL3vpnIpv4NlriParser.OP_NID, Set.of( + AbstractOperandParser.AND_BIT_VALUE, AbstractOperandParser.END_OF_LIST_VALUE, + BitmaskOperandParser.MATCH_VALUE, BitmaskOperandParser.NOT_VALUE))) + .withChild(ImmutableNodes.leafNode(FlowspecL3vpnIpv4NlriParser.VALUE_NID, Set.of( + AbstractFlowspecNlriParser.DO_NOT_VALUE, AbstractFlowspecNlriParser.FIRST_VALUE, + AbstractFlowspecNlriParser.IS_A_VALUE, AbstractFlowspecNlriParser.LAST_VALUE))) + .build()) .build()).build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); expectedFS.setFlowspecType(new FragmentCaseBuilder().setFragments(List.of(new FragmentsBuilder() @@ -964,7 +957,7 @@ public class FlowspecL3vpnIpv4NlriParserTest { @Test public void testExtractFlowspecRouteDistinguisher() { assertEquals(RouteDistinguisherUtil.parseRouteDistinguisher(ROUTE_DISTINGUISHER), - extractRouteDistinguisher(Builders.mapEntryBuilder() + extractRouteDistinguisher(ImmutableNodes.newMapEntryBuilder() .withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, "foo")) .withChild(ImmutableNodes.leafNode(RD_NID, ROUTE_DISTINGUISHER)) .build(), AbstractFlowspecL3vpnNlriParser.RD_NID)); diff --git a/bgp/extensions/flowspec/src/test/java/org/opendaylight/protocol/bgp/flowspec/FlowspecL3vpnIpv6NlriParserTest.java b/bgp/extensions/flowspec/src/test/java/org/opendaylight/protocol/bgp/flowspec/FlowspecL3vpnIpv6NlriParserTest.java index 55ae280d37..0bae5919e4 100644 --- a/bgp/extensions/flowspec/src/test/java/org/opendaylight/protocol/bgp/flowspec/FlowspecL3vpnIpv6NlriParserTest.java +++ b/bgp/extensions/flowspec/src/test/java/org/opendaylight/protocol/bgp/flowspec/FlowspecL3vpnIpv6NlriParserTest.java @@ -71,9 +71,7 @@ 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.spi.node.ImmutableNodes; @RunWith(MockitoJUnitRunner.StrictStubs.class) public class FlowspecL3vpnIpv6NlriParserTest { @@ -279,7 +277,7 @@ public class FlowspecL3vpnIpv6NlriParserTest { .yang.bgp.flowspec.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type .DestinationFlowspecL3vpnIpv6Case) result.getWithdrawnRoutes().getDestinationType()) .getDestinationFlowspecL3vpnIpv6(); - final List flows = flowspecDst.getFlowspec(); + final List flows = flowspecDst.nonnullFlowspec(); final RouteDistinguisher rd = flowspecDst.getRouteDistinguisher(); assertEquals(2, flows.size()); @@ -383,27 +381,25 @@ public class FlowspecL3vpnIpv6NlriParserTest { @Test public void testExtractFlowspecFragments() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.unkeyedListBuilder() + .withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FRAGMENT_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.OP_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.OP_NID) - .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE, - AbstractOperandParser.END_OF_LIST_VALUE, BitmaskOperandParser.MATCH_VALUE, - BitmaskOperandParser.NOT_VALUE)).build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.VALUE_NID) - .withValue(Set.of(AbstractFlowspecNlriParser.DO_NOT_VALUE, - AbstractFlowspecNlriParser.FIRST_VALUE, AbstractFlowspecNlriParser.IS_A_VALUE, - AbstractFlowspecNlriParser.LAST_VALUE)).build()).build()) + .withChild(ImmutableNodes.leafNode(FlowspecL3vpnIpv6NlriParser.OP_NID, Set.of( + AbstractOperandParser.AND_BIT_VALUE, AbstractOperandParser.END_OF_LIST_VALUE, + BitmaskOperandParser.MATCH_VALUE, BitmaskOperandParser.NOT_VALUE))) + .withChild(ImmutableNodes.leafNode(FlowspecL3vpnIpv6NlriParser.VALUE_NID, Set.of( + AbstractFlowspecNlriParser.DO_NOT_VALUE, AbstractFlowspecNlriParser.FIRST_VALUE, + AbstractFlowspecNlriParser.IS_A_VALUE, AbstractFlowspecNlriParser.LAST_VALUE))) + .build()) .build()).build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); expectedFS.setFlowspecType(new FragmentCaseBuilder().setFragments(List.of( @@ -414,34 +410,34 @@ public class FlowspecL3vpnIpv6NlriParserTest { @Test public void testExtractFlowspecNextHeaders() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.unkeyedListBuilder().withNodeIdentifier(NEXT_HEADER_NID) - .withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(NEXT_HEADER_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.OP_NID) - .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE, - AbstractOperandParser.AND_BIT_VALUE)).build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.VALUE_NID) - .withValue(Uint8.valueOf(100)).build()).build()) - .withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(NEXT_HEADER_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.OP_NID) - .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE)).build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.VALUE_NID) - .withValue(Uint8.valueOf(200)).build()).build()) - .withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(NEXT_HEADER_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.OP_NID) - .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE, - AbstractOperandParser.AND_BIT_VALUE, AbstractNumericOperandParser.EQUALS_VALUE)) - .build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.VALUE_NID) - .withValue(Uint8.valueOf(210)).build()).build()) + .withChild(ImmutableNodes.newUnkeyedListBuilder().withNodeIdentifier(NEXT_HEADER_NID) + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder().withNodeIdentifier(NEXT_HEADER_NID) + .withChild(ImmutableNodes.leafNode(FlowspecL3vpnIpv6NlriParser.OP_NID, Set.of( + AbstractOperandParser.END_OF_LIST_VALUE, AbstractOperandParser.AND_BIT_VALUE))) + .withChild( + ImmutableNodes.leafNode(FlowspecL3vpnIpv6NlriParser.VALUE_NID, Uint8.valueOf(100))) + .build()) + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder().withNodeIdentifier(NEXT_HEADER_NID) + .withChild(ImmutableNodes.leafNode(FlowspecL3vpnIpv6NlriParser.OP_NID, + Set.of(AbstractOperandParser.AND_BIT_VALUE))) + .withChild( + ImmutableNodes.leafNode(FlowspecL3vpnIpv6NlriParser.VALUE_NID, Uint8.valueOf(200))) + .build()) + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder().withNodeIdentifier(NEXT_HEADER_NID) + .withChild(ImmutableNodes.leafNode(FlowspecL3vpnIpv6NlriParser.OP_NID, Set.of( + AbstractOperandParser.END_OF_LIST_VALUE, AbstractOperandParser.AND_BIT_VALUE, + AbstractNumericOperandParser.EQUALS_VALUE))) + .withChild( + ImmutableNodes.leafNode(FlowspecL3vpnIpv6NlriParser.VALUE_NID, Uint8.valueOf(210))) + .build()) .build()).build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder() @@ -459,27 +455,27 @@ public class FlowspecL3vpnIpv6NlriParserTest { @Test public void testExtractFlowspecFlowLabels() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.unkeyedListBuilder().withNodeIdentifier(FLOW_LABEL_NID) - .withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(FLOW_LABEL_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.OP_NID) - .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE, - AbstractOperandParser.AND_BIT_VALUE)).build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.VALUE_NID) - .withValue(Uint32.valueOf(100)).build()).build()) - .withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(FLOW_LABEL_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.OP_NID) - .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE)).build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.VALUE_NID) - .withValue(Uint32.valueOf(200)).build()).build()) + .withChild(ImmutableNodes.newUnkeyedListBuilder().withNodeIdentifier(FLOW_LABEL_NID) + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder().withNodeIdentifier(FLOW_LABEL_NID) + .withChild(ImmutableNodes.leafNode(FlowspecL3vpnIpv6NlriParser.OP_NID, Set.of( + AbstractOperandParser.END_OF_LIST_VALUE, AbstractOperandParser.AND_BIT_VALUE))) + .withChild( + ImmutableNodes.leafNode(FlowspecL3vpnIpv6NlriParser.VALUE_NID, Uint32.valueOf(100))) + .build()) + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder().withNodeIdentifier(FLOW_LABEL_NID) + .withChild(ImmutableNodes.leafNode(FlowspecL3vpnIpv6NlriParser.OP_NID, Set.of( + AbstractOperandParser.AND_BIT_VALUE))) + .withChild( + ImmutableNodes.leafNode(FlowspecL3vpnIpv6NlriParser.VALUE_NID, Uint32.valueOf(200))) + .build()) .build()).build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); @@ -494,17 +490,16 @@ public class FlowspecL3vpnIpv6NlriParserTest { @Test public void testExtractFlowspecDestPrefix() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.DEST_PREFIX_NID) - .withValue("102:304:500::/40").build()).build()).build()).build()); + .withChild(ImmutableNodes.leafNode(FlowspecL3vpnIpv6NlriParser.DEST_PREFIX_NID, "102:304:500::/40")) + .build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); expectedFS.setFlowspecType(new DestinationIpv6PrefixCaseBuilder().setDestinationPrefix( new Ipv6Prefix("102:304:500::/40")).build()); @@ -513,17 +508,17 @@ public class FlowspecL3vpnIpv6NlriParserTest { @Test public void testExtractFlowspecSourcePrefix() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(SimpleFlowspecIpv4NlriParser.SOURCE_PREFIX_NID) - .withValue("102:304:600::/40").build()).build()).build()).build()); + .withChild( + ImmutableNodes.leafNode(SimpleFlowspecIpv4NlriParser.SOURCE_PREFIX_NID, "102:304:600::/40")) + .build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); expectedFS.setFlowspecType(new SourceIpv6PrefixCaseBuilder().setSourcePrefix(new Ipv6Prefix("102:304:600::/40")) .build()); diff --git a/bgp/extensions/flowspec/src/test/java/org/opendaylight/protocol/bgp/flowspec/SimpleFlowspecIpv4NlriParserTest.java b/bgp/extensions/flowspec/src/test/java/org/opendaylight/protocol/bgp/flowspec/SimpleFlowspecIpv4NlriParserTest.java index 4f1355fb0e..47a26dc4c6 100644 --- a/bgp/extensions/flowspec/src/test/java/org/opendaylight/protocol/bgp/flowspec/SimpleFlowspecIpv4NlriParserTest.java +++ b/bgp/extensions/flowspec/src/test/java/org/opendaylight/protocol/bgp/flowspec/SimpleFlowspecIpv4NlriParserTest.java @@ -95,9 +95,7 @@ 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.spi.node.ImmutableNodes; @RunWith(MockitoJUnitRunner.StrictStubs.class) public class SimpleFlowspecIpv4NlriParserTest { @@ -556,17 +554,16 @@ public class SimpleFlowspecIpv4NlriParserTest { @Test public void testExtractFlowspecDestPrefix() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.DEST_PREFIX_NID) - .withValue("127.0.0.5/32").build()).build()).build()).build()); + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.DEST_PREFIX_NID, "127.0.0.5/32")) + .build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); expectedFS.setFlowspecType(new DestinationPrefixCaseBuilder().setDestinationPrefix( @@ -576,17 +573,16 @@ public class SimpleFlowspecIpv4NlriParserTest { @Test public void testExtractFlowspecSourcePrefix() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.SOURCE_PREFIX_NID) - .withValue("127.0.0.6/32").build()).build()).build()).build()); + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.SOURCE_PREFIX_NID, "127.0.0.6/32")) + .build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); expectedFS.setFlowspecType(new SourcePrefixCaseBuilder().setSourcePrefix(new Ipv4Prefix("127.0.0.6/32")) @@ -596,34 +592,34 @@ public class SimpleFlowspecIpv4NlriParserTest { @Test public void testExtractFlowspecProtocolIps() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.unkeyedListBuilder().withNodeIdentifier(PROTOCOL_IP_NID) - .withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE, - AbstractOperandParser.AND_BIT_VALUE)).build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID) - .withValue(Uint8.valueOf(100)).build()).build()) - .withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE)).build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID) - .withValue(Uint8.valueOf(200)).build()).build()) - .withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE, - AbstractOperandParser.AND_BIT_VALUE, AbstractNumericOperandParser.EQUALS_VALUE)) - .build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID) - .withValue(Uint8.valueOf(240)).build()).build()) + .withChild(ImmutableNodes.newUnkeyedListBuilder().withNodeIdentifier(PROTOCOL_IP_NID) + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID) + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.OP_NID, Set.of( + AbstractOperandParser.END_OF_LIST_VALUE, AbstractOperandParser.AND_BIT_VALUE))) + .withChild( + ImmutableNodes.leafNode(AbstractFlowspecNlriParser.VALUE_NID, Uint8.valueOf(100))) + .build()) + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID) + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.OP_NID, Set.of( + AbstractOperandParser.AND_BIT_VALUE))) + .withChild( + ImmutableNodes.leafNode(AbstractFlowspecNlriParser.VALUE_NID, Uint8.valueOf(200))) + .build()) + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID) + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.OP_NID, Set.of( + AbstractOperandParser.END_OF_LIST_VALUE, AbstractOperandParser.AND_BIT_VALUE, + AbstractNumericOperandParser.EQUALS_VALUE))) + .withChild( + ImmutableNodes.leafNode(AbstractFlowspecNlriParser.VALUE_NID, Uint8.valueOf(240))) + .build()) .build()).build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); @@ -640,23 +636,23 @@ public class SimpleFlowspecIpv4NlriParserTest { @Test public void testExtractFlowspecPorts() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.unkeyedListBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.PORTS_NID) - .withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE, - AbstractOperandParser.AND_BIT_VALUE, AbstractNumericOperandParser.LESS_THAN_VALUE)) - .build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID) - .withValue(Uint16.valueOf(100)).build()).build()) + .withChild(ImmutableNodes.newUnkeyedListBuilder() + .withNodeIdentifier(AbstractFlowspecNlriParser.PORTS_NID) + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID) + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.OP_NID, Set.of( + AbstractOperandParser.END_OF_LIST_VALUE, AbstractOperandParser.AND_BIT_VALUE, + AbstractNumericOperandParser.LESS_THAN_VALUE))) + .withChild( + ImmutableNodes.leafNode(AbstractFlowspecNlriParser.VALUE_NID, Uint16.valueOf(100))) + .build()) .build()).build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder() @@ -671,24 +667,23 @@ public class SimpleFlowspecIpv4NlriParserTest { @Test public void testExtractFlowspecDestinationPorts() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.unkeyedListBuilder() + .withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.DEST_PORT_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .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()) + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.OP_NID, Set.of( + AbstractOperandParser.END_OF_LIST_VALUE, AbstractNumericOperandParser.EQUALS_VALUE))) + .withChild( + ImmutableNodes.leafNode(AbstractFlowspecNlriParser.VALUE_NID, Uint16.valueOf(1024))) + .build()) .build()).build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); expectedFS.setFlowspecType(new DestinationPortCaseBuilder() @@ -702,26 +697,26 @@ public class SimpleFlowspecIpv4NlriParserTest { @Test public void testExtractFlowspecSourcePorts() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.unkeyedListBuilder() + .withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.SOURCE_PORT_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE, - AbstractOperandParser.END_OF_LIST_VALUE, AbstractNumericOperandParser.EQUALS_VALUE, - AbstractNumericOperandParser.GREATER_THAN_VALUE, - AbstractNumericOperandParser.LESS_THAN_VALUE)).build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID) - .withValue(Uint16.valueOf(8080)).build()).build()) + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.OP_NID, Set.of( + AbstractOperandParser.AND_BIT_VALUE, AbstractOperandParser.END_OF_LIST_VALUE, + AbstractNumericOperandParser.EQUALS_VALUE, + AbstractNumericOperandParser.GREATER_THAN_VALUE, + AbstractNumericOperandParser.LESS_THAN_VALUE))) + .withChild( + ImmutableNodes.leafNode(AbstractFlowspecNlriParser.VALUE_NID, Uint16.valueOf(8080))) + .build()) .build()).build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); expectedFS.setFlowspecType(new SourcePortCaseBuilder() @@ -735,26 +730,25 @@ public class SimpleFlowspecIpv4NlriParserTest { @Test public void testExtractFlowspecSourceTypes() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.unkeyedListBuilder() + .withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.ICMP_TYPE_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE, - AbstractOperandParser.END_OF_LIST_VALUE, AbstractNumericOperandParser.EQUALS_VALUE, - AbstractNumericOperandParser.GREATER_THAN_VALUE, - AbstractNumericOperandParser.LESS_THAN_VALUE)).build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID) - .withValue(Uint8.valueOf(22)).build()).build()) + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.OP_NID, Set.of( + AbstractOperandParser.AND_BIT_VALUE, AbstractOperandParser.END_OF_LIST_VALUE, + AbstractNumericOperandParser.EQUALS_VALUE, + AbstractNumericOperandParser.GREATER_THAN_VALUE, + AbstractNumericOperandParser.LESS_THAN_VALUE))) + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.VALUE_NID, Uint8.valueOf(22))) + .build()) .build()).build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); expectedFS.setFlowspecType(new IcmpTypeCaseBuilder().setTypes(List.of(new TypesBuilder() @@ -764,23 +758,21 @@ public class SimpleFlowspecIpv4NlriParserTest { @Test public void testExtractFlowspecSourceCodes() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.unkeyedListBuilder() + .withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.ICMP_CODE_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .withValue(Set.of()).build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID) - .withValue(Uint8.valueOf(23)).build()).build()) + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.OP_NID, Set.of())) + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.VALUE_NID, Uint8.valueOf(23))) + .build()) .build()).build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); expectedFS.setFlowspecType(new IcmpCodeCaseBuilder().setCodes(List.of(new CodesBuilder() @@ -791,24 +783,23 @@ public class SimpleFlowspecIpv4NlriParserTest { @Test public void testExtractFlowspecSourceTcpFlags() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.unkeyedListBuilder() + .withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.TCP_FLAGS_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE, - AbstractOperandParser.END_OF_LIST_VALUE)).build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID) - .withValue(Uint16.valueOf(99)).build()).build()) + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.OP_NID, Set.of( + AbstractOperandParser.AND_BIT_VALUE, AbstractOperandParser.END_OF_LIST_VALUE))) + .withChild( + ImmutableNodes.leafNode(AbstractFlowspecNlriParser.VALUE_NID, Uint16.valueOf(99))) + .build()) .build()).build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); expectedFS.setFlowspecType(new TcpFlagsCaseBuilder() @@ -822,24 +813,23 @@ public class SimpleFlowspecIpv4NlriParserTest { @Test public void testExtractFlowspecPacketLengths() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.unkeyedListBuilder() + .withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.PACKET_LENGTHS_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE, - AbstractNumericOperandParser.GREATER_THAN_VALUE)).build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID) - .withValue(Uint16.valueOf(101)).build()).build()) + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.OP_NID, Set.of( + AbstractOperandParser.AND_BIT_VALUE, AbstractNumericOperandParser.GREATER_THAN_VALUE))) + .withChild( + ImmutableNodes.leafNode(AbstractFlowspecNlriParser.VALUE_NID, Uint16.valueOf(101))) + .build()) .build()).build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); expectedFS.setFlowspecType(new PacketLengthCaseBuilder() @@ -853,24 +843,23 @@ public class SimpleFlowspecIpv4NlriParserTest { @Test public void testExtractFlowspecDscps() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.unkeyedListBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.DSCP_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListBuilder() + .withNodeIdentifier(AbstractFlowspecNlriParser.DSCP_NID) + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE, - AbstractOperandParser.END_OF_LIST_VALUE, - AbstractNumericOperandParser.GREATER_THAN_VALUE)).build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID) - .withValue(Uint8.valueOf(15)).build()).build()) + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.OP_NID, Set.of( + AbstractOperandParser.AND_BIT_VALUE, AbstractOperandParser.END_OF_LIST_VALUE, + AbstractNumericOperandParser.GREATER_THAN_VALUE))) + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.VALUE_NID, Uint8.valueOf(15))) + .build()) .build()).build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); expectedFS.setFlowspecType(new DscpCaseBuilder().setDscps(List.of(new DscpsBuilder() @@ -881,27 +870,25 @@ public class SimpleFlowspecIpv4NlriParserTest { @Test public void testExtractFlowspecFragments() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.unkeyedListBuilder() + .withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FRAGMENT_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .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(Set.of(AbstractFlowspecNlriParser.DO_NOT_VALUE, - AbstractFlowspecNlriParser.FIRST_VALUE, AbstractFlowspecNlriParser.IS_A_VALUE, - AbstractFlowspecNlriParser.LAST_VALUE)).build()).build()) + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.OP_NID, Set.of( + AbstractOperandParser.AND_BIT_VALUE, AbstractOperandParser.END_OF_LIST_VALUE, + BitmaskOperandParser.MATCH_VALUE, BitmaskOperandParser.NOT_VALUE))) + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.VALUE_NID, Set.of( + AbstractFlowspecNlriParser.DO_NOT_VALUE, AbstractFlowspecNlriParser.FIRST_VALUE, + AbstractFlowspecNlriParser.IS_A_VALUE, AbstractFlowspecNlriParser.LAST_VALUE))) + .build()) .build()).build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); expectedFS.setFlowspecType(new FragmentCaseBuilder().setFragments(List.of(new FragmentsBuilder() diff --git a/bgp/extensions/flowspec/src/test/java/org/opendaylight/protocol/bgp/flowspec/SimpleFlowspecIpv6NlriParserTest.java b/bgp/extensions/flowspec/src/test/java/org/opendaylight/protocol/bgp/flowspec/SimpleFlowspecIpv6NlriParserTest.java index a45a10d4b1..2f63c83351 100644 --- a/bgp/extensions/flowspec/src/test/java/org/opendaylight/protocol/bgp/flowspec/SimpleFlowspecIpv6NlriParserTest.java +++ b/bgp/extensions/flowspec/src/test/java/org/opendaylight/protocol/bgp/flowspec/SimpleFlowspecIpv6NlriParserTest.java @@ -69,9 +69,7 @@ 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.spi.node.ImmutableNodes; @RunWith(MockitoJUnitRunner.StrictStubs.class) public class SimpleFlowspecIpv6NlriParserTest { @@ -356,27 +354,25 @@ public class SimpleFlowspecIpv6NlriParserTest { @Test public void testExtractFlowspecFragments() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.unkeyedListBuilder() + .withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FRAGMENT_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .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(Set.of(AbstractFlowspecNlriParser.DO_NOT_VALUE, - AbstractFlowspecNlriParser.FIRST_VALUE, AbstractFlowspecNlriParser.IS_A_VALUE, - AbstractFlowspecNlriParser.LAST_VALUE)).build()).build()) + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.OP_NID, Set.of( + AbstractOperandParser.AND_BIT_VALUE, AbstractOperandParser.END_OF_LIST_VALUE, + BitmaskOperandParser.MATCH_VALUE, BitmaskOperandParser.NOT_VALUE))) + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.VALUE_NID, Set.of( + AbstractFlowspecNlriParser.DO_NOT_VALUE, AbstractFlowspecNlriParser.FIRST_VALUE, + AbstractFlowspecNlriParser.IS_A_VALUE, AbstractFlowspecNlriParser.LAST_VALUE))) + .build()) .build()).build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); expectedFS.setFlowspecType(new FragmentCaseBuilder().setFragments(List.of(new FragmentsBuilder() @@ -387,34 +383,34 @@ public class SimpleFlowspecIpv6NlriParserTest { @Test public void testExtractFlowspecNextHeaders() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.unkeyedListBuilder().withNodeIdentifier(NEXT_HEADER_NID) - .withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(NEXT_HEADER_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE, - AbstractOperandParser.AND_BIT_VALUE)).build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID) - .withValue(Uint8.valueOf(100)).build()).build()) - .withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(NEXT_HEADER_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE)).build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID) - .withValue(Uint8.valueOf(200)).build()).build()) - .withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(NEXT_HEADER_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE, - AbstractOperandParser.AND_BIT_VALUE, AbstractNumericOperandParser.EQUALS_VALUE)) - .build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID) - .withValue(Uint8.valueOf(210)).build()).build()) + .withChild(ImmutableNodes.newUnkeyedListBuilder().withNodeIdentifier(NEXT_HEADER_NID) + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder().withNodeIdentifier(NEXT_HEADER_NID) + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.OP_NID, Set.of( + AbstractOperandParser.END_OF_LIST_VALUE, AbstractOperandParser.AND_BIT_VALUE))) + .withChild( + ImmutableNodes.leafNode(AbstractFlowspecNlriParser.VALUE_NID, Uint8.valueOf(100))) + .build()) + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder().withNodeIdentifier(NEXT_HEADER_NID) + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.OP_NID, Set.of( + AbstractOperandParser.AND_BIT_VALUE))) + .withChild( + ImmutableNodes.leafNode(AbstractFlowspecNlriParser.VALUE_NID, Uint8.valueOf(200))) + .build()) + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder().withNodeIdentifier(NEXT_HEADER_NID) + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.OP_NID, Set.of( + AbstractOperandParser.END_OF_LIST_VALUE, AbstractOperandParser.AND_BIT_VALUE, + AbstractNumericOperandParser.EQUALS_VALUE))) + .withChild( + ImmutableNodes.leafNode(AbstractFlowspecNlriParser.VALUE_NID, Uint8.valueOf(210))) + .build()) .build()).build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); @@ -431,27 +427,27 @@ public class SimpleFlowspecIpv6NlriParserTest { @Test public void testExtractFlowspecFlowLabels() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.unkeyedListBuilder().withNodeIdentifier(FLOW_LABEL_NID) - .withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(FLOW_LABEL_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE, - AbstractOperandParser.AND_BIT_VALUE)).build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID) - .withValue(Uint32.valueOf(100)).build()).build()) - .withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(FLOW_LABEL_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID) - .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE)).build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID) - .withValue(Uint32.valueOf(200)).build()).build()) + .withChild(ImmutableNodes.newUnkeyedListBuilder().withNodeIdentifier(FLOW_LABEL_NID) + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder().withNodeIdentifier(FLOW_LABEL_NID) + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.OP_NID, Set.of( + AbstractOperandParser.END_OF_LIST_VALUE, AbstractOperandParser.AND_BIT_VALUE))) + .withChild( + ImmutableNodes.leafNode(AbstractFlowspecNlriParser.VALUE_NID, Uint32.valueOf(100))) + .build()) + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder().withNodeIdentifier(FLOW_LABEL_NID) + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.OP_NID, Set.of( + AbstractOperandParser.AND_BIT_VALUE))) + .withChild( + ImmutableNodes.leafNode(AbstractFlowspecNlriParser.VALUE_NID, Uint32.valueOf(200))) + .build()) .build()).build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); @@ -466,17 +462,16 @@ public class SimpleFlowspecIpv6NlriParserTest { @Test public void testExtractFlowspecDestPrefix() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.DEST_PREFIX_NID) - .withValue("102:304:500::/40").build()).build()).build()).build()); + .withChild(ImmutableNodes.leafNode(AbstractFlowspecNlriParser.DEST_PREFIX_NID, "102:304:500::/40")) + .build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); expectedFS.setFlowspecType(new DestinationIpv6PrefixCaseBuilder().setDestinationPrefix( new Ipv6Prefix("102:304:500::/40")).build()); @@ -485,17 +480,17 @@ public class SimpleFlowspecIpv6NlriParserTest { @Test public void testExtractFlowspecSourcePrefix() { - final DataContainerNodeBuilder entry = - Builders.mapEntryBuilder(); + final var entry = ImmutableNodes.newMapEntryBuilder(); entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry)); - entry.withChild(Builders.unkeyedListBuilder() + entry.withChild(ImmutableNodes.newUnkeyedListBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.unkeyedListEntryBuilder() + .withChild(ImmutableNodes.newUnkeyedListEntryBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID) - .withChild(Builders.choiceBuilder() + .withChild(ImmutableNodes.newChoiceBuilder() .withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID) - .withChild(Builders.leafBuilder().withNodeIdentifier(SimpleFlowspecIpv4NlriParser.SOURCE_PREFIX_NID) - .withValue("102:304:600::/40").build()).build()).build()).build()); + .withChild( + ImmutableNodes.leafNode(SimpleFlowspecIpv4NlriParser.SOURCE_PREFIX_NID, "102:304:600::/40")) + .build()).build()).build()); final FlowspecBuilder expectedFS = new FlowspecBuilder(); expectedFS.setFlowspecType(new SourceIpv6PrefixCaseBuilder().setSourcePrefix( new Ipv6Prefix("102:304:600::/40")).build()); -- 2.36.6