use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.CommunitiesBuilder in project bgpcep by opendaylight.
the class MatchCommunityTest method testComAny.
@Test
public void testComAny() {
Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("community-any-test")).findFirst().get();
RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV4UNICAST.class, this.exportParameters, attributeContainer, statement);
assertNotNull(result.getAttributes());
attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().setCommunities(Collections.singletonList(new CommunitiesBuilder().setAsNumber(AsNumber.getDefaultInstance("65")).setSemantics(Uint16.TEN).build())).build());
result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV4UNICAST.class, this.exportParameters, attributeContainer, statement);
assertNull(result.getAttributes());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.CommunitiesBuilder in project bgpcep by opendaylight.
the class MatchCommunityTest method testComInvert.
@Test
public void testComInvert() {
Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("community-invert-test")).findFirst().get();
RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV4UNICAST.class, this.exportParameters, attributeContainer, statement);
assertNull(result.getAttributes());
attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().setCommunities(Collections.singletonList(new CommunitiesBuilder().setAsNumber(AsNumber.getDefaultInstance("65")).setSemantics(Uint16.TEN).build())).build());
result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV4UNICAST.class, this.exportParameters, attributeContainer, statement);
assertNotNull(result.getAttributes());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.CommunitiesBuilder in project bgpcep by opendaylight.
the class CommunityUtil method create.
/**
* Creates a new Community given AS number value and semantics using generated CommunitiesBuilder.
*
* @param refCache reference cache to use
* @param asn long
* @param semantics int
* @return new Community
*/
// FIXME: consider using Uint32 for asn
// FIXME: consider using Uint16 for semantics
public static Community create(final ReferenceCache refCache, final long asn, final int semantics) {
final CommunitiesBuilder builder = new CommunitiesBuilder();
builder.setAsNumber(refCache.getSharedReference(new AsNumber(Uint32.valueOf(asn))));
builder.setSemantics(refCache.getSharedReference(Uint16.valueOf(semantics)));
return refCache.getSharedReference(builder.build());
}
Aggregations