BGPCEP-577: Neighbor’s local AS configurable
[bgpcep.git] / bgp / openconfig-rp-statement / src / test / java / org / opendaylight / protocol / bgp / openconfig / routing / policy / statement / ImportAttributeTestUtil.java
1 /*
2  * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
3  *
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
7  */
8 package org.opendaylight.protocol.bgp.openconfig.routing.policy.statement;
9
10 import java.util.Collections;
11 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
12 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.AsPathBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ClusterIdBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.LocalPrefBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.MultiExitDiscBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.Origin;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.OriginBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.OriginatorIdBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.as.path.SegmentsBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpOrigin;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv4NextHopCase;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv4NextHopCaseBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder;
28
29 public final class ImportAttributeTestUtil {
30     static final AsNumber AS = new AsNumber(65L);
31
32     private ImportAttributeTestUtil() {
33         throw new UnsupportedOperationException();
34     }
35
36     public static Attributes createInput() {
37         final AttributesBuilder attBuilder = new AttributesBuilder();
38         // local pref
39         attBuilder.setLocalPref(new LocalPrefBuilder().setPref(100L).build());
40
41         // cluster pref
42         attBuilder.setClusterId(new ClusterIdBuilder()
43                 .setCluster(Collections.singletonList(new ClusterIdentifier("40.40.40.40"))).build());
44
45         // c-next-hop pref
46         attBuilder.setCNextHop(createNexHop());
47
48         // originator pref
49         attBuilder.setOriginatorId(new OriginatorIdBuilder()
50                 .setOriginator(new Ipv4Address("41.41.41.41")).build());
51
52         // origin pref
53         attBuilder.setOrigin(createOrigin());
54
55         // as path
56         attBuilder.setAsPath(new AsPathBuilder().build());
57
58         // multi-exit-disc pref
59         attBuilder.setMultiExitDisc(new MultiExitDiscBuilder().setMed(0L).build());
60         return attBuilder.build();
61     }
62
63     public static Attributes createOutput() {
64         final AttributesBuilder attBuilder = new AttributesBuilder();
65         attBuilder.setCNextHop(createNexHop());
66         attBuilder.setOrigin(createOrigin());
67         attBuilder.setAsPath(new AsPathBuilder().setSegments(Collections.singletonList(new SegmentsBuilder()
68                 .setAsSequence(Collections.singletonList(AS)).build())).build());
69         return attBuilder.build();
70     }
71
72     private static Origin createOrigin() {
73         return new OriginBuilder().setValue(BgpOrigin.Igp).build();
74     }
75
76     /**
77      * c-next-hop pref.
78      */
79     private static Ipv4NextHopCase createNexHop() {
80         return new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder()
81                 .setGlobal(new Ipv4Address("199.20.160.41")).build()).build();
82     }
83 }