use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.Communities in project bgpcep by opendaylight.
the class CommunitiesAttributeParser method serializeAttribute.
@Override
public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) {
final List<Communities> communities = pathAttributes.getCommunities();
if (communities == null || communities.isEmpty()) {
return;
}
final ByteBuf communitiesBuffer = Unpooled.buffer();
for (final Community community : communities) {
communitiesBuffer.writeShort(community.getAsNumber().getValue().shortValue());
communitiesBuffer.writeShort(community.getSemantics().shortValue());
}
AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL | AttributeUtil.TRANSITIVE, TYPE, communitiesBuffer, byteAggregator);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.Communities in project bgpcep by opendaylight.
the class CommunitiesAttributeParserTest method testParseEmptyListAttribute.
@Test
public void testParseEmptyListAttribute() {
final List<Communities> comms = new ArrayList<>();
final ByteBuf actual = Unpooled.buffer();
registry.serializeAttribute(new AttributesBuilder().setCommunities(comms).build(), actual);
assertEquals(Unpooled.buffer(), actual);
}
Aggregations