Bump to odlparent-3.0.2 and yangtools-2.0.0
[bgpcep.git] / bgp / evpn / src / test / java / org / opendaylight / protocol / bgp / evpn / impl / attributes / tunnel / identifier / PMSITunnelAttributeHandlerTestUtil.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  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
9 package org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier;
10
11 import static java.util.Collections.singletonList;
12 import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.IPV6;
13 import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.MPLS_LABEL;
14 import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.OpaqueUtilTest.OPAQUE_TEST;
15 import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.OpaqueUtilTest.OPAQUE_TEST2;
16
17 import java.util.ArrayList;
18 import java.util.Collections;
19 import java.util.List;
20 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
21 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.L2vpnAddressFamily;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.routes.evpn.routes.evpn.route.PmsiTunnelAugmentation;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.routes.evpn.routes.evpn.route.PmsiTunnelAugmentationBuilder;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AddressFamily;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.PAddressPMulticastGroup;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.PmsiTunnelBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.TunnelIdentifier;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.BidirPimTreeBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.IngressReplicationBuilder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.MldpMp2mpLspBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.MldpP2mpLspBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.PimSmTreeBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.PimSsmTreeBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.RsvpTeP2mpLspBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.p2mp.lsp.mldp.p2mp.lsp.OpaqueValue;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.p2mp.lsp.mldp.p2mp.lsp.OpaqueValueBuilder;
42 import org.opendaylight.yangtools.yang.binding.DataContainer;
43
44 final class PMSITunnelAttributeHandlerTestUtil {
45     /**
46      * ATT - TYPE - ATT LENGTH.
47      * PMSI FLAG - PMSI TYPE 0- MPLS LABEL
48      * No tunnel information present
49      */
50     static final byte[] NO_TUNNEL_INFORMATION_PRESENT_EXPECTED = {
51         (byte) 0x80, (byte) 0x16, (byte) 0x05,
52         (byte) 0x01, (byte) 0x00, (byte) 0x05, (byte) 0xdc, (byte) 0x10
53     };
54     /**
55      * ATT - TYPE - ATT LENGTH.
56      * PMSI FLAG - PMSI TYPE 1- MPLS LABEL
57      * mLDP P2MP LSP
58      */
59     static final byte[] RSVP_TE_P2MP_LSP_LSP_EXPECTED = {
60         (byte) 0x80, (byte) 0x16, (byte) 0x11,
61         (byte) 0x01, (byte) 0x01, (byte) 0x05, (byte) 0xdc, (byte) 0x10,
62         (byte) 0x00, (byte) 0x00, (byte) 0x0d, (byte) 0x82,
63         (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0f,
64         (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01,
65     };
66     /**
67      * ATT - TYPE - ATT LENGTH.
68      * PMSI FLAG - PMSI TYPE 2- MPLS LABEL
69      * mLDP P2MP LSP
70      */
71     static final byte[] M_LDP_P2MP_LSP_EXPECTED_IPV4 = {
72         (byte) 0x80, (byte) 0x16, (byte) 0x35,
73         (byte) 0x01, (byte) 0x02, (byte) 0x05, (byte) 0xdc, (byte) 0x10,
74         (byte) 0x06, (byte) 0x00, (byte) 0x01, (byte) 0x04,
75         (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01,
76         (byte) 0x00, (byte) 0x26, //Opaque Values Length
77         (byte) 0x01, (byte) 0x00, (byte) 0x0e, // Opaque Type - Length
78         (byte) 0x07, (byte) 0x00, (byte) 0x0B, //Value
79         (byte) 0x00, (byte) 0x00, (byte) 0x01,
80         (byte) 0x00, (byte) 0x00, (byte) 0x00,
81         (byte) 0x01, (byte) 0x00, (byte) 0x00,
82         (byte) 0x00, (byte) 0x00,
83         (byte) 0xff, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x10, // Opaque Type -Ext Type - Length
84         (byte) 0x07, (byte) 0x00, (byte) 0x0B, //Value
85         (byte) 0x00, (byte) 0x00, (byte) 0x01,
86         (byte) 0x00, (byte) 0x00, (byte) 0x00,
87         (byte) 0x01, (byte) 0x00, (byte) 0x00,
88         (byte) 0x00, (byte) 0x00, (byte) 0x01,
89         (byte) 0x02
90     };
91     /**
92      * ATT - TYPE - ATT LENGTH.
93      * PMSI FLAG - PMSI TYPE 2- MPLS LABEL
94      * mLDP P2MP LSP
95      */
96     static final byte[] M_LDP_P2MP_LSP_EXPECTED_WRONG_FAMILY = {
97         (byte) 0x80, (byte) 0x16, (byte) 0x20,
98         (byte) 0x01, (byte) 0x02, (byte) 0x05, (byte) 0xdc, (byte) 0x10,
99         (byte) 0x06, (byte) 0x00, (byte) 0xfc, (byte) 0x04,
100         (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01,
101         (byte) 0x00, (byte) 0x11, //Opaque Values Length
102         (byte) 0x01, (byte) 0x00, (byte) 0x03, // Opaque Type - Length
103         (byte) 0xb5, (byte) 0xeb, (byte) 0x2d,  //Value
104         (byte) 0xff, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x06, // Opaque Type -Ext Type - Length
105         (byte) 0xb5, (byte) 0xeb, (byte) 0x2d, (byte) 0xd7, (byte) 0x6d, (byte) 0xf8, //Value
106     };
107     /**
108      * ATT - TYPE - ATT LENGTH.
109      * PMSI FLAG - PMSI TYPE 2- MPLS LABEL
110      * mLDP P2MP LSP L2VPN
111      */
112     static final byte[] M_LDP_P2MP_LSP_EXPECTED_L2VPN = {
113         (byte) 0x80, (byte) 0x16, (byte) 0x35,
114         (byte) 0x01, (byte) 0x02, (byte) 0x05, (byte) 0xdc, (byte) 0x10,
115         (byte) 0x06, (byte) 0x00, (byte) 0x19, (byte) 0x04,
116         (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01,
117         (byte) 0x00, (byte) 0x26, //Opaque Values Length
118         (byte) 0x01, (byte) 0x00, (byte) 0x0e, // Opaque Type - Length
119         (byte) 0x07, (byte) 0x00, (byte) 0x0B, //Value
120         (byte) 0x00, (byte) 0x00, (byte) 0x01,
121         (byte) 0x00, (byte) 0x00, (byte) 0x00,
122         (byte) 0x01, (byte) 0x00, (byte) 0x00,
123         (byte) 0x00, (byte) 0x00,
124         (byte) 0xff, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x10, // Opaque Type -Ext Type - Length
125         (byte) 0x07, (byte) 0x00, (byte) 0x0B, //Value
126         (byte) 0x00, (byte) 0x00, (byte) 0x01,
127         (byte) 0x00, (byte) 0x00, (byte) 0x00,
128         (byte) 0x01, (byte) 0x00, (byte) 0x00,
129         (byte) 0x00, (byte) 0x00, (byte) 0x01,
130         (byte) 0x02
131     };
132     /**
133      * ATT - TYPE - ATT LENGTH.
134      * PMSI FLAG - PMSI TYPE 2- MPLS LABEL
135      * mLDP P2MP LSP IPV4
136      */
137     static final byte[] M_LDP_P2MP_LSP_EXPECTED_IPV4_2 = {
138         (byte) 0x80, (byte) 0x16, (byte) 0x3b,
139         (byte) 0x01, (byte) 0x02, (byte) 0x05, (byte) 0xdc, (byte) 0x10,
140         (byte) 0x06, (byte) 0x00, (byte) 0x01, (byte) 0x04,
141         (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01,
142         (byte) 0x00, (byte) 0x2c, //Opaque Values Length
143         (byte) 0x01, (byte) 0x00, (byte) 0x0e, // Opaque Type - Length
144         (byte) 0x07, (byte) 0x00, (byte) 0x0B, //Value
145         (byte) 0x00, (byte) 0x00, (byte) 0x01,
146         (byte) 0x00, (byte) 0x00, (byte) 0x00,
147         (byte) 0x01, (byte) 0x00, (byte) 0x00,
148         (byte) 0x00, (byte) 0x00,
149         (byte) 0xfc, (byte) 0x00, (byte) 0x03, // Wrong Opaque Type - Length
150         (byte) 0xb5, (byte) 0xeb, (byte) 0x2d,  //Value
151         (byte) 0xff, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x10, // Opaque Type -Ext Type - Length
152         (byte) 0x07, (byte) 0x00, (byte) 0x0B, //Value
153         (byte) 0x00, (byte) 0x00, (byte) 0x01,
154         (byte) 0x00, (byte) 0x00, (byte) 0x00,
155         (byte) 0x01, (byte) 0x00, (byte) 0x00,
156         (byte) 0x00, (byte) 0x00, (byte) 0x01,
157         (byte) 0x02
158     };
159     /**
160      * ATT - TYPE - ATT LENGTH.
161      * PMSI FLAG - PMSI TYPE 2- MPLS LABEL
162      * mLDP P2MP LSP IPV6
163      */
164     static final byte[] M_LDP_P2MP_LSP_EXPECTED_IPV6 = {
165         (byte) 0x80, (byte) 0x16, (byte) 0x41,
166         (byte) 0x01, (byte) 0x02, (byte) 0x05, (byte) 0xdc, (byte) 0x10,
167         (byte) 0x06, (byte) 0x00, (byte) 0x02, (byte) 0x10,
168         (byte) 0x20, (byte) 0x01, (byte) 0x00, (byte) 0x00,
169         (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
170         (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
171         (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,
172         (byte) 0x00, (byte) 0x26, //Opaque Values Length
173         (byte) 0x01, (byte) 0x00, (byte) 0x0e, // Opaque Type - Length
174         (byte) 0x07, (byte) 0x00, (byte) 0x0B, //Value
175         (byte) 0x00, (byte) 0x00, (byte) 0x01,
176         (byte) 0x00, (byte) 0x00, (byte) 0x00,
177         (byte) 0x01, (byte) 0x00, (byte) 0x00,
178         (byte) 0x00, (byte) 0x00,
179         (byte) 0xff, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x10, // Opaque Type -Ext Type - Length
180         (byte) 0x07, (byte) 0x00, (byte) 0x0B, //Value
181         (byte) 0x00, (byte) 0x00, (byte) 0x01,
182         (byte) 0x00, (byte) 0x00, (byte) 0x00,
183         (byte) 0x01, (byte) 0x00, (byte) 0x00,
184         (byte) 0x00, (byte) 0x00, (byte) 0x01,
185         (byte) 0x02
186     };
187     /**
188      * ATT - TYPE - ATT LENGTH.
189      * PMSI FLAG - PMSI TYPE 3- MPLS LABEL
190      * PIM-SSM Tree
191      */
192     static final byte[] PIM_SSM_TREE_EXPECTED = {
193         (byte) 0x80, (byte) 0x16, (byte) 0x0d,
194         (byte) 0x01, (byte) 0x03, (byte) 0x05, (byte) 0xdc, (byte) 0x10,
195         (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01,
196         (byte) 0x17, (byte) 0x01, (byte) 0x01, (byte) 0x01
197     };
198     /**
199      * ATT - TYPE - ATT LENGTH.
200      * PMSI FLAG - PMSI TYPE 4- MPLS LABEL
201      * PIM-SM Tree
202      */
203     static final byte[] PIM_SM_TREE_EXPECTED = {
204         (byte) 0x80, (byte) 0x16, (byte) 0x0d,
205         (byte) 0x01, (byte) 0x04, (byte) 0x05, (byte) 0xdc, (byte) 0x10,
206         (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01,
207         (byte) 0x17, (byte) 0x01, (byte) 0x01, (byte) 0x01
208     };
209     /**
210      * ATT - TYPE - ATT LENGTH.
211      * PMSI FLAG - PMSI TYPE 5- MPLS LABEL
212      * BIDIR-PIM Tree
213      */
214     static final byte[] BIDIR_PIM_EXPECTED = {
215         (byte) 0x80, (byte) 0x16, (byte) 0x0d,
216         (byte) 0x01, (byte) 0x05, (byte) 0x05, (byte) 0xdc, (byte) 0x10,
217         (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01,
218         (byte) 0x17, (byte) 0x01, (byte) 0x01, (byte) 0x01
219     };
220     /**
221      * ATT - TYPE - ATT LENGTH.
222      * PMSI FLAG - PMSI TYPE 6- MPLS LABEL
223      * Ingress Replication
224      */
225     static final byte[] INGRESS_REPLICATION_EXPECTED = {
226         (byte) 0x80, (byte) 0x16, (byte) 0x09,
227         (byte) 0x01, (byte) 0x06, (byte) 0x05, (byte) 0xdc, (byte) 0x10,
228         (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01
229     };
230     /**
231      * ATT - TYPE - ATT LENGTH.
232      * PMSI FLAG - PMSI TYPE 7- MPLS LABEL
233      * mLDP MP2MP LSP
234      */
235     static final byte[] M_LDP_MP_2_MP_LSP_EXPECTED = {
236         (byte) 0x80, (byte) 0x16, (byte) 0x16,
237         (byte) 0x01, (byte) 0x07, (byte) 0x05, (byte) 0xdc, (byte) 0x10,
238         (byte) 0x01, (byte) 0x00, (byte) 0x0e, // Opaque Type - Length
239         (byte) 0x07, (byte) 0x00, (byte) 0x0B, //Value
240         (byte) 0x00, (byte) 0x00, (byte) 0x01,
241         (byte) 0x00, (byte) 0x00, (byte) 0x00,
242         (byte) 0x01, (byte) 0x00, (byte) 0x00,
243         (byte) 0x00, (byte) 0x00
244     };
245     /**
246      * ATT - TYPE - ATT LENGTH.
247      * PMSI FLAG - PMSI TYPE 7- MPLS LABEL
248      * mLDP MP2MP LSP
249      */
250     static final byte[] M_LDP_MP_2_MP_LSP_WRONG = {
251         (byte) 0x80, (byte) 0x16, (byte) 0x0b,
252         (byte) 0x01, (byte) 0x07, (byte) 0x05, (byte) 0xdc, (byte) 0x10,
253         (byte) 0xfc, (byte) 0x00, (byte) 0x03, // Opaque Type - Length
254         (byte) 0xb5, (byte) 0xeb, (byte) 0x2d,  //Value
255     };
256
257     static final IpAddress P_MULTICAST = new IpAddress(new Ipv4Address("23.1.1.1"));
258     static final IpAddress IP_ADDRESS = new IpAddress(new Ipv4Address("1.1.1.1"));
259     private static final Short NO_SUPPORTED_OPAQUE = 200;
260
261     private PMSITunnelAttributeHandlerTestUtil() {
262         throw new UnsupportedOperationException();
263     }
264
265     static class MockTunnelIdentifier implements TunnelIdentifier {
266         @Override
267         public Class<? extends DataContainer> getImplementedInterface() {
268             return MockTunnelIdentifier.class;
269         }
270     }
271
272     private abstract static class NonSupportedAddressFamily extends AddressFamily {
273     }
274
275     private static PAddressPMulticastGroup buildPAddressPMulticastGroup() {
276         return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel
277                 .pmsi.tunnel.tunnel.identifier.bidir.pim.tree.BidirPimTreeBuilder()
278                 .setPAddress(IP_ADDRESS).setPMulticastGroup(P_MULTICAST).build();
279     }
280
281     private static PmsiTunnelBuilder getPmsiTunnelBuilder() {
282         final PmsiTunnelBuilder pmsiTunnelBuilder = new PmsiTunnelBuilder();
283         pmsiTunnelBuilder.setLeafInformationRequired(true);
284         pmsiTunnelBuilder.setMplsLabel(MPLS_LABEL);
285         return pmsiTunnelBuilder;
286     }
287
288     private static Attributes buildAttribute(final PmsiTunnelBuilder pmsiTunnelBuilder) {
289         return new AttributesBuilder().setUnrecognizedAttributes(Collections.emptyList())
290                 .addAugmentation(PmsiTunnelAugmentation.class,
291             new PmsiTunnelAugmentationBuilder().setPmsiTunnel(pmsiTunnelBuilder.build()).build()).build();
292     }
293
294     static Attributes buildBidirPimTreeAttribute() {
295         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
296         pmsiTunnelBuilder.setTunnelIdentifier(new BidirPimTreeBuilder()
297                 .setBidirPimTree(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel
298                         .rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.bidir.pim.tree
299                         .BidirPimTreeBuilder(buildPAddressPMulticastGroup()).build()).build());
300         return buildAttribute(pmsiTunnelBuilder);
301     }
302
303     static Attributes buildPimSMTreeAttribute() {
304         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
305         pmsiTunnelBuilder.setTunnelIdentifier(new PimSmTreeBuilder().setPimSmTree(new org.opendaylight.yang.gen.v1
306                 .urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel
307                 .identifier.pim.sm.tree.PimSmTreeBuilder(buildPAddressPMulticastGroup()).build()).build());
308         return buildAttribute(pmsiTunnelBuilder);
309     }
310
311     static Attributes buildPimSSMTreeAttribute() {
312         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
313         pmsiTunnelBuilder.setTunnelIdentifier(new PimSsmTreeBuilder().setPimSsmTree(new org.opendaylight.yang.gen.v1
314                 .urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel
315                 .identifier.pim.ssm.tree.PimSsmTreeBuilder(buildPAddressPMulticastGroup()).build()).build());
316         return buildAttribute(pmsiTunnelBuilder);
317     }
318
319     static Attributes buildNoSupportedOpaqueAttribute() {
320         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
321         final List<OpaqueValue> nonSupported = singletonList(new OpaqueValueBuilder()
322                 .setOpaque(OPAQUE_TEST).setOpaqueType(NO_SUPPORTED_OPAQUE).build());
323         pmsiTunnelBuilder.setTunnelIdentifier(buildMldpP2mpLsp(IP_ADDRESS, Ipv4AddressFamily.class, nonSupported));
324         return buildAttribute(pmsiTunnelBuilder);
325     }
326
327     static Attributes buildNoSupportedFamilyAttribute() {
328         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
329         pmsiTunnelBuilder.setTunnelIdentifier(buildMldpP2mpLsp(IP_ADDRESS, NonSupportedAddressFamily.class,
330                 createOpaqueList()));
331         return buildAttribute(pmsiTunnelBuilder);
332     }
333
334     static Attributes buildMldpP2mpLspIpv4Attribute() {
335         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
336         pmsiTunnelBuilder.setTunnelIdentifier(
337                 buildMldpP2mpLsp(IP_ADDRESS, Ipv4AddressFamily.class, createOpaqueList()));
338         return buildAttribute(pmsiTunnelBuilder);
339     }
340
341     static Attributes buildMldpP2mpLspIpv6Attribute() {
342         final PmsiTunnelBuilder pmsiTunnelBuilder = new PmsiTunnelBuilder();
343         pmsiTunnelBuilder.setLeafInformationRequired(true);
344         pmsiTunnelBuilder.setMplsLabel(MPLS_LABEL);
345         pmsiTunnelBuilder.setTunnelIdentifier(buildMldpP2mpLsp(IPV6, Ipv6AddressFamily.class, createOpaqueList()));
346         return buildAttribute(pmsiTunnelBuilder);
347     }
348
349     static Attributes buildMldpp2MPLspL2vpnAttribute() {
350         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
351         pmsiTunnelBuilder.setTunnelIdentifier(
352                 buildMldpP2mpLsp(IP_ADDRESS, L2vpnAddressFamily.class, createOpaqueList()));
353         return buildAttribute(pmsiTunnelBuilder);
354     }
355
356     private static TunnelIdentifier buildMldpP2mpLsp(final IpAddress ipAddress,
357             final Class<? extends AddressFamily> family, final List<OpaqueValue> opaqueList) {
358         return new MldpP2mpLspBuilder().setMldpP2mpLsp(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml
359             .ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.p2mp.lsp.MldpP2mpLspBuilder()
360             .setRootNodeAddress(ipAddress).setAddressFamily(family).setOpaqueValue(opaqueList).build()).build();
361     }
362
363     static Attributes buildRsvpTep2MPLspAttribute() {
364         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
365         pmsiTunnelBuilder.setTunnelIdentifier(new RsvpTeP2mpLspBuilder()
366                 .setRsvpTeP2mpLps(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel
367                         .rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.rsvp.te.p2mp.lsp.RsvpTeP2mpLpsBuilder()
368             .setP2mpId(3458L).setTunnelId(15).setExtendedTunnelId(IP_ADDRESS).build()).build());
369         return buildAttribute(pmsiTunnelBuilder);
370     }
371
372     static Attributes buildIngressReplicationAttribute() {
373         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
374         pmsiTunnelBuilder.setTunnelIdentifier(new IngressReplicationBuilder().setIngressReplication(new org
375                 .opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi
376                 .tunnel.tunnel.identifier.ingress.replication.IngressReplicationBuilder()
377                 .setReceivingEndpointAddress(IP_ADDRESS).build()).build());
378         return buildAttribute(pmsiTunnelBuilder);
379     }
380
381     static Attributes buildMldpMP2mpLspWrongAttribute() {
382         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
383         pmsiTunnelBuilder.setTunnelIdentifier(new MldpMp2mpLspBuilder().setMldpMp2mpLsp(new org.opendaylight.yang.gen
384                 .v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier
385                 .mldp.mp2mp.lsp.MldpMp2mpLspBuilder().setOpaque(OPAQUE_TEST).setOpaqueType(NO_SUPPORTED_OPAQUE)
386                 .build()).build());
387         return buildAttribute(pmsiTunnelBuilder);
388     }
389
390     static Attributes buildMLDpMp2mPLspAttribute() {
391         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
392         pmsiTunnelBuilder.setTunnelIdentifier(new MldpMp2mpLspBuilder().setMldpMp2mpLsp(new org.opendaylight.yang.gen
393                 .v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel
394                 .identifier.mldp.mp2mp.lsp.MldpMp2mpLspBuilder().setOpaque(OPAQUE_TEST)
395                 .setOpaqueType(OpaqueUtil.GENERIC_LSP_IDENTIFIER).build()).build());
396         return buildAttribute(pmsiTunnelBuilder);
397     }
398
399     private static List<OpaqueValue> createOpaqueList() {
400         final List<OpaqueValue> opaqueValues = new ArrayList<>();
401         opaqueValues.add(new OpaqueValueBuilder().setOpaque(OPAQUE_TEST)
402                 .setOpaqueType(OpaqueUtil.GENERIC_LSP_IDENTIFIER).build());
403         opaqueValues.add(new OpaqueValueBuilder().setOpaque(OPAQUE_TEST2)
404                 .setOpaqueType((short) 2).setOpaqueType(OpaqueUtil.EXTENDED_TYPE)
405             .setOpaqueExtendedType(4).build());
406         return opaqueValues;
407     }
408
409     static Attributes buildWOTunnelInfAttribute() {
410         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
411         return buildAttribute(pmsiTunnelBuilder);
412     }
413 }