GBP ofoverlay.sf test improvements
[groupbasedpolicy.git] / renderers / ofoverlay / src / test / java / org / opendaylight / groupbasedpolicy / renderer / ofoverlay / sf / L4ClassifierTest.java
1 package org.opendaylight.groupbasedpolicy.renderer.ofoverlay.sf;
2
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertNull;
5 import static org.junit.Assert.assertSame;
6 import static org.junit.Assert.assertTrue;
7
8 import java.util.ArrayList;
9 import java.util.HashMap;
10 import java.util.HashSet;
11 import java.util.List;
12 import java.util.Map;
13 import java.util.Set;
14
15 import com.google.common.collect.ImmutableMap;
16 import org.apache.commons.lang3.tuple.Pair;
17 import org.junit.Rule;
18 import org.junit.Test;
19 import org.junit.rules.ExpectedException;
20 import org.opendaylight.groupbasedpolicy.api.sf.IpProtoClassifierDefinition;
21 import org.opendaylight.groupbasedpolicy.api.sf.L4ClassifierDefinition;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.ParameterValue;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.ParameterValueBuilder;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatch;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder;
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.TcpMatchBuilder;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
31
32 public class L4ClassifierTest {
33
34     private static final long LESSER_RANGE_START = 79L;
35     private static final long LESSER_RANGE_END = 81L;
36     private static final long GREATER_RANGE_START = 8079L;
37     private static final long GREATER_RANGE_END = 8081L;
38     private static final long SINGLE_PORT = 80L;
39     private static final int SINGLE_PORT_INT = 80;
40
41     @Rule
42     public ExpectedException thrown = ExpectedException.none();
43
44     @Test
45     public void testUpdate_TcpSrcPort() {
46         List<MatchBuilder> matches = new ArrayList<>();
47         Map<String, ParameterValue> params = new HashMap<>();
48         matches.add(new MatchBuilder()
49             .setEthernetMatch(
50                     ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV4_ETH_TYPE)));
51         Long sPort = SINGLE_PORT;
52         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM,
53                 ClassifierTestUtils.TCP));
54         params.putAll(ClassifierTestUtils.createIntValueParam(L4ClassifierDefinition.SRC_PORT_PARAM, sPort));
55
56         List<MatchBuilder> updated = Classifier.L4_CL.update(matches, params);
57
58         assertEquals(1, updated.size());
59         MatchBuilder first = updated.get(0);
60         assertEquals(ClassifierTestUtils.IPV4_ETH_TYPE, first.getEthernetMatch().getEthernetType());
61         TcpMatch match = new TcpMatchBuilder((TcpMatch) first.getLayer4Match()).build();
62         assertSame(sPort, match.getTcpSourcePort().getValue().longValue());
63         assertNull(match.getTcpDestinationPort());
64     }
65
66     @Test
67     public void testUpdate_TcpDstPort() {
68         List<MatchBuilder> matches = new ArrayList<>();
69         Map<String, ParameterValue> params = new HashMap<>();
70         Long dPort = SINGLE_PORT;
71         matches.add(new MatchBuilder()
72             .setEthernetMatch(
73                     ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV6_ETH_TYPE)));
74         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM,
75                 ClassifierTestUtils.TCP));
76         params.putAll(ClassifierTestUtils.createIntValueParam(L4ClassifierDefinition.DST_PORT_PARAM, dPort));
77
78         List<MatchBuilder> updated = Classifier.L4_CL.update(matches, params);
79
80         assertEquals(1, updated.size());
81         MatchBuilder first = updated.get(0);
82         assertEquals(ClassifierTestUtils.IPV6_ETH_TYPE, first.getEthernetMatch().getEthernetType());
83         TcpMatch match = new TcpMatchBuilder((TcpMatch) first.getLayer4Match()).build();
84         assertSame(dPort, match.getTcpDestinationPort().getValue().longValue());
85         assertNull(match.getTcpSourcePort());
86     }
87
88     @Test
89     public void testUpdate_TcpSrcPort_DstPortRange() {
90         List<MatchBuilder> matches = new ArrayList<>();
91         Map<String, ParameterValue> params = new HashMap<>();
92         matches.add(new MatchBuilder()
93             .setEthernetMatch(
94                     ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV4_ETH_TYPE)));
95         Long dstRangeStart = GREATER_RANGE_START;
96         Long dstRangeEnd = GREATER_RANGE_END;
97         Long srcPort = SINGLE_PORT;
98         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM,
99                 ClassifierTestUtils.TCP));
100         params.putAll(ClassifierTestUtils.createIntValueParam(L4ClassifierDefinition.SRC_PORT_PARAM, srcPort));
101         params.putAll(ClassifierTestUtils.createRangeValueParam(L4ClassifierDefinition.DST_PORT_RANGE_PARAM,
102                 dstRangeStart, dstRangeEnd));
103         Classifier.L4_CL.checkPresenceOfRequiredParams(params);
104
105         List<MatchBuilder> updated = Classifier.L4_CL.update(matches, params);
106
107         Set<Long> dstPorts = new HashSet<>();
108         for (MatchBuilder match : updated) {
109             assertEquals(ClassifierTestUtils.IPV4_ETH_TYPE, match.getEthernetMatch().getEthernetType());
110             assertEquals(srcPort,
111                     Long.valueOf(new TcpMatchBuilder((TcpMatch) match.getLayer4Match()).getTcpSourcePort().getValue()));
112             dstPorts.add(new TcpMatchBuilder((TcpMatch) match.getLayer4Match()).getTcpDestinationPort()
113                 .getValue()
114                 .longValue());
115         }
116         for (Long port = dstRangeStart; port <= dstRangeEnd; port++) {
117             assertTrue(dstPorts.contains((port)));
118         }
119     }
120
121     @Test
122     public void testUpdate_OverrideDstPortWithTheSameValue() {
123         List<MatchBuilder> matches = new ArrayList<>();
124         Map<String, ParameterValue> params = new HashMap<>();
125         Long dPort = SINGLE_PORT;
126         matches.add(new MatchBuilder().setLayer4Match(ClassifierTestUtils.createUdpDstPort(SINGLE_PORT_INT))
127             .setEthernetMatch(
128                     ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV6_ETH_TYPE)));
129         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM,
130                 ClassifierTestUtils.UDP));
131         params.putAll(ClassifierTestUtils.createIntValueParam(L4ClassifierDefinition.DST_PORT_PARAM, dPort));
132
133         List<MatchBuilder> updated = Classifier.L4_CL.update(matches, params);
134
135         assertEquals(1, updated.size());
136         MatchBuilder first = updated.get(0);
137         assertEquals(ClassifierTestUtils.IPV6_ETH_TYPE, first.getEthernetMatch().getEthernetType());
138         UdpMatch match = new UdpMatchBuilder((UdpMatch) first.getLayer4Match()).build();
139         assertSame(dPort, match.getUdpDestinationPort().getValue().longValue());
140         assertNull(match.getUdpSourcePort());
141     }
142
143     @Test
144     public void testUpdate_AddUdpSrcPortRange() {
145         List<MatchBuilder> matches = new ArrayList<>();
146         Map<String, ParameterValue> params = new HashMap<>();
147         matches.add(new MatchBuilder().setLayer4Match(ClassifierTestUtils.createUdpDstPort(SINGLE_PORT_INT))
148             .setEthernetMatch(
149                     ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV4_ETH_TYPE)));
150         Long srcRangeStart = GREATER_RANGE_START;
151         Long srcRangeEnd = GREATER_RANGE_END;
152         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM,
153                 ClassifierTestUtils.UDP));
154         params.putAll(ClassifierTestUtils.createRangeValueParam(L4ClassifierDefinition.SRC_PORT_RANGE_PARAM,
155                 srcRangeStart, srcRangeEnd));
156
157         List<MatchBuilder> updated = Classifier.L4_CL.update(matches, params);
158
159         assertEquals(3, updated.size());
160         Set<Long> srcPorts = new HashSet<>();
161         for (MatchBuilder match : updated) {
162             assertEquals(ClassifierTestUtils.IPV4_ETH_TYPE, match.getEthernetMatch().getEthernetType());
163             assertSame(SINGLE_PORT_INT,
164                     new UdpMatchBuilder((UdpMatch) match.getLayer4Match()).getUdpDestinationPort().getValue());
165             assertEquals(SINGLE_PORT_INT, new UdpMatchBuilder((UdpMatch) match.getLayer4Match()).getUdpDestinationPort()
166                 .getValue()
167                 .longValue());
168             srcPorts
169                 .add(new UdpMatchBuilder((UdpMatch) match.getLayer4Match()).getUdpSourcePort()
170                         .getValue()
171                         .longValue());
172         }
173         for (Long port = srcRangeStart; port <= srcRangeEnd; port++) {
174             assertTrue(srcPorts.contains((port)));
175         }
176     }
177
178     @Test
179     public void testUpdate_UdpSrcPortRange_DstPort() {
180         List<MatchBuilder> matches = new ArrayList<>();
181         Map<String, ParameterValue> params = new HashMap<>();
182         matches.add(new MatchBuilder().setLayer4Match(ClassifierTestUtils.createUdpDstPort(SINGLE_PORT_INT))
183             .setEthernetMatch(
184                     ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV6_ETH_TYPE)));
185         Long dPort = SINGLE_PORT;
186         Long srcRangeStart = GREATER_RANGE_START;
187         Long srcRangeEnd = GREATER_RANGE_END;
188         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM,
189                 ClassifierTestUtils.UDP));
190         params.putAll(ClassifierTestUtils.createIntValueParam(L4ClassifierDefinition.DST_PORT_PARAM, dPort));
191         params.putAll(ClassifierTestUtils.createRangeValueParam(L4ClassifierDefinition.SRC_PORT_RANGE_PARAM,
192                 srcRangeStart, srcRangeEnd));
193         Classifier.L4_CL.checkPresenceOfRequiredParams(params);
194
195         List<MatchBuilder> updated = Classifier.L4_CL.update(matches, params);
196
197         assertEquals(3, updated.size());
198         Set<Long> srcPorts = new HashSet<>();
199         for (MatchBuilder match : updated) {
200             assertEquals(ClassifierTestUtils.IPV6_ETH_TYPE, match.getEthernetMatch().getEthernetType());
201             assertSame(dPort, new UdpMatchBuilder((UdpMatch) match.getLayer4Match()).getUdpDestinationPort()
202                 .getValue()
203                 .longValue());
204             srcPorts
205                 .add(new UdpMatchBuilder((UdpMatch) match.getLayer4Match()).getUdpSourcePort()
206                         .getValue()
207                         .longValue());
208         }
209         for (Long port = srcRangeStart; port <= srcRangeEnd; port++) {
210             assertTrue(srcPorts.contains((port)));
211         }
212     }
213
214     @Test
215     public void testUpdate_OverrideSrcPortWithTheSameValue() {
216         List<MatchBuilder> matches = new ArrayList<>();
217         Map<String, ParameterValue> params = new HashMap<>();
218         Long sPort = SINGLE_PORT;
219         matches.add(new MatchBuilder().setLayer4Match(ClassifierTestUtils.createSctpSrcPort(sPort.intValue()))
220             .setEthernetMatch(ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV4_ETH_TYPE)));
221         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM,
222                 ClassifierTestUtils.SCTP));
223         params.putAll(ClassifierTestUtils.createIntValueParam(L4ClassifierDefinition.SRC_PORT_PARAM, sPort));
224
225         List<MatchBuilder> updated = Classifier.L4_CL.update(matches, params);
226
227         assertEquals(1, updated.size());
228         MatchBuilder first = updated.get(0);
229         assertEquals(ClassifierTestUtils.IPV4_ETH_TYPE, first.getEthernetMatch().getEthernetType());
230         SctpMatch match = new SctpMatchBuilder((SctpMatch) first.getLayer4Match()).build();
231         assertSame(sPort, match.getSctpSourcePort().getValue().longValue());
232         assertNull(match.getSctpDestinationPort());
233     }
234
235     @Test
236     public void testUpdate_AddSctpDstPortRange() {
237         List<MatchBuilder> matches = new ArrayList<>();
238         Map<String, ParameterValue> params = new HashMap<>();
239         matches.add(new MatchBuilder().setLayer4Match(ClassifierTestUtils.createSctpSrcPort(SINGLE_PORT_INT))
240             .setEthernetMatch(
241                     ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV4_ETH_TYPE)));
242         Long dstRangeStart = GREATER_RANGE_START;
243         Long dstRangeEnd = GREATER_RANGE_END;
244         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM,
245                 ClassifierTestUtils.SCTP));
246         params.putAll(ClassifierTestUtils.createRangeValueParam(L4ClassifierDefinition.DST_PORT_RANGE_PARAM,
247                 dstRangeStart, dstRangeEnd));
248
249         List<MatchBuilder> updated = Classifier.L4_CL.update(matches, params);
250
251         assertEquals(3, updated.size());
252         Set<Long> dstPorts = new HashSet<>();
253         for (MatchBuilder match : updated) {
254             assertEquals(ClassifierTestUtils.IPV4_ETH_TYPE, match.getEthernetMatch().getEthernetType());
255             assertSame(SINGLE_PORT_INT,
256                     new SctpMatchBuilder((SctpMatch) match.getLayer4Match()).getSctpSourcePort().getValue());
257             dstPorts.add(new SctpMatchBuilder((SctpMatch) match.getLayer4Match()).getSctpDestinationPort()
258                 .getValue()
259                 .longValue());
260         }
261         for (Long port = dstRangeStart; port <= dstRangeEnd; port++) {
262             assertTrue(dstPorts.contains((port)));
263         }
264     }
265
266     @Test
267     public void testUpdate_Sctp_SrcPortRange_DstPortRange() {
268         List<MatchBuilder> matches = new ArrayList<>();
269         Map<String, ParameterValue> params = new HashMap<>();
270         matches.add(new MatchBuilder()
271             .setEthernetMatch(
272                     ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV4_ETH_TYPE)));
273         Long srcRangeStart = LESSER_RANGE_START;
274         Long srcRangeEnd = LESSER_RANGE_END;
275         Long dstRangeStart = GREATER_RANGE_START;
276         Long dstRangeEnd = GREATER_RANGE_END;
277         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM,
278                 ClassifierTestUtils.SCTP));
279         params.putAll(ClassifierTestUtils.createRangeValueParam(L4ClassifierDefinition.SRC_PORT_RANGE_PARAM,
280                 srcRangeStart, srcRangeEnd));
281         params.putAll(ClassifierTestUtils.createRangeValueParam(L4ClassifierDefinition.DST_PORT_RANGE_PARAM,
282                 dstRangeStart, dstRangeEnd));
283         Classifier.L4_CL.checkPresenceOfRequiredParams(params);
284
285         List<MatchBuilder> updated = Classifier.L4_CL.update(matches, params);
286
287         assertEquals(9, updated.size());
288         Set<Pair<Long, Long>> set = new HashSet<>();
289         for (MatchBuilder match : updated) {
290             Long srcPort =
291                     new SctpMatchBuilder((SctpMatch) match.getLayer4Match()).getSctpSourcePort().getValue().longValue();
292             Long dstPort = new SctpMatchBuilder((SctpMatch) match.getLayer4Match()).getSctpDestinationPort()
293                 .getValue()
294                 .longValue();
295             set.add(Pair.of(srcPort, dstPort));
296         }
297         for (Long sPort = srcRangeStart; sPort <= srcRangeEnd; sPort++) {
298             for (Long dPort = dstRangeStart; dPort <= dstRangeEnd; dPort++) {
299                 assertTrue(set.contains(Pair.of(sPort, dPort)));
300             }
301         }
302     }
303
304     @Test
305     public void testCheckPresenceOfRequiredParams_SrcPort_SrtPortRange_MutualExclusion() {
306         Map<String, ParameterValue> params = new HashMap<>();
307         Long srcRangeStart = GREATER_RANGE_START;
308         Long srcRangeEnd = GREATER_RANGE_END;
309         Long srcPort = SINGLE_PORT;
310         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM,
311                 ClassifierTestUtils.SCTP));
312         params.putAll(ClassifierTestUtils.createIntValueParam(L4ClassifierDefinition.SRC_PORT_PARAM, srcPort));
313         params.putAll(ClassifierTestUtils.createRangeValueParam(L4ClassifierDefinition.SRC_PORT_RANGE_PARAM,
314                 srcRangeStart, srcRangeEnd));
315
316         thrown.expect(IllegalArgumentException.class);
317         thrown.expectMessage(Classifier.MSG_MUTUALLY_EXCLUSIVE);
318         Classifier.L4_CL.checkPresenceOfRequiredParams(params);
319     }
320
321     @Test
322     public void testCheckPresenceOfRequiredParams_DstPort_DstPortRange_MutualExclusion() {
323         Map<String, ParameterValue> params = new HashMap<>();
324         Long dstRangeStart = GREATER_RANGE_START;
325         Long dstRangeEnd = GREATER_RANGE_END;
326         Long dstPort = SINGLE_PORT;
327         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM,
328                 ClassifierTestUtils.UDP));
329         params.putAll(ClassifierTestUtils.createIntValueParam(L4ClassifierDefinition.DST_PORT_PARAM, dstPort));
330         params.putAll(ClassifierTestUtils.createRangeValueParam(L4ClassifierDefinition.DST_PORT_RANGE_PARAM,
331                 dstRangeStart, dstRangeEnd));
332
333         thrown.expect(IllegalArgumentException.class);
334         thrown.expectMessage(Classifier.MSG_MUTUALLY_EXCLUSIVE);
335         Classifier.L4_CL.checkPresenceOfRequiredParams(params);
336     }
337
338     @Test
339     public void testCheckPresenceOfRequiredParams_RangeValueMismatch() {
340         Map<String, ParameterValue> params = new HashMap<>();
341         Long dstRangeStart = GREATER_RANGE_END;
342         Long dstRangeEnd = GREATER_RANGE_START;
343         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM,
344                 ClassifierTestUtils.TCP));
345         params.putAll(ClassifierTestUtils.createRangeValueParam(L4ClassifierDefinition.DST_PORT_RANGE_PARAM,
346                 dstRangeStart, dstRangeEnd));
347
348         thrown.expect(IllegalArgumentException.class);
349         thrown.expectMessage(Classifier.MSG_RANGE_VALUE_MISMATCH);
350         Classifier.L4_CL.checkPresenceOfRequiredParams(params);
351     }
352
353     @Test
354     public void testUpdate_UnsupportedProtocol() {
355         List<MatchBuilder> matches = new ArrayList<>();
356         Map<String, ParameterValue> params = new HashMap<>();
357         matches.add(new MatchBuilder());
358         Long dstRangeStart = GREATER_RANGE_START;
359         Long dstRangeEnd = GREATER_RANGE_END;
360         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM, 136));
361         params.putAll(ClassifierTestUtils.createRangeValueParam(L4ClassifierDefinition.DST_PORT_RANGE_PARAM,
362                 dstRangeStart, dstRangeEnd));
363
364         thrown.expect(IllegalArgumentException.class);
365         thrown.expectMessage(Classifier.MSG_NOT_SUPPORTED);
366         Classifier.L4_CL.update(matches, params);
367     }
368
369     @Test
370     public void testUpdate_ClassificationConflict() {
371         List<MatchBuilder> matches = new ArrayList<>();
372         Map<String, ParameterValue> params = new HashMap<>();
373         matches.add(new MatchBuilder().setLayer4Match(ClassifierTestUtils.createSctpDstPort(SINGLE_PORT_INT)));
374         Long dstRangeStart = GREATER_RANGE_START;
375         Long dstRangeEnd = GREATER_RANGE_END;
376         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM,
377                 ClassifierTestUtils.UDP));
378         params.putAll(ClassifierTestUtils.createRangeValueParam(L4ClassifierDefinition.DST_PORT_RANGE_PARAM,
379                 dstRangeStart, dstRangeEnd));
380
381         thrown.expect(IllegalArgumentException.class);
382         thrown.expectMessage(Classifier.MSG_CLASSIFICATION_CONFLICT_DETECTED);
383         Classifier.L4_CL.update(matches, params);
384     }
385
386     @Test
387     public void testUpdate_NoProto() {
388         List<MatchBuilder> matches = new ArrayList<>();
389         Map<String, ParameterValue> params = new HashMap<>();
390         matches.add(new MatchBuilder());
391         Long dstRangeStart = GREATER_RANGE_START;
392         Long dstRangeEnd = GREATER_RANGE_END;
393         params.putAll(ClassifierTestUtils.createRangeValueParam(L4ClassifierDefinition.DST_PORT_RANGE_PARAM,
394                 dstRangeStart, dstRangeEnd));
395
396         thrown.expect(IllegalArgumentException.class);
397         thrown.expectMessage(Classifier.MSG_IS_MISSING);
398         Classifier.L4_CL.update(matches, params);
399     }
400
401     @Test
402     public void testCheckPresenceOfRequiredParameters_SrcPortNotSet() {
403         Map<String, ParameterValue> params = new HashMap<>();
404         params.putAll(ImmutableMap.of(L4ClassifierDefinition.SRC_PORT_PARAM, new ParameterValueBuilder().build()));
405
406         thrown.expect(IllegalArgumentException.class);
407         thrown.expectMessage(Classifier.MSG_NOT_SPECIFIED);
408         Classifier.L4_CL.checkPresenceOfRequiredParams(params);
409     }
410
411     @Test
412     public void testCheckPresenceOfRequiredParameters_DstPortNotSet() {
413         Map<String, ParameterValue> params = new HashMap<>();
414         params.putAll(ImmutableMap.of(L4ClassifierDefinition.DST_PORT_PARAM, new ParameterValueBuilder().build()));
415
416         thrown.expect(IllegalArgumentException.class);
417         thrown.expectMessage(Classifier.MSG_NOT_SPECIFIED);
418         Classifier.L4_CL.checkPresenceOfRequiredParams(params);
419     }
420
421     @Test
422     public void testCheckPresenceOfRequiredParameters_SrcRangeNotSet() {
423         Map<String, ParameterValue> params = new HashMap<>();
424         params.putAll(ImmutableMap.of(L4ClassifierDefinition.SRC_PORT_RANGE_PARAM,
425                 new ParameterValueBuilder().build()));
426
427         thrown.expect(IllegalArgumentException.class);
428         thrown.expectMessage(Classifier.MSG_NOT_PRESENT);
429         Classifier.L4_CL.checkPresenceOfRequiredParams(params);
430     }
431
432     @Test
433     public void testCheckPresenceOfRequiredParameters_DstRangeNotSet() {
434         Map<String, ParameterValue> params = new HashMap<>();
435         params.putAll(ImmutableMap.of(L4ClassifierDefinition.DST_PORT_RANGE_PARAM,
436                 new ParameterValueBuilder().build()));
437
438         thrown.expect(IllegalArgumentException.class);
439         thrown.expectMessage(Classifier.MSG_NOT_PRESENT);
440         Classifier.L4_CL.checkPresenceOfRequiredParams(params);
441     }
442 }