Migrate away from legacy setters
[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.rev180329.path.attributes.Attributes;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.AttributesBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.AsPathBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.ClusterIdBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.LocalPrefBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.MultiExitDiscBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.Origin;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.OriginBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.OriginatorIdBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.as.path.SegmentsBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.BgpOrigin;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.ClusterIdentifier;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.Ipv4NextHopCase;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.Ipv4NextHopCaseBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder;
28 import org.opendaylight.yangtools.yang.common.Uint32;
29
30 public final class ImportAttributeTestUtil {
31     static final AsNumber AS = new AsNumber(Uint32.valueOf(65));
32
33     private ImportAttributeTestUtil() {
34         throw new UnsupportedOperationException();
35     }
36
37     public static Attributes createInput() {
38         final AttributesBuilder attBuilder = new AttributesBuilder();
39         // local pref
40         attBuilder.setLocalPref(new LocalPrefBuilder().setPref(Uint32.valueOf(100)).build());
41
42         // cluster pref
43         attBuilder.setClusterId(new ClusterIdBuilder()
44                 .setCluster(Collections.singletonList(new ClusterIdentifier("40.40.40.40"))).build());
45
46         // c-next-hop pref
47         attBuilder.setCNextHop(createNexHop());
48
49         // originator pref
50         attBuilder.setOriginatorId(new OriginatorIdBuilder()
51                 .setOriginator(new Ipv4Address("41.41.41.41")).build());
52
53         // origin pref
54         attBuilder.setOrigin(createOrigin());
55
56         // as path
57         attBuilder.setAsPath(new AsPathBuilder().build());
58
59         // multi-exit-disc pref
60         attBuilder.setMultiExitDisc(new MultiExitDiscBuilder().setMed(Uint32.ZERO).build());
61         return attBuilder.build();
62     }
63
64     public static Attributes createOutput() {
65         final AttributesBuilder attBuilder = new AttributesBuilder();
66         attBuilder.setCNextHop(createNexHop());
67         attBuilder.setOrigin(createOrigin());
68         attBuilder.setAsPath(new AsPathBuilder().setSegments(Collections.singletonList(new SegmentsBuilder()
69                 .setAsSequence(Collections.singletonList(AS)).build())).build());
70         return attBuilder.build();
71     }
72
73     private static Origin createOrigin() {
74         return new OriginBuilder().setValue(BgpOrigin.Igp).build();
75     }
76
77     /**
78      * c-next-hop pref.
79      */
80     private static Ipv4NextHopCase createNexHop() {
81         return new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder()
82                 .setGlobal(new Ipv4Address("199.20.160.41")).build()).build();
83     }
84 }