Bump mdsal to 5.0.2
[openflowplugin.git] / openflowplugin / src / test / java / org / opendaylight / openflowplugin / openflow / md / core / sal / convertor / match / MatchV10ResponseConvertorTest.java
1 /*
2  * Copyright (c) 2014, 2015 Pantheon Technologies s.r.o. 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.openflowplugin.openflow.md.core.sal.convertor.match;
10
11 import java.util.Optional;
12 import org.junit.Assert;
13 import org.junit.Before;
14 import org.junit.Test;
15 import org.opendaylight.openflowplugin.api.OFConstants;
16 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
17 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
18 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
20 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder;
32 import org.opendaylight.yangtools.yang.common.Uint16;
33 import org.opendaylight.yangtools.yang.common.Uint32;
34 import org.opendaylight.yangtools.yang.common.Uint64;
35 import org.opendaylight.yangtools.yang.common.Uint8;
36
37 /**
38  * Unit tests for v1.0 match conversion.
39  *
40  * @author michal.polkorab
41  */
42 public class MatchV10ResponseConvertorTest {
43
44     private ConvertorManager convertorManager;
45
46     /**
47      * Initializes OpenflowPortsUtil.
48      */
49     @Before
50     public void startUp() {
51         convertorManager = ConvertorManagerFactory.createDefaultManager();
52     }
53
54     /**
55      * Test {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)}.
56      */
57     @Test
58     public void test() {
59         MatchV10Builder builder = new MatchV10Builder();
60         builder.setWildcards(new FlowWildcardsV10(false, false, false, false,
61                 false, false, false, false, false, false));
62         builder.setNwSrcMask((short) 24);
63         builder.setNwDstMask((short) 16);
64         builder.setInPort(6653);
65         builder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
66         builder.setDlDst(new MacAddress("02:02:02:02:02:02"));
67         builder.setDlVlan(128);
68         builder.setDlVlanPcp((short) 2);
69         builder.setDlType(15);
70         builder.setNwTos((short) 16);
71         builder.setNwProto((short) 6);
72         builder.setNwSrc(new Ipv4Address("1.1.1.2"));
73         builder.setNwDst(new Ipv4Address("32.16.8.1"));
74         builder.setTpSrc(2048);
75         builder.setTpDst(4096);
76         MatchV10 match = builder.build();
77
78         final VersionDatapathIdConvertorData datapathIdConvertorData =
79                 new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
80         datapathIdConvertorData.setDatapathId(Uint64.valueOf(42));
81
82         final Match salMatch = convert(match, datapathIdConvertorData).build();
83
84         Assert.assertEquals("Wrong in port", "openflow:42:6653", salMatch.getInPort().getValue());
85         Assert.assertEquals("Wrong dl src", new MacAddress("01:01:01:01:01:01"), salMatch.getEthernetMatch()
86                 .getEthernetSource().getAddress());
87         Assert.assertEquals("Wrong dl dst", new MacAddress("02:02:02:02:02:02"), salMatch.getEthernetMatch()
88                 .getEthernetDestination().getAddress());
89         Assert.assertEquals("Wrong dl type", 15,
90                 salMatch.getEthernetMatch().getEthernetType().getType().getValue().intValue());
91         Assert.assertEquals("Wrong dl vlan", 128,
92                 salMatch.getVlanMatch().getVlanId().getVlanId().getValue().intValue());
93         Assert.assertEquals("Wrong dl vlan pcp", 2, salMatch.getVlanMatch().getVlanPcp().getValue().intValue());
94         Ipv4Match ipv4Match = (Ipv4Match) salMatch.getLayer3Match();
95         Assert.assertEquals("Wrong nw src address", "1.1.1.2/24", ipv4Match.getIpv4Source().getValue());
96         Assert.assertEquals("Wrong nw dst address", "32.16.8.1/16", ipv4Match.getIpv4Destination().getValue());
97         Assert.assertEquals("Wrong ip protocol", 6, salMatch.getIpMatch().getIpProtocol().intValue());
98         Assert.assertEquals("Wrong ip proto", null, salMatch.getIpMatch().getIpProto());
99         Assert.assertEquals("Wrong ip ecn", null, salMatch.getIpMatch().getIpEcn());
100         Assert.assertEquals("Wrong ip dscp", 4, salMatch.getIpMatch().getIpDscp().getValue().intValue());
101         TcpMatch tcpMatch = (TcpMatch) salMatch.getLayer4Match();
102         Assert.assertEquals("Wrong tp dst", 4096, tcpMatch.getTcpDestinationPort().getValue().intValue());
103         Assert.assertEquals("Wrong tp src", 2048, tcpMatch.getTcpSourcePort().getValue().intValue());
104         Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
105     }
106
107     /**
108      * Test {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)}.
109      */
110     @Test
111     public void testWildcardedMatch() {
112         MatchV10Builder builder = new MatchV10Builder();
113         builder.setWildcards(new FlowWildcardsV10(true, true, true, true,
114                 true, true, true, true, true, true));
115         builder.setNwSrcMask((short) 24);
116         builder.setNwDstMask((short) 16);
117         builder.setInPort(6653);
118         builder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
119         builder.setDlDst(new MacAddress("02:02:02:02:02:02"));
120         builder.setDlVlan(128);
121         builder.setDlVlanPcp((short) 2);
122         builder.setDlType(15);
123         builder.setNwTos((short) 14);
124         builder.setNwProto((short) 6);
125         builder.setNwSrc(new Ipv4Address("1.1.1.2"));
126         builder.setNwDst(new Ipv4Address("32.16.8.1"));
127         builder.setTpSrc(2048);
128         builder.setTpDst(4096);
129         MatchV10 match = builder.build();
130
131         final VersionDatapathIdConvertorData datapathIdConvertorData =
132                 new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
133         datapathIdConvertorData.setDatapathId(Uint64.valueOf(42));
134
135         final Match salMatch = convert(match, datapathIdConvertorData).build();
136
137         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
138         Assert.assertEquals("Wrong dl match", null, salMatch.getEthernetMatch());
139         Assert.assertEquals("Wrong dl vlan match", null, salMatch.getVlanMatch());
140         Assert.assertEquals("Wrong layer 3 match", null, salMatch.getLayer3Match());
141         Assert.assertEquals("Wrong layer 4 match", null, salMatch.getLayer4Match());
142         Assert.assertEquals("Wrong ip match", null, salMatch.getIpMatch());
143         Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
144     }
145
146     /**
147      * Test {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)}.
148      */
149     @Test
150     public void testWildcardedMatchWithNoValuesSet() {
151         MatchV10Builder builder = new MatchV10Builder();
152         builder.setWildcards(new FlowWildcardsV10(true, true, true, true,
153                 true, true, true, true, true, true));
154         MatchV10 match = builder.build();
155
156         final VersionDatapathIdConvertorData datapathIdConvertorData =
157                 new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
158         datapathIdConvertorData.setDatapathId(Uint64.valueOf(42));
159
160         final Match salMatch = convert(match, datapathIdConvertorData).build();
161
162         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
163         Assert.assertEquals("Wrong dl match", null, salMatch.getEthernetMatch());
164         Assert.assertEquals("Wrong dl vlan match", null, salMatch.getVlanMatch());
165         Assert.assertEquals("Wrong layer 3 match", null, salMatch.getLayer3Match());
166         Assert.assertEquals("Wrong layer 4 match", null, salMatch.getLayer4Match());
167         Assert.assertEquals("Wrong ip match", null, salMatch.getIpMatch());
168         Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
169     }
170
171     /**
172      * Test {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)}.
173      */
174     @Test
175     public void testMatchWithValuesUnset() {
176         MatchV10Builder builder = new MatchV10Builder();
177         builder.setWildcards(new FlowWildcardsV10(false, false, false, false,
178                 false, false, false, false, false, false));
179         builder.setNwProto((short) 17);
180         builder.setTpSrc(2048);
181         builder.setTpDst(4096);
182         MatchV10 match = builder.build();
183
184         final VersionDatapathIdConvertorData datapathIdConvertorData =
185                 new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
186         datapathIdConvertorData.setDatapathId(Uint64.valueOf(42));
187
188         final Match salMatch = convert(match, datapathIdConvertorData).build();
189
190         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
191         Assert.assertEquals("Wrong dl match", null, salMatch.getEthernetMatch());
192         Assert.assertEquals("Wrong dl vlan match", null, salMatch.getVlanMatch());
193         Assert.assertEquals("Wrong layer 3 match", null, salMatch.getLayer3Match());
194         UdpMatch udpMatch = (UdpMatch) salMatch.getLayer4Match();
195         Assert.assertEquals("Wrong udp dst", 4096, udpMatch.getUdpDestinationPort().getValue().intValue());
196         Assert.assertEquals("Wrong udp src", 2048, udpMatch.getUdpSourcePort().getValue().intValue());
197         Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
198     }
199
200     /**
201      * Test {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)}.
202      */
203     @Test(expected = NullPointerException.class)
204     public void testEmptyMatch() {
205         MatchV10Builder builder = new MatchV10Builder();
206         MatchV10 match = builder.build();
207
208         final VersionDatapathIdConvertorData datapathIdConvertorData =
209                 new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
210         datapathIdConvertorData.setDatapathId(Uint64.valueOf(42));
211
212         final Match salMatch = convert(match, datapathIdConvertorData).build();
213     }
214
215     /**
216      * ICMPv4 match test for {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)}.
217      */
218     @Test
219     public void testIcmpv4Match() {
220         // NW_PROTO, TP_SRC, TP_DST are wildcarded.
221         Uint32 dlType = Uint32.valueOf(0x800L);
222         FlowWildcardsV10 wc = new FlowWildcardsV10(
223             true, true, false, true, true, true, true, true, true, true);
224         MatchV10Builder builder = new MatchV10Builder().setWildcards(wc).setDlType(dlType.intValue());
225         MatchV10 match = builder.build();
226
227         Uint64 dpid = Uint64.valueOf(12345L);
228         final VersionDatapathIdConvertorData datapathIdConvertorData =
229                 new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
230         datapathIdConvertorData.setDatapathId(dpid);
231
232         Match salMatch = convert(match, datapathIdConvertorData).build();
233
234         EthernetMatch etherMatch = salMatch.getEthernetMatch();
235         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
236         Assert.assertEquals("Wrong dl src",
237                             null, etherMatch.getEthernetSource());
238         Assert.assertEquals("Wrong dl dst",
239                             null, etherMatch.getEthernetDestination());
240         Assert.assertEquals("Wrong dl type", dlType,
241                             etherMatch.getEthernetType().getType().getValue());
242         Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
243         Assert.assertEquals("Wrong IP match", null, salMatch.getIpMatch());
244         Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
245         Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
246         Assert.assertEquals("Wrong ICMPv4 match",
247                             null, salMatch.getIcmpv4Match());
248
249         // NW_PROTO is not wildcarded but null.
250         wc = new FlowWildcardsV10(
251             true, true, false, true, true, true, false, true, true, true);
252         match = builder.setWildcards(wc).build();
253
254         salMatch = convert(match, datapathIdConvertorData).build();
255         etherMatch = salMatch.getEthernetMatch();
256         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
257         Assert.assertEquals("Wrong dl src",
258                             null, etherMatch.getEthernetSource());
259         Assert.assertEquals("Wrong dl dst",
260                             null, etherMatch.getEthernetDestination());
261         Assert.assertEquals("Wrong dl type", dlType,
262                             etherMatch.getEthernetType().getType().getValue());
263         Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
264         Assert.assertEquals("Wrong IP match", null, salMatch.getIpMatch());
265         Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
266         Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
267         Assert.assertEquals("Wrong ICMPv4 match",
268                             null, salMatch.getIcmpv4Match());
269
270         // Specify ICMPv4 protocol.
271         Uint8 ipProto = Uint8.ONE;
272         match = builder.setNwProto(ipProto.shortValue()).build();
273         salMatch = convert(match, datapathIdConvertorData).build();
274         etherMatch = salMatch.getEthernetMatch();
275         IpMatch ipMatch = salMatch.getIpMatch();
276         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
277         Assert.assertEquals("Wrong dl src",
278                             null, etherMatch.getEthernetSource());
279         Assert.assertEquals("Wrong dl dst",
280                             null, etherMatch.getEthernetDestination());
281         Assert.assertEquals("Wrong dl type", dlType,
282                             etherMatch.getEthernetType().getType().getValue());
283         Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
284         Assert.assertEquals("Wrong ip protocol",
285                             ipProto, ipMatch.getIpProtocol());
286         Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
287         Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
288         Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
289         Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
290         Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
291         Assert.assertEquals("Wrong ICMPv4 match",
292                             null, salMatch.getIcmpv4Match());
293
294         // TP_SRC is not wildcarded but null.
295         wc = new FlowWildcardsV10(
296             true, true, false, true, true, true, false, true, true, false);
297         match = builder.setWildcards(wc).build();
298         salMatch = convert(match, datapathIdConvertorData).build();
299         etherMatch = salMatch.getEthernetMatch();
300         ipMatch = salMatch.getIpMatch();
301         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
302         Assert.assertEquals("Wrong dl src",
303                             null, etherMatch.getEthernetSource());
304         Assert.assertEquals("Wrong dl dst",
305                             null, etherMatch.getEthernetDestination());
306         Assert.assertEquals("Wrong dl type", dlType,
307                             etherMatch.getEthernetType().getType().getValue());
308         Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
309         Assert.assertEquals("Wrong ip protocol",
310                             ipProto, ipMatch.getIpProtocol());
311         Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
312         Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
313         Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
314         Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
315         Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
316         Assert.assertEquals("Wrong ICMPv4 match",
317                             null, salMatch.getIcmpv4Match());
318
319         // Specify ICMPv4 type.
320         Uint8 icmpType = Uint8.valueOf(10);
321         match = builder.setTpSrc(icmpType.intValue()).build();
322         salMatch = convert(match, datapathIdConvertorData).build();
323         etherMatch = salMatch.getEthernetMatch();
324         ipMatch = salMatch.getIpMatch();
325         Icmpv4Match icmpv4Match = salMatch.getIcmpv4Match();
326         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
327         Assert.assertEquals("Wrong dl src",
328                             null, etherMatch.getEthernetSource());
329         Assert.assertEquals("Wrong dl dst",
330                             null, etherMatch.getEthernetDestination());
331         Assert.assertEquals("Wrong dl type", dlType,
332                             etherMatch.getEthernetType().getType().getValue());
333         Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
334         Assert.assertEquals("Wrong ip protocol",
335                             ipProto, ipMatch.getIpProtocol());
336         Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
337         Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
338         Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
339         Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
340         Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
341         Assert.assertEquals("Wrong ICMPv4 type",
342                             icmpType, icmpv4Match.getIcmpv4Type());
343         Assert.assertEquals("Wrong ICMPv4 code",
344                             null, icmpv4Match.getIcmpv4Code());
345
346         // TP_DST is not wildcarded but null.
347         wc = new FlowWildcardsV10(
348             true, true, false, true, true, true, false, true, false, false);
349         match = builder.setWildcards(wc).build();
350         salMatch = convert(match, datapathIdConvertorData).build();
351         etherMatch = salMatch.getEthernetMatch();
352         ipMatch = salMatch.getIpMatch();
353         icmpv4Match = salMatch.getIcmpv4Match();
354         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
355         Assert.assertEquals("Wrong dl src",
356                             null, etherMatch.getEthernetSource());
357         Assert.assertEquals("Wrong dl dst",
358                             null, etherMatch.getEthernetDestination());
359         Assert.assertEquals("Wrong dl type", dlType,
360                             etherMatch.getEthernetType().getType().getValue());
361         Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
362         Assert.assertEquals("Wrong ip protocol",
363                             ipProto, ipMatch.getIpProtocol());
364         Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
365         Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
366         Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
367         Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
368         Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
369         Assert.assertEquals("Wrong ICMPv4 type",
370                             icmpType, icmpv4Match.getIcmpv4Type());
371         Assert.assertEquals("Wrong ICMPv4 code",
372                             null, icmpv4Match.getIcmpv4Code());
373
374         // Specify ICMPv4 code only.
375         Uint8 icmpCode = Uint8.valueOf(33);
376         match = builder.setTpSrc((Uint16) null).setTpDst(icmpCode.intValue()).build();
377         salMatch = convert(match, datapathIdConvertorData).build();
378         etherMatch = salMatch.getEthernetMatch();
379         ipMatch = salMatch.getIpMatch();
380         icmpv4Match = salMatch.getIcmpv4Match();
381         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
382         Assert.assertEquals("Wrong dl src",
383                             null, etherMatch.getEthernetSource());
384         Assert.assertEquals("Wrong dl dst",
385                             null, etherMatch.getEthernetDestination());
386         Assert.assertEquals("Wrong dl type", dlType,
387                             etherMatch.getEthernetType().getType().getValue());
388         Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
389         Assert.assertEquals("Wrong ip protocol",
390                             ipProto, ipMatch.getIpProtocol());
391         Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
392         Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
393         Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
394         Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
395         Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
396         Assert.assertEquals("Wrong ICMPv4 type",
397                             null, icmpv4Match.getIcmpv4Type());
398         Assert.assertEquals("Wrong ICMPv4 code",
399                             icmpCode, icmpv4Match.getIcmpv4Code());
400
401         // Specify both ICMPv4 type and code.
402         icmpType = Uint8.ZERO;
403         icmpCode = Uint8.valueOf(8);
404         match = builder.setTpSrc(icmpType.intValue()).setTpDst(icmpCode.intValue()).build();
405         salMatch = convert(match, datapathIdConvertorData).build();
406         etherMatch = salMatch.getEthernetMatch();
407         ipMatch = salMatch.getIpMatch();
408         icmpv4Match = salMatch.getIcmpv4Match();
409         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
410         Assert.assertEquals("Wrong dl src",
411                             null, etherMatch.getEthernetSource());
412         Assert.assertEquals("Wrong dl dst",
413                             null, etherMatch.getEthernetDestination());
414         Assert.assertEquals("Wrong dl type", dlType,
415                             etherMatch.getEthernetType().getType().getValue());
416         Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
417         Assert.assertEquals("Wrong ip protocol",
418                             ipProto, ipMatch.getIpProtocol());
419         Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
420         Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
421         Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
422         Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
423         Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
424         Assert.assertEquals("Wrong ICMPv4 type",
425                             icmpType, icmpv4Match.getIcmpv4Type());
426         Assert.assertEquals("Wrong ICMPv4 code",
427                             icmpCode, icmpv4Match.getIcmpv4Code());
428     }
429
430     /**
431      * TCP match test for {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)}.
432      */
433     @Test
434     public void testTcpMatch() {
435         // TP_SRC, TP_DST are wildcarded.
436         // NW_PROTO is not wildcarded but null.
437         Uint32 dlType = Uint32.valueOf(0x800L);
438         FlowWildcardsV10 wc = new FlowWildcardsV10(
439             true, true, false, true, true, true, false, true, true, true);
440         MatchV10Builder builder = new MatchV10Builder().setWildcards(wc).setDlType(dlType.intValue());
441         MatchV10 match = builder.build();
442
443         Uint64 dpid = Uint64.valueOf(12345L);
444         final VersionDatapathIdConvertorData datapathIdConvertorData =
445                 new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
446         datapathIdConvertorData.setDatapathId(dpid);
447
448         Match salMatch = convert(match, datapathIdConvertorData).build();
449         EthernetMatch etherMatch = salMatch.getEthernetMatch();
450         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
451         Assert.assertEquals("Wrong dl src",
452                             null, etherMatch.getEthernetSource());
453         Assert.assertEquals("Wrong dl dst",
454                             null, etherMatch.getEthernetDestination());
455         Assert.assertEquals("Wrong dl type", dlType,
456                             etherMatch.getEthernetType().getType().getValue());
457         Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
458         Assert.assertEquals("Wrong IP match", null, salMatch.getIpMatch());
459         Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
460         Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
461         Assert.assertEquals("Wrong ICMPv4 match",
462                             null, salMatch.getIcmpv4Match());
463
464         // Specify TCP protocol.
465         Uint8 ipProto = Uint8.valueOf(6);
466         match = builder.setNwProto(ipProto).build();
467         salMatch = convert(match, datapathIdConvertorData).build();
468         etherMatch = salMatch.getEthernetMatch();
469         IpMatch ipMatch = salMatch.getIpMatch();
470         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
471         Assert.assertEquals("Wrong dl src",
472                             null, etherMatch.getEthernetSource());
473         Assert.assertEquals("Wrong dl dst",
474                             null, etherMatch.getEthernetDestination());
475         Assert.assertEquals("Wrong dl type", dlType,
476                             etherMatch.getEthernetType().getType().getValue());
477         Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
478         Assert.assertEquals("Wrong ip protocol",
479                             ipProto, ipMatch.getIpProtocol());
480         Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
481         Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
482         Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
483         Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
484         Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
485         Assert.assertEquals("Wrong ICMPv4 match",
486                             null, salMatch.getIcmpv4Match());
487
488         // TP_SRC is not wildcarded but null.
489         wc = new FlowWildcardsV10(
490             true, true, false, true, true, true, false, true, true, false);
491         match = builder.setWildcards(wc).build();
492         salMatch = convert(match, datapathIdConvertorData).build();
493         etherMatch = salMatch.getEthernetMatch();
494         ipMatch = salMatch.getIpMatch();
495         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
496         Assert.assertEquals("Wrong dl src",
497                             null, etherMatch.getEthernetSource());
498         Assert.assertEquals("Wrong dl dst",
499                             null, etherMatch.getEthernetDestination());
500         Assert.assertEquals("Wrong dl type", dlType,
501                             etherMatch.getEthernetType().getType().getValue());
502         Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
503         Assert.assertEquals("Wrong ip protocol",
504                             ipProto, ipMatch.getIpProtocol());
505         Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
506         Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
507         Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
508         Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
509         Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
510         Assert.assertEquals("Wrong ICMPv4 match",
511                             null, salMatch.getIcmpv4Match());
512
513         // Specify TCP source port.
514         Uint16 srcPort = Uint16.valueOf(60000);
515         match = builder.setTpSrc(srcPort).build();
516         salMatch = convert(match, datapathIdConvertorData).build();
517         etherMatch = salMatch.getEthernetMatch();
518         ipMatch = salMatch.getIpMatch();
519         TcpMatch tcpMatch = (TcpMatch)salMatch.getLayer4Match();
520         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
521         Assert.assertEquals("Wrong dl src",
522                             null, etherMatch.getEthernetSource());
523         Assert.assertEquals("Wrong dl dst",
524                             null, etherMatch.getEthernetDestination());
525         Assert.assertEquals("Wrong dl type", dlType,
526                             etherMatch.getEthernetType().getType().getValue());
527         Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
528         Assert.assertEquals("Wrong ip protocol",
529                             ipProto, ipMatch.getIpProtocol());
530         Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
531         Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
532         Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
533         Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
534         Assert.assertEquals("Wrong TCP src", srcPort,
535                             tcpMatch.getTcpSourcePort().getValue());
536         Assert.assertEquals("Wrong TCP dst", null,
537                             tcpMatch.getTcpDestinationPort());
538         Assert.assertEquals("Wrong ICMPv4 match",
539                             null, salMatch.getIcmpv4Match());
540
541         // TP_DST is not wildcarded but null.
542         wc = new FlowWildcardsV10(
543             true, true, false, true, true, true, false, true, false, false);
544         match = builder.setWildcards(wc).build();
545         salMatch = convert(match, datapathIdConvertorData).build();
546         etherMatch = salMatch.getEthernetMatch();
547         ipMatch = salMatch.getIpMatch();
548         tcpMatch = (TcpMatch)salMatch.getLayer4Match();
549         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
550         Assert.assertEquals("Wrong dl src",
551                             null, etherMatch.getEthernetSource());
552         Assert.assertEquals("Wrong dl dst",
553                             null, etherMatch.getEthernetDestination());
554         Assert.assertEquals("Wrong dl type", dlType,
555                             etherMatch.getEthernetType().getType().getValue());
556         Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
557         Assert.assertEquals("Wrong ip protocol",
558                             ipProto, ipMatch.getIpProtocol());
559         Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
560         Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
561         Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
562         Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
563         Assert.assertEquals("Wrong TCP src", srcPort,
564                             tcpMatch.getTcpSourcePort().getValue());
565         Assert.assertEquals("Wrong TCP dst", null,
566                             tcpMatch.getTcpDestinationPort());
567         Assert.assertEquals("Wrong ICMPv4 match",
568                             null, salMatch.getIcmpv4Match());
569
570         // Specify TCP destination port only.
571         Uint16 dstPort = Uint16.valueOf(6653);
572         match = builder.setTpSrc((Uint16) null).setTpDst(dstPort).build();
573         salMatch = convert(match, datapathIdConvertorData).build();
574         etherMatch = salMatch.getEthernetMatch();
575         ipMatch = salMatch.getIpMatch();
576         tcpMatch = (TcpMatch)salMatch.getLayer4Match();
577         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
578         Assert.assertEquals("Wrong dl src",
579                             null, etherMatch.getEthernetSource());
580         Assert.assertEquals("Wrong dl dst",
581                             null, etherMatch.getEthernetDestination());
582         Assert.assertEquals("Wrong dl type", dlType,
583                             etherMatch.getEthernetType().getType().getValue());
584         Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
585         Assert.assertEquals("Wrong ip protocol",
586                             ipProto, ipMatch.getIpProtocol());
587         Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
588         Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
589         Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
590         Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
591         Assert.assertEquals("Wrong TCP src", null,
592                             tcpMatch.getTcpSourcePort());
593         Assert.assertEquals("Wrong TCP dst", dstPort,
594                             tcpMatch.getTcpDestinationPort().getValue());
595         Assert.assertEquals("Wrong ICMPv4 match",
596                             null, salMatch.getIcmpv4Match());
597
598         // Specify both source and destination port.
599         srcPort = Uint16.valueOf(32767);
600         dstPort = Uint16.valueOf(9999);
601         match = builder.setTpSrc(srcPort).setTpDst(dstPort).build();
602         salMatch = convert(match, datapathIdConvertorData).build();
603         etherMatch = salMatch.getEthernetMatch();
604         ipMatch = salMatch.getIpMatch();
605         tcpMatch = (TcpMatch)salMatch.getLayer4Match();
606         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
607         Assert.assertEquals("Wrong dl src",
608                             null, etherMatch.getEthernetSource());
609         Assert.assertEquals("Wrong dl dst",
610                             null, etherMatch.getEthernetDestination());
611         Assert.assertEquals("Wrong dl type", dlType,
612                             etherMatch.getEthernetType().getType().getValue());
613         Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
614         Assert.assertEquals("Wrong ip protocol",
615                             ipProto, ipMatch.getIpProtocol());
616         Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
617         Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
618         Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
619         Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
620         Assert.assertEquals("Wrong TCP src", srcPort,
621                             tcpMatch.getTcpSourcePort().getValue());
622         Assert.assertEquals("Wrong TCP dst", dstPort,
623                             tcpMatch.getTcpDestinationPort().getValue());
624         Assert.assertEquals("Wrong ICMPv4 match",
625                             null, salMatch.getIcmpv4Match());
626     }
627
628     /**
629      * UDP match test for {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)}.
630      */
631     @Test
632     public void testUdpMatch() {
633         // TP_SRC, TP_DST are wildcarded.
634         // NW_PROTO is not wildcarded but null.
635         Uint32 dlType = Uint32.valueOf(0x800L);
636         FlowWildcardsV10 wc = new FlowWildcardsV10(
637             true, true, false, true, true, true, false, true, true, true);
638         MatchV10Builder builder = new MatchV10Builder().setWildcards(wc).setDlType(dlType.intValue());
639         MatchV10 match = builder.build();
640
641         Uint64 dpid = Uint64.valueOf(12345L);
642         final VersionDatapathIdConvertorData datapathIdConvertorData =
643                 new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
644         datapathIdConvertorData.setDatapathId(dpid);
645
646         Match salMatch = convert(match, datapathIdConvertorData).build();
647         EthernetMatch etherMatch = salMatch.getEthernetMatch();
648         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
649         Assert.assertEquals("Wrong dl src",
650                             null, etherMatch.getEthernetSource());
651         Assert.assertEquals("Wrong dl dst",
652                             null, etherMatch.getEthernetDestination());
653         Assert.assertEquals("Wrong dl type", dlType,
654                             etherMatch.getEthernetType().getType().getValue());
655         Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
656         Assert.assertEquals("Wrong IP match", null, salMatch.getIpMatch());
657         Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
658         Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
659         Assert.assertEquals("Wrong ICMPv4 match",
660                             null, salMatch.getIcmpv4Match());
661
662         // Specify UDP protocol.
663         Uint8 ipProto = Uint8.valueOf(17);
664         match = builder.setNwProto(ipProto).build();
665         salMatch = convert(match, datapathIdConvertorData).build();
666         etherMatch = salMatch.getEthernetMatch();
667         IpMatch ipMatch = salMatch.getIpMatch();
668         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
669         Assert.assertEquals("Wrong dl src",
670                             null, etherMatch.getEthernetSource());
671         Assert.assertEquals("Wrong dl dst",
672                             null, etherMatch.getEthernetDestination());
673         Assert.assertEquals("Wrong dl type", dlType,
674                             etherMatch.getEthernetType().getType().getValue());
675         Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
676         Assert.assertEquals("Wrong ip protocol",
677                             ipProto, ipMatch.getIpProtocol());
678         Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
679         Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
680         Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
681         Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
682         Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
683         Assert.assertEquals("Wrong ICMPv4 match",
684                             null, salMatch.getIcmpv4Match());
685
686         // TP_SRC is not wildcarded but null.
687         wc = new FlowWildcardsV10(
688             true, true, false, true, true, true, false, true, true, false);
689         match = builder.setWildcards(wc).build();
690         salMatch = convert(match, datapathIdConvertorData).build();
691         etherMatch = salMatch.getEthernetMatch();
692         ipMatch = salMatch.getIpMatch();
693         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
694         Assert.assertEquals("Wrong dl src",
695                             null, etherMatch.getEthernetSource());
696         Assert.assertEquals("Wrong dl dst",
697                             null, etherMatch.getEthernetDestination());
698         Assert.assertEquals("Wrong dl type", dlType,
699                             etherMatch.getEthernetType().getType().getValue());
700         Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
701         Assert.assertEquals("Wrong ip protocol",
702                             ipProto, ipMatch.getIpProtocol());
703         Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
704         Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
705         Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
706         Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
707         Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
708         Assert.assertEquals("Wrong ICMPv4 match",
709                             null, salMatch.getIcmpv4Match());
710
711         // Specify UDP source port.
712         Uint16 srcPort = Uint16.valueOf(60000);
713         match = builder.setTpSrc(srcPort).build();
714         salMatch = convert(match, datapathIdConvertorData).build();
715         etherMatch = salMatch.getEthernetMatch();
716         ipMatch = salMatch.getIpMatch();
717         UdpMatch udpMatch = (UdpMatch)salMatch.getLayer4Match();
718         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
719         Assert.assertEquals("Wrong dl src",
720                             null, etherMatch.getEthernetSource());
721         Assert.assertEquals("Wrong dl dst",
722                             null, etherMatch.getEthernetDestination());
723         Assert.assertEquals("Wrong dl type", dlType,
724                             etherMatch.getEthernetType().getType().getValue());
725         Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
726         Assert.assertEquals("Wrong ip protocol",
727                             ipProto, ipMatch.getIpProtocol());
728         Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
729         Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
730         Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
731         Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
732         Assert.assertEquals("Wrong UDP src", srcPort,
733                             udpMatch.getUdpSourcePort().getValue());
734         Assert.assertEquals("Wrong UDP dst", null,
735                             udpMatch.getUdpDestinationPort());
736         Assert.assertEquals("Wrong ICMPv4 match",
737                             null, salMatch.getIcmpv4Match());
738
739         // TP_DST is not wildcarded but null.
740         wc = new FlowWildcardsV10(
741             true, true, false, true, true, true, false, true, false, false);
742         match = builder.setWildcards(wc).build();
743         salMatch = convert(match, datapathIdConvertorData).build();
744         etherMatch = salMatch.getEthernetMatch();
745         ipMatch = salMatch.getIpMatch();
746         udpMatch = (UdpMatch)salMatch.getLayer4Match();
747         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
748         Assert.assertEquals("Wrong dl src",
749                             null, etherMatch.getEthernetSource());
750         Assert.assertEquals("Wrong dl dst",
751                             null, etherMatch.getEthernetDestination());
752         Assert.assertEquals("Wrong dl type", dlType,
753                             etherMatch.getEthernetType().getType().getValue());
754         Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
755         Assert.assertEquals("Wrong ip protocol",
756                             ipProto, ipMatch.getIpProtocol());
757         Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
758         Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
759         Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
760         Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
761         Assert.assertEquals("Wrong UDP src", srcPort,
762                             udpMatch.getUdpSourcePort().getValue());
763         Assert.assertEquals("Wrong UDP dst", null,
764                             udpMatch.getUdpDestinationPort());
765         Assert.assertEquals("Wrong ICMPv4 match",
766                             null, salMatch.getIcmpv4Match());
767
768         // Specify UDP destination port only.
769         Uint16 dstPort = Uint16.valueOf(6653);
770         match = builder.setTpSrc((Uint16) null).setTpDst(dstPort).build();
771         salMatch = convert(match, datapathIdConvertorData).build();
772         etherMatch = salMatch.getEthernetMatch();
773         ipMatch = salMatch.getIpMatch();
774         udpMatch = (UdpMatch)salMatch.getLayer4Match();
775         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
776         Assert.assertEquals("Wrong dl src",
777                             null, etherMatch.getEthernetSource());
778         Assert.assertEquals("Wrong dl dst",
779                             null, etherMatch.getEthernetDestination());
780         Assert.assertEquals("Wrong dl type", dlType,
781                             etherMatch.getEthernetType().getType().getValue());
782         Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
783         Assert.assertEquals("Wrong ip protocol",
784                             ipProto, ipMatch.getIpProtocol());
785         Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
786         Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
787         Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
788         Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
789         Assert.assertEquals("Wrong UDP src", null,
790                             udpMatch.getUdpSourcePort());
791         Assert.assertEquals("Wrong UDP dst", dstPort,
792                             udpMatch.getUdpDestinationPort().getValue());
793         Assert.assertEquals("Wrong ICMPv4 match",
794                             null, salMatch.getIcmpv4Match());
795
796         // Specify both source and destination port.
797         srcPort = Uint16.valueOf(32767);
798         dstPort = Uint16.valueOf(9999);
799         match = builder.setTpSrc(srcPort).setTpDst(dstPort).build();
800         salMatch = convert(match, datapathIdConvertorData).build();
801         etherMatch = salMatch.getEthernetMatch();
802         ipMatch = salMatch.getIpMatch();
803         udpMatch = (UdpMatch)salMatch.getLayer4Match();
804         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
805         Assert.assertEquals("Wrong dl src",
806                             null, etherMatch.getEthernetSource());
807         Assert.assertEquals("Wrong dl dst",
808                             null, etherMatch.getEthernetDestination());
809         Assert.assertEquals("Wrong dl type", dlType,
810                             etherMatch.getEthernetType().getType().getValue());
811         Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
812         Assert.assertEquals("Wrong ip protocol",
813                             ipProto, ipMatch.getIpProtocol());
814         Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
815         Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
816         Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
817         Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
818         Assert.assertEquals("Wrong UDP src", srcPort,
819                             udpMatch.getUdpSourcePort().getValue());
820         Assert.assertEquals("Wrong UDP dst", dstPort,
821                             udpMatch.getUdpDestinationPort().getValue());
822         Assert.assertEquals("Wrong ICMPv4 match",
823                             null, salMatch.getIcmpv4Match());
824     }
825
826     private MatchBuilder convert(final MatchV10 match, final VersionDatapathIdConvertorData data) {
827         final Optional<MatchBuilder> salMatchOptional = convertorManager.convert(match, data);
828
829         return salMatchOptional.orElse(new MatchBuilder());
830     }
831 }