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.openconfig.routing.policy.statement;
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.Ipv4AddressNoZone;
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;
30 public final class ImportAttributeTestUtil {
31 static final AsNumber AS = new AsNumber(Uint32.valueOf(65));
33 private ImportAttributeTestUtil() {
37 public static Attributes createInput() {
38 final AttributesBuilder attBuilder = new AttributesBuilder();
40 attBuilder.setLocalPref(new LocalPrefBuilder().setPref(Uint32.valueOf(100)).build());
43 attBuilder.setClusterId(new ClusterIdBuilder()
44 .setCluster(Collections.singletonList(new ClusterIdentifier("40.40.40.40"))).build());
47 attBuilder.setCNextHop(createNexHop());
50 attBuilder.setOriginatorId(new OriginatorIdBuilder()
51 .setOriginator(new Ipv4AddressNoZone("41.41.41.41")).build());
54 attBuilder.setOrigin(createOrigin());
57 attBuilder.setAsPath(new AsPathBuilder().build());
59 // multi-exit-disc pref
60 attBuilder.setMultiExitDisc(new MultiExitDiscBuilder().setMed(Uint32.ZERO).build());
61 return attBuilder.build();
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();
73 private static Origin createOrigin() {
74 return new OriginBuilder().setValue(BgpOrigin.Igp).build();
80 private static Ipv4NextHopCase createNexHop() {
81 return new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder()
82 .setGlobal(new Ipv4AddressNoZone("199.20.160.41")).build()).build();