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.Ipv4Address;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.AsPathBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ClusterId;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ClusterIdBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.OriginatorId;
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.Segments;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.as.path.SegmentsBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier;
26 public final class ExportAttributeTestUtil {
27 public static final long LOCAL_AS = 8;
28 public static final Ipv4Address IPV4 = new Ipv4Address("1.2.3.4");
29 public static final ClusterIdentifier CLUSTER = new ClusterIdentifier(IPV4);
31 private ExportAttributeTestUtil() {
32 throw new UnsupportedOperationException();
36 * container cluster-id. {
38 * type cluster-identifier;
41 * container originator-id {
48 public static Attributes createInputWithOriginator() {
49 return new AttributesBuilder().setClusterId(createClusterId()).setOriginatorId(createOriginatorId()).build();
52 public static Attributes createClusterInput() {
53 return new AttributesBuilder().setClusterId(createClusterIdInput()).build();
56 private static ClusterId createClusterId() {
57 final ClusterIdentifier cluster1 = new ClusterIdentifier(new Ipv4Address("1.1.1.1"));
58 final ClusterIdentifier cluster2 = new ClusterIdentifier(new Ipv4Address("1.1.1.2"));
59 return new ClusterIdBuilder().setCluster(Arrays.asList(CLUSTER, cluster1, cluster2)).build();
62 private static ClusterId createClusterIdInput() {
63 final ClusterIdentifier cluster1 = new ClusterIdentifier(new Ipv4Address("1.1.1.1"));
64 final ClusterIdentifier cluster2 = new ClusterIdentifier(new Ipv4Address("1.1.1.2"));
65 return new ClusterIdBuilder().setCluster(Arrays.asList(cluster1, cluster2)).build();
68 private static OriginatorId createOriginatorId() {
69 return new OriginatorIdBuilder().setOriginator(IPV4).build();
75 static Attributes createPathInputWithAs() {
76 return createPathInput(createSequenceWithLocalAs());
79 static Attributes createPathInput(final List<Segments> segB) {
80 return new AttributesBuilder().setAsPath(new AsPathBuilder().setSegments(segB).build()).build();
83 private static List<Segments> createSequenceWithLocalAs() {
84 return Collections.singletonList(new SegmentsBuilder()
85 .setAsSequence(Collections.singletonList(new AsNumber(LOCAL_AS))).build());