From ddf69b8f72e45e85452ef03947809b8959124712 Mon Sep 17 00:00:00 2001 From: "Claudio D. Gasparini" Date: Mon, 18 Dec 2017 14:03:51 +0100 Subject: [PATCH] Enforce findbug & checkstyle under evon module Change-Id: Ib09de798d809002e03379805d299e8e577331be4 Signed-off-by: Claudio D. Gasparini --- bgp/evpn/pom.xml | 19 +++ .../protocol/bgp/evpn/impl/BGPActivator.java | 19 ++- .../bgp/evpn/impl/EvpnRibSupport.java | 18 ++- .../PMSITunnelAttributeHandler.java | 4 +- .../tunnel/identifier/BidirPimTreeParser.java | 14 +- .../identifier/IngressReplicationParser.java | 17 ++- .../tunnel/identifier/MldpMp2mpLspParser.java | 15 ++- .../tunnel/identifier/MldpP2mpLspParser.java | 21 +-- .../tunnel/identifier/OpaqueUtil.java | 44 +++---- .../tunnel/identifier/PimSmTreeParser.java | 15 ++- .../tunnel/identifier/PimSsmTreeParser.java | 14 +- .../identifier/RsvpTeP2MpLspParser.java | 3 +- .../identifier/TunnelIdentifierHandler.java | 3 +- .../identifier/TunnelIdentifierParser.java | 6 +- .../TunnelIdentifierSerializer.java | 8 +- .../bgp/evpn/impl/esi/types/ASGenParser.java | 3 +- .../evpn/impl/esi/types/AbstractEsiType.java | 2 +- .../evpn/impl/esi/types/ArbitraryParser.java | 6 +- .../bgp/evpn/impl/esi/types/EsiModelUtil.java | 32 +++-- .../bgp/evpn/impl/esi/types/LacpParser.java | 3 +- .../bgp/evpn/impl/esi/types/LanParser.java | 6 +- .../bgp/evpn/impl/esi/types/MacParser.java | 3 +- .../evpn/impl/esi/types/RouterIdParser.java | 6 +- .../communities/ESImpRouteTargetExtCom.java | 12 +- .../communities/Layer2AttributesExtCom.java | 34 ++--- .../bgp/evpn/impl/nlri/AbstractEvpnNlri.java | 2 +- .../bgp/evpn/impl/nlri/EthADRParser.java | 37 +++--- .../bgp/evpn/impl/nlri/EthSegRParser.java | 28 ++-- .../bgp/evpn/impl/nlri/EvpnNlriParser.java | 38 +++--- .../evpn/impl/nlri/IncMultEthTagRParser.java | 49 +++---- .../bgp/evpn/impl/nlri/MACIpAdvRParser.java | 57 ++++---- .../bgp/evpn/impl/nlri/NlriModelUtil.java | 30 +++-- .../protocol/bgp/evpn/spi/EsiParser.java | 2 +- .../protocol/bgp/evpn/spi/EsiRegistry.java | 11 +- .../protocol/bgp/evpn/spi/EsiSerializer.java | 4 +- .../protocol/bgp/evpn/spi/EvpnRegistry.java | 8 +- .../protocol/bgp/evpn/spi/EvpnSerializer.java | 6 +- .../evpn/spi/pojo/SimpleEsiTypeRegistry.java | 13 +- .../evpn/spi/pojo/SimpleEvpnNlriRegistry.java | 13 +- .../bgp/evpn/impl/BGPActivatorTest.java | 11 +- .../bgp/evpn/impl/EvpnRibSupportTest.java | 62 +++++---- .../protocol/bgp/evpn/impl/EvpnTestUtil.java | 8 +- .../bgp/evpn/impl/TableTypeActivatorTest.java | 3 +- .../tunnel/identifier/OpaqueUtilTest.java | 31 ++--- .../PAddressPMulticastGroupUtilTest.java | 39 +++--- .../PMSITunnelAttributeHandlerTest.java | 88 +++++++------ .../PMSITunnelAttributeHandlerTestUtil.java | 122 ++++++++++-------- .../evpn/impl/esi/types/ASGenParserTest.java | 15 ++- .../impl/esi/types/ArbitraryParserTest.java | 13 +- .../evpn/impl/esi/types/LacpParserTest.java | 21 +-- .../evpn/impl/esi/types/LanParserTest.java | 16 ++- .../evpn/impl/esi/types/MacParserTest.java | 19 +-- .../impl/esi/types/RouterIdParserTest.java | 13 +- .../communities/DefaultGatewayExtComTest.java | 5 +- .../communities/ESILabelExtComTest.java | 5 +- .../ESImpRouteTargetExtComTest.java | 5 +- .../Layer2AttributesExtComTest.java | 33 ++--- .../communities/MACMobExtComTest.java | 5 +- .../bgp/evpn/impl/nlri/EthADRParserTest.java | 12 +- .../bgp/evpn/impl/nlri/EthSegRParserTest.java | 42 +++--- .../nlri/EvpnNlriAttributesParserTest.java | 27 ++-- .../evpn/impl/nlri/EvpnNlriParserTest.java | 46 ++++--- .../impl/nlri/IncMultEthTagRParserTest.java | 9 +- .../evpn/impl/nlri/MACIpAdvRParserTest.java | 42 +++--- .../spi/pojo/SimpleEsiTypeRegistryTest.java | 20 +-- .../spi/pojo/SimpleEvpnNlriRegistryTest.java | 13 +- 66 files changed, 778 insertions(+), 572 deletions(-) diff --git a/bgp/evpn/pom.xml b/bgp/evpn/pom.xml index 09faedaea5..125637b7e7 100644 --- a/bgp/evpn/pom.xml +++ b/bgp/evpn/pom.xml @@ -119,6 +119,25 @@ + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + checkstyle.violationSeverity=error + + + + org.codehaus.mojo + findbugs-maven-plugin + + true + + + + + scm:git:ssh://git.opendaylight.org:29418/bgpcep.git scm:git:ssh://git.opendaylight.org:29418/bgpcep.git diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/BGPActivator.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/BGPActivator.java index 6b6f4726e4..006973950a 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/BGPActivator.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/BGPActivator.java @@ -8,6 +8,7 @@ package org.opendaylight.protocol.bgp.evpn.impl; +import com.google.common.annotations.VisibleForTesting; import java.util.ArrayList; import java.util.List; import org.opendaylight.protocol.bgp.evpn.impl.attributes.PMSITunnelAttributeHandler; @@ -34,8 +35,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.type import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv6NextHopCase; public final class BGPActivator extends AbstractBGPExtensionProviderActivator { - private static final int L2VPN_AFI = 25; - private static final int EVPN_SAFI = 70; + @VisibleForTesting + static final int L2VPN_AFI = 25; + @VisibleForTesting + static final int EVPN_SAFI = 70; @Override protected List startImpl(final BGPExtensionProviderContext context) { @@ -53,8 +56,10 @@ public final class BGPActivator extends AbstractBGPExtensionProviderActivator { return regs; } - private static void registerAttributesHandler(final BGPExtensionProviderContext context, final List regs) { - final PMSITunnelAttributeHandler pmsiParser = new PMSITunnelAttributeHandler(context.getAddressFamilyRegistry()); + private static void registerAttributesHandler(final BGPExtensionProviderContext context, + final List regs) { + final PMSITunnelAttributeHandler pmsiParser = + new PMSITunnelAttributeHandler(context.getAddressFamilyRegistry()); regs.add(context.registerAttributeParser(pmsiParser.getType(), pmsiParser)); regs.add(context.registerAttributeSerializer(pmsiParser.getClazz(), pmsiParser)); } @@ -67,7 +72,8 @@ public final class BGPActivator extends AbstractBGPExtensionProviderActivator { regs.add(context.registerNlriSerializer(EvpnRoutes.class, nlriHandler)); } - private static void registerExtendedCommunities(final BGPExtensionProviderContext context, final List regs) { + private static void registerExtendedCommunities(final BGPExtensionProviderContext context, + final List regs) { final DefaultGatewayExtCom defGEC = new DefaultGatewayExtCom(); regs.add(context.registerExtendedCommunityParser(defGEC.getType(true), defGEC.getSubType(), defGEC)); regs.add(context.registerExtendedCommunitySerializer(DefaultGatewayExtendedCommunityCase.class, defGEC)); @@ -77,7 +83,8 @@ public final class BGPActivator extends AbstractBGPExtensionProviderActivator { regs.add(context.registerExtendedCommunitySerializer(EsiLabelExtendedCommunityCase.class, esiLEC)); final ESImpRouteTargetExtCom esImpEC = new ESImpRouteTargetExtCom(); - regs.add(context.registerExtendedCommunityParser(esImpEC.getType(true), esImpEC.getSubType(), esImpEC)); + regs.add(context.registerExtendedCommunityParser(esImpEC.getType(true), + esImpEC.getSubType(), esImpEC)); regs.add(context.registerExtendedCommunitySerializer(EsImportRouteExtendedCommunityCase.class, esImpEC)); final MACMobExtCom macEC = new MACMobExtCom(); diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/EvpnRibSupport.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/EvpnRibSupport.java index 610594e70b..0099ac6842 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/EvpnRibSupport.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/EvpnRibSupport.java @@ -52,7 +52,8 @@ final class EvpnRibSupport extends AbstractRIBSupport { private static final NodeIdentifier NLRI_ROUTES_LIST = NodeIdentifier.create(EvpnDestination.QNAME); private EvpnRibSupport() { - super(EvpnRoutesCase.class, EvpnRoutes.class, EvpnRoute.class, L2vpnAddressFamily.class, EvpnSubsequentAddressFamily.class, DestinationEvpn.QNAME); + super(EvpnRoutesCase.class, EvpnRoutes.class, EvpnRoute.class, + L2vpnAddressFamily.class, EvpnSubsequentAddressFamily.class, DestinationEvpn.QNAME); } static EvpnRibSupport getInstance() { @@ -79,16 +80,18 @@ final class EvpnRibSupport extends AbstractRIBSupport { @Nonnull @Override protected DestinationType buildDestination(@Nonnull final Collection routes) { - return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update.attributes.mp.reach.nlri.advertized - .routes.destination.type.DestinationEvpnCaseBuilder().setDestinationEvpn(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml. - ns.yang.bgp.evpn.rev171213.update.attributes.mp.reach.nlri.advertized.routes.destination.type.destination.evpn._case. - DestinationEvpnBuilder().setEvpnDestination(extractRoutes(routes)).build()).build(); + return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update + .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationEvpnCaseBuilder() + .setDestinationEvpn(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn + .rev171213.update.attributes.mp.reach.nlri.advertized.routes.destination.type.destination + .evpn._case.DestinationEvpnBuilder().setEvpnDestination(extractRoutes(routes)).build()).build(); } @Nonnull @Override protected DestinationType buildWithdrawnDestination(@Nonnull final Collection routes) { - return new DestinationEvpnCaseBuilder().setDestinationEvpn(new DestinationEvpnBuilder().setEvpnDestination(extractRoutes(routes)).build()).build(); + return new DestinationEvpnCaseBuilder().setDestinationEvpn(new DestinationEvpnBuilder() + .setEvpnDestination(extractRoutes(routes)).build()).build(); } private static List extractRoutes(final Collection routes) { @@ -99,7 +102,8 @@ final class EvpnRibSupport extends AbstractRIBSupport { protected void processDestination(final DOMDataWriteTransaction tx, final YangInstanceIdentifier routesPath, final ContainerNode destination, final ContainerNode attributes, final ApplyRoute function) { if (destination != null) { - final Optional> maybeRoutes = destination.getChild(NLRI_ROUTES_LIST); + final Optional> maybeRoutes = destination + .getChild(NLRI_ROUTES_LIST); if (maybeRoutes.isPresent()) { final DataContainerChild routes = maybeRoutes.get(); if (routes instanceof UnkeyedListNode) { diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/PMSITunnelAttributeHandler.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/PMSITunnelAttributeHandler.java index 160e345cc4..05a2f7f493 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/PMSITunnelAttributeHandler.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/PMSITunnelAttributeHandler.java @@ -56,7 +56,7 @@ public final class PMSITunnelAttributeHandler implements AttributeParser, Attrib private static void parseMpls(final PmsiTunnelBuilder pmsiTunnelBuilder, final ByteBuf buffer) { final MplsLabel mpls = MplsLabelUtil.mplsLabelForByteBuf(buffer); - if(mpls.getValue() != 0) { + if (mpls.getValue() != 0) { pmsiTunnelBuilder.setMplsLabel(mpls); } } @@ -88,7 +88,7 @@ public final class PMSITunnelAttributeHandler implements AttributeParser, Attrib } private static void serializeMpls(final MplsLabel mplsLabel, final ByteBuf body) { - if(mplsLabel == null) { + if (mplsLabel == null) { body.writeZero(MPLS_LENGTH); } body.writeBytes(MplsLabelUtil.byteBufForMplsLabel(mplsLabel)); diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/BidirPimTreeParser.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/BidirPimTreeParser.java index b0053791b8..a12544c039 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/BidirPimTreeParser.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/BidirPimTreeParser.java @@ -17,16 +17,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tun final class BidirPimTreeParser implements TunnelIdentifierSerializer, TunnelIdentifierParser { @Override public int serialize(final TunnelIdentifier tunnelIdentifier, final ByteBuf buffer) { - Preconditions.checkArgument(tunnelIdentifier instanceof BidirPimTree, "The tunnelIdentifier %s is not BidirPimTree type.", tunnelIdentifier); - PAddressPMulticastGroupUtil.serializeSenderPMulticastGroup(((BidirPimTree) tunnelIdentifier).getBidirPimTree(), buffer); + Preconditions.checkArgument(tunnelIdentifier instanceof BidirPimTree, + "The tunnelIdentifier %s is not BidirPimTree type.", tunnelIdentifier); + PAddressPMulticastGroupUtil + .serializeSenderPMulticastGroup(((BidirPimTree) tunnelIdentifier).getBidirPimTree(), buffer); return TunnelType.BIDIR_PIM_TREE.getIntValue(); } @Override public TunnelIdentifier parse(final ByteBuf buffer) { - final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.bidir.pim.tree. - BidirPimTreeBuilder bidirPimTree = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.bidir.pim.tree. - BidirPimTreeBuilder(PAddressPMulticastGroupUtil.parseSenderPMulticastGroup(buffer)); + final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi + .tunnel.tunnel.identifier.bidir.pim.tree.BidirPimTreeBuilder bidirPimTree = + new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel + .pmsi.tunnel.tunnel.identifier.bidir.pim.tree.BidirPimTreeBuilder(PAddressPMulticastGroupUtil + .parseSenderPMulticastGroup(buffer)); return new BidirPimTreeBuilder().setBidirPimTree(bidirPimTree.build()).build(); } } diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/IngressReplicationParser.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/IngressReplicationParser.java index 20bfd30f22..619664d6fa 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/IngressReplicationParser.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/IngressReplicationParser.java @@ -20,19 +20,22 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tun final class IngressReplicationParser implements TunnelIdentifierSerializer, TunnelIdentifierParser { @Override public int serialize(final TunnelIdentifier tunnelIdentifier, final ByteBuf buffer) { - Preconditions.checkArgument(tunnelIdentifier instanceof IngressReplication, "The tunnelIdentifier %s is not IngressReplication type.", tunnelIdentifier); - final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.ingress.replication. - IngressReplication ingressReplication = ((IngressReplication) tunnelIdentifier).getIngressReplication(); + Preconditions.checkArgument(tunnelIdentifier instanceof IngressReplication, + "The tunnelIdentifier %s is not IngressReplication type.", tunnelIdentifier); + final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi + .tunnel.tunnel.identifier.ingress.replication.IngressReplication ingressReplication = + ((IngressReplication) tunnelIdentifier).getIngressReplication(); serializeIpAddress(ingressReplication.getReceivingEndpointAddress(), buffer); return TunnelType.INGRESS_REPLICATION.getIntValue(); } @Override public TunnelIdentifier parse(final ByteBuf buffer) { - final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier - .ingress.replication.IngressReplication builder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi - .tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.ingress.replication.IngressReplicationBuilder() - .setReceivingEndpointAddress(parseIpAddress(buffer.readableBytes(), buffer)).build(); + final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi + .tunnel.tunnel.identifier.ingress.replication.IngressReplication builder = + new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel + .pmsi.tunnel.tunnel.identifier.ingress.replication.IngressReplicationBuilder() + .setReceivingEndpointAddress(parseIpAddress(buffer.readableBytes(), buffer)).build(); return new IngressReplicationBuilder().setIngressReplication(builder).build(); } } diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/MldpMp2mpLspParser.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/MldpMp2mpLspParser.java index bd4d31d960..311a683e7f 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/MldpMp2mpLspParser.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/MldpMp2mpLspParser.java @@ -20,9 +20,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tun final class MldpMp2mpLspParser implements TunnelIdentifierSerializer, TunnelIdentifierParser { @Override public int serialize(final TunnelIdentifier tunnelIdentifier, final ByteBuf buffer) { - Preconditions.checkArgument(tunnelIdentifier instanceof MldpMp2mpLsp, "The tunnelIdentifier %s is not MldpMp2mpLsp type.", tunnelIdentifier); - final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp. - MldpMp2mpLsp mldpMp2mpLsp = ((MldpMp2mpLsp) tunnelIdentifier).getMldpMp2mpLsp(); + Preconditions.checkArgument(tunnelIdentifier instanceof MldpMp2mpLsp, + "The tunnelIdentifier %s is not MldpMp2mpLsp type.", tunnelIdentifier); + final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi + .tunnel.tunnel.identifier.mldp.mp2mp.lsp.MldpMp2mpLsp mldpMp2mpLsp = + ((MldpMp2mpLsp) tunnelIdentifier).getMldpMp2mpLsp(); if (!OpaqueUtil.serializeOpaque(mldpMp2mpLsp, buffer)) { return NO_TUNNEL_INFORMATION_PRESENT; } @@ -35,9 +37,10 @@ final class MldpMp2mpLspParser implements TunnelIdentifierSerializer, TunnelIden if (opaque == null) { return null; } - final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp. - MldpMp2mpLsp mldpMp2mpLsp = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp. - MldpMp2mpLspBuilder(opaque).build(); + final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi + .tunnel.tunnel.identifier.mldp.mp2mp.lsp.MldpMp2mpLsp mldpMp2mpLsp = + new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel + .pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp.MldpMp2mpLspBuilder(opaque).build(); return new MldpMp2mpLspBuilder().setMldpMp2mpLsp(mldpMp2mpLsp).build(); } } diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/MldpP2mpLspParser.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/MldpP2mpLspParser.java index cc30e4e759..e0d57a433a 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/MldpP2mpLspParser.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/MldpP2mpLspParser.java @@ -41,9 +41,11 @@ final class MldpP2mpLspParser implements TunnelIdentifierSerializer, TunnelIdent @Override public int serialize(final TunnelIdentifier tunnelIdentifier, final ByteBuf buffer) { - Preconditions.checkArgument(tunnelIdentifier instanceof MldpP2mpLsp, "The tunnelIdentifier %s is not RsvpTeP2mpLps type.", tunnelIdentifier); - final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp - .p2mp.lsp.MldpP2mpLsp mldpP2mpLsp = ((MldpP2mpLsp) tunnelIdentifier).getMldpP2mpLsp(); + Preconditions.checkArgument(tunnelIdentifier instanceof MldpP2mpLsp, + "The tunnelIdentifier %s is not RsvpTeP2mpLps type.", tunnelIdentifier); + final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi + .tunnel.tunnel.identifier.mldp.p2mp.lsp.MldpP2mpLsp mldpP2mpLsp = + ((MldpP2mpLsp) tunnelIdentifier).getMldpP2mpLsp(); final ByteBuf opaqueValues = Unpooled.buffer(); final int addressFamily = getAddressFamilyValue(mldpP2mpLsp.getAddressFamily()); @@ -79,13 +81,16 @@ final class MldpP2mpLspParser implements TunnelIdentifierSerializer, TunnelIdent @Override public TunnelIdentifier parse(final ByteBuf buffer) { - final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp - .p2mp.lsp.MldpP2mpLspBuilder mldpP2mpLsp = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp - .p2mp.lsp.MldpP2mpLspBuilder(); + final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi + .tunnel.tunnel.identifier.mldp.p2mp.lsp.MldpP2mpLspBuilder mldpP2mpLsp = + new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel + .pmsi.tunnel.tunnel.identifier.mldp.p2mp.lsp.MldpP2mpLspBuilder(); buffer.skipBytes(RESERVED); - final Class addressFamily = this.addressFamilyRegistry.classForFamily(buffer.readUnsignedShort()); + final Class addressFamily = this.addressFamilyRegistry + .classForFamily(buffer.readUnsignedShort()); if (addressFamily == null) { - LOG.debug("Skipping serialization of TunnelIdentifier {}, address family type supported", ByteBufUtil.hexDump(buffer)); + LOG.debug("Skipping serialization of TunnelIdentifier {}, address family type supported", + ByteBufUtil.hexDump(buffer)); return null; } mldpP2mpLsp.setAddressFamily(addressFamily); diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/OpaqueUtil.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/OpaqueUtil.java index d5909b605c..ab975b0d6d 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/OpaqueUtil.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/OpaqueUtil.java @@ -38,17 +38,17 @@ final class OpaqueUtil { static boolean serializeOpaque(final Opaque opaque, final ByteBuf byteBuf) { final Short type = opaque.getOpaqueType(); switch (type) { - case GENERIC_LSP_IDENTIFIER: - ByteBufWriteUtil.writeUnsignedByte(type, byteBuf); - writeGeneric(opaque.getOpaque(), byteBuf); - break; - case EXTENDED_TYPE: - ByteBufWriteUtil.writeUnsignedByte(type, byteBuf); - writeExtended(opaque.getOpaque(), opaque.getOpaqueExtendedType(), byteBuf); - break; - default: - LOG.debug("Skipping serialization of Opaque Value {}", opaque); - return false; + case GENERIC_LSP_IDENTIFIER: + ByteBufWriteUtil.writeUnsignedByte(type, byteBuf); + writeGeneric(opaque.getOpaque(), byteBuf); + break; + case EXTENDED_TYPE: + ByteBufWriteUtil.writeUnsignedByte(type, byteBuf); + writeExtended(opaque.getOpaque(), opaque.getOpaqueExtendedType(), byteBuf); + break; + default: + LOG.debug("Skipping serialization of Opaque Value {}", opaque); + return false; } return true; } @@ -75,17 +75,17 @@ final class OpaqueUtil { final short type = buffer.readUnsignedByte(); final OpaqueValueBuilder builder = new OpaqueValueBuilder(); switch (type) { - case GENERIC_LSP_IDENTIFIER: - builder.setOpaque(buildOpaqueValue(buffer)); - break; - case EXTENDED_TYPE: - buildExtended(builder, buffer); - break; - default: - final int length = buffer.readUnsignedShort(); - buffer.skipBytes(length); - LOG.debug("Skipping parsing of Opaque Value {}", buffer); - return null; + case GENERIC_LSP_IDENTIFIER: + builder.setOpaque(buildOpaqueValue(buffer)); + break; + case EXTENDED_TYPE: + buildExtended(builder, buffer); + break; + default: + final int length = buffer.readUnsignedShort(); + buffer.skipBytes(length); + LOG.debug("Skipping parsing of Opaque Value {}", buffer); + return null; } builder.setOpaqueType(type); return builder.build(); diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/PimSmTreeParser.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/PimSmTreeParser.java index c237afe8fd..649aad1850 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/PimSmTreeParser.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/PimSmTreeParser.java @@ -8,7 +8,6 @@ package org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier; - import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.TunnelIdentifier; @@ -18,16 +17,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tun final class PimSmTreeParser implements TunnelIdentifierSerializer, TunnelIdentifierParser { @Override public int serialize(final TunnelIdentifier tunnelIdentifier, final ByteBuf buffer) { - Preconditions.checkArgument(tunnelIdentifier instanceof PimSmTree, "The tunnelIdentifier %s is not PimSmTree type.", tunnelIdentifier); - PAddressPMulticastGroupUtil.serializeSenderPMulticastGroup(((PimSmTree) tunnelIdentifier).getPimSmTree(), buffer); + Preconditions.checkArgument(tunnelIdentifier instanceof PimSmTree, + "The tunnelIdentifier %s is not PimSmTree type.", tunnelIdentifier); + PAddressPMulticastGroupUtil.serializeSenderPMulticastGroup(((PimSmTree) tunnelIdentifier) + .getPimSmTree(), buffer); return TunnelType.PIM_SM_TREE.getIntValue(); } @Override public TunnelIdentifier parse(final ByteBuf buffer) { - final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.pim.sm.tree. - PimSmTreeBuilder pimSmTree = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.pim.sm.tree. - PimSmTreeBuilder(PAddressPMulticastGroupUtil.parseSenderPMulticastGroup(buffer)); + final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi + .tunnel.tunnel.identifier.pim.sm.tree.PimSmTreeBuilder pimSmTree = + new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel + .pmsi.tunnel.tunnel.identifier.pim.sm.tree.PimSmTreeBuilder(PAddressPMulticastGroupUtil + .parseSenderPMulticastGroup(buffer)); return new PimSmTreeBuilder().setPimSmTree(pimSmTree.build()).build(); } } diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/PimSsmTreeParser.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/PimSsmTreeParser.java index 43d9a54473..298248c0d2 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/PimSsmTreeParser.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/PimSsmTreeParser.java @@ -17,16 +17,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tun final class PimSsmTreeParser implements TunnelIdentifierSerializer, TunnelIdentifierParser { @Override public int serialize(final TunnelIdentifier tunnelIdentifier, final ByteBuf buffer) { - Preconditions.checkArgument(tunnelIdentifier instanceof PimSsmTree, "The tunnelIdentifier %s is not PimSsmTree type.", tunnelIdentifier); - PAddressPMulticastGroupUtil.serializeSenderPMulticastGroup(((PimSsmTree) tunnelIdentifier).getPimSsmTree(), buffer); + Preconditions.checkArgument(tunnelIdentifier instanceof PimSsmTree, + "The tunnelIdentifier %s is not PimSsmTree type.", tunnelIdentifier); + PAddressPMulticastGroupUtil + .serializeSenderPMulticastGroup(((PimSsmTree) tunnelIdentifier).getPimSsmTree(), buffer); return TunnelType.PIM_SSM_TREE.getIntValue(); } @Override public TunnelIdentifier parse(final ByteBuf buffer) { - final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.pim.ssm.tree. - PimSsmTreeBuilder pimSsmTree = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.pim.ssm.tree. - PimSsmTreeBuilder(PAddressPMulticastGroupUtil.parseSenderPMulticastGroup(buffer)); + final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi + .tunnel.tunnel.identifier.pim.ssm.tree.PimSsmTreeBuilder pimSsmTree = + new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel + .pmsi.tunnel.tunnel.identifier.pim.ssm.tree.PimSsmTreeBuilder(PAddressPMulticastGroupUtil + .parseSenderPMulticastGroup(buffer)); return new PimSsmTreeBuilder().setPimSsmTree(pimSsmTree.build()).build(); } } diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/RsvpTeP2MpLspParser.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/RsvpTeP2MpLspParser.java index c39fce5c5b..16e7b67a86 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/RsvpTeP2MpLspParser.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/RsvpTeP2MpLspParser.java @@ -26,7 +26,8 @@ final class RsvpTeP2MpLspParser implements TunnelIdentifierSerializer, TunnelIde @Override public int serialize(final TunnelIdentifier tunnelIdentifier, final ByteBuf buffer) { - Preconditions.checkArgument(tunnelIdentifier instanceof RsvpTeP2mpLsp, "The tunnelIdentifier %s is not RsvpTeP2mpLps type.", tunnelIdentifier); + Preconditions.checkArgument(tunnelIdentifier instanceof RsvpTeP2mpLsp, + "The tunnelIdentifier %s is not RsvpTeP2mpLps type.", tunnelIdentifier); final RsvpTeP2mpLps rsvpTeP2mpLsp = ((RsvpTeP2mpLsp) tunnelIdentifier).getRsvpTeP2mpLps(); ByteBufWriteUtil.writeUnsignedInt(rsvpTeP2mpLsp.getP2mpId(), buffer); buffer.writeZero(RESERVED); diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/TunnelIdentifierHandler.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/TunnelIdentifierHandler.java index d6c34c87b6..987ad0a3eb 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/TunnelIdentifierHandler.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/TunnelIdentifierHandler.java @@ -21,7 +21,8 @@ public final class TunnelIdentifierHandler { private static final Logger LOG = LoggerFactory.getLogger(TunnelIdentifierHandler.class); private static final String SKIP_SERIALIZATION = "Skipping serialization of PMSI Tunnel Attribute {}"; private static final String SKIP_PARSE = "Skipping parsing of PMSI Tunnel Attribute type {}"; - private final HandlerRegistry handlers = new HandlerRegistry<>(); + private final HandlerRegistry handlers = + new HandlerRegistry<>(); public TunnelIdentifierHandler(final AddressFamilyRegistry addressFamilyRegistry) { final RsvpTeP2MpLspParser rsvpTeP2MpLspParser = new RsvpTeP2MpLspParser(); diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/TunnelIdentifierParser.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/TunnelIdentifierParser.java index dc67b565a2..6707b1da1b 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/TunnelIdentifierParser.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/TunnelIdentifierParser.java @@ -9,13 +9,17 @@ package org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier; import io.netty.buffer.ByteBuf; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.TunnelIdentifier; interface TunnelIdentifierParser { /** * Parse Tunnel Identifier from buffer. + * * @param buffer Encoded Tunnel Identifier in ByteBuf. * @return Parsed Tunnel Identifier body */ - TunnelIdentifier parse(ByteBuf buffer); + @Nullable + TunnelIdentifier parse(@Nonnull ByteBuf buffer); } diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/TunnelIdentifierSerializer.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/TunnelIdentifierSerializer.java index 8a83505b6c..cc1ad603ef 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/TunnelIdentifierSerializer.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/TunnelIdentifierSerializer.java @@ -9,14 +9,16 @@ package org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier; import io.netty.buffer.ByteBuf; +import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.TunnelIdentifier; interface TunnelIdentifierSerializer { /** - * Serialize tunnel identifier + * Serialize tunnel identifier. + * * @param tunnelIdentifier Tunnel Identifier body - * @param buffer Encoded Tunnel Identifier in ByteBuf + * @param buffer Encoded Tunnel Identifier in ByteBuf * @return Tunnel identifier Type */ - int serialize(TunnelIdentifier tunnelIdentifier, ByteBuf buffer); + int serialize(@Nonnull TunnelIdentifier tunnelIdentifier, @Nonnull ByteBuf buffer); } diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/ASGenParser.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/ASGenParser.java index 620ec0d94a..55a303170c 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/ASGenParser.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/ASGenParser.java @@ -27,7 +27,8 @@ final class ASGenParser extends AbstractEsiType { @Override public void serializeBody(final Esi esi, final ByteBuf body) { - Preconditions.checkArgument(esi instanceof AsGeneratedCase, "Unknown esi instance. Passed %s. Needed AsGeneratedCase.", esi.getClass()); + Preconditions.checkArgument(esi instanceof AsGeneratedCase, + "Unknown esi instance. Passed %s. Needed AsGeneratedCase.", esi.getClass()); final AsGenerated asGen = ((AsGeneratedCase) esi).getAsGenerated(); writeUnsignedInt(asGen.getAs().getValue(), body); writeUnsignedInt(asGen.getLocalDiscriminator(), body); diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/AbstractEsiType.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/AbstractEsiType.java index e9bd5fd43c..8b8ab4a911 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/AbstractEsiType.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/AbstractEsiType.java @@ -28,7 +28,7 @@ abstract class AbstractEsiType implements EsiParser, EsiSerializer { buffer.writeBytes(body); } - protected abstract void serializeBody(final Esi esi, final ByteBuf buffer); + protected abstract void serializeBody(Esi esi, ByteBuf buffer); protected abstract EsiType getType(); } diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/ArbitraryParser.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/ArbitraryParser.java index 61fb881b00..dee87772f1 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/ArbitraryParser.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/ArbitraryParser.java @@ -25,7 +25,8 @@ final class ArbitraryParser extends AbstractEsiType { @Override public void serializeBody(final Esi esiCase, final ByteBuf body) { - Preconditions.checkArgument(esiCase instanceof ArbitraryCase, "Unknown esi instance. Passed %s. Needed ArbitraryCase.", esiCase.getClass()); + Preconditions.checkArgument(esiCase instanceof ArbitraryCase, + "Unknown esi instance. Passed %s. Needed ArbitraryCase.", esiCase.getClass()); body.writeBytes(((ArbitraryCase) esiCase).getArbitrary().getArbitrary()); } @@ -42,6 +43,7 @@ final class ArbitraryParser extends AbstractEsiType { @Override public Esi parseEsi(final ByteBuf body) { - return new ArbitraryCaseBuilder().setArbitrary(new ArbitraryBuilder().setArbitrary(ByteArray.readBytes(body, ARBITRARY_LENGTH)).build()).build(); + return new ArbitraryCaseBuilder().setArbitrary(new ArbitraryBuilder() + .setArbitrary(ByteArray.readBytes(body, ARBITRARY_LENGTH)).build()).build(); } } diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/EsiModelUtil.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/EsiModelUtil.java index 2fd47e8427..89ee156b50 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/EsiModelUtil.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/EsiModelUtil.java @@ -20,15 +20,24 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; final class EsiModelUtil { - static final NodeIdentifier LD_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "local-discriminator").intern()); - static final NodeIdentifier ARB_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "arbitrary").intern()); - static final NodeIdentifier AS_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "as").intern()); - static final NodeIdentifier LACP_MAC_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "ce-lacp-mac-address").intern()); - static final NodeIdentifier PK_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "ce-lacp-port-key").intern()); - static final NodeIdentifier BRIDGE_MAC_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "root-bridge-mac-address").intern()); - static final NodeIdentifier RBP_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "root-bridge-priority").intern()); - static final NodeIdentifier SYSTEM_MAC_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "system-mac-address").intern()); - static final NodeIdentifier RD_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "router-id").intern()); + static final NodeIdentifier LD_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, + "local-discriminator").intern()); + static final NodeIdentifier ARB_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, + "arbitrary").intern()); + static final NodeIdentifier AS_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, + "as").intern()); + static final NodeIdentifier LACP_MAC_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, + "ce-lacp-mac-address").intern()); + static final NodeIdentifier PK_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, + "ce-lacp-port-key").intern()); + static final NodeIdentifier BRIDGE_MAC_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, + "root-bridge-mac-address").intern()); + static final NodeIdentifier RBP_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, + "root-bridge-priority").intern()); + static final NodeIdentifier SYSTEM_MAC_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, + "system-mac-address").intern()); + static final NodeIdentifier RD_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, + "router-id").intern()); private EsiModelUtil() { throw new UnsupportedOperationException(); @@ -40,8 +49,9 @@ final class EsiModelUtil { static Arbitrary extractArbitrary(final ContainerNode esi) { final byte[] arbitrary = (byte[]) esi.getChild(ARB_NID).get().getValue(); - Preconditions.checkArgument(arbitrary.length == ArbitraryParser.ARBITRARY_LENGTH, "Wrong length of array of bytes. Expected: %s Passed: %s " + - ";", ArbitraryParser.ARBITRARY_LENGTH, arbitrary.length); + Preconditions.checkArgument(arbitrary.length == ArbitraryParser.ARBITRARY_LENGTH, + "Wrong length of array of bytes. Expected: %s Passed: %s " + + ";", ArbitraryParser.ARBITRARY_LENGTH, arbitrary.length); return new ArbitraryBuilder().setArbitrary(arbitrary).build(); } diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/LacpParser.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/LacpParser.java index a09af8cf4e..c134b332de 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/LacpParser.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/LacpParser.java @@ -28,7 +28,8 @@ final class LacpParser extends AbstractEsiType { @Override public void serializeBody(final Esi esi, final ByteBuf body) { - Preconditions.checkArgument(esi instanceof LacpAutoGeneratedCase, "Unknown esi instance. Passed %s. Needed LacpAutoGeneratedCase.", esi.getClass()); + Preconditions.checkArgument(esi instanceof LacpAutoGeneratedCase, + "Unknown esi instance. Passed %s. Needed LacpAutoGeneratedCase.", esi.getClass()); final LacpAutoGenerated lacp = ((LacpAutoGeneratedCase) esi).getLacpAutoGenerated(); body.writeBytes(IetfYangUtil.INSTANCE.bytesFor(lacp.getCeLacpMacAddress())); ByteBufWriteUtil.writeUnsignedShort(lacp.getCeLacpPortKey(), body); diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/LanParser.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/LanParser.java index 587ca28bf0..7523c0c8c0 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/LanParser.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/LanParser.java @@ -28,7 +28,8 @@ final class LanParser extends AbstractEsiType { @Override public void serializeBody(final Esi esi, final ByteBuf body) { - Preconditions.checkArgument(esi instanceof LanAutoGeneratedCase, "Unknown esi instance. Passed %s. Needed LanAutoGeneratedCase.", esi.getClass()); + Preconditions.checkArgument(esi instanceof LanAutoGeneratedCase, + "Unknown esi instance. Passed %s. Needed LanAutoGeneratedCase.", esi.getClass()); final LanAutoGenerated lan = ((LanAutoGeneratedCase) esi).getLanAutoGenerated(); body.writeBytes(IetfYangUtil.INSTANCE.bytesFor(lan.getRootBridgeMacAddress())); ByteBufWriteUtil.writeUnsignedShort(lan.getRootBridgePriority(), body); @@ -51,7 +52,8 @@ final class LanParser extends AbstractEsiType { @Override public Esi parseEsi(final ByteBuf buffer) { final LanAutoGenerated t2 = new LanAutoGeneratedBuilder() - .setRootBridgeMacAddress(IetfYangUtil.INSTANCE.macAddressFor(ByteArray.readBytes(buffer, MAC_ADDRESS_LENGTH))) + .setRootBridgeMacAddress(IetfYangUtil.INSTANCE + .macAddressFor(ByteArray.readBytes(buffer, MAC_ADDRESS_LENGTH))) .setRootBridgePriority(buffer.readUnsignedShort()).build(); return new LanAutoGeneratedCaseBuilder().setLanAutoGenerated(t2).build(); } diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/MacParser.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/MacParser.java index 93f2ca91b9..07a6941404 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/MacParser.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/MacParser.java @@ -29,7 +29,8 @@ final class MacParser extends AbstractEsiType { @Override public void serializeBody(final Esi esi, final ByteBuf body) { - Preconditions.checkArgument(esi instanceof MacAutoGeneratedCase, "Unknown esi instance. Passed %s. Needed MacAutoGeneratedCase.", esi.getClass()); + Preconditions.checkArgument(esi instanceof MacAutoGeneratedCase, + "Unknown esi instance. Passed %s. Needed MacAutoGeneratedCase.", esi.getClass()); final MacAutoGenerated macAuto = ((MacAutoGeneratedCase) esi).getMacAutoGenerated(); body.writeBytes(IetfYangUtil.INSTANCE.bytesFor(macAuto.getSystemMacAddress())); ByteBufWriteUtil.writeMedium(macAuto.getLocalDiscriminator().getValue().intValue(), body); diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/RouterIdParser.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/RouterIdParser.java index f282f97231..7a17154f25 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/RouterIdParser.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/RouterIdParser.java @@ -27,7 +27,8 @@ final class RouterIdParser extends AbstractEsiType { @Override public void serializeBody(final Esi esi, final ByteBuf body) { - Preconditions.checkArgument(esi instanceof RouterIdGeneratedCase, "Unknown esi instance. Passed %s. Needed RouterIdGeneratedCase.", esi.getClass()); + Preconditions.checkArgument(esi instanceof RouterIdGeneratedCase, + "Unknown esi instance. Passed %s. Needed RouterIdGeneratedCase.", esi.getClass()); final RouterIdGenerated routerID = ((RouterIdGeneratedCase) esi).getRouterIdGenerated(); ByteBufWriteUtil.writeIpv4Address(routerID.getRouterId(), body); ByteBufWriteUtil.writeUnsignedInt(routerID.getLocalDiscriminator(), body); @@ -49,7 +50,8 @@ final class RouterIdParser extends AbstractEsiType { @Override public Esi parseEsi(final ByteBuf buffer) { - final RouterIdGenerated routerID = new RouterIdGeneratedBuilder().setRouterId(Ipv4Util.addressForByteBuf(buffer)) + final RouterIdGenerated routerID = new RouterIdGeneratedBuilder() + .setRouterId(Ipv4Util.addressForByteBuf(buffer)) .setLocalDiscriminator(buffer.readUnsignedInt()).build(); return new RouterIdGeneratedCaseBuilder().setRouterIdGenerated(routerID).build(); } diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/ESImpRouteTargetExtCom.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/ESImpRouteTargetExtCom.java index 02c69bd6e6..9f3e7efd8f 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/ESImpRouteTargetExtCom.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/ESImpRouteTargetExtCom.java @@ -9,8 +9,6 @@ package org.opendaylight.protocol.bgp.evpn.impl.extended.communities; import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; -import org.opendaylight.protocol.bgp.parser.BGPDocumentedException; -import org.opendaylight.protocol.bgp.parser.BGPParsingException; import org.opendaylight.protocol.util.ByteArray; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; @@ -25,18 +23,20 @@ public final class ESImpRouteTargetExtCom extends AbstractExtendedCommunities { private static final int MAC_ADDRESS_LENGTH = 6; @Override - public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException { + public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) { final MacAddress mac = IetfYangUtil.INSTANCE.macAddressFor(ByteArray.readBytes(buffer, MAC_ADDRESS_LENGTH)); return new EsImportRouteExtendedCommunityCaseBuilder().setEsImportRouteExtendedCommunity( - new EsImportRouteExtendedCommunityBuilder().setEsImport(mac).build()).build(); + new EsImportRouteExtendedCommunityBuilder().setEsImport(mac).build()).build(); } @Override public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) { Preconditions.checkArgument(extendedCommunity instanceof EsImportRouteExtendedCommunityCase, - "The extended community %s is not EsImportRouteExtendedCommunityCaseCase type.", extendedCommunity); - final EsImportRouteExtendedCommunity extCom = ((EsImportRouteExtendedCommunityCase) extendedCommunity).getEsImportRouteExtendedCommunity(); + "The extended community %s is not EsImportRouteExtendedCommunityCaseCase type.", + extendedCommunity); + final EsImportRouteExtendedCommunity extCom = ((EsImportRouteExtendedCommunityCase) extendedCommunity) + .getEsImportRouteExtendedCommunity(); byteAggregator.writeBytes(IetfYangUtil.INSTANCE.bytesFor(extCom.getEsImport())); } diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/Layer2AttributesExtCom.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/Layer2AttributesExtCom.java index bbc54120ea..f3b97e40c1 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/Layer2AttributesExtCom.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/Layer2AttributesExtCom.java @@ -11,8 +11,6 @@ package org.opendaylight.protocol.bgp.evpn.impl.extended.communities; import com.google.common.base.Preconditions; import com.google.common.primitives.UnsignedBytes; import io.netty.buffer.ByteBuf; -import org.opendaylight.protocol.bgp.parser.BGPDocumentedException; -import org.opendaylight.protocol.bgp.parser.BGPParsingException; import org.opendaylight.protocol.util.BitArray; import org.opendaylight.protocol.util.ByteBufWriteUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.NormalizationType; @@ -36,8 +34,15 @@ public class Layer2AttributesExtCom extends AbstractExtendedCommunities { private static final int THREE_BITS_SHIFT = 3; private static final int FIVE_BITS_SHIFT = 5; + private static short getFlagShort(final BitArray flags, final int index) { + short opMode = 0; + opMode |= flags.get(index + 1) ? 1 : 0; + opMode |= (flags.get(index) ? 1 : 0) << 1; + return opMode; + } + @Override - public ExtendedCommunity parseExtendedCommunity(final ByteBuf body) throws BGPDocumentedException, BGPParsingException { + public ExtendedCommunity parseExtendedCommunity(final ByteBuf body) { final Layer2AttributesExtendedCommunityBuilder builder = new Layer2AttributesExtendedCommunityBuilder(); final BitArray flags = BitArray.valueOf(body, FLAGS_SIZE); builder.setBackupPe(flags.get(BACKUP_PE_OFFSET)); @@ -50,21 +55,16 @@ public class Layer2AttributesExtCom extends AbstractExtendedCommunities { builder.setL2Mtu(body.readUnsignedShort()); body.skipBytes(RESERVED); return new Layer2AttributesExtendedCommunityCaseBuilder() - .setLayer2AttributesExtendedCommunity(builder.build()).build(); - } - - private static short getFlagShort(final BitArray flags, final int index) { - short opMode= 0; - opMode |= flags.get(index + 1) ? 1 : 0; - opMode |= (flags.get(index) ? 1 : 0) << 1; - return opMode; + .setLayer2AttributesExtendedCommunity(builder.build()).build(); } @Override public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf body) { Preconditions.checkArgument(extendedCommunity instanceof Layer2AttributesExtendedCommunityCase, - "The extended community %s is not EsImportRouteExtendedCommunityCaseCase type.", extendedCommunity); - final Layer2AttributesExtendedCommunity extCom = ((Layer2AttributesExtendedCommunityCase) extendedCommunity).getLayer2AttributesExtendedCommunity(); + "The extended community %s is not EsImportRouteExtendedCommunityCaseCase type.", + extendedCommunity); + final Layer2AttributesExtendedCommunity extCom = ((Layer2AttributesExtendedCommunityCase) extendedCommunity) + .getLayer2AttributesExtendedCommunity(); final BitArray flags = new BitArray(FLAGS_SIZE); flags.set(PRIMARY_PE_OFFSET, extCom.isPrimaryPe()); flags.set(BACKUP_PE_OFFSET, extCom.isBackupPe()); @@ -73,17 +73,17 @@ public class Layer2AttributesExtCom extends AbstractExtendedCommunities { final byte[] res = flags.array(); byte aux = 0; final OperationalMode modeOfOperation = extCom.getModeOfOperation(); - if ( modeOfOperation != null) { + if (modeOfOperation != null) { aux = UnsignedBytes.checkedCast(modeOfOperation.getIntValue()); aux = (byte) (aux << THREE_BITS_SHIFT); - res[res.length -1] = (byte) (res[res.length -1] | aux); + res[res.length - 1] = (byte) (res[res.length - 1] | aux); } final NormalizationType normalizationType = extCom.getOperatingPer(); - if ( normalizationType != null) { + if (normalizationType != null) { aux = UnsignedBytes.checkedCast(normalizationType.getIntValue()); aux = (byte) (aux << FIVE_BITS_SHIFT); - res[res.length -1] = (byte) (res[res.length -1] | aux); + res[res.length - 1] = (byte) (res[res.length - 1] | aux); } ByteBufWriteUtil.writeUnsignedShort((int) res[res.length - 1], body); ByteBufWriteUtil.writeUnsignedShort(extCom.getL2Mtu(), body); diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/AbstractEvpnNlri.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/AbstractEvpnNlri.java index 79513ca9dd..43b5ebfcf7 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/AbstractEvpnNlri.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/AbstractEvpnNlri.java @@ -39,7 +39,7 @@ abstract class AbstractEvpnNlri implements EvpnParser, EvpnSerializer { protected abstract NlriType getType(); - protected abstract ByteBuf serializeBody(final EvpnChoice evpn); + protected abstract ByteBuf serializeBody(EvpnChoice evpn); protected static Esi serializeEsi(final ContainerNode evpn) { return SimpleEsiTypeRegistry.getInstance().parseEsiModel((ChoiceNode) evpn.getChild(ESI_NID).get()); diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EthADRParser.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EthADRParser.java index 57820c0a76..10c54c096d 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EthADRParser.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EthADRParser.java @@ -32,16 +32,18 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; final class EthADRParser extends AbstractEvpnNlri { - protected static final NodeIdentifier ETH_AD_ROUTE_NID = new NodeIdentifier(EthernetADRoute.QNAME); + static final NodeIdentifier ETH_AD_ROUTE_NID = new NodeIdentifier(EthernetADRoute.QNAME); private static final int CONTENT_LENGTH = 17; @Override public EvpnChoice parseEvpn(final ByteBuf buffer) { - Preconditions.checkArgument(buffer.readableBytes() == CONTENT_LENGTH, "Wrong length of array of bytes. Passed: %s ;", buffer); + Preconditions.checkArgument(buffer.readableBytes() == CONTENT_LENGTH, + "Wrong length of array of bytes. Passed: %s ;", buffer); final Esi esi = SimpleEsiTypeRegistry.getInstance().parseEsi(buffer.readSlice(ESI_SIZE)); final EthernetTagId eti = new EthernetTagIdBuilder().setVlanId(buffer.readUnsignedInt()).build(); final MplsLabel label = mplsLabelForByteBuf(buffer); - final EthernetADRouteBuilder builder = new EthernetADRouteBuilder().setEsi(esi).setEthernetTagId(eti).setMplsLabel(label); + final EthernetADRouteBuilder builder = new EthernetADRouteBuilder() + .setEsi(esi).setEthernetTagId(eti).setMplsLabel(label); return new EthernetADRouteCaseBuilder().setEthernetADRoute(builder.build()).build(); } @@ -51,9 +53,20 @@ final class EthADRParser extends AbstractEvpnNlri { } @Override - public ByteBuf serializeBody(final EvpnChoice evpn) { - Preconditions.checkArgument(evpn instanceof EthernetADRouteCase, "Unknown evpn instance. Passed %s. Needed EthernetADRouteCase.", evpn.getClass()); - return serializeBody(((EthernetADRouteCase) evpn).getEthernetADRoute()); + public ByteBuf serializeBody(final EvpnChoice evpnChoice) { + Preconditions.checkArgument(evpnChoice instanceof EthernetADRouteCase, + "Unknown evpn instance. Passed %s. Needed EthernetADRouteCase.", evpnChoice.getClass()); + + final EthernetADRoute evpn = ((EthernetADRouteCase) evpnChoice).getEthernetADRoute(); + final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH); + SimpleEsiTypeRegistry.getInstance().serializeEsi(evpn.getEsi(), body); + ByteBufWriteUtil.writeUnsignedInt(evpn.getEthernetTagId().getVlanId(), body); + + final MplsLabel mpls = evpn.getMplsLabel(); + if (mpls != null) { + body.writeBytes(byteBufForMplsLabel(evpn.getMplsLabel())); + } + return body; } @Override @@ -74,16 +87,4 @@ final class EthADRParser extends AbstractEvpnNlri { builder.setEthernetTagId(extractETI(evpn)); return builder; } - - private static ByteBuf serializeBody(final EthernetADRoute evpn) { - final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH); - SimpleEsiTypeRegistry.getInstance().serializeEsi(evpn.getEsi(), body); - ByteBufWriteUtil.writeUnsignedInt(evpn.getEthernetTagId().getVlanId(), body); - - final MplsLabel mpls = evpn.getMplsLabel(); - if (mpls != null) { - body.writeBytes(byteBufForMplsLabel(evpn.getMplsLabel())); - } - return body; - } } \ No newline at end of file diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EthSegRParser.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EthSegRParser.java index e09a2f6027..c83512aaea 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EthSegRParser.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EthSegRParser.java @@ -29,13 +29,14 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; final class EthSegRParser extends AbstractEvpnNlri { - protected static final NodeIdentifier ES_ROUTE_NID = new NodeIdentifier(EsRoute.QNAME); + static final NodeIdentifier ES_ROUTE_NID = new NodeIdentifier(EsRoute.QNAME); private static final int CONTENT_LENGTH = 15; private static final int CONTENT_LENGTH2 = 27; @Override public EvpnChoice parseEvpn(final ByteBuf buffer) { - Preconditions.checkArgument(buffer.readableBytes() == CONTENT_LENGTH || buffer.readableBytes() == CONTENT_LENGTH2, + Preconditions.checkArgument(buffer.readableBytes() == CONTENT_LENGTH + || buffer.readableBytes() == CONTENT_LENGTH2, "Wrong length of array of bytes. Passed: %s ;", buffer); final Esi esi = SimpleEsiTypeRegistry.getInstance().parseEsi(buffer.readSlice(ESI_SIZE)); @@ -52,9 +53,15 @@ final class EthSegRParser extends AbstractEvpnNlri { @Override public ByteBuf serializeBody(final EvpnChoice evpnInput) { - Preconditions.checkArgument(evpnInput instanceof EsRouteCase, "Unknown evpn instance. Passed %s. Needed EsRouteCase.", - evpnInput.getClass()); - return serializeBody(((EsRouteCase) evpnInput).getEsRoute()); + Preconditions.checkArgument(evpnInput instanceof EsRouteCase, + "Unknown evpn instance. Passed %s. Needed EsRouteCase.", evpnInput.getClass()); + final EsRoute evpn = ((EsRouteCase) evpnInput).getEsRoute(); + final ByteBuf body = Unpooled.buffer(); + SimpleEsiTypeRegistry.getInstance().serializeEsi(evpn.getEsi(), body); + final ByteBuf orig = serializeOrigRouteIp(evpn.getOrigRouteIp()); + Preconditions.checkArgument(orig.readableBytes() > 0); + body.writeBytes(orig); + return body; } @Override @@ -70,16 +77,7 @@ final class EthSegRParser extends AbstractEvpnNlri { return new EsRouteCaseBuilder().setEsRoute(builder.build()).build(); } - private static ByteBuf serializeBody(final EsRoute evpn) { - final ByteBuf body = Unpooled.buffer(); - SimpleEsiTypeRegistry.getInstance().serializeEsi(evpn.getEsi(), body); - final ByteBuf orig = serializeOrigRouteIp(evpn.getOrigRouteIp()); - Preconditions.checkArgument(orig.readableBytes() > 0); - body.writeBytes(orig); - return body; - } - - public static IpAddress parseOrigRouteIp(final ByteBuf buffer) { + static IpAddress parseOrigRouteIp(final ByteBuf buffer) { final int ipLength = buffer.readUnsignedByte(); if (ipLength == Ipv6Util.IPV6_BITS_LENGTH) { return new IpAddress(Ipv6Util.addressForByteBuf(buffer)); diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EvpnNlriParser.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EvpnNlriParser.java index 87575ae1ba..84dda24bde 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EvpnNlriParser.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EvpnNlriParser.java @@ -60,7 +60,8 @@ public final class EvpnNlriParser implements NlriParser, NlriSerializer { return extractDestination(evpnChoice, EvpnRegistry::serializeEvpnModel); } - private static EvpnDestination extractDestination(final DataContainerNode evpnChoice, final ExtractionInterface extract) { + private static EvpnDestination extractDestination(final DataContainerNode evpnChoice, + final ExtractionInterface extract) { final EvpnRegistry reg = SimpleEvpnNlriRegistry.getInstance(); final ChoiceNode cont = (ChoiceNode) evpnChoice.getChild(EVPN_CHOICE_NID).get(); final EvpnChoice evpnValue = extract.check(reg, cont); @@ -68,10 +69,12 @@ public final class EvpnNlriParser implements NlriParser, NlriSerializer { LOG.warn("Unrecognized Nlri {}", cont); return null; } - return new EvpnDestinationBuilder().setRouteDistinguisher(extractRouteDistinguisher(evpnChoice)).setEvpnChoice(evpnValue).build(); + return new EvpnDestinationBuilder().setRouteDistinguisher(extractRouteDistinguisher(evpnChoice)) + .setEvpnChoice(evpnValue).build(); } - public static EvpnDestination extractRouteKeyDestination(final DataContainerNode evpnChoice) { + public static EvpnDestination extractRouteKeyDestination( + final DataContainerNode evpnChoice) { return extractDestination(evpnChoice, EvpnRegistry::serializeEvpnRouteKey); } @@ -83,10 +86,11 @@ public final class EvpnNlriParser implements NlriParser, NlriSerializer { final List dst = parseNlri(nlri); builder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType( - new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn. - routes.destination.type.DestinationEvpnCaseBuilder().setDestinationEvpn(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns. - yang.bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.evpn._case.DestinationEvpnBuilder() - .setEvpnDestination(dst).build()).build()).build()); + new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update.attributes + .mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCaseBuilder() + .setDestinationEvpn(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn + .rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination + .evpn._case.DestinationEvpnBuilder().setEvpnDestination(dst).build()).build()).build()); } @Override @@ -97,7 +101,8 @@ public final class EvpnNlriParser implements NlriParser, NlriSerializer { final List dst = parseNlri(nlri); builder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType( - new DestinationEvpnCaseBuilder().setDestinationEvpn(new DestinationEvpnBuilder().setEvpnDestination(dst).build()).build()).build()); + new DestinationEvpnCaseBuilder().setDestinationEvpn(new DestinationEvpnBuilder() + .setEvpnDestination(dst).build()).build()).build()); } @Nullable @@ -134,19 +139,22 @@ public final class EvpnNlriParser implements NlriParser, NlriSerializer { } else if (pathAttributes2 != null) { final MpUnreachNlri mpUnreachNlri = pathAttributes2.getMpUnreachNlri(); final WithdrawnRoutes withdrawnRoutes = mpUnreachNlri.getWithdrawnRoutes(); - if (withdrawnRoutes != null && withdrawnRoutes.getDestinationType() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml - .ns.yang.bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCase) { - final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn. - routes.destination.type.DestinationEvpnCase evpnCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml - .ns.yang.bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCase) mpUnreachNlri.getWithdrawnRoutes().getDestinationType(); + if (withdrawnRoutes != null && withdrawnRoutes.getDestinationType() + instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213 + .update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCase) { + final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update + .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCase evpnCase = + (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update + .attributes.mp.unreach.nlri.withdrawn.routes.destination.type + .DestinationEvpnCase) mpUnreachNlri.getWithdrawnRoutes().getDestinationType(); serializeNlri(evpnCase.getDestinationEvpn().getEvpnDestination(), byteAggregator); } } } - public static void serializeNlri(final List cEvpn, final ByteBuf output) { + public static void serializeNlri(final List destinationList, final ByteBuf output) { ByteBuf nlriOutput = null; - for (final EvpnDestination dest : cEvpn) { + for (final EvpnDestination dest : destinationList) { final ByteBuf nlriCommon = Unpooled.buffer(); serializeRouteDistinquisher(dest.getRouteDistinguisher(), nlriCommon); nlriOutput = SimpleEvpnNlriRegistry.getInstance().serializeEvpn(dest.getEvpnChoice(), nlriCommon); diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/IncMultEthTagRParser.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/IncMultEthTagRParser.java index e3bad4109a..21c647a6e7 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/IncMultEthTagRParser.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/IncMultEthTagRParser.java @@ -29,18 +29,27 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; final class IncMultEthTagRParser extends AbstractEvpnNlri { - protected static final NodeIdentifier INC_MULT_ROUTE_NID = new NodeIdentifier(IncMultiEthernetTagRes.QNAME); + static final NodeIdentifier INC_MULT_ROUTE_NID = new NodeIdentifier(IncMultiEthernetTagRes.QNAME); private static final int CONTENT_LENGTH = 9; private static final int CONTENT_LENGTH2 = 21; + private static EvpnChoice serializeModel(final ContainerNode evpn) { + final IncMultiEthernetTagResBuilder builder = new IncMultiEthernetTagResBuilder(); + builder.setEthernetTagId(extractETI(evpn)); + builder.setOrigRouteIp(extractOrigRouteIp(evpn)); + return new IncMultiEthernetTagResCaseBuilder().setIncMultiEthernetTagRes(builder.build()).build(); + } + @Override public EvpnChoice parseEvpn(final ByteBuf buffer) { - Preconditions.checkArgument(buffer.readableBytes() == CONTENT_LENGTH || buffer.readableBytes() == CONTENT_LENGTH2, - "Wrong length of array of bytes. Passed: %s ;", buffer); + Preconditions.checkArgument(buffer.readableBytes() == CONTENT_LENGTH + || buffer.readableBytes() == CONTENT_LENGTH2, + "Wrong length of array of bytes. Passed: %s ;", buffer); final EthernetTagId eti = new EthernetTagIdBuilder().setVlanId(buffer.readUnsignedInt()).build(); IpAddress ip = requireNonNull(EthSegRParser.parseOrigRouteIp(buffer)); - final IncMultiEthernetTagResBuilder builder = new IncMultiEthernetTagResBuilder().setEthernetTagId(eti).setOrigRouteIp(ip); + final IncMultiEthernetTagResBuilder builder = new IncMultiEthernetTagResBuilder() + .setEthernetTagId(eti).setOrigRouteIp(ip); return new IncMultiEthernetTagResCaseBuilder().setIncMultiEthernetTagRes(builder.build()).build(); } @@ -50,31 +59,27 @@ final class IncMultEthTagRParser extends AbstractEvpnNlri { } @Override - public ByteBuf serializeBody(final EvpnChoice evpn) { - Preconditions.checkArgument(evpn instanceof IncMultiEthernetTagResCase, "Unknown evpn instance. Passed %s. Needed IncMultiEthernetTagResCase.", - evpn.getClass()); - return serializeBody(((IncMultiEthernetTagResCase) evpn).getIncMultiEthernetTagRes()); + public ByteBuf serializeBody(final EvpnChoice evpnChoice) { + Preconditions.checkArgument(evpnChoice instanceof IncMultiEthernetTagResCase, + "Unknown evpn instance. Passed %s. Needed IncMultiEthernetTagResCase.", + evpnChoice.getClass()); + + final IncMultiEthernetTagRes evpn = ((IncMultiEthernetTagResCase) evpnChoice).getIncMultiEthernetTagRes(); + final ByteBuf body = Unpooled.buffer(); + ByteBufWriteUtil.writeUnsignedInt(evpn.getEthernetTagId().getVlanId(), body); + final ByteBuf orig = EthSegRParser.serializeOrigRouteIp(evpn.getOrigRouteIp()); + Preconditions.checkArgument(orig.readableBytes() > 0); + body.writeBytes(orig); + return body; } @Override public EvpnChoice serializeEvpnModel(final ContainerNode evpn) { - return createRouteKey(evpn); + return serializeModel(evpn); } @Override public EvpnChoice createRouteKey(final ContainerNode evpn) { - final IncMultiEthernetTagResBuilder builder = new IncMultiEthernetTagResBuilder(); - builder.setEthernetTagId(extractETI(evpn)); - builder.setOrigRouteIp(extractOrigRouteIp(evpn)); - return new IncMultiEthernetTagResCaseBuilder().setIncMultiEthernetTagRes(builder.build()).build(); - } - - private static ByteBuf serializeBody(final IncMultiEthernetTagRes evpn) { - final ByteBuf body = Unpooled.buffer(); - ByteBufWriteUtil.writeUnsignedInt(evpn.getEthernetTagId().getVlanId(), body); - final ByteBuf orig = EthSegRParser.serializeOrigRouteIp(evpn.getOrigRouteIp()); - Preconditions.checkArgument(orig.readableBytes() > 0); - body.writeBytes(orig); - return body; + return serializeModel(evpn); } } diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/MACIpAdvRParser.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/MACIpAdvRParser.java index 6dc7e731cb..0cf4e36f4d 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/MACIpAdvRParser.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/MACIpAdvRParser.java @@ -59,7 +59,8 @@ final class MACIpAdvRParser extends AbstractEvpnNlri { } else { label2 = null; } - final MacIpAdvRouteBuilder builder = new MacIpAdvRouteBuilder().setEsi(esi).setEthernetTagId(eti).setMacAddress(mac).setIpAddress(ip) + final MacIpAdvRouteBuilder builder = new MacIpAdvRouteBuilder().setEsi(esi).setEthernetTagId(eti) + .setMacAddress(mac).setIpAddress(ip) .setMplsLabel1(label1).setMplsLabel2(label2); return new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(builder.build()).build(); } @@ -70,36 +71,12 @@ final class MACIpAdvRParser extends AbstractEvpnNlri { } @Override - public ByteBuf serializeBody(final EvpnChoice evpn) { - Preconditions.checkArgument(evpn instanceof MacIpAdvRouteCase, "Unknown evpn instance. Passed %s. Needed MacIpAdvRouteCase.", evpn.getClass()); - return serializeBody((MacIpAdvRouteCase) evpn); - } - - @Override - public EvpnChoice serializeEvpnModel(final ContainerNode evpn) { - final MacIpAdvRouteBuilder builder = serializeKeyModel(evpn); - builder.setEsi(serializeEsi(evpn)); - builder.setMplsLabel1(extractMplsLabel(evpn, MPLS1_NID)); - builder.setMplsLabel2(extractMplsLabel(evpn, MPLS2_NID)); - return new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(builder.build()).build(); - } - - @Override - public EvpnChoice createRouteKey(final ContainerNode evpn) { - return new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(serializeKeyModel(evpn).build()).build(); - } - - private static MacIpAdvRouteBuilder serializeKeyModel(final ContainerNode evpn) { - final MacIpAdvRouteBuilder builder = new MacIpAdvRouteBuilder(); - builder.setEthernetTagId(extractETI(evpn)); - builder.setMacAddress(extractMAC(evpn)); - builder.setIpAddress(extractIp(evpn)); - return builder; - } + public ByteBuf serializeBody(final EvpnChoice evpnChoice) { + Preconditions.checkArgument(evpnChoice instanceof MacIpAdvRouteCase, + "Unknown evpn instance. Passed %s. Needed MacIpAdvRouteCase.", evpnChoice.getClass()); - private static ByteBuf serializeBody(final MacIpAdvRouteCase evpnCase) { final ByteBuf body = Unpooled.buffer(); - final MacIpAdvRoute evpn = evpnCase.getMacIpAdvRoute(); + final MacIpAdvRoute evpn = ((MacIpAdvRouteCase) evpnChoice).getMacIpAdvRoute(); final Esi esi = evpn.getEsi(); if (esi != null) { SimpleEsiTypeRegistry.getInstance().serializeEsi(evpn.getEsi(), body); @@ -123,6 +100,28 @@ final class MACIpAdvRParser extends AbstractEvpnNlri { return body; } + @Override + public EvpnChoice serializeEvpnModel(final ContainerNode evpn) { + final MacIpAdvRouteBuilder builder = serializeKeyModel(evpn); + builder.setEsi(serializeEsi(evpn)); + builder.setMplsLabel1(extractMplsLabel(evpn, MPLS1_NID)); + builder.setMplsLabel2(extractMplsLabel(evpn, MPLS2_NID)); + return new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(builder.build()).build(); + } + + @Override + public EvpnChoice createRouteKey(final ContainerNode evpn) { + return new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(serializeKeyModel(evpn).build()).build(); + } + + private static MacIpAdvRouteBuilder serializeKeyModel(final ContainerNode evpn) { + final MacIpAdvRouteBuilder builder = new MacIpAdvRouteBuilder(); + builder.setEthernetTagId(extractETI(evpn)); + builder.setMacAddress(extractMAC(evpn)); + builder.setIpAddress(extractIp(evpn)); + return builder; + } + private static ByteBuf serializeIp(final IpAddress ipAddress) { final ByteBuf body = Unpooled.buffer(); if (ipAddress != null) { diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/NlriModelUtil.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/NlriModelUtil.java index dbec267b7b..c0b082b7f7 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/NlriModelUtil.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/NlriModelUtil.java @@ -23,15 +23,24 @@ import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode; final class NlriModelUtil { - static final NodeIdentifier ETI_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "ethernet-tag-id").intern()); - static final NodeIdentifier VLAN_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "vlan-id").intern()); - static final NodeIdentifier RD_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "route-distinguisher").intern()); - static final NodeIdentifier ORI_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "orig-route-ip").intern()); - static final NodeIdentifier MAC_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "mac-address").intern()); - static final NodeIdentifier IP_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "ip-address").intern()); - static final NodeIdentifier MPLS_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "mpls-label").intern()); - static final NodeIdentifier MPLS1_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "mpls-label1").intern()); - static final NodeIdentifier MPLS2_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "mpls-label2").intern()); + static final NodeIdentifier ETI_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, + "ethernet-tag-id").intern()); + static final NodeIdentifier VLAN_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, + "vlan-id").intern()); + static final NodeIdentifier RD_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, + "route-distinguisher").intern()); + static final NodeIdentifier ORI_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, + "orig-route-ip").intern()); + static final NodeIdentifier MAC_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, + "mac-address").intern()); + static final NodeIdentifier IP_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, + "ip-address").intern()); + static final NodeIdentifier MPLS_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, + "mpls-label").intern()); + static final NodeIdentifier MPLS1_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, + "mpls-label1").intern()); + static final NodeIdentifier MPLS2_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, + "mpls-label2").intern()); private NlriModelUtil() { throw new UnsupportedOperationException(); @@ -63,7 +72,8 @@ final class NlriModelUtil { return null; } - static MplsLabel extractMplsLabel(final DataContainerNode evpn, final NodeIdentifier mplsNid) { + static MplsLabel extractMplsLabel(final DataContainerNode evpn, + final NodeIdentifier mplsNid) { if (evpn.getChild(mplsNid).isPresent()) { return new MplsLabel((Long) evpn.getChild(mplsNid).get().getValue()); } diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/EsiParser.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/EsiParser.java index 9b952b8774..c239924716 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/EsiParser.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/EsiParser.java @@ -14,7 +14,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn public interface EsiParser { /** - * Parse Ethernet Segment Identifier + * Parse Ethernet Segment Identifier. * * @param buffer encoded ESI body in Bytebuf * @return Ethernet Segment Identifier diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/EsiRegistry.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/EsiRegistry.java index 2fc8b8b5d7..7ad3a11ac8 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/EsiRegistry.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/EsiRegistry.java @@ -10,30 +10,31 @@ package org.opendaylight.protocol.bgp.evpn.spi; import io.netty.buffer.ByteBuf; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.esi.Esi; import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode; public interface EsiRegistry { /** - * Parse Esi + * Parse Esi. * * @param buffer encoded ESI body in Bytebuf * @return Ethernet Segment Identifier */ - @Nonnull + @Nullable Esi parseEsi(@Nonnull ByteBuf buffer); /** - * Parse Esi Model + * Parse Esi Model. * * @param esi ChoiceNode containing ESI * @return Ethernet Segment Identifier */ - @Nonnull + @Nullable Esi parseEsiModel(@Nonnull ChoiceNode esi); /** - * Serialize Esi + * Serialize Esi. * * @param esi Ethernet Segment Identifier * @param buffer write in Bytebuf encoded ESI body diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/EsiSerializer.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/EsiSerializer.java index 653a8e1bcb..4e514e49a3 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/EsiSerializer.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/EsiSerializer.java @@ -15,7 +15,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; public interface EsiSerializer { /** - * Serialize Ethernet Segment Identifier + * Serialize Ethernet Segment Identifier. * * @param esi Ethernet Segment Identifier * @param buffer write in Bytebuf encoded ESI body @@ -23,7 +23,7 @@ public interface EsiSerializer { void serializeEsi(@Nonnull Esi esi, @Nonnull ByteBuf buffer); /** - * Serialize Ethernet Segment Identifier Model + * Serialize Ethernet Segment Identifier Model. * * @param esi Ethernet Segment Identifier Model * @return Ethernet Segment Identifier diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/EvpnRegistry.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/EvpnRegistry.java index dba457f2d6..335c409389 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/EvpnRegistry.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/EvpnRegistry.java @@ -26,7 +26,7 @@ public interface EvpnRegistry { @Nullable EvpnChoice parseEvpn(@Nonnull NlriType type, @Nonnull ByteBuf buffer); /** - * Encode input BGP Evpn to output buffer + * Encode input BGP Evpn to output buffer. * * @param evpn EvpnChoice * @param common encoded common Evpn @@ -40,13 +40,13 @@ public interface EvpnRegistry { * @param evpnChoice ChoiceNode containing Evpn * @return EvpnChoice */ - @Nonnull EvpnChoice serializeEvpnModel(@Nonnull ChoiceNode evpnChoice); + @Nullable EvpnChoice serializeEvpnModel(@Nonnull ChoiceNode evpnChoice); /** - * Create Route key from Evpn model + * Create Route key from Evpn model. * * @param evpnChoice ChoiceNode containing Evpn * @return EvpnChoice */ - @Nonnull EvpnChoice serializeEvpnRouteKey(@Nonnull ChoiceNode evpnChoice); + @Nullable EvpnChoice serializeEvpnRouteKey(@Nonnull ChoiceNode evpnChoice); } diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/EvpnSerializer.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/EvpnSerializer.java index 7d9d380f36..f9ba582b87 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/EvpnSerializer.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/EvpnSerializer.java @@ -15,6 +15,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; public interface EvpnSerializer { /** + * Serialize Evpn. + * * @param evpn Evpn * @param buffer Encode common Evpn parts to output buffer * @return Encode Evpn to output buffer @@ -23,7 +25,7 @@ public interface EvpnSerializer { ByteBuf serializeEvpn(@Nonnull EvpnChoice evpn, @Nonnull ByteBuf buffer); /** - * Serialize Evpn + * Serialize Evpn Model. * * @param evpn ChoiceNode containing Evpn * @return Evpn @@ -32,7 +34,7 @@ public interface EvpnSerializer { EvpnChoice serializeEvpnModel(@Nonnull ContainerNode evpn); /** - * create Route key from Evpn model + * create Route key from Evpn model. * * @param evpn ContainerNode containing Evpn * @return Evpn diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/pojo/SimpleEsiTypeRegistry.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/pojo/SimpleEsiTypeRegistry.java index c23221dbbe..c8e56a5c41 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/pojo/SimpleEsiTypeRegistry.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/pojo/SimpleEsiTypeRegistry.java @@ -49,14 +49,16 @@ public final class SimpleEsiTypeRegistry implements EsiRegistry { return this.handlers.registerSerializer(esiType, serializer); } - public AutoCloseable registerEsiModelSerializer(final QName qName, final EsiSerializer serializer) { - return this.modelHandlers.register(new NodeIdentifier(qName), serializer); + public AutoCloseable registerEsiModelSerializer(final QName qname, final EsiSerializer serializer) { + return this.modelHandlers.register(new NodeIdentifier(qname), serializer); } @Override public Esi parseEsi(final ByteBuf buffer) { - Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty."); - Preconditions.checkArgument(buffer.readableBytes() == CONTENT_LENGTH, "Wrong length of array of bytes. Passed: " + buffer.readableBytes() + ";"); + Preconditions.checkArgument(buffer != null && buffer.isReadable(), + "Array of bytes is mandatory. Can't be null or empty."); + Preconditions.checkArgument(buffer.readableBytes() == CONTENT_LENGTH, + "Wrong length of array of bytes. Passed: " + buffer.readableBytes() + ";"); final EsiParser parser = this.handlers.getParser(EsiType.forValue(buffer.readByte()).getIntValue()); if (parser == null) { @@ -67,7 +69,8 @@ public final class SimpleEsiTypeRegistry implements EsiRegistry { @Override public Esi parseEsiModel(final ChoiceNode esiChoice) { - Preconditions.checkArgument(esiChoice != null && !esiChoice.getValue().isEmpty(), "ESI is mandatory. Can't be null or empty."); + Preconditions.checkArgument(esiChoice != null && !esiChoice.getValue().isEmpty(), + "ESI is mandatory. Can't be null or empty."); final ContainerNode cont = (ContainerNode) Iterables.getOnlyElement(esiChoice.getValue()); final EsiSerializer serializer = this.modelHandlers.get(cont.getIdentifier()); if (serializer != null) { diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/pojo/SimpleEvpnNlriRegistry.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/pojo/SimpleEvpnNlriRegistry.java index 93d41f1290..c73fcf8806 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/pojo/SimpleEvpnNlriRegistry.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/pojo/SimpleEvpnNlriRegistry.java @@ -45,17 +45,19 @@ public final class SimpleEvpnNlriRegistry implements EvpnRegistry { return this.handlers.registerParser(esiType.getIntValue(), parser); } - public AutoCloseable registerNlriSerializer(final Class evpnClass, final EvpnSerializer serializer) { + public AutoCloseable registerNlriSerializer(final Class evpnClass, + final EvpnSerializer serializer) { return this.handlers.registerSerializer(evpnClass, serializer); } - public AutoCloseable registerNlriModelSerializer(final QName qName, final EvpnSerializer serializer) { - return this.modelHandlers.register(new NodeIdentifier(qName), serializer); + public AutoCloseable registerNlriModelSerializer(final QName qname, final EvpnSerializer serializer) { + return this.modelHandlers.register(new NodeIdentifier(qname), serializer); } @Override public EvpnChoice parseEvpn(final NlriType type, final ByteBuf buffer) { - Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty."); + Preconditions.checkArgument(buffer != null && buffer.isReadable(), + "Array of bytes is mandatory. Can't be null or empty."); final EvpnParser parser = this.handlers.getParser(type.getIntValue()); if (parser == null) { return null; @@ -83,7 +85,8 @@ public final class SimpleEvpnNlriRegistry implements EvpnRegistry { } private EvpnChoice getEvpnCase(final ChoiceNode evpnChoice, final SerializerInterface serializerInterface) { - Preconditions.checkArgument(evpnChoice != null && !evpnChoice.getValue().isEmpty(), "Evpn case is mandatory. Can't be null or empty."); + Preconditions.checkArgument(evpnChoice != null && !evpnChoice.getValue().isEmpty(), + "Evpn case is mandatory. Can't be null or empty."); final ContainerNode cont = (ContainerNode) Iterables.getOnlyElement(evpnChoice.getValue()); final EvpnSerializer serializer = this.modelHandlers.get(cont.getIdentifier()); if (serializer == null) { diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/BGPActivatorTest.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/BGPActivatorTest.java index 145b49b71e..fcf62ed4a7 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/BGPActivatorTest.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/BGPActivatorTest.java @@ -9,6 +9,8 @@ package org.opendaylight.protocol.bgp.evpn.impl; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +import static org.opendaylight.protocol.bgp.evpn.impl.BGPActivator.EVPN_SAFI; +import static org.opendaylight.protocol.bgp.evpn.impl.BGPActivator.L2VPN_AFI; import org.junit.Test; import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext; @@ -21,11 +23,12 @@ public class BGPActivatorTest { public void testActivator() throws Exception { final BGPActivator act = new BGPActivator(); final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext(); - assertNull(context.getAddressFamilyRegistry().classForFamily(25)); - assertNull(context.getSubsequentAddressFamilyRegistry().classForFamily(70)); + assertNull(context.getAddressFamilyRegistry().classForFamily(L2VPN_AFI)); + assertNull(context.getSubsequentAddressFamilyRegistry().classForFamily(EVPN_SAFI)); act.start(context); - assertEquals(L2vpnAddressFamily.class, context.getAddressFamilyRegistry().classForFamily(25)); - assertEquals(EvpnSubsequentAddressFamily.class, context.getSubsequentAddressFamilyRegistry().classForFamily(70)); + assertEquals(L2vpnAddressFamily.class, context.getAddressFamilyRegistry().classForFamily(L2VPN_AFI)); + assertEquals(EvpnSubsequentAddressFamily.class, context.getSubsequentAddressFamilyRegistry() + .classForFamily(EVPN_SAFI)); act.close(); } } \ No newline at end of file diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/EvpnRibSupportTest.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/EvpnRibSupportTest.java index 2ba829d20d..20a4790adc 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/EvpnRibSupportTest.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/EvpnRibSupportTest.java @@ -7,7 +7,6 @@ */ package org.opendaylight.protocol.bgp.evpn.impl; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.RD; @@ -56,23 +55,32 @@ public final class EvpnRibSupportTest extends AbstractRIBSupportTest { private static final EvpnRibSupport RIB_SUPPORT = EvpnRibSupport.getInstance(); private static final EvpnRoute ROUTE; private static final EvpnRouteKey ROUTE_KEY; - private static final EvpnDestination EVPN_DESTINATION = new EvpnDestinationBuilder().setRouteDistinguisher(RD).setEvpnChoice(ETHERNET_AD_ROUTE_CASE).build(); - private static final DestinationEvpnCase REACH_NLRI = new DestinationEvpnCaseBuilder().setDestinationEvpn(new DestinationEvpnBuilder() - .setEvpnDestination(Collections.singletonList(EVPN_DESTINATION)).build()).build(); - private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCase UNREACH_NLRI = - new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type. - DestinationEvpnCaseBuilder().setDestinationEvpn(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.evpn._case. - DestinationEvpnBuilder().setEvpnDestination(Collections.singletonList(EVPN_DESTINATION)).build()).build(); + private static final EvpnDestination EVPN_DESTINATION = new EvpnDestinationBuilder().setRouteDistinguisher(RD) + .setEvpnChoice(ETHERNET_AD_ROUTE_CASE).build(); + private static final DestinationEvpnCase REACH_NLRI = new DestinationEvpnCaseBuilder() + .setDestinationEvpn(new DestinationEvpnBuilder() + .setEvpnDestination(Collections.singletonList(EVPN_DESTINATION)).build()).build(); + private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update + .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCase UNREACH_NLRI = + new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update.attributes + .mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCaseBuilder() + .setDestinationEvpn(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn + .rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type + .destination.evpn._case.DestinationEvpnBuilder() + .setEvpnDestination(Collections.singletonList(EVPN_DESTINATION)).build()).build(); private static final EvpnRoutes EVPN_ROUTES; + static { final BGPActivator act = new BGPActivator(); final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext(); act.start(context); final ByteBuf buffer = Unpooled.buffer(); - EvpnNlriParser.serializeNlri(Collections.singletonList(new EvpnDestinationBuilder().setRouteDistinguisher(RD).setEvpnChoice(ETHERNET_AD_ROUTE_CASE_KEY).build()), buffer); + EvpnNlriParser.serializeNlri(Collections.singletonList(new EvpnDestinationBuilder() + .setRouteDistinguisher(RD).setEvpnChoice(ETHERNET_AD_ROUTE_CASE_KEY).build()), buffer); ROUTE_KEY = new EvpnRouteKey(ByteArray.encodeBase64(buffer)); - ROUTE = new EvpnRouteBuilder().setRouteKey(ROUTE_KEY.getRouteKey()).setAttributes(ATTRIBUTES).setRouteDistinguisher(RD).setEvpnChoice(ETHERNET_AD_ROUTE_CASE).build(); + ROUTE = new EvpnRouteBuilder().setRouteKey(ROUTE_KEY.getRouteKey()) + .setAttributes(ATTRIBUTES).setRouteDistinguisher(RD).setEvpnChoice(ETHERNET_AD_ROUTE_CASE).build(); EVPN_ROUTES = new EvpnRoutesBuilder().setEvpnRoute(Collections.singletonList(ROUTE)).build(); } @@ -86,7 +94,8 @@ public final class EvpnRibSupportTest extends AbstractRIBSupportTest { @Test public void testDeleteRoutes() { RIB_SUPPORT.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI)); - final InstanceIdentifier instanceIdentifier = (InstanceIdentifier) this.deletedRoutes.get(0); + @SuppressWarnings("unchecked") final InstanceIdentifier instanceIdentifier = + (InstanceIdentifier) this.deletedRoutes.get(0); assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(EvpnRoute.class)); } @@ -100,7 +109,8 @@ public final class EvpnRibSupportTest extends AbstractRIBSupportTest { @Test public void testEmptyRoute() throws Exception { - final Routes empty = new EvpnRoutesCaseBuilder().setEvpnRoutes(new EvpnRoutesBuilder().setEvpnRoute(Collections.emptyList()).build()).build(); + final Routes empty = new EvpnRoutesCaseBuilder().setEvpnRoutes( + new EvpnRoutesBuilder().setEvpnRoute(Collections.emptyList()).build()).build(); final ChoiceNode emptyRoutes = RIB_SUPPORT.emptyRoutes(); assertEquals(createRoutes(empty), emptyRoutes); } @@ -108,14 +118,16 @@ public final class EvpnRibSupportTest extends AbstractRIBSupportTest { @Test public void testBuildMpUnreachNlriUpdate() { final Update update = RIB_SUPPORT.buildUpdate(Collections.emptyList(), createRoutes(EVPN_ROUTES), ATTRIBUTES); - assertEquals(UNREACH_NLRI, update.getAttributes().getAugmentation(Attributes2.class).getMpUnreachNlri().getWithdrawnRoutes().getDestinationType()); + assertEquals(UNREACH_NLRI, update.getAttributes().getAugmentation(Attributes2.class).getMpUnreachNlri() + .getWithdrawnRoutes().getDestinationType()); assertNull(update.getAttributes().getAugmentation(Attributes1.class)); } @Test public void testBuildMpReachNlriUpdate() { final Update update = RIB_SUPPORT.buildUpdate(createRoutes(EVPN_ROUTES), Collections.emptyList(), ATTRIBUTES); - assertEquals(REACH_NLRI, update.getAttributes().getAugmentation(Attributes1.class).getMpReachNlri().getAdvertizedRoutes().getDestinationType()); + assertEquals(REACH_NLRI, update.getAttributes().getAugmentation(Attributes1.class).getMpReachNlri() + .getAdvertizedRoutes().getDestinationType()); assertNull(update.getAttributes().getAugmentation(Attributes2.class)); } @@ -126,12 +138,12 @@ public final class EvpnRibSupportTest extends AbstractRIBSupportTest { @Test public void testCacheableNlriObjects() { - Assert.assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableNlriObjects()); + assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableNlriObjects()); } @Test public void testCacheableAttributeObjects() { - Assert.assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableAttributeObjects()); + assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableAttributeObjects()); } @Test @@ -142,39 +154,41 @@ public final class EvpnRibSupportTest extends AbstractRIBSupportTest { @Test public void testRoutePath() { final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(EVPN_ROUTES); - Assert.assertEquals(getRoutePath().node(prefixNii), RIB_SUPPORT.routePath(getTablePath().node(Routes.QNAME), prefixNii)); + assertEquals(getRoutePath().node(prefixNii), + RIB_SUPPORT.routePath(getTablePath().node(Routes.QNAME), prefixNii)); } @Test public void testExtractPathId() { - Assert.assertEquals((Long) NON_PATH_ID, RIB_SUPPORT.extractPathId(null)); + assertEquals((Long) NON_PATH_ID, RIB_SUPPORT.extractPathId(null)); } @Test public void testRouteAttributesIdentifier() { - Assert.assertEquals(new NodeIdentifier(QName.create(EvpnRoutes.QNAME, Attributes.QNAME.getLocalName().intern())), RIB_SUPPORT - .routeAttributesIdentifier()); + assertEquals(new NodeIdentifier(QName.create(EvpnRoutes.QNAME, + Attributes.QNAME.getLocalName().intern())), RIB_SUPPORT.routeAttributesIdentifier()); } @Test public void testRoutesCaseClass() { - Assert.assertEquals(EvpnRoutesCase.class, RIB_SUPPORT.routesCaseClass()); + assertEquals(EvpnRoutesCase.class, RIB_SUPPORT.routesCaseClass()); } @Test public void testRoutesContainerClass() { - Assert.assertEquals(EvpnRoutes.class, RIB_SUPPORT.routesContainerClass()); + assertEquals(EvpnRoutes.class, RIB_SUPPORT.routesContainerClass()); } @Test public void testRoutesListClass() { - Assert.assertEquals(EvpnRoute.class, RIB_SUPPORT.routesListClass()); + assertEquals(EvpnRoute.class, RIB_SUPPORT.routesListClass()); } @Test public void testChangedRoutes() { final Routes emptyCase = new EvpnRoutesCaseBuilder().build(); - DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyCase)).getRootNode(); + DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), + createRoutes(emptyCase)).getRootNode(); Assert.assertTrue(RIB_SUPPORT.changedRoutes(tree).isEmpty()); final Routes emptyRoutes = new EvpnRoutesCaseBuilder().setEvpnRoutes(new EvpnRoutesBuilder().build()).build(); diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/EvpnTestUtil.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/EvpnTestUtil.java index cd156ba3e0..4d328497f2 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/EvpnTestUtil.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/EvpnTestUtil.java @@ -16,7 +16,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types. import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RouteDistinguisher; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RouteDistinguisherBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeSchemaAwareBuilder; @@ -43,12 +43,12 @@ public final class EvpnTestUtil { public static final String RD_MODEL = "1.2.3.4:258"; public static final RouteDistinguisher RD = RouteDistinguisherBuilder.getDefaultInstance(RD_MODEL); - public static DataContainerNodeAttrBuilder createContBuilder(final YangInstanceIdentifier - .NodeIdentifier nid) { + public static DataContainerNodeAttrBuilder createContBuilder( + final NodeIdentifier nid) { return ImmutableContainerNodeSchemaAwareBuilder.create().withNodeIdentifier(nid); } - public static ImmutableLeafNodeBuilder createValueBuilder(final T value, YangInstanceIdentifier.NodeIdentifier nid) { + public static ImmutableLeafNodeBuilder createValueBuilder(final T value, NodeIdentifier nid) { final ImmutableLeafNodeBuilder valueBuilder = new ImmutableLeafNodeBuilder<>(); valueBuilder.withNodeIdentifier(nid).withValue(value); return valueBuilder; diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/TableTypeActivatorTest.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/TableTypeActivatorTest.java index db967c6a29..ac130fe8a7 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/TableTypeActivatorTest.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/TableTypeActivatorTest.java @@ -21,7 +21,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mult public class TableTypeActivatorTest { - private static final BgpTableType EVPN = new BgpTableTypeImpl(L2vpnAddressFamily.class, EvpnSubsequentAddressFamily.class); + private static final BgpTableType EVPN = new BgpTableTypeImpl( + L2vpnAddressFamily.class, EvpnSubsequentAddressFamily.class); @Test public void testActivator() { diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/OpaqueUtilTest.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/OpaqueUtilTest.java index be712ff807..247cc5dcdb 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/OpaqueUtilTest.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/OpaqueUtilTest.java @@ -14,8 +14,6 @@ import static org.junit.Assert.assertEquals; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; import java.util.Arrays; import java.util.List; import org.junit.Test; @@ -26,7 +24,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tun import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.p2mp.lsp.mldp.p2mp.lsp.OpaqueValueBuilder; public class OpaqueUtilTest { - private static final byte[] OPAQUE_WRONG= { + private static final byte[] OPAQUE_WRONG = { (byte) 0xfc, (byte) 0x00, (byte) 0x03, // Opaque Type - Length (byte) 0xb5, (byte) 0xeb, (byte) 0x2d, //Value }; @@ -65,14 +63,16 @@ public class OpaqueUtilTest { }; static final HexString OPAQUE_TEST = new HexString("07:00:0b:00:00:01:00:00:00:01:00:00:00:00"); - static final HexString OPAQUE_TEST2 = new HexString ("07:00:0b:00:00:01:00:00:00:01:00:00:00:00:01:02"); - private static final Opaque OPAQUE = new OpaqueValueBuilder().setOpaque(OPAQUE_TEST).setOpaqueType(OpaqueUtil.GENERIC_LSP_IDENTIFIER).build(); - private static final Opaque OPAQUE_EXTENDED = new OpaqueValueBuilder().setOpaque(OPAQUE_TEST2).setOpaqueType((short) 2) - .setOpaqueType(OpaqueUtil.EXTENDED_TYPE).setOpaqueExtendedType(4).build(); - private static final List OPAQUE_VALUE_LIST = Arrays.asList((OpaqueValue) OPAQUE, (OpaqueValue) OPAQUE_EXTENDED); + static final HexString OPAQUE_TEST2 = new HexString("07:00:0b:00:00:01:00:00:00:01:00:00:00:00:01:02"); + private static final Opaque OPAQUE = new OpaqueValueBuilder().setOpaque(OPAQUE_TEST) + .setOpaqueType(OpaqueUtil.GENERIC_LSP_IDENTIFIER).build(); + private static final Opaque OPAQUE_EXTENDED = new OpaqueValueBuilder().setOpaque(OPAQUE_TEST2) + .setOpaqueType((short) 2).setOpaqueType(OpaqueUtil.EXTENDED_TYPE).setOpaqueExtendedType(4).build(); + private static final List OPAQUE_VALUE_LIST = Arrays.asList((OpaqueValue) OPAQUE, + (OpaqueValue) OPAQUE_EXTENDED); @Test - public void serializeOpaque() throws Exception { + public void serializeOpaque() { final ByteBuf actualOpaque = Unpooled.buffer(); OpaqueUtil.serializeOpaque(OPAQUE, actualOpaque); assertArrayEquals(OPAQUE_EXPECTED, ByteArray.readAllBytes(actualOpaque)); @@ -95,21 +95,10 @@ public class OpaqueUtilTest { } @Test - public void parseOpaqueList() throws Exception { + public void parseOpaqueList() { final ByteBuf opaqueValues = Unpooled.buffer(); OpaqueUtil.serializeOpaqueList(OPAQUE_VALUE_LIST, opaqueValues); assertArrayEquals(OPAQUE_VALUES_EXPECTED, ByteArray.readAllBytes(opaqueValues)); assertEquals(OPAQUE_VALUE_LIST, OpaqueUtil.parseOpaqueList(Unpooled.wrappedBuffer(OPAQUE_VALUES_EXPECTED))); } - - @Test(expected = UnsupportedOperationException.class) - public void testPrivateConstructor() throws Throwable { - final Constructor c = OpaqueUtil.class.getDeclaredConstructor(); - c.setAccessible(true); - try { - c.newInstance(); - } catch (final InvocationTargetException e) { - throw e.getCause(); - } - } } \ No newline at end of file diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/PAddressPMulticastGroupUtilTest.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/PAddressPMulticastGroupUtilTest.java index c7a2d7f26b..0d53773fd3 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/PAddressPMulticastGroupUtilTest.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/PAddressPMulticastGroupUtilTest.java @@ -12,13 +12,11 @@ import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.IPV6; -import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.P_ADDRESS; +import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.IP_ADDRESS; import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.P_MULTICAST; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; import org.junit.Test; import org.opendaylight.protocol.util.ByteArray; import org.opendaylight.protocol.util.Ipv4Util; @@ -43,7 +41,7 @@ public class PAddressPMulticastGroupUtilTest { private static class MyPAddressPMulticastGroup implements PAddressPMulticastGroup { @Override public IpAddress getPAddress() { - return P_ADDRESS; + return IP_ADDRESS; } @Override @@ -60,37 +58,30 @@ public class PAddressPMulticastGroupUtilTest { @Test public void parseIpAddress() throws Exception { final ByteBuf ipv4Actual = Unpooled.buffer(); - PAddressPMulticastGroupUtil.serializeIpAddress(P_ADDRESS, ipv4Actual); + PAddressPMulticastGroupUtil.serializeIpAddress(IP_ADDRESS, ipv4Actual); assertArrayEquals(IPV4_ADDRESS_EXPECTED, ByteArray.readAllBytes(ipv4Actual)); final ByteBuf ipv6Actual = Unpooled.buffer(); PAddressPMulticastGroupUtil.serializeIpAddress(IPV6, ipv6Actual); assertArrayEquals(IPV6_ADDRESS_EXPECTED, ByteArray.readAllBytes(ipv6Actual)); - assertEquals(P_ADDRESS, PAddressPMulticastGroupUtil.parseIpAddress(Ipv4Util.IP4_LENGTH, Unpooled.wrappedBuffer(IPV4_ADDRESS_EXPECTED))); - assertEquals(IPV6, PAddressPMulticastGroupUtil.parseIpAddress(Ipv6Util.IPV6_LENGTH, Unpooled.wrappedBuffer(IPV6_ADDRESS_EXPECTED))); - assertNull(PAddressPMulticastGroupUtil.parseIpAddress(6, Unpooled.wrappedBuffer(IPV4_ADDRESS_EXPECTED))); + assertEquals(IP_ADDRESS, PAddressPMulticastGroupUtil.parseIpAddress(Ipv4Util.IP4_LENGTH, + Unpooled.wrappedBuffer(IPV4_ADDRESS_EXPECTED))); + assertEquals(IPV6, PAddressPMulticastGroupUtil.parseIpAddress(Ipv6Util.IPV6_LENGTH, + Unpooled.wrappedBuffer(IPV6_ADDRESS_EXPECTED))); + assertNull(PAddressPMulticastGroupUtil.parseIpAddress(6, + Unpooled.wrappedBuffer(IPV4_ADDRESS_EXPECTED))); } @Test public void parseIpAddressPMulticastGroup() throws Exception { final PAddressPMulticastGroup pAddressPMulticastGroup = new MyPAddressPMulticastGroup(); final ByteBuf pAddressPMulticastGroupActual = Unpooled.buffer(); - PAddressPMulticastGroupUtil.serializeSenderPMulticastGroup(pAddressPMulticastGroup, pAddressPMulticastGroupActual); + PAddressPMulticastGroupUtil.serializeSenderPMulticastGroup(pAddressPMulticastGroup, + pAddressPMulticastGroupActual); assertArrayEquals(SENDER_P_MULTICAST_GROUP_EXPECTED, ByteArray.readAllBytes(pAddressPMulticastGroupActual)); - final PAddressPMulticastGroup actual = PAddressPMulticastGroupUtil.parseSenderPMulticastGroup(Unpooled.wrappedBuffer - (SENDER_P_MULTICAST_GROUP_EXPECTED)); - assertEquals(pAddressPMulticastGroup.getPAddress(), actual.getPAddress()); - assertEquals(pAddressPMulticastGroup.getPMulticastGroup(), actual.getPMulticastGroup()); - } - - @Test(expected = UnsupportedOperationException.class) - public void testPrivateConstructor() throws Throwable { - final Constructor constructor = PAddressPMulticastGroupUtil.class.getDeclaredConstructor(); - constructor.setAccessible(true); - try { - constructor.newInstance(); - } catch (final InvocationTargetException e) { - throw e.getCause(); - } + final PAddressPMulticastGroup actual = PAddressPMulticastGroupUtil + .parseSenderPMulticastGroup(Unpooled.wrappedBuffer(SENDER_P_MULTICAST_GROUP_EXPECTED)); + assertEquals(IP_ADDRESS, actual.getPAddress()); + assertEquals(P_MULTICAST, actual.getPMulticastGroup()); } } \ No newline at end of file diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/PMSITunnelAttributeHandlerTest.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/PMSITunnelAttributeHandlerTest.java index 884059ac7c..57a8fb48b9 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/PMSITunnelAttributeHandlerTest.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/PMSITunnelAttributeHandlerTest.java @@ -8,7 +8,6 @@ package org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier; - import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -27,17 +26,17 @@ import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifi import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.PIM_SSM_TREE_EXPECTED; import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.RSVP_TE_P2MP_LSP_LSP_EXPECTED; import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildBidirPimTreeAttribute; -import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildINGRESSREPLICATIONAttribute; -import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildMLDPMP2MPLSPAttribute; -import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildMLDPMP2MPLSPWrongAttribute; -import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildMLDPP2MPLSPIpv4Attribute; -import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildMLDPP2MPLSPIpv6Attribute; -import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildMLDPP2MPLSPL2vpnAttribute; +import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildIngressReplicationAttribute; +import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildMLDpMp2mPLspAttribute; +import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildMldpMP2mpLspWrongAttribute; +import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildMldpP2mpLspIpv4Attribute; +import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildMldpP2mpLspIpv6Attribute; +import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildMldpp2MPLspL2vpnAttribute; import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildNoSupportedFamilyAttribute; import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildNoSupportedOpaqueAttribute; import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildPimSMTreeAttribute; import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildPimSSMTreeAttribute; -import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildRSVPTEP2MPLSPLSPAttribute; +import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildRsvpTep2MPLspAttribute; import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildWOTunnelInfAttribute; import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.TunnelIdentifierHandler.NO_TUNNEL_INFORMATION_PRESENT; @@ -63,7 +62,8 @@ public class PMSITunnelAttributeHandlerTest { public void setUp() { final BGPExtensionProviderContext ctx = new SimpleBGPExtensionProviderContext(); - final org.opendaylight.protocol.bgp.parser.impl.BGPActivator inetActivator = new org.opendaylight.protocol.bgp.parser.impl.BGPActivator(); + final org.opendaylight.protocol.bgp.parser.impl.BGPActivator inetActivator = + new org.opendaylight.protocol.bgp.parser.impl.BGPActivator(); inetActivator.start(ctx); final BGPActivator bgpActivator = new BGPActivator(); bgpActivator.start(ctx); @@ -77,7 +77,8 @@ public class PMSITunnelAttributeHandlerTest { this.handler.serializeAttribute(attributes, actual); assertArrayEquals(BIDIR_PIM_EXPECTED, ByteArray.readAllBytes(actual)); final Attributes expected = buildBidirPimTreeAttribute(); - final Attributes actualAttr = this.handler.parseAttributes(Unpooled.wrappedBuffer(BIDIR_PIM_EXPECTED), null); + final Attributes actualAttr = this.handler.parseAttributes( + Unpooled.wrappedBuffer(BIDIR_PIM_EXPECTED), null); assertEquals(expected, actualAttr); } @@ -88,7 +89,8 @@ public class PMSITunnelAttributeHandlerTest { this.handler.serializeAttribute(attributes, actual); assertArrayEquals(PIM_SM_TREE_EXPECTED, ByteArray.readAllBytes(actual)); final Attributes expected = buildPimSMTreeAttribute(); - final Attributes actualAttr = this.handler.parseAttributes(Unpooled.wrappedBuffer(PIM_SM_TREE_EXPECTED), null); + final Attributes actualAttr = this.handler.parseAttributes( + Unpooled.wrappedBuffer(PIM_SM_TREE_EXPECTED), null); assertEquals(expected, actualAttr); } @@ -103,28 +105,32 @@ public class PMSITunnelAttributeHandlerTest { @Test public void parsePimSSMTree() throws Exception { final Attributes expected = buildPimSSMTreeAttribute(); - final Attributes actual = this.handler.parseAttributes(Unpooled.wrappedBuffer(PIM_SSM_TREE_EXPECTED), null); + final Attributes actual = this.handler.parseAttributes( + Unpooled.wrappedBuffer(PIM_SSM_TREE_EXPECTED), null); assertEquals(expected, actual); } @Test public void testMldpP2MpLsp() throws Exception { final ByteBuf actualIpv4 = Unpooled.buffer(); - final Attributes expectedIpv4Att = buildMLDPP2MPLSPIpv4Attribute(); + final Attributes expectedIpv4Att = buildMldpP2mpLspIpv4Attribute(); - final BGPExtensionProviderContext providerContext = ServiceLoaderBGPExtensionProviderContext.getSingletonInstance(); + final BGPExtensionProviderContext providerContext = ServiceLoaderBGPExtensionProviderContext + .getSingletonInstance(); providerContext.getAttributeRegistry().serializeAttribute(expectedIpv4Att, actualIpv4); assertArrayEquals(M_LDP_P2MP_LSP_EXPECTED_IPV4, ByteArray.readAllBytes(actualIpv4)); - final Attributes actualIpv4Attribute = this.handler.parseAttributes(Unpooled.wrappedBuffer(M_LDP_P2MP_LSP_EXPECTED_IPV4_2), null); + final Attributes actualIpv4Attribute = this.handler.parseAttributes( + Unpooled.wrappedBuffer(M_LDP_P2MP_LSP_EXPECTED_IPV4_2), null); assertEquals(expectedIpv4Att, actualIpv4Attribute); - final Attributes expectedIpv6Att = buildMLDPP2MPLSPIpv6Attribute(); + final Attributes expectedIpv6Att = buildMldpP2mpLspIpv6Attribute(); final ByteBuf actualIpv6 = Unpooled.buffer(); this.handler.serializeAttribute(expectedIpv6Att, actualIpv6); assertArrayEquals(M_LDP_P2MP_LSP_EXPECTED_IPV6, ByteArray.readAllBytes(actualIpv6)); - final Attributes actualIpv6Attribute = this.handler.parseAttributes(Unpooled.wrappedBuffer(M_LDP_P2MP_LSP_EXPECTED_IPV6), null); + final Attributes actualIpv6Attribute = this.handler.parseAttributes( + Unpooled.wrappedBuffer(M_LDP_P2MP_LSP_EXPECTED_IPV6), null); assertEquals(expectedIpv6Att, actualIpv6Attribute); final ByteBuf actualL2vpn = Unpooled.buffer(); @@ -132,11 +138,13 @@ public class PMSITunnelAttributeHandlerTest { assertArrayEquals(new byte[0], ByteArray.readAllBytes(actualIpv4)); - final Attributes actualWrongFamily = this.handler.parseAttributes(Unpooled.wrappedBuffer(M_LDP_P2MP_LSP_EXPECTED_WRONG_FAMILY), null); + final Attributes actualWrongFamily = this.handler.parseAttributes( + Unpooled.wrappedBuffer(M_LDP_P2MP_LSP_EXPECTED_WRONG_FAMILY), null); assertEquals(buildWOTunnelInfAttribute(), actualWrongFamily); - final Attributes expectedL2vpnAtt = buildMLDPP2MPLSPL2vpnAttribute(); - final Attributes actualL2vpnAttribute = this.handler.parseAttributes(Unpooled.wrappedBuffer(M_LDP_P2MP_LSP_EXPECTED_L2VPN), null); + final Attributes expectedL2vpnAtt = buildMldpp2MPLspL2vpnAttribute(); + final Attributes actualL2vpnAttribute = this.handler.parseAttributes( + Unpooled.wrappedBuffer(M_LDP_P2MP_LSP_EXPECTED_L2VPN), null); assertEquals(expectedL2vpnAtt, actualL2vpnAttribute); final ByteBuf actualL2vp = Unpooled.buffer(); @@ -150,38 +158,42 @@ public class PMSITunnelAttributeHandlerTest { @Test public void testRsvpteP2MplspLsp() throws Exception { - final Attributes expected = buildRSVPTEP2MPLSPLSPAttribute(); + final Attributes expected = buildRsvpTep2MPLspAttribute(); final ByteBuf actual = Unpooled.buffer(); this.handler.serializeAttribute(expected, actual); assertArrayEquals(RSVP_TE_P2MP_LSP_LSP_EXPECTED, ByteArray.readAllBytes(actual)); - final Attributes actualAttr = this.handler.parseAttributes(Unpooled.wrappedBuffer(RSVP_TE_P2MP_LSP_LSP_EXPECTED), null); + final Attributes actualAttr = this.handler.parseAttributes( + Unpooled.wrappedBuffer(RSVP_TE_P2MP_LSP_LSP_EXPECTED), null); assertEquals(expected, actualAttr); } @Test public void testIngressReplication() throws Exception { - final Attributes expected = buildINGRESSREPLICATIONAttribute(); + final Attributes expected = buildIngressReplicationAttribute(); final ByteBuf actual = Unpooled.buffer(); this.handler.serializeAttribute(expected, actual); assertArrayEquals(INGRESS_REPLICATION_EXPECTED, ByteArray.readAllBytes(actual)); - final Attributes actualAttr = this.handler.parseAttributes(Unpooled.wrappedBuffer(INGRESS_REPLICATION_EXPECTED), null); + final Attributes actualAttr = this.handler.parseAttributes( + Unpooled.wrappedBuffer(INGRESS_REPLICATION_EXPECTED), null); assertEquals(expected, actualAttr); } @Test public void testMldpmP2MpLsp() throws Exception { - final Attributes expected = buildMLDPMP2MPLSPAttribute(); + final Attributes expected = buildMLDpMp2mPLspAttribute(); final ByteBuf actual = Unpooled.buffer(); this.handler.serializeAttribute(expected, actual); assertArrayEquals(M_LDP_MP_2_MP_LSP_EXPECTED, ByteArray.readAllBytes(actual)); - final Attributes actualAttr = this.handler.parseAttributes(Unpooled.wrappedBuffer(M_LDP_MP_2_MP_LSP_EXPECTED), null); + final Attributes actualAttr = this.handler.parseAttributes( + Unpooled.wrappedBuffer(M_LDP_MP_2_MP_LSP_EXPECTED), null); assertEquals(expected, actualAttr); - final Attributes actualWrong = this.handler.parseAttributes(Unpooled.wrappedBuffer(M_LDP_MP_2_MP_LSP_WRONG), null); + final Attributes actualWrong = this.handler.parseAttributes( + Unpooled.wrappedBuffer(M_LDP_MP_2_MP_LSP_WRONG), null); assertEquals(buildWOTunnelInfAttribute(), actualWrong); - final Attributes wrongAttribute = buildMLDPMP2MPLSPWrongAttribute(); + final Attributes wrongAttribute = buildMldpMP2mpLspWrongAttribute(); final ByteBuf actualWrongBuf = Unpooled.buffer(); this.handler.serializeAttribute(wrongAttribute, actualWrongBuf); assertArrayEquals(NO_TUNNEL_INFORMATION_PRESENT_EXPECTED, ByteArray.readAllBytes(actualWrongBuf)); @@ -195,23 +207,27 @@ public class PMSITunnelAttributeHandlerTest { this.handler.serializeAttribute(attributes, actual); assertArrayEquals(NO_TUNNEL_INFORMATION_PRESENT_EXPECTED, ByteArray.readAllBytes(actual)); final Attributes expected = buildWOTunnelInfAttribute(); - final Attributes actualAttr = this.handler.parseAttributes(Unpooled.wrappedBuffer(NO_TUNNEL_INFORMATION_PRESENT_EXPECTED), null); + final Attributes actualAttr = this.handler.parseAttributes( + Unpooled.wrappedBuffer(NO_TUNNEL_INFORMATION_PRESENT_EXPECTED), null); assertEquals(expected, actualAttr); } @Test - public void testTunnelIdentifierUtil() throws Throwable { - final TunnelIdentifierHandler tunnelIdentifierHandler = new TunnelIdentifierHandler(ServiceLoaderBGPExtensionProviderContext - .getSingletonInstance().getAddressFamilyRegistry()); + public void testTunnelIdentifierUtil() { + final TunnelIdentifierHandler tunnelIdentifierHandler = + new TunnelIdentifierHandler(ServiceLoaderBGPExtensionProviderContext.getSingletonInstance() + .getAddressFamilyRegistry()); assertNull(tunnelIdentifierHandler.parse(1, Unpooled.buffer())); assertNull(tunnelIdentifierHandler.parse(125, Unpooled.buffer())); - assertEquals(NO_TUNNEL_INFORMATION_PRESENT, tunnelIdentifierHandler.serialize(new MockTunnelIdentifier(), Unpooled.buffer())); + assertEquals(NO_TUNNEL_INFORMATION_PRESENT, tunnelIdentifierHandler + .serialize(new MockTunnelIdentifier(), Unpooled.buffer())); } @Test - public void testPMSITunnelAttributeParser() throws Throwable { - final PMSITunnelAttributeHandler pmsiHandler = new PMSITunnelAttributeHandler(ServiceLoaderBGPExtensionProviderContext - .getSingletonInstance().getAddressFamilyRegistry()); + public void testPMSITunnelAttributeParser() { + final PMSITunnelAttributeHandler pmsiHandler = + new PMSITunnelAttributeHandler(ServiceLoaderBGPExtensionProviderContext.getSingletonInstance() + .getAddressFamilyRegistry()); assertEquals(22, pmsiHandler.getType()); final AttributesBuilder builder = new AttributesBuilder(); final ByteBuf emptyBuffer = Unpooled.buffer(); diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/PMSITunnelAttributeHandlerTestUtil.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/PMSITunnelAttributeHandlerTestUtil.java index 736e8eb571..8caf7b84a9 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/PMSITunnelAttributeHandlerTestUtil.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/attributes/tunnel/identifier/PMSITunnelAttributeHandlerTestUtil.java @@ -8,6 +8,7 @@ package org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier; +import static java.util.Collections.singletonList; import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.IPV6; import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.MPLS_LABEL; import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.OpaqueUtilTest.OPAQUE_TEST; @@ -42,7 +43,7 @@ import org.opendaylight.yangtools.yang.binding.DataContainer; final class PMSITunnelAttributeHandlerTestUtil { /** - * ATT - TYPE - ATT LENGTH + * ATT - TYPE - ATT LENGTH. * PMSI FLAG - PMSI TYPE 0- MPLS LABEL * No tunnel information present */ @@ -51,7 +52,7 @@ final class PMSITunnelAttributeHandlerTestUtil { (byte) 0x01, (byte) 0x00, (byte) 0x05, (byte) 0xdc, (byte) 0x10 }; /** - * ATT - TYPE - ATT LENGTH + * ATT - TYPE - ATT LENGTH. * PMSI FLAG - PMSI TYPE 1- MPLS LABEL * mLDP P2MP LSP */ @@ -63,7 +64,7 @@ final class PMSITunnelAttributeHandlerTestUtil { (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01, }; /** - * ATT - TYPE - ATT LENGTH + * ATT - TYPE - ATT LENGTH. * PMSI FLAG - PMSI TYPE 2- MPLS LABEL * mLDP P2MP LSP */ @@ -88,7 +89,7 @@ final class PMSITunnelAttributeHandlerTestUtil { (byte) 0x02 }; /** - * ATT - TYPE - ATT LENGTH + * ATT - TYPE - ATT LENGTH. * PMSI FLAG - PMSI TYPE 2- MPLS LABEL * mLDP P2MP LSP */ @@ -104,7 +105,7 @@ final class PMSITunnelAttributeHandlerTestUtil { (byte) 0xb5, (byte) 0xeb, (byte) 0x2d, (byte) 0xd7, (byte) 0x6d, (byte) 0xf8, //Value }; /** - * ATT - TYPE - ATT LENGTH + * ATT - TYPE - ATT LENGTH. * PMSI FLAG - PMSI TYPE 2- MPLS LABEL * mLDP P2MP LSP L2VPN */ @@ -129,7 +130,7 @@ final class PMSITunnelAttributeHandlerTestUtil { (byte) 0x02 }; /** - * ATT - TYPE - ATT LENGTH + * ATT - TYPE - ATT LENGTH. * PMSI FLAG - PMSI TYPE 2- MPLS LABEL * mLDP P2MP LSP IPV4 */ @@ -156,7 +157,7 @@ final class PMSITunnelAttributeHandlerTestUtil { (byte) 0x02 }; /** - * ATT - TYPE - ATT LENGTH + * ATT - TYPE - ATT LENGTH. * PMSI FLAG - PMSI TYPE 2- MPLS LABEL * mLDP P2MP LSP IPV6 */ @@ -184,7 +185,7 @@ final class PMSITunnelAttributeHandlerTestUtil { (byte) 0x02 }; /** - * ATT - TYPE - ATT LENGTH + * ATT - TYPE - ATT LENGTH. * PMSI FLAG - PMSI TYPE 3- MPLS LABEL * PIM-SSM Tree */ @@ -195,7 +196,7 @@ final class PMSITunnelAttributeHandlerTestUtil { (byte) 0x17, (byte) 0x01, (byte) 0x01, (byte) 0x01 }; /** - * ATT - TYPE - ATT LENGTH + * ATT - TYPE - ATT LENGTH. * PMSI FLAG - PMSI TYPE 4- MPLS LABEL * PIM-SM Tree */ @@ -206,7 +207,7 @@ final class PMSITunnelAttributeHandlerTestUtil { (byte) 0x17, (byte) 0x01, (byte) 0x01, (byte) 0x01 }; /** - * ATT - TYPE - ATT LENGTH + * ATT - TYPE - ATT LENGTH. * PMSI FLAG - PMSI TYPE 5- MPLS LABEL * BIDIR-PIM Tree */ @@ -217,7 +218,7 @@ final class PMSITunnelAttributeHandlerTestUtil { (byte) 0x17, (byte) 0x01, (byte) 0x01, (byte) 0x01 }; /** - * ATT - TYPE - ATT LENGTH + * ATT - TYPE - ATT LENGTH. * PMSI FLAG - PMSI TYPE 6- MPLS LABEL * Ingress Replication */ @@ -227,7 +228,7 @@ final class PMSITunnelAttributeHandlerTestUtil { (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01 }; /** - * ATT - TYPE - ATT LENGTH + * ATT - TYPE - ATT LENGTH. * PMSI FLAG - PMSI TYPE 7- MPLS LABEL * mLDP MP2MP LSP */ @@ -242,7 +243,7 @@ final class PMSITunnelAttributeHandlerTestUtil { (byte) 0x00, (byte) 0x00 }; /** - * ATT - TYPE - ATT LENGTH + * ATT - TYPE - ATT LENGTH. * PMSI FLAG - PMSI TYPE 7- MPLS LABEL * mLDP MP2MP LSP */ @@ -254,7 +255,7 @@ final class PMSITunnelAttributeHandlerTestUtil { }; static final IpAddress P_MULTICAST = new IpAddress(new Ipv4Address("23.1.1.1")); - static final IpAddress P_ADDRESS = new IpAddress(new Ipv4Address("1.1.1.1")); + static final IpAddress IP_ADDRESS = new IpAddress(new Ipv4Address("1.1.1.1")); private static final Short NO_SUPPORTED_OPAQUE = 200; static class MockTunnelIdentifier implements TunnelIdentifier { @@ -264,12 +265,13 @@ final class PMSITunnelAttributeHandlerTestUtil { } } - static abstract class NonSupportedAddressFamily extends AddressFamily { + private abstract static class NonSupportedAddressFamily extends AddressFamily { } private static PAddressPMulticastGroup buildPAddressPMulticastGroup() { - return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier - .bidir.pim.tree.BidirPimTreeBuilder().setPAddress(P_ADDRESS).setPMulticastGroup(P_MULTICAST).build(); + return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel + .pmsi.tunnel.tunnel.identifier.bidir.pim.tree.BidirPimTreeBuilder() + .setPAddress(IP_ADDRESS).setPMulticastGroup(P_MULTICAST).build(); } private static PmsiTunnelBuilder getPmsiTunnelBuilder() { @@ -280,51 +282,59 @@ final class PMSITunnelAttributeHandlerTestUtil { } private static Attributes buildAttribute(final PmsiTunnelBuilder pmsiTunnelBuilder) { - return new AttributesBuilder().setUnrecognizedAttributes(Collections.emptyList()).addAugmentation(PmsiTunnelAugmentation.class, + return new AttributesBuilder().setUnrecognizedAttributes(Collections.emptyList()) + .addAugmentation(PmsiTunnelAugmentation.class, new PmsiTunnelAugmentationBuilder().setPmsiTunnel(pmsiTunnelBuilder.build()).build()).build(); } static Attributes buildBidirPimTreeAttribute() { final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder(); - pmsiTunnelBuilder.setTunnelIdentifier(new BidirPimTreeBuilder().setBidirPimTree(new org.opendaylight.yang.gen.v1.urn.opendaylight.params - .xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.bidir.pim.tree.BidirPimTreeBuilder(buildPAddressPMulticastGroup()).build()).build()); + pmsiTunnelBuilder.setTunnelIdentifier(new BidirPimTreeBuilder() + .setBidirPimTree(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel + .rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.bidir.pim.tree + .BidirPimTreeBuilder(buildPAddressPMulticastGroup()).build()).build()); return buildAttribute(pmsiTunnelBuilder); } static Attributes buildPimSMTreeAttribute() { final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder(); - pmsiTunnelBuilder.setTunnelIdentifier(new PimSmTreeBuilder().setPimSmTree(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns - .yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.pim.sm.tree.PimSmTreeBuilder(buildPAddressPMulticastGroup()).build()).build()); + pmsiTunnelBuilder.setTunnelIdentifier(new PimSmTreeBuilder().setPimSmTree(new org.opendaylight.yang.gen.v1 + .urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel + .identifier.pim.sm.tree.PimSmTreeBuilder(buildPAddressPMulticastGroup()).build()).build()); return buildAttribute(pmsiTunnelBuilder); } static Attributes buildPimSSMTreeAttribute() { final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder(); - pmsiTunnelBuilder.setTunnelIdentifier(new PimSsmTreeBuilder().setPimSsmTree(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns - .yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.pim.ssm.tree.PimSsmTreeBuilder(buildPAddressPMulticastGroup()).build()).build()); + pmsiTunnelBuilder.setTunnelIdentifier(new PimSsmTreeBuilder().setPimSsmTree(new org.opendaylight.yang.gen.v1 + .urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel + .identifier.pim.ssm.tree.PimSsmTreeBuilder(buildPAddressPMulticastGroup()).build()).build()); return buildAttribute(pmsiTunnelBuilder); } static Attributes buildNoSupportedOpaqueAttribute() { final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder(); - final List nonSupported = Collections.singletonList(new OpaqueValueBuilder().setOpaque(OPAQUE_TEST).setOpaqueType(NO_SUPPORTED_OPAQUE).build()); - pmsiTunnelBuilder.setTunnelIdentifier(buildMldpP2mpLsp(P_ADDRESS, Ipv4AddressFamily.class, nonSupported)); + final List nonSupported = singletonList(new OpaqueValueBuilder() + .setOpaque(OPAQUE_TEST).setOpaqueType(NO_SUPPORTED_OPAQUE).build()); + pmsiTunnelBuilder.setTunnelIdentifier(buildMldpP2mpLsp(IP_ADDRESS, Ipv4AddressFamily.class, nonSupported)); return buildAttribute(pmsiTunnelBuilder); } static Attributes buildNoSupportedFamilyAttribute() { final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder(); - pmsiTunnelBuilder.setTunnelIdentifier(buildMldpP2mpLsp(P_ADDRESS, NonSupportedAddressFamily.class, createOpaqueList())); + pmsiTunnelBuilder.setTunnelIdentifier(buildMldpP2mpLsp(IP_ADDRESS, NonSupportedAddressFamily.class, + createOpaqueList())); return buildAttribute(pmsiTunnelBuilder); } - static Attributes buildMLDPP2MPLSPIpv4Attribute() { + static Attributes buildMldpP2mpLspIpv4Attribute() { final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder(); - pmsiTunnelBuilder.setTunnelIdentifier(buildMldpP2mpLsp(P_ADDRESS, Ipv4AddressFamily.class, createOpaqueList())); + pmsiTunnelBuilder.setTunnelIdentifier( + buildMldpP2mpLsp(IP_ADDRESS, Ipv4AddressFamily.class, createOpaqueList())); return buildAttribute(pmsiTunnelBuilder); } - static Attributes buildMLDPP2MPLSPIpv6Attribute() { + static Attributes buildMldpP2mpLspIpv6Attribute() { final PmsiTunnelBuilder pmsiTunnelBuilder = new PmsiTunnelBuilder(); pmsiTunnelBuilder.setLeafInformationRequired(true); pmsiTunnelBuilder.setMplsLabel(MPLS_LABEL); @@ -332,54 +342,62 @@ final class PMSITunnelAttributeHandlerTestUtil { return buildAttribute(pmsiTunnelBuilder); } - static Attributes buildMLDPP2MPLSPL2vpnAttribute() { + static Attributes buildMldpp2MPLspL2vpnAttribute() { final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder(); - pmsiTunnelBuilder.setTunnelIdentifier(buildMldpP2mpLsp(P_ADDRESS, L2vpnAddressFamily.class, createOpaqueList())); + pmsiTunnelBuilder.setTunnelIdentifier( + buildMldpP2mpLsp(IP_ADDRESS, L2vpnAddressFamily.class, createOpaqueList())); return buildAttribute(pmsiTunnelBuilder); } - private static TunnelIdentifier buildMldpP2mpLsp(final IpAddress pAddress, final Class family, final List opaqueList) { + private static TunnelIdentifier buildMldpP2mpLsp(final IpAddress ipAddress, + final Class family, final List opaqueList) { return new MldpP2mpLspBuilder().setMldpP2mpLsp(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml .ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.p2mp.lsp.MldpP2mpLspBuilder() - .setRootNodeAddress(pAddress).setAddressFamily(family).setOpaqueValue(opaqueList).build()).build(); + .setRootNodeAddress(ipAddress).setAddressFamily(family).setOpaqueValue(opaqueList).build()).build(); } - static Attributes buildRSVPTEP2MPLSPLSPAttribute() { + static Attributes buildRsvpTep2MPLspAttribute() { final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder(); - pmsiTunnelBuilder.setTunnelIdentifier(new RsvpTeP2mpLspBuilder().setRsvpTeP2mpLps(new org.opendaylight.yang.gen.v1.urn.opendaylight.params - .xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.rsvp.te.p2mp.lsp.RsvpTeP2mpLpsBuilder() - .setP2mpId(3458L).setTunnelId(15).setExtendedTunnelId(P_ADDRESS).build()).build()); + pmsiTunnelBuilder.setTunnelIdentifier(new RsvpTeP2mpLspBuilder() + .setRsvpTeP2mpLps(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel + .rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.rsvp.te.p2mp.lsp.RsvpTeP2mpLpsBuilder() + .setP2mpId(3458L).setTunnelId(15).setExtendedTunnelId(IP_ADDRESS).build()).build()); return buildAttribute(pmsiTunnelBuilder); } - static Attributes buildINGRESSREPLICATIONAttribute() { + static Attributes buildIngressReplicationAttribute() { final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder(); - pmsiTunnelBuilder.setTunnelIdentifier(new IngressReplicationBuilder().setIngressReplication(new org.opendaylight.yang.gen.v1.urn - .opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.ingress.replication.IngressReplicationBuilder() - .setReceivingEndpointAddress(P_ADDRESS).build()).build()); + pmsiTunnelBuilder.setTunnelIdentifier(new IngressReplicationBuilder().setIngressReplication(new org + .opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi + .tunnel.tunnel.identifier.ingress.replication.IngressReplicationBuilder() + .setReceivingEndpointAddress(IP_ADDRESS).build()).build()); return buildAttribute(pmsiTunnelBuilder); } - static Attributes buildMLDPMP2MPLSPWrongAttribute() { + static Attributes buildMldpMP2mpLspWrongAttribute() { final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder(); - pmsiTunnelBuilder.setTunnelIdentifier(new MldpMp2mpLspBuilder().setMldpMp2mpLsp(new org.opendaylight.yang.gen.v1.urn.opendaylight.params - .xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp - .MldpMp2mpLspBuilder().setOpaque(OPAQUE_TEST).setOpaqueType(NO_SUPPORTED_OPAQUE).build()).build()); + pmsiTunnelBuilder.setTunnelIdentifier(new MldpMp2mpLspBuilder().setMldpMp2mpLsp(new org.opendaylight.yang.gen + .v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier + .mldp.mp2mp.lsp.MldpMp2mpLspBuilder().setOpaque(OPAQUE_TEST).setOpaqueType(NO_SUPPORTED_OPAQUE) + .build()).build()); return buildAttribute(pmsiTunnelBuilder); } - static Attributes buildMLDPMP2MPLSPAttribute() { + static Attributes buildMLDpMp2mPLspAttribute() { final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder(); - pmsiTunnelBuilder.setTunnelIdentifier(new MldpMp2mpLspBuilder().setMldpMp2mpLsp(new org.opendaylight.yang.gen.v1.urn.opendaylight.params - .xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp - .MldpMp2mpLspBuilder().setOpaque(OPAQUE_TEST).setOpaqueType(OpaqueUtil.GENERIC_LSP_IDENTIFIER).build()).build()); + pmsiTunnelBuilder.setTunnelIdentifier(new MldpMp2mpLspBuilder().setMldpMp2mpLsp(new org.opendaylight.yang.gen + .v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel + .identifier.mldp.mp2mp.lsp.MldpMp2mpLspBuilder().setOpaque(OPAQUE_TEST) + .setOpaqueType(OpaqueUtil.GENERIC_LSP_IDENTIFIER).build()).build()); return buildAttribute(pmsiTunnelBuilder); } private static List createOpaqueList() { final List opaqueValues = new ArrayList<>(); - opaqueValues.add(new OpaqueValueBuilder().setOpaque(OPAQUE_TEST).setOpaqueType(OpaqueUtil.GENERIC_LSP_IDENTIFIER).build()); - opaqueValues.add(new OpaqueValueBuilder().setOpaque(OPAQUE_TEST2).setOpaqueType((short) 2).setOpaqueType(OpaqueUtil.EXTENDED_TYPE) + opaqueValues.add(new OpaqueValueBuilder().setOpaque(OPAQUE_TEST) + .setOpaqueType(OpaqueUtil.GENERIC_LSP_IDENTIFIER).build()); + opaqueValues.add(new OpaqueValueBuilder().setOpaque(OPAQUE_TEST2) + .setOpaqueType((short) 2).setOpaqueType(OpaqueUtil.EXTENDED_TYPE) .setOpaqueExtendedType(4).build()); return opaqueValues; } diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/ASGenParserTest.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/ASGenParserTest.java index 9ac2ee77d2..cb3b6e225a 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/ASGenParserTest.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/ASGenParserTest.java @@ -33,10 +33,10 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; public final class ASGenParserTest { - private static final byte[] VALUE = {(byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x02, - (byte) 0x02, (byte) 0x00}; - private static final byte[] RESULT = {(byte) 0x05, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x02, - (byte) 0x02, (byte) 0x00}; + private static final byte[] VALUE = {(byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x02, + (byte) 0x02, (byte) 0x02, (byte) 0x00}; + private static final byte[] RESULT = {(byte) 0x05, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x02, + (byte) 0x02, (byte) 0x02, (byte) 0x02, (byte) 0x00}; private ASGenParser parser; @Before @@ -48,15 +48,16 @@ public final class ASGenParserTest { public void parserTest() { final ByteBuf buff = Unpooled.buffer(VALUE_SIZE); - final AsGeneratedCase asGen = new AsGeneratedCaseBuilder().setAsGenerated(new AsGeneratedBuilder().setAs(AS_NUMBER).setLocalDiscriminator(LD) - .build()).build(); + final AsGeneratedCase asGen = new AsGeneratedCaseBuilder().setAsGenerated(new AsGeneratedBuilder() + .setAs(AS_NUMBER).setLocalDiscriminator(LD).build()).build(); this.parser.serializeEsi(asGen, buff); assertArrayEquals(RESULT, ByteArray.getAllBytes(buff)); final Esi acResult = this.parser.parseEsi(Unpooled.wrappedBuffer(VALUE)); assertEquals(asGen, acResult); - final ContainerNode cont = createContBuilder(new NodeIdentifier(AsGenerated.QNAME)).addChild(createValueBuilder(AS_MODEL, AS_NID).build()) + final ContainerNode cont = createContBuilder(new NodeIdentifier(AsGenerated.QNAME)) + .addChild(createValueBuilder(AS_MODEL, AS_NID).build()) .addChild(createValueBuilder(LD, LD_NID).build()).build(); final Esi acmResult = this.parser.serializeEsi(cont); assertEquals(asGen, acmResult); diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/ArbitraryParserTest.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/ArbitraryParserTest.java index f0f65ae87f..6ed2c35f83 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/ArbitraryParserTest.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/ArbitraryParserTest.java @@ -29,10 +29,10 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; public final class ArbitraryParserTest { - private static final byte[] ARB_VALUE = {(byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, - (byte) 0x08, (byte) 0x09}; - private static final byte[] ARB_RESULT = {(byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06, - (byte) 0x07, (byte) 0x08, (byte) 0x09}; + private static final byte[] ARB_VALUE = {(byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05, + (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09}; + private static final byte[] ARB_RESULT = {(byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, + (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09}; private ArbitraryParser parser; @Before @@ -44,7 +44,8 @@ public final class ArbitraryParserTest { public void parserTest() { final ByteBuf buff = Unpooled.buffer(VALUE_SIZE); - final ArbitraryCase arbitrary = new ArbitraryCaseBuilder().setArbitrary(new ArbitraryBuilder().setArbitrary(ARB_VALUE).build()).build(); + final ArbitraryCase arbitrary = new ArbitraryCaseBuilder().setArbitrary(new ArbitraryBuilder() + .setArbitrary(ARB_VALUE).build()).build(); this.parser.serializeEsi(arbitrary, buff); assertArrayEquals(ARB_RESULT, ByteArray.getAllBytes(buff)); @@ -52,7 +53,7 @@ public final class ArbitraryParserTest { assertEquals(arbitrary, acResult); final ContainerNode cont = createContBuilder(new NodeIdentifier(Arbitrary.QNAME)) - .addChild(createValueBuilder(ARB_VALUE, ARB_NID).build()).build(); + .addChild(createValueBuilder(ARB_VALUE, ARB_NID).build()).build(); final Esi acmResult = this.parser.serializeEsi(cont); assertEquals(arbitrary, acmResult); } diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/LacpParserTest.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/LacpParserTest.java index 735dcf208a..01fe7b1aad 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/LacpParserTest.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/LacpParserTest.java @@ -33,10 +33,10 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; public final class LacpParserTest { - private static final byte[] VALUE = {(byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, - (byte) 0x02, (byte) 0x00}; - private static final byte[] RESULT = {(byte) 0x01, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, - (byte) 0x02, (byte) 0x00}; + private static final byte[] VALUE = {(byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, + (byte) 0x02, (byte) 0x02, (byte) 0x00}; + private static final byte[] RESULT = {(byte) 0x01, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, + (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00}; private LacpParser parser; @Before @@ -48,18 +48,19 @@ public final class LacpParserTest { public void parserTest() { final ByteBuf buff = Unpooled.buffer(VALUE_SIZE); - final LacpAutoGeneratedCase lanAuto = new LacpAutoGeneratedCaseBuilder().setLacpAutoGenerated(new LacpAutoGeneratedBuilder() - .setCeLacpMacAddress(MAC).setCeLacpPortKey(PORT).build()).build(); + final LacpAutoGeneratedCase lanAuto = new LacpAutoGeneratedCaseBuilder() + .setLacpAutoGenerated(new LacpAutoGeneratedBuilder() + .setCeLacpMacAddress(MAC).setCeLacpPortKey(PORT).build()).build(); this.parser.serializeEsi(lanAuto, buff); assertArrayEquals(RESULT, ByteArray.getAllBytes(buff)); final Esi acResult = this.parser.parseEsi(Unpooled.wrappedBuffer(VALUE)); assertEquals(lanAuto, acResult); - final ContainerNode cont = createContBuilder( new NodeIdentifier(LacpAutoGenerated.QNAME)) - .addChild(createValueBuilder(MAC_MODEL, LACP_MAC_NID).build()) - .addChild(createValueBuilder(PORT, PK_NID).build()) - .build(); + final ContainerNode cont = createContBuilder(new NodeIdentifier(LacpAutoGenerated.QNAME)) + .addChild(createValueBuilder(MAC_MODEL, LACP_MAC_NID).build()) + .addChild(createValueBuilder(PORT, PK_NID).build()) + .build(); final Esi acmResult = this.parser.serializeEsi(cont); assertEquals(lanAuto, acmResult); } diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/LanParserTest.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/LanParserTest.java index a662d024a2..084828af6e 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/LanParserTest.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/LanParserTest.java @@ -36,12 +36,13 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContaine public class LanParserTest { private static final Integer PRIORITY = 514; - public static final LanAutoGeneratedCase LAN_AUT_GEN_CASE = new LanAutoGeneratedCaseBuilder().setLanAutoGenerated(new LanAutoGeneratedBuilder() + public static final LanAutoGeneratedCase LAN_AUT_GEN_CASE = new LanAutoGeneratedCaseBuilder() + .setLanAutoGenerated(new LanAutoGeneratedBuilder() .setRootBridgeMacAddress(MAC).setRootBridgePriority(PRIORITY).build()).build(); - private static final byte[] VALUE = {(byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, - (byte) 0x02, (byte) 0x00}; - private static final byte[] RESULT = {(byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, - (byte) 0x02, (byte) 0x00}; + private static final byte[] VALUE = {(byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, + (byte) 0x02, (byte) 0x02, (byte) 0x00}; + private static final byte[] RESULT = {(byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, + (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00}; private LanParser parser; @Before @@ -74,7 +75,8 @@ public class LanParserTest { } private static ContainerNode createLanCont() { - return createContBuilder(new NodeIdentifier(LanAutoGenerated.QNAME)).addChild(createValueBuilder(MAC_MODEL, BRIDGE_MAC_NID).build()) - .addChild(createValueBuilder(PRIORITY, RBP_NID).build()).build(); + return createContBuilder(new NodeIdentifier(LanAutoGenerated.QNAME)) + .addChild(createValueBuilder(MAC_MODEL, BRIDGE_MAC_NID).build()) + .addChild(createValueBuilder(PRIORITY, RBP_NID).build()).build(); } } \ No newline at end of file diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/MacParserTest.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/MacParserTest.java index 5eb229b0b0..259598d56e 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/MacParserTest.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/MacParserTest.java @@ -33,10 +33,10 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; public final class MacParserTest { - private static final byte[] VALUE = {(byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, - (byte) 0x02, (byte) 0x00}; - private static final byte[] RESULT = {(byte) 0x03, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, - (byte) 0x02, (byte) 0x00}; + private static final byte[] VALUE = {(byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, + (byte) 0x02, (byte) 0x02, (byte) 0x00}; + private static final byte[] RESULT = {(byte) 0x03, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, + (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00}; private static final long UINT24_LD_MODEL = 131584L; private static final Uint24 UINT24_LD = new Uint24(UINT24_LD_MODEL); private MacParser parser; @@ -50,16 +50,19 @@ public final class MacParserTest { public void parserTest() { final ByteBuf buff = Unpooled.buffer(VALUE_SIZE); - final MacAutoGeneratedCase macAuto = new MacAutoGeneratedCaseBuilder().setMacAutoGenerated(new MacAutoGeneratedBuilder() - .setLocalDiscriminator(UINT24_LD).setSystemMacAddress(MAC).build()).build(); + final MacAutoGeneratedCase macAuto = new MacAutoGeneratedCaseBuilder() + .setMacAutoGenerated(new MacAutoGeneratedBuilder() + .setLocalDiscriminator(UINT24_LD) + .setSystemMacAddress(MAC).build()).build(); this.parser.serializeEsi(macAuto, buff); assertArrayEquals(RESULT, ByteArray.getAllBytes(buff)); final Esi acResult = this.parser.parseEsi(Unpooled.wrappedBuffer(VALUE)); assertEquals(macAuto, acResult); - final ContainerNode cont = createContBuilder(new NodeIdentifier(MacAutoGenerated.QNAME)).addChild(createValueBuilder(MAC_MODEL, SYSTEM_MAC_NID).build()) - .addChild(createValueBuilder(UINT24_LD_MODEL, LD_NID).build()).build(); + final ContainerNode cont = createContBuilder(new NodeIdentifier(MacAutoGenerated.QNAME)) + .addChild(createValueBuilder(MAC_MODEL, SYSTEM_MAC_NID).build()) + .addChild(createValueBuilder(UINT24_LD_MODEL, LD_NID).build()).build(); final Esi acmResult = this.parser.serializeEsi(cont); assertEquals(macAuto, acmResult); } diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/RouterIdParserTest.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/RouterIdParserTest.java index c643ea4dd7..5844562bfd 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/RouterIdParserTest.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/RouterIdParserTest.java @@ -35,13 +35,14 @@ import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder; public class RouterIdParserTest { - public static final byte[] RESULT = {(byte) 0x04, (byte) 0x2A, (byte) 0x2A, (byte) 0x2A, (byte) 0x2A, (byte) 0x02, (byte) 0x02, (byte) 0x02, - (byte) 0x02, (byte) 0x00}; - private static final byte[] VALUE = {(byte) 0x2A, (byte) 0x2A, (byte) 0x2A, (byte) 0x2A, (byte) 0x02, (byte) 0x02, (byte) 0x02, - (byte) 0x02, (byte) 0x00}; + public static final byte[] RESULT = {(byte) 0x04, (byte) 0x2A, (byte) 0x2A, (byte) 0x2A, (byte) 0x2A, (byte) 0x02, + (byte) 0x02, (byte) 0x02, (byte) 0x02, (byte) 0x00}; + private static final byte[] VALUE = {(byte) 0x2A, (byte) 0x2A, (byte) 0x2A, (byte) 0x2A, (byte) 0x02, (byte) 0x02, + (byte) 0x02, (byte) 0x02, (byte) 0x00}; private static final Ipv4Address ROUTE_ID = new Ipv4Address("42.42.42.42"); - public static final RouterIdGeneratedCase ROUTE_ID_CASE = new RouterIdGeneratedCaseBuilder().setRouterIdGenerated(new RouterIdGeneratedBuilder() - .setLocalDiscriminator(LD).setRouterId(ROUTE_ID).build()).build(); + public static final RouterIdGeneratedCase ROUTE_ID_CASE = new RouterIdGeneratedCaseBuilder() + .setRouterIdGenerated(new RouterIdGeneratedBuilder() + .setLocalDiscriminator(LD).setRouterId(ROUTE_ID).build()).build(); private static final String ROUTE_ID_MODEL = "42.42.42.42"; private RouterIdParser parser; diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/DefaultGatewayExtComTest.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/DefaultGatewayExtComTest.java index 04073e821a..130e279c86 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/DefaultGatewayExtComTest.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/DefaultGatewayExtComTest.java @@ -37,8 +37,9 @@ public class DefaultGatewayExtComTest { public void parserTest() throws BGPParsingException, BGPDocumentedException { final ByteBuf buff = Unpooled.buffer(COMMUNITY_VALUE_SIZE); - final DefaultGatewayExtendedCommunityCase expected = new DefaultGatewayExtendedCommunityCaseBuilder().setDefaultGatewayExtendedCommunity( - new DefaultGatewayExtendedCommunityBuilder().build()).build(); + final DefaultGatewayExtendedCommunityCase expected = new DefaultGatewayExtendedCommunityCaseBuilder() + .setDefaultGatewayExtendedCommunity( + new DefaultGatewayExtendedCommunityBuilder().build()).build(); this.parser.serializeExtendedCommunity(expected, buff); assertArrayEquals(RESULT, ByteArray.getAllBytes(buff)); diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/ESILabelExtComTest.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/ESILabelExtComTest.java index eeb93a2e48..e5699f8c29 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/ESILabelExtComTest.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/ESILabelExtComTest.java @@ -38,8 +38,9 @@ public class ESILabelExtComTest { public void parserTest() throws BGPParsingException, BGPDocumentedException { final ByteBuf buff = Unpooled.buffer(COMMUNITY_VALUE_SIZE); - final EsiLabelExtendedCommunityCase expected = new EsiLabelExtendedCommunityCaseBuilder().setEsiLabelExtendedCommunity( - new EsiLabelExtendedCommunityBuilder().setSingleActiveMode(true).setEsiLabel(MPLS_LABEL).build()).build(); + final EsiLabelExtendedCommunityCase expected = new EsiLabelExtendedCommunityCaseBuilder() + .setEsiLabelExtendedCommunity(new EsiLabelExtendedCommunityBuilder() + .setSingleActiveMode(true).setEsiLabel(MPLS_LABEL).build()).build(); this.parser.serializeExtendedCommunity(expected, buff); assertArrayEquals(RESULT, ByteArray.getAllBytes(buff)); diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/ESImpRouteTargetExtComTest.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/ESImpRouteTargetExtComTest.java index 4a1994582d..efac6296ab 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/ESImpRouteTargetExtComTest.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/ESImpRouteTargetExtComTest.java @@ -38,8 +38,9 @@ public class ESImpRouteTargetExtComTest { public void parserTest() throws BGPParsingException, BGPDocumentedException { final ByteBuf buff = Unpooled.buffer(COMMUNITY_VALUE_SIZE); - final EsImportRouteExtendedCommunityCase expected = new EsImportRouteExtendedCommunityCaseBuilder().setEsImportRouteExtendedCommunity( - new EsImportRouteExtendedCommunityBuilder().setEsImport(MAC).build()).build(); + final EsImportRouteExtendedCommunityCase expected = new EsImportRouteExtendedCommunityCaseBuilder() + .setEsImportRouteExtendedCommunity( + new EsImportRouteExtendedCommunityBuilder().setEsImport(MAC).build()).build(); this.parser.serializeExtendedCommunity(expected, buff); assertArrayEquals(RESULT, ByteArray.getAllBytes(buff)); diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/Layer2AttributesExtComTest.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/Layer2AttributesExtComTest.java index efe2362724..4c1bb85616 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/Layer2AttributesExtComTest.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/Layer2AttributesExtComTest.java @@ -28,9 +28,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.ExtendedCommunity; public class Layer2AttributesExtComTest { - private static final byte[] EXPECTEDS = {(byte) 0x00, (byte) 0x07, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x00}; - private static final byte[] EVPN_VPWS = {(byte) 0x00, (byte) 0x2f, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x00}; - private static final byte[] EVPN_VPWS_2 = {(byte) 0x00, (byte) 0x57, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x00}; + private static final byte[] EXPECTEDS = {(byte) 0x00, (byte) 0x07, (byte) 0x01, (byte) 0x01, + (byte) 0x00, (byte) 0x00}; + private static final byte[] EVPN_VPWS = {(byte) 0x00, (byte) 0x2f, (byte) 0x01, (byte) 0x01, + (byte) 0x00, (byte) 0x00}; + private static final byte[] EVPN_VPWS_2 = {(byte) 0x00, (byte) 0x57, (byte) 0x01, (byte) 0x01, + (byte) 0x00, (byte) 0x00}; private Layer2AttributesExtCom parser; @Before @@ -43,8 +46,8 @@ public class Layer2AttributesExtComTest { final ByteBuf buff = Unpooled.buffer(COMMUNITY_VALUE_SIZE); final Layer2AttributesExtendedCommunityCase expected = new Layer2AttributesExtendedCommunityCaseBuilder() - .setLayer2AttributesExtendedCommunity(new Layer2AttributesExtendedCommunityBuilder().setBackupPe(true) - .setControlWord(true).setPrimaryPe(true).setL2Mtu(257).build()).build(); + .setLayer2AttributesExtendedCommunity(new Layer2AttributesExtendedCommunityBuilder().setBackupPe(true) + .setControlWord(true).setPrimaryPe(true).setL2Mtu(257).build()).build(); this.parser.serializeExtendedCommunity(expected, buff); final byte[] resultByte = ByteArray.getAllBytes(buff); assertArrayEquals(EXPECTEDS, resultByte); @@ -58,11 +61,11 @@ public class Layer2AttributesExtComTest { final ByteBuf buff = Unpooled.buffer(COMMUNITY_VALUE_SIZE); final Layer2AttributesExtendedCommunityCase expected = new Layer2AttributesExtendedCommunityCaseBuilder() - .setLayer2AttributesExtendedCommunity(new Layer2AttributesExtendedCommunityBuilder().setBackupPe(true) - .setControlWord(true).setPrimaryPe(true).setL2Mtu(257) - .setModeOfOperation(OperationalMode.VlanAwareFxc) - .setOperatingPer(NormalizationType.SingleVid) - .build()).build(); + .setLayer2AttributesExtendedCommunity(new Layer2AttributesExtendedCommunityBuilder().setBackupPe(true) + .setControlWord(true).setPrimaryPe(true).setL2Mtu(257) + .setModeOfOperation(OperationalMode.VlanAwareFxc) + .setOperatingPer(NormalizationType.SingleVid) + .build()).build(); this.parser.serializeExtendedCommunity(expected, buff); final byte[] resultByte = ByteArray.getAllBytes(buff); assertArrayEquals(EVPN_VPWS, resultByte); @@ -72,11 +75,11 @@ public class Layer2AttributesExtComTest { final ByteBuf buff2 = Unpooled.buffer(COMMUNITY_VALUE_SIZE); final Layer2AttributesExtendedCommunityCase expected2 = new Layer2AttributesExtendedCommunityCaseBuilder() - .setLayer2AttributesExtendedCommunity(new Layer2AttributesExtendedCommunityBuilder().setBackupPe(true) - .setControlWord(true).setPrimaryPe(true).setL2Mtu(257) - .setModeOfOperation(OperationalMode.VlanUnawareFxc) - .setOperatingPer(NormalizationType.DoubleVid) - .build()).build(); + .setLayer2AttributesExtendedCommunity(new Layer2AttributesExtendedCommunityBuilder().setBackupPe(true) + .setControlWord(true).setPrimaryPe(true).setL2Mtu(257) + .setModeOfOperation(OperationalMode.VlanUnawareFxc) + .setOperatingPer(NormalizationType.DoubleVid) + .build()).build(); this.parser.serializeExtendedCommunity(expected2, buff2); final byte[] resultByte2 = ByteArray.getAllBytes(buff2); assertArrayEquals(EVPN_VPWS_2, resultByte2); diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/MACMobExtComTest.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/MACMobExtComTest.java index 461c6899f2..ddbcb87673 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/MACMobExtComTest.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/MACMobExtComTest.java @@ -38,8 +38,9 @@ public class MACMobExtComTest { public void parserTest() throws BGPParsingException, BGPDocumentedException { final ByteBuf buff = Unpooled.buffer(COMMUNITY_VALUE_SIZE); - final MacMobilityExtendedCommunityCase expected = new MacMobilityExtendedCommunityCaseBuilder().setMacMobilityExtendedCommunity( - new MacMobilityExtendedCommunityBuilder().setStatic(true).setSeqNumber(LD).build()).build(); + final MacMobilityExtendedCommunityCase expected = new MacMobilityExtendedCommunityCaseBuilder() + .setMacMobilityExtendedCommunity(new MacMobilityExtendedCommunityBuilder() + .setStatic(true).setSeqNumber(LD).build()).build(); this.parser.serializeExtendedCommunity(expected, buff); assertArrayEquals(RESULT, ByteArray.getAllBytes(buff)); diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EthADRParserTest.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EthADRParserTest.java index 8b6048c250..99ea159e1d 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EthADRParserTest.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EthADRParserTest.java @@ -44,7 +44,8 @@ public class EthADRParserTest { public static final byte[] RESULT = { (byte) 0x01, (byte) 0x19, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x01, (byte) 0x02, - (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00, + (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, + (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0a, (byte) 0x05, (byte) 0xdc, (byte) 0x10 }; public static final byte[] ROUDE_DISTIN = { @@ -52,12 +53,15 @@ public class EthADRParserTest { }; static final EthernetTagId ETI = new EthernetTagIdBuilder().setVlanId(VLAN).build(); public static final EthernetADRouteCase ETHERNET_AD_ROUTE_CASE_KEY = new EthernetADRouteCaseBuilder() - .setEthernetADRoute(new EthernetADRouteBuilder().setEsi(LAN_AUT_GEN_CASE).setEthernetTagId(ETI).build()).build(); - public static final EthernetADRouteCase ETHERNET_AD_ROUTE_CASE = new EthernetADRouteCaseBuilder().setEthernetADRoute(new EthernetADRouteBuilder() + .setEthernetADRoute(new EthernetADRouteBuilder().setEsi(LAN_AUT_GEN_CASE) + .setEthernetTagId(ETI).build()).build(); + public static final EthernetADRouteCase ETHERNET_AD_ROUTE_CASE = new EthernetADRouteCaseBuilder() + .setEthernetADRoute(new EthernetADRouteBuilder() .setEsi(LAN_AUT_GEN_CASE).setEthernetTagId(ETI).setMplsLabel(MPLS_LABEL).build()).build(); static final byte[] WRONG_VALUE = {(byte) 0x00}; private static final byte[] VALUE = { - (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00, + (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, + (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0a, (byte) 0x05, (byte) 0xdc, (byte) 0x10 }; private EthADRParser parser; diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EthSegRParserTest.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EthSegRParserTest.java index 5a26a910f0..0284e6c414 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EthSegRParserTest.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EthSegRParserTest.java @@ -40,17 +40,18 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContaine public class EthSegRParserTest { private static final byte[] VALUE = { - (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00, - (byte) 0x20, (byte) 0x7f, (byte) 0x00, (byte) 0x00, (byte) 0x01 + (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, + (byte) 0x02, (byte) 0x00, (byte) 0x20, (byte) 0x7f, (byte) 0x00, (byte) 0x00, (byte) 0x01 }; private static final byte[] RESULT = { (byte) 0x04, (byte) 0x17, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x01, (byte) 0x02, - (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00, - (byte) 0x20, (byte) 0x7f, (byte) 0x00, (byte) 0x00, (byte) 0x01 + (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, + (byte) 0x02, (byte) 0x00, (byte) 0x20, (byte) 0x7f, (byte) 0x00, (byte) 0x00, (byte) 0x01 }; private static final byte[] VALUE2 = { - (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00, + (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, + (byte) 0x02, (byte) 0x00, (byte) 0x80,//IPV6 (byte) 0x20, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, @@ -60,7 +61,8 @@ public class EthSegRParserTest { private static final byte[] RESULT2 = { (byte) 0x04, (byte) 0x23, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x01, (byte) 0x02, - (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00, + (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, + (byte) 0x02, (byte) 0x00, (byte) 0x80,//IPV6 (byte) 0x20, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, @@ -77,16 +79,20 @@ public class EthSegRParserTest { @Test public void parserTest() { - final EsRouteCase expected = new EsRouteCaseBuilder().setEsRoute(new EsRouteBuilder().setEsi(LAN_AUT_GEN_CASE).setOrigRouteIp(IP).build()).build(); - assertArrayEquals(RESULT, ByteArray.getAllBytes(this.parser.serializeEvpn(expected, Unpooled.wrappedBuffer(ROUDE_DISTIN)))); + final EsRouteCase expected = new EsRouteCaseBuilder().setEsRoute(new EsRouteBuilder() + .setEsi(LAN_AUT_GEN_CASE).setOrigRouteIp(IP).build()).build(); + assertArrayEquals(RESULT, ByteArray.getAllBytes(this.parser.serializeEvpn(expected, + Unpooled.wrappedBuffer(ROUDE_DISTIN)))); final EvpnChoice result = this.parser.parseEvpn(Unpooled.wrappedBuffer(VALUE)); assertEquals(expected, result); - final DataContainerNodeBuilder choice = Builders.choiceBuilder(); + final DataContainerNodeBuilder choice = Builders + .choiceBuilder(); choice.withNodeIdentifier(EthSegRParser.ES_ROUTE_NID); - final ContainerNode arbitraryC = createContBuilder(EthSegRParser.ES_ROUTE_NID).addChild(LanParserTest.createLanChoice()) - .addChild(createValueBuilder(IP_MODEL, ORI_NID).build()).build(); + final ContainerNode arbitraryC = createContBuilder(EthSegRParser.ES_ROUTE_NID) + .addChild(LanParserTest.createLanChoice()) + .addChild(createValueBuilder(IP_MODEL, ORI_NID).build()).build(); final EvpnChoice modelResult = this.parser.serializeEvpnModel(arbitraryC); assertEquals(expected, modelResult); @@ -96,16 +102,20 @@ public class EthSegRParserTest { @Test public void parser2Test() { - final EsRouteCase expected = new EsRouteCaseBuilder().setEsRoute(new EsRouteBuilder().setEsi(LAN_AUT_GEN_CASE).setOrigRouteIp(IPV6).build()).build(); - assertArrayEquals(RESULT2, ByteArray.getAllBytes(this.parser.serializeEvpn(expected, Unpooled.wrappedBuffer(ROUDE_DISTIN)))); + final EsRouteCase expected = new EsRouteCaseBuilder().setEsRoute(new EsRouteBuilder() + .setEsi(LAN_AUT_GEN_CASE).setOrigRouteIp(IPV6).build()).build(); + assertArrayEquals(RESULT2, ByteArray.getAllBytes(this.parser.serializeEvpn(expected, + Unpooled.wrappedBuffer(ROUDE_DISTIN)))); final EvpnChoice result = this.parser.parseEvpn(Unpooled.wrappedBuffer(VALUE2)); assertEquals(expected, result); - final DataContainerNodeBuilder choice = Builders.choiceBuilder(); + final DataContainerNodeBuilder choice = Builders + .choiceBuilder(); choice.withNodeIdentifier(EthSegRParser.ES_ROUTE_NID); - final ContainerNode arbitraryC = createContBuilder(EthSegRParser.ES_ROUTE_NID).addChild(LanParserTest.createLanChoice()) - .addChild(createValueBuilder(IPV6_MODEL, ORI_NID).build()).build(); + final ContainerNode arbitraryC = createContBuilder(EthSegRParser.ES_ROUTE_NID) + .addChild(LanParserTest.createLanChoice()) + .addChild(createValueBuilder(IPV6_MODEL, ORI_NID).build()).build(); final EvpnChoice modelResult = this.parser.serializeEvpnModel(arbitraryC); assertEquals(expected, modelResult); diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EvpnNlriAttributesParserTest.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EvpnNlriAttributesParserTest.java index b14a581be0..e7f202879b 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EvpnNlriAttributesParserTest.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EvpnNlriAttributesParserTest.java @@ -7,13 +7,13 @@ */ package org.opendaylight.protocol.bgp.evpn.impl.nlri; -import static org.junit.Assert.assertArrayEquals; +import static java.util.Collections.singletonList; import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.RD; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import java.util.ArrayList; -import java.util.Collections; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.opendaylight.protocol.bgp.evpn.impl.esi.types.ESIActivator; @@ -53,14 +53,17 @@ public class EvpnNlriAttributesParserTest { final Attributes att = new AttributesBuilder().addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(createReach()).build()).build(); this.parser.serializeAttribute(att, buffer); - assertArrayEquals(IncMultEthTagRParserTest.RESULT, ByteArray.getAllBytes(buffer)); + Assert.assertArrayEquals(IncMultEthTagRParserTest.RESULT, ByteArray.getAllBytes(buffer)); } private static MpReachNlri createReach() { final MpReachNlriBuilder mpReachExpected = new MpReachNlriBuilder(); final AdvertizedRoutes wd = new AdvertizedRoutesBuilder().setDestinationType(new DestinationEvpnCaseBuilder() - .setDestinationEvpn(new DestinationEvpnBuilder().setEvpnDestination(Collections.singletonList(new EvpnDestinationBuilder() - .setRouteDistinguisher(RD).setEvpnChoice(IncMultEthTagRParserTest.createIncMultiCase()).build())).build()).build()).build(); + .setDestinationEvpn(new DestinationEvpnBuilder().setEvpnDestination( + singletonList(new EvpnDestinationBuilder() + .setRouteDistinguisher(RD) + .setEvpnChoice(IncMultEthTagRParserTest.createIncMultiCase()) + .build())).build()).build()).build(); return mpReachExpected.setAdvertizedRoutes(wd).build(); } @@ -70,14 +73,20 @@ public class EvpnNlriAttributesParserTest { final Attributes att = new AttributesBuilder().addAugmentation(Attributes2.class, new Attributes2Builder().setMpUnreachNlri(createUnreach()).build()).build(); this.parser.serializeAttribute(att, buffer); - assertArrayEquals(IncMultEthTagRParserTest.RESULT, ByteArray.getAllBytes(buffer)); + Assert.assertArrayEquals(IncMultEthTagRParserTest.RESULT, ByteArray.getAllBytes(buffer)); } private static MpUnreachNlri createUnreach() { final MpUnreachNlriBuilder mpReachExpected = new MpUnreachNlriBuilder(); - final WithdrawnRoutes wd = new WithdrawnRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCaseBuilder() - .setDestinationEvpn(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.evpn._case.DestinationEvpnBuilder().setEvpnDestination(Collections.singletonList(new EvpnDestinationBuilder() - .setRouteDistinguisher(RD).setEvpnChoice(IncMultEthTagRParserTest.createIncMultiCase()).build())).build()).build()).build(); + final WithdrawnRoutes wd = new WithdrawnRoutesBuilder() + .setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn + .rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type + .DestinationEvpnCaseBuilder().setDestinationEvpn(new org.opendaylight.yang.gen.v1.urn + .opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn + .routes.destination.type.destination.evpn._case.DestinationEvpnBuilder() + .setEvpnDestination(singletonList(new EvpnDestinationBuilder() + .setRouteDistinguisher(RD).setEvpnChoice(IncMultEthTagRParserTest.createIncMultiCase()) + .build())).build()).build()).build(); return mpReachExpected.setWithdrawnRoutes(wd).build(); } diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EvpnNlriParserTest.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EvpnNlriParserTest.java index a22a336f2a..007299857e 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EvpnNlriParserTest.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EvpnNlriParserTest.java @@ -50,13 +50,19 @@ public class EvpnNlriParserTest { private List dest; private EvpnNlriParser parser; + static ChoiceNode createMACIpAdvChoice() { + final DataContainerNodeBuilder choice = Builders.choiceBuilder(); + choice.withNodeIdentifier(EVPN_CHOICE_NID); + return choice.addChild(MACIpAdvRParserTest.createMacIpCont()).build(); + } + @Before public void setUp() { ESIActivator.registerEsiTypeParsers(new ArrayList<>()); NlriActivator.registerNlriParsers(new ArrayList<>()); this.dest = Collections.singletonList(new EvpnDestinationBuilder() - .setRouteDistinguisher(RD) - .setEvpnChoice(IncMultEthTagRParserTest.createIncMultiCase()).build()); + .setRouteDistinguisher(RD) + .setEvpnChoice(IncMultEthTagRParserTest.createIncMultiCase()).build()); this.parser = new EvpnNlriParser(); } @@ -77,10 +83,13 @@ public class EvpnNlriParserTest { private MpUnreachNlri createUnreach() { final MpUnreachNlriBuilder mpReachExpected = new MpUnreachNlriBuilder(); - final WithdrawnRoutes wd = new WithdrawnRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang. - bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCaseBuilder().setDestinationEvpn( - new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes. - destination.type.destination.evpn._case.DestinationEvpnBuilder().setEvpnDestination(this.dest).build()).build()).build(); + final WithdrawnRoutes wd = new WithdrawnRoutesBuilder().setDestinationType( + new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update + .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCaseBuilder() + .setDestinationEvpn(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp + .evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type + .destination.evpn._case.DestinationEvpnBuilder() + .setEvpnDestination(this.dest).build()).build()).build(); return mpReachExpected.setWithdrawnRoutes(wd).build(); } @@ -90,8 +99,9 @@ public class EvpnNlriParserTest { this.parser.parseNlri(Unpooled.wrappedBuffer(IncMultEthTagRParserTest.RESULT), mpReach); final MpReachNlriBuilder mpReachExpected = new MpReachNlriBuilder(); - final AdvertizedRoutes wd = new AdvertizedRoutesBuilder().setDestinationType(new DestinationEvpnCaseBuilder().setDestinationEvpn( - new DestinationEvpnBuilder().setEvpnDestination(this.dest).build()).build()).build(); + final AdvertizedRoutes wd = new AdvertizedRoutesBuilder().setDestinationType(new DestinationEvpnCaseBuilder() + .setDestinationEvpn(new DestinationEvpnBuilder().setEvpnDestination(this.dest).build()) + .build()).build(); mpReachExpected.setAdvertizedRoutes(wd); assertEquals(mpReachExpected.build(), mpReach.build()); } @@ -112,30 +122,28 @@ public class EvpnNlriParserTest { @Test public void testExtractEvpnDestination() throws BGPParsingException { - final DataContainerNodeAttrBuilder evpnBI = ImmutableUnkeyedListEntryNodeBuilder.create(); + final DataContainerNodeAttrBuilder evpnBI = + ImmutableUnkeyedListEntryNodeBuilder.create(); evpnBI.withNodeIdentifier(EVPN_NID); evpnBI.withChild(createMACIpAdvChoice()); evpnBI.withChild(createValueBuilder(RD_MODEL, RD_NID).build()); final EvpnDestination destResult = EvpnNlriParser.extractEvpnDestination(evpnBI.build()); - final EvpnDestination expected = new EvpnDestinationBuilder().setRouteDistinguisher(RD).setEvpnChoice(MACIpAdvRParserTest.createdExpectedResult()).build(); + final EvpnDestination expected = new EvpnDestinationBuilder() + .setRouteDistinguisher(RD) + .setEvpnChoice(MACIpAdvRParserTest.createdExpectedResult()).build(); assertEquals(expected, destResult); } - - public static ChoiceNode createMACIpAdvChoice() { - final DataContainerNodeBuilder choice = Builders.choiceBuilder(); - choice.withNodeIdentifier(EVPN_CHOICE_NID); - return choice.addChild(MACIpAdvRParserTest.createMacIpCont()).build(); - } - @Test public void testExtractRouteKey() throws BGPParsingException { - final DataContainerNodeAttrBuilder evpnBI = ImmutableUnkeyedListEntryNodeBuilder.create(); + final DataContainerNodeAttrBuilder evpnBI = + ImmutableUnkeyedListEntryNodeBuilder.create(); evpnBI.withNodeIdentifier(EVPN_CHOICE_NID); evpnBI.withChild(createValueBuilder(RD_MODEL, RD_NID).build()); evpnBI.withChild(createMACIpAdvChoice()); final EvpnDestination destResult = EvpnNlriParser.extractRouteKeyDestination(evpnBI.build()); - final EvpnDestination expected = new EvpnDestinationBuilder().setRouteDistinguisher(RD).setEvpnChoice(MACIpAdvRParserTest.createdExpectedRouteKey()).build(); + final EvpnDestination expected = new EvpnDestinationBuilder().setRouteDistinguisher(RD) + .setEvpnChoice(MACIpAdvRParserTest.createdExpectedRouteKey()).build(); assertEquals(expected, destResult); } } \ No newline at end of file diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/IncMultEthTagRParserTest.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/IncMultEthTagRParserTest.java index 82ae306601..6fac50b3fb 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/IncMultEthTagRParserTest.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/IncMultEthTagRParserTest.java @@ -59,7 +59,8 @@ public class IncMultEthTagRParserTest { public void parserTest() { final IncMultiEthernetTagResCase expected = IncMultEthTagRParserTest.createIncMultiCase(); - assertArrayEquals(RESULT, ByteArray.getAllBytes(this.parser.serializeEvpn(expected, Unpooled.wrappedBuffer(ROUDE_DISTIN)))); + assertArrayEquals(RESULT, ByteArray.getAllBytes(this.parser.serializeEvpn(expected, + Unpooled.wrappedBuffer(ROUDE_DISTIN)))); final EvpnChoice result = this.parser.parseEvpn(Unpooled.wrappedBuffer(VALUE)); assertEquals(expected, result); @@ -75,9 +76,9 @@ public class IncMultEthTagRParserTest { assertEquals(expected, keyResult); } - public static IncMultiEthernetTagResCase createIncMultiCase() { - return new IncMultiEthernetTagResCaseBuilder().setIncMultiEthernetTagRes(new IncMultiEthernetTagResBuilder().setEthernetTagId(ETI) - .setOrigRouteIp(IP).build()).build(); + static IncMultiEthernetTagResCase createIncMultiCase() { + return new IncMultiEthernetTagResCaseBuilder().setIncMultiEthernetTagRes( + new IncMultiEthernetTagResBuilder().setEthernetTagId(ETI).setOrigRouteIp(IP).build()).build(); } @Test(expected = IllegalArgumentException.class) diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/MACIpAdvRParserTest.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/MACIpAdvRParserTest.java index 702e8e4cd4..1458980d93 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/MACIpAdvRParserTest.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/MACIpAdvRParserTest.java @@ -52,7 +52,8 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContaine public class MACIpAdvRParserTest { private static final byte[] VALUE = { - (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00, + (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, + (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0a, (byte) 0x30, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x20, (byte) 0x7f, (byte) 0x00, (byte) 0x00, (byte) 0x01, @@ -62,7 +63,8 @@ public class MACIpAdvRParserTest { private static final byte[] RESULT = { (byte) 0x02, (byte) 0x28, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x01, (byte) 0x02, - (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00, + (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, + (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0a, (byte) 0x30, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x20, (byte) 0x7f, (byte) 0x00, (byte) 0x00, (byte) 0x01, @@ -70,16 +72,18 @@ public class MACIpAdvRParserTest { (byte) 0x05, (byte) 0xdc, (byte) 0x20 }; private static final byte[] VALUE2 = { - (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00, + (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, + (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0a, (byte) 0x30, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, - (byte) 0x80, 0x20, (byte) 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - (byte) 0x05, (byte) 0xdc, (byte) 0x10, + (byte) 0x80, 0x20, (byte) 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, (byte) 0x05, (byte) 0xdc, (byte) 0x10, }; private static final byte[] RESULT2 = { (byte) 0x02, (byte) 0x31, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x01, (byte) 0x02, //RD - (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00, //ESI + (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, + (byte) 0x02, (byte) 0x00, //ESI (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0a, // ETI (byte) 0x30, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, // MAC (byte) 0x80,//IPV6 @@ -101,7 +105,8 @@ public class MACIpAdvRParserTest { @Test public void parserCase1Test() { final MacIpAdvRouteCase expected = createdExpectedResult(); - assertArrayEquals(RESULT, ByteArray.getAllBytes(this.parser.serializeEvpn(expected, Unpooled.wrappedBuffer(ROUDE_DISTIN)))); + assertArrayEquals(RESULT, ByteArray.getAllBytes(this.parser.serializeEvpn(expected, + Unpooled.wrappedBuffer(ROUDE_DISTIN)))); final EvpnChoice result = this.parser.parseEvpn(Unpooled.wrappedBuffer(VALUE)); assertEquals(expected, result); @@ -113,13 +118,14 @@ public class MACIpAdvRParserTest { } static MacIpAdvRouteCase createdExpectedResult() { - return new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(new MacIpAdvRouteBuilder().setEsi(LAN_AUT_GEN_CASE).setEthernetTagId(ETI) - .setMacAddress(MAC).setIpAddress(IP).setMplsLabel1(MPLS_LABEL).setMplsLabel2(MPLS_LABEL2).build()).build(); + return new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(new MacIpAdvRouteBuilder().setEsi(LAN_AUT_GEN_CASE) + .setEthernetTagId(ETI).setMacAddress(MAC).setIpAddress(IP).setMplsLabel1(MPLS_LABEL) + .setMplsLabel2(MPLS_LABEL2).build()).build(); } static MacIpAdvRouteCase createdExpectedRouteKey() { - return new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(new MacIpAdvRouteBuilder().setEthernetTagId(ETI).setMacAddress(MAC) - .setIpAddress(IP).build()).build(); + return new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(new MacIpAdvRouteBuilder().setEthernetTagId(ETI) + .setMacAddress(MAC).setIpAddress(IP).build()).build(); } static ContainerNode createMacIpCont() { @@ -140,17 +146,21 @@ public class MACIpAdvRParserTest { @Test public void parserCase2Test() { - final MacIpAdvRouteCase expected = new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(new MacIpAdvRouteBuilder().setEsi(LAN_AUT_GEN_CASE) - .setEthernetTagId(ETI).setMacAddress(MAC).setIpAddress(IPV6).setMplsLabel1(MPLS_LABEL).build()).build(); - assertArrayEquals(RESULT2, ByteArray.getAllBytes(this.parser.serializeEvpn(expected, Unpooled.wrappedBuffer(ROUDE_DISTIN)))); + final MacIpAdvRouteCase expected = new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(new MacIpAdvRouteBuilder() + .setEsi(LAN_AUT_GEN_CASE).setEthernetTagId(ETI).setMacAddress(MAC).setIpAddress(IPV6) + .setMplsLabel1(MPLS_LABEL).build()).build(); + assertArrayEquals(RESULT2, ByteArray.getAllBytes(this.parser.serializeEvpn(expected, + Unpooled.wrappedBuffer(ROUDE_DISTIN)))); final EvpnChoice result = this.parser.parseEvpn(Unpooled.wrappedBuffer(VALUE2)); assertEquals(expected, result); final DataContainerNodeBuilder choice = Builders.choiceBuilder(); choice.withNodeIdentifier(MACIpAdvRParser.MAC_IP_ADV_ROUTE_NID); - final ContainerNode macIp = createContBuilder(MACIpAdvRParser.MAC_IP_ADV_ROUTE_NID).addChild(LanParserTest.createLanChoice()).addChild(createEti()) - .addChild(createValueBuilder(MAC_MODEL, MAC_NID).build()).addChild(createValueBuilder(IPV6_MODEL, IP_NID).build()) + final ContainerNode macIp = createContBuilder(MACIpAdvRParser.MAC_IP_ADV_ROUTE_NID) + .addChild(LanParserTest.createLanChoice()).addChild(createEti()) + .addChild(createValueBuilder(MAC_MODEL, MAC_NID).build()) + .addChild(createValueBuilder(IPV6_MODEL, IP_NID).build()) .addChild(createValueBuilder(MPLS_LABEL_MODEL, MPLS1_NID).build()).build(); final EvpnChoice modelResult = this.parser.serializeEvpnModel(macIp); diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/spi/pojo/SimpleEsiTypeRegistryTest.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/spi/pojo/SimpleEsiTypeRegistryTest.java index 3207003b41..bb59949abb 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/spi/pojo/SimpleEsiTypeRegistryTest.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/spi/pojo/SimpleEsiTypeRegistryTest.java @@ -24,7 +24,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.routes.evpn.routes.EvpnRoute; import org.opendaylight.yangtools.yang.binding.DataContainer; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder; @@ -32,10 +32,10 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContaine public class SimpleEsiTypeRegistryTest { private static final int ESI_TYPE_LENGTH = 10; - private class notRegistered implements Esi { + private class NotRegistered implements Esi { @Override public Class getImplementedInterface() { - return notRegistered.class; + return NotRegistered.class; } } @@ -47,10 +47,12 @@ public class SimpleEsiTypeRegistryTest { @Test public void registryTest() { final ByteBuf buff = Unpooled.buffer(ESI_TYPE_LENGTH); + + final SimpleEsiTypeRegistry reg = SimpleEsiTypeRegistry.getInstance(); SimpleEsiTypeRegistry.getInstance().serializeEsi(ROUTE_ID_CASE, buff); assertArrayEquals(RouterIdParserTest.RESULT, ByteArray.getAllBytes(buff)); - assertEquals(ROUTE_ID_CASE, SimpleEsiTypeRegistry.getInstance().parseEsiModel(RouterIdParserTest.createRouterIdCase())); - assertEquals(RouterIdParserTest.ROUTE_ID_CASE, SimpleEsiTypeRegistry.getInstance().parseEsi(Unpooled.wrappedBuffer(buff))); + assertEquals(ROUTE_ID_CASE, reg.parseEsiModel(RouterIdParserTest.createRouterIdCase())); + assertEquals(RouterIdParserTest.ROUTE_ID_CASE, reg.parseEsi(Unpooled.wrappedBuffer(buff))); } @Test(expected = IllegalArgumentException.class) @@ -61,14 +63,16 @@ public class SimpleEsiTypeRegistryTest { @Test public void registryNullTest() { final ByteBuf body = Unpooled.buffer(); - SimpleEsiTypeRegistry.getInstance().serializeEsi(new notRegistered(), body); + SimpleEsiTypeRegistry.getInstance().serializeEsi(new NotRegistered(), body); assertEquals(0, body.readableBytes()); } @Test(expected = IllegalArgumentException.class) public void registryNullModelTest() { - final DataContainerNodeBuilder noRegister = Builders.choiceBuilder(); - noRegister.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(EvpnRoute.QNAME, "no-register").intern())); + final DataContainerNodeBuilder noRegister = + Builders.choiceBuilder(); + noRegister.withNodeIdentifier(new NodeIdentifier(QName.create(EvpnRoute.QNAME, + "no-register").intern())); assertNull(SimpleEsiTypeRegistry.getInstance().parseEsiModel(noRegister.build())); } diff --git a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/spi/pojo/SimpleEvpnNlriRegistryTest.java b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/spi/pojo/SimpleEvpnNlriRegistryTest.java index 1a229d51fa..3962661526 100644 --- a/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/spi/pojo/SimpleEvpnNlriRegistryTest.java +++ b/bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/spi/pojo/SimpleEvpnNlriRegistryTest.java @@ -30,13 +30,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.EvpnChoice; import org.opendaylight.yangtools.yang.binding.DataContainer; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder; public final class SimpleEvpnNlriRegistryTest { - public static final YangInstanceIdentifier.NodeIdentifier EVPN_NID = new YangInstanceIdentifier.NodeIdentifier(EvpnChoice.QNAME); + public static final NodeIdentifier EVPN_NID = new NodeIdentifier(EvpnChoice.QNAME); private class NotRegistered implements EvpnChoice { @Override @@ -54,7 +54,8 @@ public final class SimpleEvpnNlriRegistryTest { @Test public void registryTest() { - final ByteBuf buff = SimpleEvpnNlriRegistry.getInstance().serializeEvpn(ETHERNET_AD_ROUTE_CASE, Unpooled.wrappedBuffer(ROUDE_DISTIN)); + final ByteBuf buff = SimpleEvpnNlriRegistry.getInstance().serializeEvpn(ETHERNET_AD_ROUTE_CASE, + Unpooled.wrappedBuffer(ROUDE_DISTIN)); assertArrayEquals(EthADRParserTest.RESULT, ByteArray.getAllBytes(buff)); final EvpnChoice resultModel = SimpleEvpnNlriRegistry.getInstance().serializeEvpnModel(createEthADRModel()); assertEquals(ETHERNET_AD_ROUTE_CASE, resultModel); @@ -77,8 +78,10 @@ public final class SimpleEvpnNlriRegistryTest { @Test public void registryNullModelTest() { - final DataContainerNodeBuilder choice = Builders.choiceBuilder().withNodeIdentifier(EVPN_NID); - choice.addChild(createContBuilder(new YangInstanceIdentifier.NodeIdentifier(QName.create(Evpn.QNAME, "test").intern())).build()).build(); + final DataContainerNodeBuilder choice = Builders.choiceBuilder() + .withNodeIdentifier(EVPN_NID); + choice.addChild(createContBuilder(new NodeIdentifier(QName.create(Evpn.QNAME, "test").intern())) + .build()).build(); assertNull(SimpleEvpnNlriRegistry.getInstance().serializeEvpnModel(choice.build())); } } \ No newline at end of file -- 2.36.6