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;
32 import org.opendaylight.yangtools.yang.common.Uint16;
34 public class MatchAfiSafiNotInTest extends AbstractStatementRegistryConsumerTest {
36 private BGPRouteEntryExportParameters exportParameters;
37 private List<Statement> basicStatements;
38 private PolicyRIBBaseParametersImpl baseAttributes;
42 public void setUp() throws Exception {
44 this.basicStatements = loadStatement("match-afi-safi-not-in-test");
45 this.baseAttributes = new PolicyRIBBaseParametersImpl(LOCAL_AS, IPV4, CLUSTER);
49 public void testExtComAny() {
50 Statement statement = this.basicStatements.stream()
51 .filter(st -> st.getName().equals("match-afi-safi-not-in-test")).findFirst().get();
52 RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
53 new AttributesBuilder().build());
54 RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
57 this.exportParameters,
60 assertNotNull(result.getAttributes());
63 attributeContainer = routeAttributeContainerFalse(new AttributesBuilder()
64 .setExtendedCommunities(Collections.singletonList(new ExtendedCommunitiesBuilder()
65 .setExtendedCommunity(new As4RouteOriginExtendedCommunityCaseBuilder()
66 .setAs4RouteOriginExtendedCommunity(new As4RouteOriginExtendedCommunityBuilder()
67 .setAs4SpecificCommon(new As4SpecificCommonBuilder()
68 .setAsNumber(AsNumber.getDefaultInstance("65000"))
69 .setLocalAdministrator(Uint16.valueOf(123))
70 .build()).build()).build()).build())).build());
72 result = this.statementRegistry.applyExportStatement(
75 this.exportParameters,
78 assertNull(result.getAttributes());