blob: 6e539a864a241fe32cae53b78efea6e88ba19495 [file] [log] [blame]
Ray Milkeyd03eda02015-01-09 14:58:48 -08001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.codec.impl;
17
Jian Lice8c5602016-03-03 21:43:24 -080018import com.fasterxml.jackson.databind.JsonNode;
Ray Milkeyd03eda02015-01-09 14:58:48 -080019import org.hamcrest.Description;
Ray Milkeyd03eda02015-01-09 14:58:48 -080020import org.hamcrest.TypeSafeDiagnosingMatcher;
Yafit Hadar5796d972015-10-15 13:16:11 +030021import org.onlab.util.HexString;
22import org.onosproject.net.OduSignalId;
Ray Milkeyd03eda02015-01-09 14:58:48 -080023import org.onosproject.net.flow.instructions.Instruction;
Jian Lice8c5602016-03-03 21:43:24 -080024import org.onosproject.net.flow.instructions.Instructions.GroupInstruction;
Jian Li47b26232016-03-07 09:59:59 -080025import org.onosproject.net.flow.instructions.Instructions.MeterInstruction;
Yafit Hadar5796d972015-10-15 13:16:11 +030026import org.onosproject.net.flow.instructions.Instructions.NoActionInstruction;
27import org.onosproject.net.flow.instructions.Instructions.OutputInstruction;
28import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModLambdaInstruction;
29import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction;
30import org.onosproject.net.flow.instructions.L1ModificationInstruction.ModOduSignalIdInstruction;
31import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction;
32import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsLabelInstruction;
33import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction;
34import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction;
35import org.onosproject.net.flow.instructions.L2ModificationInstruction.PushHeaderInstructions;
36import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction;
37import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction;
Ray Milkeyd03eda02015-01-09 14:58:48 -080038
Ray Milkeyd03eda02015-01-09 14:58:48 -080039/**
40 * Hamcrest matcher for instructions.
41 */
Ray Milkeydb358082015-01-13 16:34:38 -080042public final class InstructionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNode> {
Ray Milkeyd03eda02015-01-09 14:58:48 -080043
44 private final Instruction instruction;
45
Ray Milkeydb358082015-01-13 16:34:38 -080046 private InstructionJsonMatcher(Instruction instructionValue) {
Ray Milkeyd03eda02015-01-09 14:58:48 -080047 instruction = instructionValue;
48 }
49
50 /**
51 * Matches the contents of a push header instruction.
52 *
53 * @param instructionJson JSON instruction to match
Pavlin Radoslavovfebe82c2015-02-11 19:08:15 -080054 * @param description Description object used for recording errors
Ray Milkeyd03eda02015-01-09 14:58:48 -080055 * @return true if contents match, false otherwise
56 */
57 private boolean matchPushHeaderInstruction(JsonNode instructionJson,
58 Description description) {
59 PushHeaderInstructions instructionToMatch =
60 (PushHeaderInstructions) instruction;
61 final String jsonSubtype = instructionJson.get("subtype").textValue();
62 if (!instructionToMatch.subtype().name().equals(jsonSubtype)) {
63 description.appendText("subtype was " + jsonSubtype);
64 return false;
65 }
66
67 final String jsonType = instructionJson.get("type").textValue();
68 if (!instructionToMatch.type().name().equals(jsonType)) {
69 description.appendText("type was " + jsonType);
70 return false;
71 }
72
73 final JsonNode ethJson = instructionJson.get("ethernetType");
74 if (ethJson == null) {
75 description.appendText("ethernetType was not null");
76 return false;
77 }
78
alshabib7b808c52015-06-26 14:22:24 -070079 if (instructionToMatch.ethernetType().toShort() != ethJson.asInt()) {
Yuta HIGUCHI32a53c52015-02-08 01:25:40 -080080 description.appendText("ethernetType was " + ethJson);
Ray Milkeyd03eda02015-01-09 14:58:48 -080081 return false;
82 }
Yuta HIGUCHI32a53c52015-02-08 01:25:40 -080083
Ray Milkeyd03eda02015-01-09 14:58:48 -080084 return true;
85 }
86
87 /**
88 * Matches the contents of an output instruction.
89 *
90 * @param instructionJson JSON instruction to match
Pavlin Radoslavovfebe82c2015-02-11 19:08:15 -080091 * @param description Description object used for recording errors
Ray Milkeyd03eda02015-01-09 14:58:48 -080092 * @return true if contents match, false otherwise
93 */
94 private boolean matchOutputInstruction(JsonNode instructionJson,
95 Description description) {
Ray Milkeyd03eda02015-01-09 14:58:48 -080096 final String jsonType = instructionJson.get("type").textValue();
Andrea Campanella5df35952015-12-08 15:46:49 -080097 OutputInstruction instructionToMatch = (OutputInstruction) instruction;
Ray Milkeyd03eda02015-01-09 14:58:48 -080098 if (!instructionToMatch.type().name().equals(jsonType)) {
99 description.appendText("type was " + jsonType);
100 return false;
101 }
102
Andrea Campanella5df35952015-12-08 15:46:49 -0800103 if (instructionJson.get("port").isLong() ||
104 instructionJson.get("port").isInt()) {
105 final long jsonPort = instructionJson.get("port").asLong();
106 if (instructionToMatch.port().toLong() != (jsonPort)) {
107 description.appendText("port was " + jsonPort);
108 return false;
109 }
110 } else if (instructionJson.get("port").isTextual()) {
111 final String jsonPort = instructionJson.get("port").textValue();
112 if (!instructionToMatch.port().toString().equals(jsonPort)) {
113 description.appendText("port was " + jsonPort);
114 return false;
115 }
116 } else {
117 final String jsonPort = instructionJson.get("port").toString();
118 description.appendText("Unmathcing types ");
119 description.appendText("instructionToMatch " + instructionToMatch.port().toString());
120 description.appendText("jsonPort " + jsonPort);
Ray Milkeyd03eda02015-01-09 14:58:48 -0800121 }
122
123 return true;
124 }
125
126 /**
Jian Lice8c5602016-03-03 21:43:24 -0800127 * Matches the contents of a group instruction.
128 *
129 * @param instructionJson JSON instruction to match
130 * @param description Description object used for recording errors
131 * @return true if contents match, false otherwise
132 */
133 private boolean matchGroupInstruction(JsonNode instructionJson,
134 Description description) {
135 final String jsonType = instructionJson.get("type").textValue();
136 GroupInstruction instructionToMatch = (GroupInstruction) instruction;
137 if (!instructionToMatch.type().name().equals(jsonType)) {
138 description.appendText("type was " + jsonType);
139 return false;
140 }
141
Jian Li47b26232016-03-07 09:59:59 -0800142 final int jsonGroupId = instructionJson.get("groupId").intValue();
143 if (instructionToMatch.groupId().id() != jsonGroupId) {
144 description.appendText("groupId was " + jsonGroupId);
145 return false;
146 }
147
148 return true;
149 }
150
151 /**
152 * Matches the contents of a meter instruction.
153 *
154 * @param instructionJson JSON instruction to match
155 * @param description Description object used for recording errors
156 * @return true if contents match, false otherwise
157 */
158 private boolean matchMeterInstruction(JsonNode instructionJson,
159 Description description) {
160 final String jsonType = instructionJson.get("type").textValue();
161 MeterInstruction instructionToMatch = (MeterInstruction) instruction;
162 if (!instructionToMatch.type().name().equals(jsonType)) {
163 description.appendText("type was " + jsonType);
164 return false;
165 }
166
167 final long jsonMeterId = instructionJson.get("meterId").longValue();
168 if (instructionToMatch.meterId().id() != jsonMeterId) {
169 description.appendText("meterId was " + jsonMeterId);
170 return false;
Jian Lice8c5602016-03-03 21:43:24 -0800171 }
172
173 return true;
174 }
175
176 /**
Ray Milkeyd03eda02015-01-09 14:58:48 -0800177 * Matches the contents of a mod lambda instruction.
178 *
179 * @param instructionJson JSON instruction to match
Pavlin Radoslavovfebe82c2015-02-11 19:08:15 -0800180 * @param description Description object used for recording errors
Ray Milkeyd03eda02015-01-09 14:58:48 -0800181 * @return true if contents match, false otherwise
182 */
183 private boolean matchModLambdaInstruction(JsonNode instructionJson,
184 Description description) {
185 ModLambdaInstruction instructionToMatch =
186 (ModLambdaInstruction) instruction;
187 final String jsonSubtype = instructionJson.get("subtype").textValue();
188 if (!instructionToMatch.subtype().name().equals(jsonSubtype)) {
189 description.appendText("subtype was " + jsonSubtype);
190 return false;
191 }
192
193 final String jsonType = instructionJson.get("type").textValue();
194 if (!instructionToMatch.type().name().equals(jsonType)) {
195 description.appendText("type was " + jsonType);
196 return false;
197 }
198
199 final long jsonLambda = instructionJson.get("lambda").shortValue();
200 if (instructionToMatch.lambda() != jsonLambda) {
201 description.appendText("lambda was " + jsonLambda);
202 return false;
203 }
204
205 return true;
206 }
207
208 /**
Yafit Hadar5796d972015-10-15 13:16:11 +0300209 * Matches the contents of a mod OCh singal instruction.
Sho SHIMIZUed7af542015-05-05 19:10:45 -0700210 *
211 * @param instructionJson JSON instruction to match
212 * @param description Description object used for recording errors
213 * @return true if contents matches, false otherwise
214 */
215 private boolean matchModOchSingalInstruction(JsonNode instructionJson,
216 Description description) {
217 ModOchSignalInstruction instructionToMatch =
218 (ModOchSignalInstruction) instruction;
219
220 String jsonSubType = instructionJson.get("subtype").textValue();
221 if (!instructionToMatch.subtype().name().equals(jsonSubType)) {
222 description.appendText("subtype was " + jsonSubType);
223 return false;
224 }
225
226 String jsonType = instructionJson.get("type").textValue();
227 if (!instructionToMatch.type().name().equals(jsonType)) {
228 description.appendText("type was " + jsonType);
229 return false;
230 }
231
232 String jsonGridType = instructionJson.get("gridType").textValue();
233 if (!instructionToMatch.lambda().gridType().name().equals(jsonGridType)) {
234 description.appendText("gridType was " + jsonGridType);
235 return false;
236 }
237
238 String jsonChannelSpacing = instructionJson.get("channelSpacing").textValue();
239 if (!instructionToMatch.lambda().channelSpacing().name().equals(jsonChannelSpacing)) {
240 description.appendText("channelSpacing was " + jsonChannelSpacing);
241 return false;
242 }
243
244 int jsonSpacingMultiplier = instructionJson.get("spacingMultiplier").intValue();
245 if (instructionToMatch.lambda().spacingMultiplier() != jsonSpacingMultiplier) {
246 description.appendText("spacingMultiplier was " + jsonSpacingMultiplier);
247 return false;
248 }
249
250 int jsonSlotGranularity = instructionJson.get("slotGranularity").intValue();
251 if (instructionToMatch.lambda().slotGranularity() != jsonSlotGranularity) {
252 description.appendText("slotGranularity was " + jsonSlotGranularity);
253 return false;
254 }
255
256 return true;
257 }
258
259 /**
Yafit Hadar5796d972015-10-15 13:16:11 +0300260 * Matches the contents of a mod ODU singal Id instruction.
261 *
262 * @param instructionJson JSON instruction to match
263 * @param description Description object used for recording errors
264 * @return true if contents matches, false otherwise
265 */
266 private boolean matchModOduSingalIdInstruction(JsonNode instructionJson,
267 Description description) {
268 ModOduSignalIdInstruction instructionToMatch =
269 (ModOduSignalIdInstruction) instruction;
270 String jsonSubType = instructionJson.get("subtype").textValue();
271 if (!instructionToMatch.subtype().name().equals(jsonSubType)) {
272 description.appendText("subtype was " + jsonSubType);
273 return false;
274 }
275 String jsonType = instructionJson.get("type").textValue();
276 if (!instructionToMatch.type().name().equals(jsonType)) {
277 description.appendText("type was " + jsonType);
278 return false;
279 }
280 final JsonNode jsonOduSignal = instructionJson.get("oduSignalId");
281 int jsonTpn = jsonOduSignal.get("tributaryPortNumber").intValue();
282 int jsonTsLen = jsonOduSignal.get("tributarySlotLength").intValue();
Jian Li68c4fc42016-01-11 16:07:03 -0800283 byte[] tributaryBitMap = HexString.fromHexString(jsonOduSignal.get("tributarySlotBitmap").asText());
Yafit Hadar5796d972015-10-15 13:16:11 +0300284 OduSignalId jsonOduSignalId = OduSignalId.oduSignalId(jsonTpn, jsonTsLen, tributaryBitMap);
285 if (!instructionToMatch.oduSignalId().equals(jsonOduSignalId)) {
286 description.appendText("oduSignalId was " + instructionToMatch);
287 return false;
288 }
289 return true;
290 }
291
292
293 /**
Ray Milkeydb358082015-01-13 16:34:38 -0800294 * Matches the contents of a mod Ethernet instruction.
Ray Milkeyd03eda02015-01-09 14:58:48 -0800295 *
296 * @param instructionJson JSON instruction to match
Pavlin Radoslavovfebe82c2015-02-11 19:08:15 -0800297 * @param description Description object used for recording errors
Ray Milkeyd03eda02015-01-09 14:58:48 -0800298 * @return true if contents match, false otherwise
299 */
300 private boolean matchModEtherInstruction(JsonNode instructionJson,
301 Description description) {
302 ModEtherInstruction instructionToMatch =
303 (ModEtherInstruction) instruction;
304 final String jsonSubtype = instructionJson.get("subtype").textValue();
305 if (!instructionToMatch.subtype().name().equals(jsonSubtype)) {
306 description.appendText("subtype was " + jsonSubtype);
307 return false;
308 }
309
310 final String jsonType = instructionJson.get("type").textValue();
311 if (!instructionToMatch.type().name().equals(jsonType)) {
312 description.appendText("type was " + jsonType);
313 return false;
314 }
315
316 final String jsonMac = instructionJson.get("mac").textValue();
317 final String mac = instructionToMatch.mac().toString();
318 if (!mac.equals(jsonMac)) {
319 description.appendText("mac was " + jsonMac);
320 return false;
321 }
322
323 return true;
324 }
325
326 /**
327 * Matches the contents of a mod vlan id instruction.
328 *
329 * @param instructionJson JSON instruction to match
Pavlin Radoslavovfebe82c2015-02-11 19:08:15 -0800330 * @param description Description object used for recording errors
Ray Milkeyd03eda02015-01-09 14:58:48 -0800331 * @return true if contents match, false otherwise
332 */
333 private boolean matchModVlanIdInstruction(JsonNode instructionJson,
334 Description description) {
335 ModVlanIdInstruction instructionToMatch =
336 (ModVlanIdInstruction) instruction;
337 final String jsonSubtype = instructionJson.get("subtype").textValue();
338 if (!instructionToMatch.subtype().name().equals(jsonSubtype)) {
339 description.appendText("subtype was " + jsonSubtype);
340 return false;
341 }
342
343 final String jsonType = instructionJson.get("type").textValue();
344 if (!instructionToMatch.type().name().equals(jsonType)) {
345 description.appendText("type was " + jsonType);
346 return false;
347 }
348
349 final short jsonVlanId = instructionJson.get("vlanId").shortValue();
350 final short vlanId = instructionToMatch.vlanId().toShort();
351 if (jsonVlanId != vlanId) {
352 description.appendText("vlan id was " + jsonVlanId);
353 return false;
354 }
355
356 return true;
357 }
358
359 /**
360 * Matches the contents of a mod vlan pcp instruction.
361 *
362 * @param instructionJson JSON instruction to match
Pavlin Radoslavovfebe82c2015-02-11 19:08:15 -0800363 * @param description Description object used for recording errors
Ray Milkeyd03eda02015-01-09 14:58:48 -0800364 * @return true if contents match, false otherwise
365 */
366 private boolean matchModVlanPcpInstruction(JsonNode instructionJson,
367 Description description) {
368 ModVlanPcpInstruction instructionToMatch =
369 (ModVlanPcpInstruction) instruction;
370 final String jsonSubtype = instructionJson.get("subtype").textValue();
371 if (!instructionToMatch.subtype().name().equals(jsonSubtype)) {
372 description.appendText("subtype was " + jsonSubtype);
373 return false;
374 }
375
376 final String jsonType = instructionJson.get("type").textValue();
377 if (!instructionToMatch.type().name().equals(jsonType)) {
378 description.appendText("type was " + jsonType);
379 return false;
380 }
381
382 final short jsonVlanPcp = instructionJson.get("vlanPcp").shortValue();
383 final short vlanId = instructionToMatch.vlanPcp();
384 if (jsonVlanPcp != vlanId) {
385 description.appendText("vlan pcp was " + jsonVlanPcp);
386 return false;
387 }
388
389 return true;
390 }
391
392 /**
393 * Matches the contents of a mod ip instruction.
394 *
395 * @param instructionJson JSON instruction to match
Pavlin Radoslavovfebe82c2015-02-11 19:08:15 -0800396 * @param description Description object used for recording errors
Ray Milkeyd03eda02015-01-09 14:58:48 -0800397 * @return true if contents match, false otherwise
398 */
399 private boolean matchModIpInstruction(JsonNode instructionJson,
400 Description description) {
401 ModIPInstruction instructionToMatch =
402 (ModIPInstruction) instruction;
403 final String jsonSubtype = instructionJson.get("subtype").textValue();
404 if (!instructionToMatch.subtype().name().equals(jsonSubtype)) {
405 description.appendText("subtype was " + jsonSubtype);
406 return false;
407 }
408
409 final String jsonType = instructionJson.get("type").textValue();
410 if (!instructionToMatch.type().name().equals(jsonType)) {
411 description.appendText("type was " + jsonType);
412 return false;
413 }
414
415 final String jsonIp = instructionJson.get("ip").textValue();
416 final String ip = instructionToMatch.ip().toString();
417 if (!ip.equals(jsonIp)) {
418 description.appendText("ip was " + jsonIp);
419 return false;
420 }
421
422 return true;
423 }
424
425 /**
Pavlin Radoslavovfebe82c2015-02-11 19:08:15 -0800426 * Matches the contents of a mod IPv6 Flow Label instruction.
427 *
428 * @param instructionJson JSON instruction to match
429 * @param description Description object used for recording errors
430 * @return true if contents match, false otherwise
431 */
432 private boolean matchModIPv6FlowLabelInstruction(JsonNode instructionJson,
433 Description description) {
434 ModIPv6FlowLabelInstruction instructionToMatch =
435 (ModIPv6FlowLabelInstruction) instruction;
436 final String jsonSubtype = instructionJson.get("subtype").textValue();
437 if (!instructionToMatch.subtype().name().equals(jsonSubtype)) {
438 description.appendText("subtype was " + jsonSubtype);
439 return false;
440 }
441
442 final String jsonType = instructionJson.get("type").textValue();
443 if (!instructionToMatch.type().name().equals(jsonType)) {
444 description.appendText("type was " + jsonType);
445 return false;
446 }
447
448 final int jsonFlowLabel = instructionJson.get("flowLabel").intValue();
449 final int flowLabel = instructionToMatch.flowLabel();
450 if (flowLabel != jsonFlowLabel) {
451 description.appendText("IPv6 flow label was " + jsonFlowLabel);
452 return false;
453 }
454
455 return true;
456 }
457
458 /**
Ray Milkeydb358082015-01-13 16:34:38 -0800459 * Matches the contents of a mod MPLS label instruction.
Ray Milkeyd03eda02015-01-09 14:58:48 -0800460 *
461 * @param instructionJson JSON instruction to match
Pavlin Radoslavovfebe82c2015-02-11 19:08:15 -0800462 * @param description Description object used for recording errors
Ray Milkeyd03eda02015-01-09 14:58:48 -0800463 * @return true if contents match, false otherwise
464 */
465 private boolean matchModMplsLabelInstruction(JsonNode instructionJson,
466 Description description) {
467 ModMplsLabelInstruction instructionToMatch =
468 (ModMplsLabelInstruction) instruction;
469 final String jsonSubtype = instructionJson.get("subtype").textValue();
470 if (!instructionToMatch.subtype().name().equals(jsonSubtype)) {
471 description.appendText("subtype was " + jsonSubtype);
472 return false;
473 }
474
475 final String jsonType = instructionJson.get("type").textValue();
476 if (!instructionToMatch.type().name().equals(jsonType)) {
477 description.appendText("type was " + jsonType);
478 return false;
479 }
480
481 final int jsonLabel = instructionJson.get("label").intValue();
Ray Milkey125572b2016-02-22 16:48:17 -0800482 final int label = instructionToMatch.label().toInt();
Ray Milkeyd03eda02015-01-09 14:58:48 -0800483 if (label != jsonLabel) {
Pavlin Radoslavovfebe82c2015-02-11 19:08:15 -0800484 description.appendText("MPLS label was " + jsonLabel);
Ray Milkeyd03eda02015-01-09 14:58:48 -0800485 return false;
486 }
487
488 return true;
489 }
490
491 @Override
492 public boolean matchesSafely(JsonNode jsonInstruction, Description description) {
493
494 // check type
495 final JsonNode jsonTypeNode = jsonInstruction.get("type");
496 final String jsonType = jsonTypeNode.textValue();
497 final String type = instruction.type().name();
498 if (!jsonType.equals(type)) {
499 description.appendText("type was " + type);
500 return false;
501 }
502
503 if (instruction instanceof PushHeaderInstructions) {
504 return matchPushHeaderInstruction(jsonInstruction, description);
Ray Milkeyd03eda02015-01-09 14:58:48 -0800505 } else if (instruction instanceof OutputInstruction) {
506 return matchOutputInstruction(jsonInstruction, description);
Jian Lice8c5602016-03-03 21:43:24 -0800507 } else if (instruction instanceof GroupInstruction) {
508 return matchGroupInstruction(jsonInstruction, description);
Jian Li47b26232016-03-07 09:59:59 -0800509 } else if (instruction instanceof MeterInstruction) {
510 return matchMeterInstruction(jsonInstruction, description);
Ray Milkeyd03eda02015-01-09 14:58:48 -0800511 } else if (instruction instanceof ModLambdaInstruction) {
512 return matchModLambdaInstruction(jsonInstruction, description);
Sho SHIMIZUed7af542015-05-05 19:10:45 -0700513 } else if (instruction instanceof ModOchSignalInstruction) {
514 return matchModOchSingalInstruction(jsonInstruction, description);
Ray Milkeyd03eda02015-01-09 14:58:48 -0800515 } else if (instruction instanceof ModEtherInstruction) {
516 return matchModEtherInstruction(jsonInstruction, description);
517 } else if (instruction instanceof ModVlanIdInstruction) {
518 return matchModVlanIdInstruction(jsonInstruction, description);
519 } else if (instruction instanceof ModVlanPcpInstruction) {
520 return matchModVlanPcpInstruction(jsonInstruction, description);
521 } else if (instruction instanceof ModIPInstruction) {
522 return matchModIpInstruction(jsonInstruction, description);
Pavlin Radoslavovfebe82c2015-02-11 19:08:15 -0800523 } else if (instruction instanceof ModIPv6FlowLabelInstruction) {
524 return matchModIPv6FlowLabelInstruction(jsonInstruction,
525 description);
Ray Milkeyd03eda02015-01-09 14:58:48 -0800526 } else if (instruction instanceof ModMplsLabelInstruction) {
527 return matchModMplsLabelInstruction(jsonInstruction, description);
Yafit Hadar5796d972015-10-15 13:16:11 +0300528 } else if (instruction instanceof ModOduSignalIdInstruction) {
529 return matchModOduSingalIdInstruction(jsonInstruction, description);
Brian O'Connorb75a67a2015-10-07 14:34:06 -0700530 } else if (instruction instanceof NoActionInstruction) {
531 return true;
Ray Milkeyd03eda02015-01-09 14:58:48 -0800532 }
533
534 return false;
535 }
536
537 @Override
538 public void describeTo(Description description) {
539 description.appendText(instruction.toString());
540 }
541
542 /**
543 * Factory to allocate an instruction matcher.
544 *
545 * @param instruction instruction object we are looking for
546 * @return matcher
547 */
548 public static InstructionJsonMatcher matchesInstruction(Instruction instruction) {
549 return new InstructionJsonMatcher(instruction);
550 }
551}