Search in sources :

Example 1 with LuOriginatorSrgbTlvBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.bgp.prefix.sid.tlv.LuOriginatorSrgbTlvBuilder in project bgpcep by opendaylight.

the class BgpPrefixSidTlvsTest method testOriginatorParser.

@Test
public void testOriginatorParser() {
    final OriginatorSrgbTlvParser parser = new OriginatorSrgbTlvParser();
    final List<SrgbValue> list = new ArrayList<>();
    final Srgb srgb1 = new Srgb(Uint32.ONE);
    final Srgb srgb2 = new Srgb(Uint32.TWO);
    list.add(new SrgbValueBuilder().setBase(srgb1).setRange(srgb2).build());
    list.add(new SrgbValueBuilder().setBase(srgb2).setRange(srgb1).build());
    final LuOriginatorSrgbTlv tlv = new LuOriginatorSrgbTlvBuilder().setSrgbValue(list).build();
    final ByteBuf serialized = Unpooled.buffer(14);
    parser.serializeBgpPrefixSidTlv(tlv, serialized);
    final byte[] expected = new byte[] { 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 2, 0, 0, 1 };
    assertArrayEquals(expected, serialized.array());
    final LuOriginatorSrgbTlv parsed = parser.parseBgpPrefixSidTlv(serialized);
    assertEquals(tlv.getSrgbValue().size(), parsed.getSrgbValue().size());
    assertEquals(tlv.getSrgbValue().get(0).getBase(), srgb1);
    assertEquals(tlv.getSrgbValue().get(0).getRange(), srgb2);
    assertEquals(tlv.getSrgbValue().get(1).getBase(), srgb2);
    assertEquals(tlv.getSrgbValue().get(1).getRange(), srgb1);
    assertEquals(3, parser.getType());
}
Also used : LuOriginatorSrgbTlvBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.bgp.prefix.sid.tlv.LuOriginatorSrgbTlvBuilder) ArrayList(java.util.ArrayList) LuOriginatorSrgbTlv(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.bgp.prefix.sid.tlv.LuOriginatorSrgbTlv) SrgbValue(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.originator.srgb.tlv.SrgbValue) SrgbValueBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.originator.srgb.tlv.SrgbValueBuilder) ByteBuf(io.netty.buffer.ByteBuf) Srgb(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.Srgb) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 Srgb (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.Srgb)1 SrgbValue (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.originator.srgb.tlv.SrgbValue)1 SrgbValueBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.originator.srgb.tlv.SrgbValueBuilder)1 LuOriginatorSrgbTlv (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.bgp.prefix.sid.tlv.LuOriginatorSrgbTlv)1 LuOriginatorSrgbTlvBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.bgp.prefix.sid.tlv.LuOriginatorSrgbTlvBuilder)1