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
8 package org.opendaylight.protocol.bgp.rib.impl.config;
10 import static org.opendaylight.protocol.bgp.rib.impl.config.AbstractConfig.AS;
11 import static org.opendaylight.protocol.bgp.rib.impl.config.BgpPeerTest.NEIGHBOR_ADDRESS;
12 import static org.opendaylight.protocol.bgp.rib.impl.config.BgpPeerTest.createAddPath;
13 import static org.opendaylight.protocol.bgp.rib.impl.config.BgpPeerTest.createAfiSafi;
14 import static org.opendaylight.protocol.bgp.rib.impl.config.BgpPeerTest.createConfig;
15 import static org.opendaylight.protocol.bgp.rib.impl.config.BgpPeerTest.createNeighborExpected;
16 import static org.opendaylight.protocol.bgp.rib.impl.config.BgpPeerTest.createTimers;
17 import static org.opendaylight.protocol.bgp.rib.impl.config.BgpPeerTest.createTransport;
19 import java.util.ArrayList;
20 import java.util.Collections;
21 import java.util.List;
22 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi;
23 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafiBuilder;
24 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.AfiSafisBuilder;
25 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.ConfigBuilder;
26 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.StateBuilder;
27 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor;
28 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborBuilder;
29 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Global;
30 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.GlobalBuilder;
31 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Neighbors;
32 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.NeighborsBuilder;
33 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
34 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV6UNICAST;
35 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.GlobalAddPathsConfig;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.GlobalAddPathsConfigBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.BgpId;
39 import org.opendaylight.yangtools.yang.common.Uint8;
41 final class RIBTestsUtil {
42 private static final BgpId BGP_ID = new BgpId(new Ipv4AddressNoZone("127.0.0.1"));
43 private static final List<AfiSafi> AFISAFIS_IPV4 = new ArrayList<>();
44 private static final List<AfiSafi> AFISAFIS_IPV6 = new ArrayList<>();
47 AFISAFIS_IPV4.add(new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class)
48 .addAugmentation(GlobalAddPathsConfig.class, new GlobalAddPathsConfigBuilder().setReceive(true)
49 .setSendMax(Uint8.ZERO).build()).build());
53 AFISAFIS_IPV6.add(new AfiSafiBuilder().setAfiSafiName(IPV6UNICAST.class)
54 .addAugmentation(GlobalAddPathsConfig.class, new GlobalAddPathsConfigBuilder().setReceive(true)
55 .setSendMax(Uint8.ZERO).build()).build());
58 private RIBTestsUtil() {
62 public static Global createGlobalIpv4() {
63 return new GlobalBuilder()
64 .setAfiSafis(new AfiSafisBuilder().setAfiSafi(AFISAFIS_IPV4).build())
65 .setConfig(new ConfigBuilder().setAs(AS).setRouterId(BGP_ID).build())
66 .setState(new StateBuilder().setAs(AS).build())
70 public static Global createGlobalIpv6() {
71 return new GlobalBuilder()
72 .setAfiSafis(new AfiSafisBuilder().setAfiSafi(AFISAFIS_IPV6).build())
73 .setConfig(new ConfigBuilder().setAs(AS).setRouterId(BGP_ID).build())
74 .setState(new StateBuilder().setAs(AS).build())
78 public static Neighbors createNeighbors() {
79 return new NeighborsBuilder()
80 .setNeighbor(Collections.singletonList(createNeighbor()))
84 private static Neighbor createNeighbor() {
85 return createNeighborExpected(NEIGHBOR_ADDRESS);
88 public static Neighbors createNeighborsNoRR() {
89 return new NeighborsBuilder()
90 .setNeighbor(Collections.singletonList(createNeighborNoRR()))
94 private static Neighbor createNeighborNoRR() {
95 return new NeighborBuilder()
96 .setAfiSafis(createAfiSafi())
97 .setConfig(createConfig())
98 .setNeighborAddress(NEIGHBOR_ADDRESS)
99 .setTimers(createTimers())
100 .setTransport(createTransport())
101 .setAddPaths(createAddPath())