Search in sources :

Example 66 with AttributesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder in project bgpcep by opendaylight.

the class ClusterIdAttributeParserTest method testParserAttribute.

@Test
public void testParserAttribute() throws Exception {
    final List<ClusterIdentifier> list = new ArrayList<>();
    final Ipv4AddressNoZone ip1 = new Ipv4AddressNoZone("192.168.1.1");
    final Ipv4AddressNoZone ip2 = new Ipv4AddressNoZone("192.168.1.2");
    list.add(new ClusterIdentifier(ip1));
    list.add(new ClusterIdentifier(ip2));
    final Attributes clusterId = new AttributesBuilder().setClusterId(new ClusterIdBuilder().setCluster(list).build()).build();
    final ByteBuf output = Unpooled.buffer();
    this.parser.serializeAttribute(clusterId, output);
    assertArrayEquals(CLUSTER_ID_BYTES, ByteArray.getAllBytes(output));
    AttributesBuilder clusterIdOutput = new AttributesBuilder();
    this.parser.parseAttribute(Unpooled.wrappedBuffer(ByteArray.cutBytes(CLUSTER_ID_BYTES, 3)), clusterIdOutput, null);
    assertEquals(clusterId, clusterIdOutput.build());
}
Also used : Ipv4AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone) ArrayList(java.util.ArrayList) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes) ClusterIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ClusterIdentifier) ClusterIdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterIdBuilder) ByteBuf(io.netty.buffer.ByteBuf) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder) Test(org.junit.Test)

Example 67 with AttributesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder in project bgpcep by opendaylight.

the class ExtendedCommunitiesAttributeParserTest method testEmptyListExtendedCommunityAttributeParser.

@Test
public void testEmptyListExtendedCommunityAttributeParser() throws BGPDocumentedException, BGPParsingException {
    final List<ExtendedCommunities> extendedCommunitiesList = new ArrayList<>();
    final AttributesBuilder attBuilder = new AttributesBuilder().setExtendedCommunities(extendedCommunitiesList);
    final ByteBuf output = Unpooled.buffer();
    this.handler.serializeAttribute(attBuilder.build(), output);
    assertEquals(output, output);
}
Also used : ExtendedCommunities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunities) ArrayList(java.util.ArrayList) ByteBuf(io.netty.buffer.ByteBuf) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder) Test(org.junit.Test)

Example 68 with AttributesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder in project bgpcep by opendaylight.

the class MultiExitDiscriminatorAttributeParserTest method testParseEmptyAttribute.

@Test
public void testParseEmptyAttribute() {
    final ByteBuf actual = Unpooled.buffer();
    registry.serializeAttribute(new AttributesBuilder().setMultiExitDisc(new MultiExitDiscBuilder().build()).build(), actual);
    assertEquals(Unpooled.buffer(), actual);
}
Also used : MultiExitDiscBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.MultiExitDiscBuilder) ByteBuf(io.netty.buffer.ByteBuf) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder) Test(org.junit.Test)

Example 69 with AttributesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder in project bgpcep by opendaylight.

the class OriginAttributeParserTest method testParseEmptyAttribute.

@Test
public void testParseEmptyAttribute() {
    final NullPointerException ex = assertThrows(NullPointerException.class, () -> attributeRegistry.serializeAttribute(new AttributesBuilder().setOrigin(new OriginBuilder().build()).build(), Unpooled.buffer()));
    assertNull(ex.getMessage());
}
Also used : OriginBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.OriginBuilder) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder) Test(org.junit.Test)

Example 70 with AttributesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder in project bgpcep by opendaylight.

the class CommunitiesAttributeParserTest method testParseEmptyAttribute.

@Test
public void testParseEmptyAttribute() {
    final ByteBuf actual = Unpooled.buffer();
    registry.serializeAttribute(new AttributesBuilder().build(), actual);
    assertEquals(Unpooled.buffer(), actual);
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder) Test(org.junit.Test)

Aggregations

AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)130 Test (org.junit.Test)117 ByteBuf (io.netty.buffer.ByteBuf)69 ArrayList (java.util.ArrayList)40 RouteAttributeContainer (org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer)35 Statement (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement)35 AttributesReachBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesReachBuilder)27 AsPathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.AsPathBuilder)26 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes)25 AttributesUnreachBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesUnreachBuilder)24 MpReachNlriBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.MpReachNlriBuilder)24 IPV4UNICAST (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST)23 AdvertizedRoutesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.mp.reach.nlri.AdvertizedRoutesBuilder)23 OriginBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.OriginBuilder)20 MpUnreachNlriBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlriBuilder)20 UpdateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.UpdateBuilder)19 WithdrawnRoutesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.mp.unreach.nlri.WithdrawnRoutesBuilder)19 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)18 Ipv4NextHopCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.Ipv4NextHopCaseBuilder)18 LocalPrefBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.LocalPrefBuilder)17