use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.adj.flags.flags.IsisAdjFlagsCaseBuilder in project bgpcep by opendaylight.
the class LinkstateAttributeParserTest method testPositiveLinks.
@Test
public void testPositiveLinks() throws BGPParsingException {
final AttributesBuilder builder = createBuilder(new LinkCaseBuilder().build());
this.parser.parseAttribute(Unpooled.copiedBuffer(LINK_ATTR), builder);
final Attributes1 attrs = builder.getAugmentation(Attributes1.class);
final LinkAttributes ls = ((LinkAttributesCase) attrs.getLinkStateAttribute()).getLinkAttributes();
assertNotNull(ls);
assertEquals("42.42.42.42", ls.getLocalIpv4RouterId().getValue());
assertEquals("43.43.43.43", ls.getRemoteIpv4RouterId().getValue());
assertEquals(Long.valueOf(0L), ls.getAdminGroup().getValue());
assertArrayEquals(new byte[] { (byte) 0x49, (byte) 0x98, (byte) 0x96, (byte) 0x80 }, ls.getMaxLinkBandwidth().getValue());
assertArrayEquals(new byte[] { (byte) 0x46, (byte) 0x43, (byte) 0x50, (byte) 0x00 }, ls.getMaxReservableBandwidth().getValue());
assertNotNull(ls.getUnreservedBandwidth());
assertEquals(8, ls.getUnreservedBandwidth().size());
assertEquals(LinkProtectionType.Dedicated1to1, ls.getLinkProtection());
assertTrue(ls.getMplsProtocol().isLdp());
assertTrue(ls.getMplsProtocol().isRsvpte());
assertEquals(new Long(10), ls.getMetric().getValue());
assertEquals(2, ls.getSharedRiskLinkGroups().size());
assertEquals(305419896, ls.getSharedRiskLinkGroups().get(0).getValue().intValue());
assertEquals("12K-2", ls.getLinkName());
final IsisAdjFlagsCase flags = new IsisAdjFlagsCaseBuilder().setAddressFamily(Boolean.TRUE).setBackup(Boolean.FALSE).setSet(Boolean.FALSE).build();
assertEquals(flags, ls.getSrAdjIds().get(0).getFlags());
assertEquals(flags, ls.getSrAdjIds().get(1).getFlags());
assertEquals(new Long(1048575L), ((LocalLabelCase) ls.getSrAdjIds().get(0).getSidLabelIndex()).getLocalLabel().getValue());
assertEquals(new Long(1048559L), ((LocalLabelCase) ls.getSrAdjIds().get(1).getSidLabelIndex()).getLocalLabel().getValue());
assertEquals(new Long(168496141L), ((SidCase) ls.getPeerNodeSid().getSidLabelIndex()).getSid());
assertEquals(new Short("5"), ls.getPeerNodeSid().getWeight().getValue());
assertEquals(new Long(168496142L), ((SidCase) ls.getPeerSetSids().get(0).getSidLabelIndex()).getSid());
assertEquals(new Short("5"), ls.getPeerSetSids().get(0).getWeight().getValue());
assertEquals(new Long(168496143L), ((SidCase) ls.getPeerAdjSid().getSidLabelIndex()).getSid());
assertEquals(new Short("5"), ls.getPeerAdjSid().getWeight().getValue());
// serialization
final ByteBuf buff = Unpooled.buffer();
this.parser.serializeAttribute(builder.build(), buff);
buff.skipBytes(3);
// there is unresolved TLV at the end, that needs to be cut off
assertArrayEquals(ByteArray.subByte(LINK_ATTR, 0, LINK_ATTR.length - 5), ByteArray.getAllBytes(buff));
}
Aggregations