637fa0c1459147e0f784320f6da53dc7a7f6d884
[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.rev180329.L2vpnAddressFamily;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.evpn.routes.evpn.routes.evpn.route.PmsiTunnelAugmentation;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.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 interface NonSupportedAddressFamily extends AddressFamily {
273
274     }
275
276     private static PAddressPMulticastGroup buildPAddressPMulticastGroup() {
277         return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel
278                 .pmsi.tunnel.tunnel.identifier.bidir.pim.tree.BidirPimTreeBuilder()
279                 .setPAddress(IP_ADDRESS).setPMulticastGroup(P_MULTICAST).build();
280     }
281
282     private static PmsiTunnelBuilder getPmsiTunnelBuilder() {
283         final PmsiTunnelBuilder pmsiTunnelBuilder = new PmsiTunnelBuilder();
284         pmsiTunnelBuilder.setLeafInformationRequired(true);
285         pmsiTunnelBuilder.setMplsLabel(MPLS_LABEL);
286         return pmsiTunnelBuilder;
287     }
288
289     private static Attributes buildAttribute(final PmsiTunnelBuilder pmsiTunnelBuilder) {
290         return new AttributesBuilder().setUnrecognizedAttributes(Collections.emptyList())
291                 .addAugmentation(PmsiTunnelAugmentation.class,
292             new PmsiTunnelAugmentationBuilder().setPmsiTunnel(pmsiTunnelBuilder.build()).build()).build();
293     }
294
295     static Attributes buildBidirPimTreeAttribute() {
296         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
297         pmsiTunnelBuilder.setTunnelIdentifier(new BidirPimTreeBuilder()
298                 .setBidirPimTree(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel
299                         .rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.bidir.pim.tree
300                         .BidirPimTreeBuilder(buildPAddressPMulticastGroup()).build()).build());
301         return buildAttribute(pmsiTunnelBuilder);
302     }
303
304     static Attributes buildPimSMTreeAttribute() {
305         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
306         pmsiTunnelBuilder.setTunnelIdentifier(new PimSmTreeBuilder().setPimSmTree(new org.opendaylight.yang.gen.v1
307                 .urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel
308                 .identifier.pim.sm.tree.PimSmTreeBuilder(buildPAddressPMulticastGroup()).build()).build());
309         return buildAttribute(pmsiTunnelBuilder);
310     }
311
312     static Attributes buildPimSSMTreeAttribute() {
313         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
314         pmsiTunnelBuilder.setTunnelIdentifier(new PimSsmTreeBuilder().setPimSsmTree(new org.opendaylight.yang.gen.v1
315                 .urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel
316                 .identifier.pim.ssm.tree.PimSsmTreeBuilder(buildPAddressPMulticastGroup()).build()).build());
317         return buildAttribute(pmsiTunnelBuilder);
318     }
319
320     static Attributes buildNoSupportedOpaqueAttribute() {
321         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
322         final List<OpaqueValue> nonSupported = singletonList(new OpaqueValueBuilder()
323                 .setOpaque(OPAQUE_TEST).setOpaqueType(NO_SUPPORTED_OPAQUE).build());
324         pmsiTunnelBuilder.setTunnelIdentifier(buildMldpP2mpLsp(IP_ADDRESS, Ipv4AddressFamily.class, nonSupported));
325         return buildAttribute(pmsiTunnelBuilder);
326     }
327
328     static Attributes buildNoSupportedFamilyAttribute() {
329         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
330         pmsiTunnelBuilder.setTunnelIdentifier(buildMldpP2mpLsp(IP_ADDRESS, NonSupportedAddressFamily.class,
331                 createOpaqueList()));
332         return buildAttribute(pmsiTunnelBuilder);
333     }
334
335     static Attributes buildMldpP2mpLspIpv4Attribute() {
336         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
337         pmsiTunnelBuilder.setTunnelIdentifier(
338                 buildMldpP2mpLsp(IP_ADDRESS, Ipv4AddressFamily.class, createOpaqueList()));
339         return buildAttribute(pmsiTunnelBuilder);
340     }
341
342     static Attributes buildMldpP2mpLspIpv6Attribute() {
343         final PmsiTunnelBuilder pmsiTunnelBuilder = new PmsiTunnelBuilder();
344         pmsiTunnelBuilder.setLeafInformationRequired(true);
345         pmsiTunnelBuilder.setMplsLabel(MPLS_LABEL);
346         pmsiTunnelBuilder.setTunnelIdentifier(buildMldpP2mpLsp(IPV6, Ipv6AddressFamily.class, createOpaqueList()));
347         return buildAttribute(pmsiTunnelBuilder);
348     }
349
350     static Attributes buildMldpp2MPLspL2vpnAttribute() {
351         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
352         pmsiTunnelBuilder.setTunnelIdentifier(
353                 buildMldpP2mpLsp(IP_ADDRESS, L2vpnAddressFamily.class, createOpaqueList()));
354         return buildAttribute(pmsiTunnelBuilder);
355     }
356
357     private static TunnelIdentifier buildMldpP2mpLsp(final IpAddress ipAddress,
358             final Class<? extends AddressFamily> family, final List<OpaqueValue> opaqueList) {
359         return new MldpP2mpLspBuilder().setMldpP2mpLsp(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml
360             .ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.p2mp.lsp.MldpP2mpLspBuilder()
361             .setRootNodeAddress(ipAddress).setAddressFamily(family).setOpaqueValue(opaqueList).build()).build();
362     }
363
364     static Attributes buildRsvpTep2MPLspAttribute() {
365         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
366         pmsiTunnelBuilder.setTunnelIdentifier(new RsvpTeP2mpLspBuilder()
367                 .setRsvpTeP2mpLps(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel
368                         .rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.rsvp.te.p2mp.lsp.RsvpTeP2mpLpsBuilder()
369             .setP2mpId(3458L).setTunnelId(15).setExtendedTunnelId(IP_ADDRESS).build()).build());
370         return buildAttribute(pmsiTunnelBuilder);
371     }
372
373     static Attributes buildIngressReplicationAttribute() {
374         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
375         pmsiTunnelBuilder.setTunnelIdentifier(new IngressReplicationBuilder().setIngressReplication(new org
376                 .opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi
377                 .tunnel.tunnel.identifier.ingress.replication.IngressReplicationBuilder()
378                 .setReceivingEndpointAddress(IP_ADDRESS).build()).build());
379         return buildAttribute(pmsiTunnelBuilder);
380     }
381
382     static Attributes buildMldpMP2mpLspWrongAttribute() {
383         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
384         pmsiTunnelBuilder.setTunnelIdentifier(new MldpMp2mpLspBuilder().setMldpMp2mpLsp(new org.opendaylight.yang.gen
385                 .v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier
386                 .mldp.mp2mp.lsp.MldpMp2mpLspBuilder().setOpaque(OPAQUE_TEST).setOpaqueType(NO_SUPPORTED_OPAQUE)
387                 .build()).build());
388         return buildAttribute(pmsiTunnelBuilder);
389     }
390
391     static Attributes buildMLDpMp2mPLspAttribute() {
392         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
393         pmsiTunnelBuilder.setTunnelIdentifier(new MldpMp2mpLspBuilder().setMldpMp2mpLsp(new org.opendaylight.yang.gen
394                 .v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel
395                 .identifier.mldp.mp2mp.lsp.MldpMp2mpLspBuilder().setOpaque(OPAQUE_TEST)
396                 .setOpaqueType(OpaqueUtil.GENERIC_LSP_IDENTIFIER).build()).build());
397         return buildAttribute(pmsiTunnelBuilder);
398     }
399
400     private static List<OpaqueValue> createOpaqueList() {
401         final List<OpaqueValue> opaqueValues = new ArrayList<>();
402         opaqueValues.add(new OpaqueValueBuilder().setOpaque(OPAQUE_TEST)
403                 .setOpaqueType(OpaqueUtil.GENERIC_LSP_IDENTIFIER).build());
404         opaqueValues.add(new OpaqueValueBuilder().setOpaque(OPAQUE_TEST2)
405                 .setOpaqueType((short) 2).setOpaqueType(OpaqueUtil.EXTENDED_TYPE)
406             .setOpaqueExtendedType(4).build());
407         return opaqueValues;
408     }
409
410     static Attributes buildWOTunnelInfAttribute() {
411         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
412         return buildAttribute(pmsiTunnelBuilder);
413     }
414 }