2 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.protocol.bgp.openconfig.routing.policy.statement;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertNull;
13 import static org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer.routeAttributeContainerFalse;
15 import java.util.Collections;
16 import java.util.List;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.mockito.Mock;
20 import org.opendaylight.protocol.bgp.openconfig.routing.policy.impl.PolicyRIBBaseParametersImpl;
21 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer;
22 import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
23 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
24 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV6UNICAST;
25 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
26 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.AttributesBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.ExtendedCommunitiesBuilder;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.as._4.spec.common.As4SpecificCommonBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.As4RouteOriginExtendedCommunityCaseBuilder;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.as._4.route.origin.extended.community._case.As4RouteOriginExtendedCommunityBuilder;
33 public class MatchAfiSafiNotInTest extends AbstractStatementRegistryConsumerTest {
35 private BGPRouteEntryExportParameters exportParameters;
36 private List<Statement> basicStatements;
37 private PolicyRIBBaseParametersImpl baseAttributes;
41 public void setUp() throws Exception {
43 this.basicStatements = loadStatement("match-afi-safi-not-in-test");
44 this.baseAttributes = new PolicyRIBBaseParametersImpl(LOCAL_AS, IPV4, CLUSTER);
48 public void testExtComAny() {
49 Statement statement = this.basicStatements.stream()
50 .filter(st -> st.getName().equals("match-afi-safi-not-in-test")).findFirst().get();
51 RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
52 new AttributesBuilder().build());
53 RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
56 this.exportParameters,
59 assertNotNull(result.getAttributes());
62 attributeContainer = routeAttributeContainerFalse(new AttributesBuilder()
63 .setExtendedCommunities(Collections.singletonList(new ExtendedCommunitiesBuilder()
64 .setExtendedCommunity(new As4RouteOriginExtendedCommunityCaseBuilder()
65 .setAs4RouteOriginExtendedCommunity(new As4RouteOriginExtendedCommunityBuilder()
66 .setAs4SpecificCommon(new As4SpecificCommonBuilder()
67 .setAsNumber(AsNumber.getDefaultInstance("65000"))
68 .setLocalAdministrator(123)
69 .build()).build()).build()).build())).build());
71 result = this.statementRegistry.applyExportStatement(
74 this.exportParameters,
77 assertNull(result.getAttributes());