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.Arrays;
11 import java.util.Collections;
12 import java.util.List;
13 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.AttributesBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.AsPathBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.ClusterId;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.ClusterIdBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.OriginatorId;
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.Segments;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.as.path.SegmentsBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.ClusterIdentifier;
25 import org.opendaylight.yangtools.yang.common.Uint32;
27 public final class ExportAttributeTestUtil {
28 public static final Uint32 REMOTE_AS = Uint32.valueOf(8);
29 public static final AsNumber LOCAL_AS = new AsNumber(Uint32.valueOf(65));
30 public static final Ipv4AddressNoZone IPV4 = new Ipv4AddressNoZone("1.2.3.4");
31 public static final ClusterIdentifier CLUSTER = new ClusterIdentifier(IPV4);
33 private ExportAttributeTestUtil() {
38 * container cluster-id. {
40 * type cluster-identifier;
43 * container originator-id {
50 public static Attributes createInputWithOriginator() {
51 return new AttributesBuilder().setClusterId(createClusterId()).setOriginatorId(createOriginatorId()).build();
54 public static Attributes createClusterInput() {
55 return new AttributesBuilder().setClusterId(createClusterIdInput()).build();
58 private static ClusterId createClusterId() {
59 final ClusterIdentifier cluster1 = new ClusterIdentifier(new Ipv4AddressNoZone("1.1.1.1"));
60 final ClusterIdentifier cluster2 = new ClusterIdentifier(new Ipv4AddressNoZone("1.1.1.2"));
61 return new ClusterIdBuilder().setCluster(Arrays.asList(CLUSTER, cluster1, cluster2)).build();
64 private static ClusterId createClusterIdInput() {
65 final ClusterIdentifier cluster1 = new ClusterIdentifier(new Ipv4AddressNoZone("1.1.1.1"));
66 final ClusterIdentifier cluster2 = new ClusterIdentifier(new Ipv4AddressNoZone("1.1.1.2"));
67 return new ClusterIdBuilder().setCluster(Arrays.asList(cluster1, cluster2)).build();
70 private static OriginatorId createOriginatorId() {
71 return new OriginatorIdBuilder().setOriginator(IPV4).build();
77 static Attributes createPathInputWithAs() {
78 return createPathInput(createSequenceWithLocalAs());
81 static Attributes createPathInput(final List<Segments> segB) {
82 return new AttributesBuilder().setAsPath(new AsPathBuilder().setSegments(segB).build()).build();
85 private static List<Segments> createSequenceWithLocalAs() {
86 return Collections.singletonList(new SegmentsBuilder()
87 .setAsSequence(Arrays.asList(new AsNumber(LOCAL_AS), new AsNumber(REMOTE_AS))).build());