blob: 352e2f538457762277a0bf7b1b714a610eb59027 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2014-present Open Networking Foundation
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07003 *
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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.intent;
Ray Milkeye6684082014-10-16 16:59:47 -070017
Jonathan Hart8ef6d3b2015-03-08 21:21:27 -070018import com.google.common.base.MoreObjects;
Andrey Komarov2398d962016-09-26 15:11:23 +030019import org.onlab.graph.Weight;
Brian O'Connorabafb502014-12-02 22:26:20 -080020import org.onosproject.core.GroupId;
Luca Pretede10c782017-01-05 17:23:08 -080021import org.onosproject.net.DefaultPath;
Brian O'Connorabafb502014-12-02 22:26:20 -080022import org.onosproject.net.DeviceId;
23import org.onosproject.net.ElementId;
Thomas Vachuskadc91b552016-03-29 14:02:47 -070024import org.onosproject.net.HostId;
Brian O'Connorabafb502014-12-02 22:26:20 -080025import org.onosproject.net.Link;
Ray Milkey5a7787a2015-02-23 11:44:30 -080026import org.onosproject.net.NetTestTools;
Ray Milkey43a28222015-02-23 13:57:58 -080027import org.onosproject.net.NetworkResource;
Brian O'Connorabafb502014-12-02 22:26:20 -080028import org.onosproject.net.Path;
Yi Tseng2a81c9d2016-09-14 10:14:24 -070029import org.onosproject.net.device.DeviceServiceAdapter;
Brian O'Connorabafb502014-12-02 22:26:20 -080030import org.onosproject.net.flow.FlowId;
31import org.onosproject.net.flow.FlowRule;
jcc3d4e14a2015-04-21 11:32:05 +080032import org.onosproject.net.flow.FlowRuleExtPayLoad;
Carmelo Cascone41605742017-06-19 15:46:44 +090033import org.onosproject.net.flow.IndexTableId;
34import org.onosproject.net.flow.TableId;
Brian O'Connorabafb502014-12-02 22:26:20 -080035import org.onosproject.net.flow.TrafficSelector;
36import org.onosproject.net.flow.TrafficTreatment;
37import org.onosproject.net.flow.criteria.Criterion;
38import org.onosproject.net.flow.criteria.Criterion.Type;
39import org.onosproject.net.flow.instructions.Instruction;
alshabib346b5b32015-03-06 00:42:16 -080040import org.onosproject.net.flow.instructions.Instructions;
Saurav Das86af8f12015-05-25 23:55:33 -070041import org.onosproject.net.flow.instructions.Instructions.MetadataInstruction;
Luca Pretede10c782017-01-05 17:23:08 -080042import org.onosproject.net.provider.ProviderId;
Brian O'Connorabafb502014-12-02 22:26:20 -080043import org.onosproject.net.topology.DefaultTopologyEdge;
44import org.onosproject.net.topology.DefaultTopologyVertex;
Andrey Komarov2398d962016-09-26 15:11:23 +030045import org.onosproject.net.topology.LinkWeigher;
Thomas Vachuska48e64e42015-09-22 15:32:55 -070046import org.onosproject.net.topology.PathServiceAdapter;
Brian O'Connorabafb502014-12-02 22:26:20 -080047import org.onosproject.net.topology.TopologyVertex;
Ray Milkey5a7787a2015-02-23 11:44:30 -080048import org.onosproject.store.Timestamp;
Ray Milkeye6684082014-10-16 16:59:47 -070049
Luca Pretede10c782017-01-05 17:23:08 -080050import java.util.ArrayList;
Jonathan Hart8ef6d3b2015-03-08 21:21:27 -070051import java.util.Arrays;
52import java.util.Collection;
53import java.util.Collections;
54import java.util.HashSet;
Jonathan Hart8ef6d3b2015-03-08 21:21:27 -070055import java.util.List;
56import java.util.Objects;
57import java.util.Set;
58import java.util.concurrent.atomic.AtomicLong;
59
Thomas Vachuska48e64e42015-09-22 15:32:55 -070060import static org.onosproject.net.NetTestTools.*;
Ray Milkey43a28222015-02-23 13:57:58 -080061
Ray Milkeye6684082014-10-16 16:59:47 -070062/**
63 * Common mocks used by the intent framework tests.
64 */
65public class IntentTestsMocks {
66 /**
67 * Mock traffic selector class used for satisfying API requirements.
68 */
69 public static class MockSelector implements TrafficSelector {
70 @Override
71 public Set<Criterion> criteria() {
72 return new HashSet<>();
73 }
Jonathan Hart936c49d2014-10-23 16:38:59 -070074
75 @Override
76 public Criterion getCriterion(Type type) {
77 return null;
78 }
Ray Milkeye6684082014-10-16 16:59:47 -070079 }
80
81 /**
82 * Mock traffic treatment class used for satisfying API requirements.
83 */
84 public static class MockTreatment implements TrafficTreatment {
85 @Override
alshabib346b5b32015-03-06 00:42:16 -080086 public List<Instruction> deferred() {
Jonathan Hart4a0ba562015-03-23 17:23:33 -070087 return Collections.emptyList();
alshabib346b5b32015-03-06 00:42:16 -080088 }
89
90 @Override
91 public List<Instruction> immediate() {
Jonathan Hart4a0ba562015-03-23 17:23:33 -070092 return Collections.emptyList();
alshabib346b5b32015-03-06 00:42:16 -080093 }
94
95 @Override
Jonathan Hart8ef6d3b2015-03-08 21:21:27 -070096 public List<Instruction> allInstructions() {
Jonathan Hart4a0ba562015-03-23 17:23:33 -070097 return Collections.emptyList();
Jonathan Hart8ef6d3b2015-03-08 21:21:27 -070098 }
99
100 @Override
alshabib346b5b32015-03-06 00:42:16 -0800101 public Instructions.TableTypeTransition tableTransition() {
102 return null;
103 }
104
105 @Override
Jonathan Hart4a0ba562015-03-23 17:23:33 -0700106 public boolean clearedDeferred() {
107 return false;
alshabib346b5b32015-03-06 00:42:16 -0800108 }
Saurav Das86af8f12015-05-25 23:55:33 -0700109
110 @Override
111 public MetadataInstruction writeMetadata() {
112 return null;
113 }
alshabib10c810b2015-08-18 16:59:04 -0700114
115 @Override
116 public Instructions.MeterInstruction metered() {
117 return null;
118 }
Ray Milkeye6684082014-10-16 16:59:47 -0700119 }
120
121 /**
122 * Mock path service for creating paths within the test.
123 */
Thomas Vachuska48e64e42015-09-22 15:32:55 -0700124 public static class MockPathService extends PathServiceAdapter {
Ray Milkeye6684082014-10-16 16:59:47 -0700125
126 final String[] pathHops;
127 final String[] reversePathHops;
128
129 /**
130 * Constructor that provides a set of hops to mock.
131 *
132 * @param pathHops path hops to mock
133 */
134 public MockPathService(String[] pathHops) {
135 this.pathHops = pathHops;
136 String[] reversed = pathHops.clone();
137 Collections.reverse(Arrays.asList(reversed));
138 reversePathHops = reversed;
139 }
140
141 @Override
142 public Set<Path> getPaths(ElementId src, ElementId dst) {
143 Set<Path> result = new HashSet<>();
144
145 String[] allHops = new String[pathHops.length];
146
147 if (src.toString().endsWith(pathHops[0])) {
148 System.arraycopy(pathHops, 0, allHops, 0, pathHops.length);
149 } else {
150 System.arraycopy(reversePathHops, 0, allHops, 0, pathHops.length);
151 }
152
Thomas Vachuskadc91b552016-03-29 14:02:47 -0700153 result.add(createPath(src instanceof HostId, dst instanceof HostId, allHops));
Ray Milkeye6684082014-10-16 16:59:47 -0700154 return result;
155 }
156
157 @Override
Andrey Komarov2398d962016-09-26 15:11:23 +0300158 public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeigher weigher) {
159 Set<Path> paths = getPaths(src, dst);
Ray Milkey8d3ce432014-11-07 16:21:10 -0800160
161 for (Path path : paths) {
Andrey Komarov2398d962016-09-26 15:11:23 +0300162 DeviceId srcDevice = path.src().elementId() instanceof DeviceId ? path.src().deviceId() : null;
163 DeviceId dstDevice = path.dst().elementId() instanceof DeviceId ? path.dst().deviceId() : null;
Thomas Vachuskadc91b552016-03-29 14:02:47 -0700164 if (srcDevice != null && dstDevice != null) {
Andrey Komarov2398d962016-09-26 15:11:23 +0300165 TopologyVertex srcVertex = new DefaultTopologyVertex(srcDevice);
166 TopologyVertex dstVertex = new DefaultTopologyVertex(dstDevice);
167 Link link = link(src.toString(), 1, dst.toString(), 1);
Ray Milkey8d3ce432014-11-07 16:21:10 -0800168
Andrey Komarov2398d962016-09-26 15:11:23 +0300169 Weight weightValue = weigher.weight(new DefaultTopologyEdge(srcVertex, dstVertex, link));
170 if (weightValue.isNegative()) {
Thomas Vachuskadc91b552016-03-29 14:02:47 -0700171 return new HashSet<>();
172 }
Ray Milkey8d3ce432014-11-07 16:21:10 -0800173 }
174 }
175 return paths;
Ray Milkeye6684082014-10-16 16:59:47 -0700176 }
177 }
Ray Milkey8d3ce432014-11-07 16:21:10 -0800178
Yi Tseng2a81c9d2016-09-14 10:14:24 -0700179 /**
180 * Mock path service for creating paths within the test.
181 *
182 */
Luca Pretede10c782017-01-05 17:23:08 -0800183 public static class Mp2MpMockPathService extends PathServiceAdapter {
Yi Tseng2a81c9d2016-09-14 10:14:24 -0700184
185 final String[] pathHops;
186 final String[] reversePathHops;
187
188 /**
189 * Constructor that provides a set of hops to mock.
190 *
191 * @param pathHops path hops to mock
192 */
193 public Mp2MpMockPathService(String[] pathHops) {
194 this.pathHops = pathHops;
195 String[] reversed = pathHops.clone();
196 Collections.reverse(Arrays.asList(reversed));
197 reversePathHops = reversed;
198 }
199
200 @Override
201 public Set<Path> getPaths(ElementId src, ElementId dst) {
202 Set<Path> result = new HashSet<>();
203
204 String[] allHops = new String[pathHops.length + 2];
205 allHops[0] = src.toString();
206 allHops[allHops.length - 1] = dst.toString();
207
208 if (pathHops.length != 0) {
209 System.arraycopy(pathHops, 0, allHops, 1, pathHops.length);
210 }
211
212 result.add(createPath(allHops));
213
214 return result;
215 }
216
217 @Override
Andrey Komarov2398d962016-09-26 15:11:23 +0300218 public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeigher weigher) {
Yi Tseng2a81c9d2016-09-14 10:14:24 -0700219 final Set<Path> paths = getPaths(src, dst);
220
221 for (Path path : paths) {
222 final DeviceId srcDevice = path.src().elementId() instanceof DeviceId ? path.src().deviceId() : null;
223 final DeviceId dstDevice = path.dst().elementId() instanceof DeviceId ? path.dst().deviceId() : null;
224 if (srcDevice != null && dstDevice != null) {
225 final TopologyVertex srcVertex = new DefaultTopologyVertex(srcDevice);
226 final TopologyVertex dstVertex = new DefaultTopologyVertex(dstDevice);
227 final Link link = link(src.toString(), 1, dst.toString(), 1);
228
Andrey Komarov2398d962016-09-26 15:11:23 +0300229 final Weight weightValue = weigher.weight(new DefaultTopologyEdge(srcVertex, dstVertex, link));
230 if (weightValue.isNegative()) {
Yi Tseng2a81c9d2016-09-14 10:14:24 -0700231 return new HashSet<>();
232 }
233 }
234 }
235 return paths;
236 }
237 }
238
Luca Pretede10c782017-01-05 17:23:08 -0800239 /**
240 * Mock path service for creating paths for MP2SP intent tests, returning
241 * pre-determined paths.
242 */
243 public static class FixedMP2MPMockPathService extends PathServiceAdapter {
Sho SHIMIZUb1681bd2016-02-22 12:47:50 -0800244
Luca Pretede10c782017-01-05 17:23:08 -0800245 final String[] pathHops;
Sho SHIMIZUb1681bd2016-02-22 12:47:50 -0800246
Luca Pretede10c782017-01-05 17:23:08 -0800247 public static final String DPID_1 = "of:s1";
248 public static final String DPID_2 = "of:s2";
249 public static final String DPID_3 = "of:s3";
250 public static final String DPID_4 = "of:s4";
Sho SHIMIZUb1681bd2016-02-22 12:47:50 -0800251
Luca Pretede10c782017-01-05 17:23:08 -0800252 /**
253 * Constructor that provides a set of hops to mock.
254 *
255 * @param pathHops path hops to mock
256 */
257 public FixedMP2MPMockPathService(String[] pathHops) {
258 this.pathHops = pathHops;
Ray Milkey8d3ce432014-11-07 16:21:10 -0800259 }
260
HIGUCHI Yutaca9cc8e2015-10-29 23:26:51 -0700261 @Override
Luca Pretede10c782017-01-05 17:23:08 -0800262 public Set<Path> getPaths(ElementId src, ElementId dst) {
263 List<Link> links = new ArrayList<>();
264 Set<Path> result = new HashSet<>();
265 ProviderId providerId = new ProviderId("of", "foo");
266 DefaultPath path;
267 if (src.toString().equals(DPID_1) && dst.toString().equals(DPID_4)) {
268 links.add(NetTestTools.linkNoPrefixes(src.toString(), 2, pathHops[0], 1));
269 links.add(NetTestTools.linkNoPrefixes(pathHops[0], 2, dst.toString(), 1));
270 } else if (src.toString().equals(DPID_2) && dst.toString().equals(DPID_4)) {
271 links.add(NetTestTools.linkNoPrefixes(src.toString(), 2, pathHops[0], 3));
272 links.add(NetTestTools.linkNoPrefixes(pathHops[0], 2, dst.toString(), 1));
273 } else if (src.toString().equals(DPID_4) && dst.toString().equals(DPID_1)) {
274 links.add(NetTestTools.linkNoPrefixes(src.toString(), 2, pathHops[0], 1));
275 links.add(NetTestTools.linkNoPrefixes(pathHops[0], 2, dst.toString(), 1));
276 } else if (src.toString().equals(DPID_4) && dst.toString().equals(DPID_2)) {
277 links.add(NetTestTools.linkNoPrefixes(src.toString(), 2, pathHops[0], 1));
278 links.add(NetTestTools.linkNoPrefixes(pathHops[0], 3, dst.toString(), 1));
279 } else {
280 return result;
Ray Milkey8d3ce432014-11-07 16:21:10 -0800281 }
Luca Pretede10c782017-01-05 17:23:08 -0800282 path = new DefaultPath(providerId, links, 3);
283 result.add(path);
Ray Milkey8d3ce432014-11-07 16:21:10 -0800284
Luca Pretede10c782017-01-05 17:23:08 -0800285 return result;
Ray Milkey8d3ce432014-11-07 16:21:10 -0800286 }
287
288 @Override
Luca Pretede10c782017-01-05 17:23:08 -0800289 public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeigher weigher) {
290 final Set<Path> paths = getPaths(src, dst);
Ray Milkey8d3ce432014-11-07 16:21:10 -0800291
Luca Pretede10c782017-01-05 17:23:08 -0800292 for (Path path : paths) {
293 final DeviceId srcDevice = path.src().elementId() instanceof DeviceId ? path.src().deviceId() : null;
294 final DeviceId dstDevice = path.dst().elementId() instanceof DeviceId ? path.dst().deviceId() : null;
295 if (srcDevice != null && dstDevice != null) {
296 final TopologyVertex srcVertex = new DefaultTopologyVertex(srcDevice);
297 final TopologyVertex dstVertex = new DefaultTopologyVertex(dstDevice);
298 final Link link = link(src.toString(), 1, dst.toString(), 1);
299
300 final Weight weightValue = weigher.weight(new DefaultTopologyEdge(srcVertex, dstVertex, link));
301 if (weightValue.isNegative()) {
302 return new HashSet<>();
303 }
304 }
305 }
306 return paths;
Ray Milkeye97ede92014-11-20 10:43:12 -0800307 }
Ray Milkey8d3ce432014-11-07 16:21:10 -0800308 }
309
Ray Milkey930fc662014-11-11 16:07:45 -0800310 private static final IntentTestsMocks.MockSelector SELECTOR =
311 new IntentTestsMocks.MockSelector();
312 private static final IntentTestsMocks.MockTreatment TREATMENT =
313 new IntentTestsMocks.MockTreatment();
314
315 public static class MockFlowRule implements FlowRule {
Ray Milkey77a455f2015-03-27 10:08:17 -0700316 static int nextId = 0;
Ray Milkey930fc662014-11-11 16:07:45 -0800317
318 int priority;
Carmelo Cascone41605742017-06-19 15:46:44 +0900319 IndexTableId tableId;
Ray Milkey77a455f2015-03-27 10:08:17 -0700320 long timestamp;
321 int id;
jcc3d4e14a2015-04-21 11:32:05 +0800322 FlowRuleExtPayLoad payLoad;
sangho11c30ac2015-01-22 14:30:55 -0800323
Ray Milkey930fc662014-11-11 16:07:45 -0800324 public MockFlowRule(int priority) {
325 this.priority = priority;
Carmelo Cascone41605742017-06-19 15:46:44 +0900326 this.tableId = DEFAULT_TABLE;
Ray Milkey77a455f2015-03-27 10:08:17 -0700327 this.timestamp = System.currentTimeMillis();
328 this.id = nextId++;
jcc3d4e14a2015-04-21 11:32:05 +0800329 this.payLoad = null;
330 }
331
332 public MockFlowRule(int priority, FlowRuleExtPayLoad payLoad) {
333 this.priority = priority;
334 this.timestamp = System.currentTimeMillis();
335 this.id = nextId++;
336 this.payLoad = payLoad;
Ray Milkey930fc662014-11-11 16:07:45 -0800337 }
338
339 @Override
340 public FlowId id() {
Ray Milkey77a455f2015-03-27 10:08:17 -0700341 return FlowId.valueOf(id);
Ray Milkey930fc662014-11-11 16:07:45 -0800342 }
343
344 @Override
345 public short appId() {
346 return 0;
347 }
348
349 @Override
Sho SHIMIZU75a5bd92014-11-25 11:22:56 -0800350 public GroupId groupId() {
Yi Tsengfa394de2017-02-01 11:26:40 -0800351 return new GroupId(0);
alshabib28204e52014-11-12 18:29:45 -0800352 }
353
354 @Override
Ray Milkey930fc662014-11-11 16:07:45 -0800355 public int priority() {
356 return priority;
357 }
358
359 @Override
360 public DeviceId deviceId() {
361 return did("1");
362 }
363
364 @Override
365 public TrafficSelector selector() {
366 return SELECTOR;
367 }
368
369 @Override
370 public TrafficTreatment treatment() {
371 return TREATMENT;
372 }
373
374 @Override
375 public int timeout() {
376 return 0;
377 }
378
379 @Override
Murat Parlakisikc6759e82016-06-29 03:22:22 -0700380 public int hardTimeout() {
381 return 0;
382 }
383
384 @Override
385 public FlowRemoveReason reason() {
386 return FlowRemoveReason.NO_REASON;
387 }
388
389 @Override
Ray Milkey930fc662014-11-11 16:07:45 -0800390 public boolean isPermanent() {
391 return false;
392 }
393
Brian O'Connor427a1762014-11-19 18:40:32 -0800394 @Override
395 public int hashCode() {
HIGUCHI Yutaca9cc8e2015-10-29 23:26:51 -0700396 return priority;
Brian O'Connor427a1762014-11-19 18:40:32 -0800397 }
Ray Milkey930fc662014-11-11 16:07:45 -0800398
Brian O'Connor427a1762014-11-19 18:40:32 -0800399 @Override
400 public boolean equals(Object obj) {
401 if (this == obj) {
402 return true;
403 }
404 if (obj == null || getClass() != obj.getClass()) {
405 return false;
406 }
407 final MockFlowRule other = (MockFlowRule) obj;
Ray Milkey77a455f2015-03-27 10:08:17 -0700408 return Objects.equals(this.timestamp, other.timestamp) &&
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700409 this.id == other.id;
Brian O'Connor427a1762014-11-19 18:40:32 -0800410 }
sangho11c30ac2015-01-22 14:30:55 -0800411
412 @Override
Jonathan Hartf44e42c2015-08-04 09:58:46 -0700413 public boolean exactMatch(FlowRule rule) {
414 return this.equals(rule);
415 }
416
417 @Override
alshabibdb774072015-04-20 13:13:51 -0700418 public int tableId() {
Carmelo Cascone41605742017-06-19 15:46:44 +0900419 return tableId.id();
420 }
421
422 @Override
423 public TableId table() {
alshabib08d98982015-04-21 16:25:50 -0700424 return tableId;
alshabibdb774072015-04-20 13:13:51 -0700425 }
jcc3d4e14a2015-04-21 11:32:05 +0800426
427 @Override
428 public FlowRuleExtPayLoad payLoad() {
429 return payLoad;
430 }
Ray Milkey930fc662014-11-11 16:07:45 -0800431 }
432
Ray Milkey5a7787a2015-02-23 11:44:30 -0800433 public static class MockIntent extends Intent {
434 private static AtomicLong counter = new AtomicLong(0);
435
436 private final Long number;
437
438 public MockIntent(Long number) {
Ray Milkeyebc5d222015-03-18 15:45:36 -0700439 super(NetTestTools.APP_ID, null, Collections.emptyList(),
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -0700440 Intent.DEFAULT_INTENT_PRIORITY);
Ray Milkey5a7787a2015-02-23 11:44:30 -0800441 this.number = number;
442 }
443
Ray Milkey43a28222015-02-23 13:57:58 -0800444 public MockIntent(Long number, Collection<NetworkResource> resources) {
Ray Milkeyebc5d222015-03-18 15:45:36 -0700445 super(NetTestTools.APP_ID, null, resources, Intent.DEFAULT_INTENT_PRIORITY);
Ray Milkey43a28222015-02-23 13:57:58 -0800446 this.number = number;
447 }
448
Ray Milkey5a7787a2015-02-23 11:44:30 -0800449 public Long number() {
450 return number;
451 }
452
453 public static Long nextId() {
454 return counter.getAndIncrement();
455 }
Ray Milkey43a28222015-02-23 13:57:58 -0800456
457 @Override
458 public String toString() {
459 return MoreObjects.toStringHelper(getClass())
460 .add("id", id())
461 .add("appId", appId())
462 .toString();
463 }
Ray Milkey5a7787a2015-02-23 11:44:30 -0800464 }
465
466 public static class MockTimestamp implements Timestamp {
467 final int value;
468
469 public MockTimestamp(int value) {
470 this.value = value;
471 }
472
473 @Override
474 public int compareTo(Timestamp o) {
475 if (!(o instanceof MockTimestamp)) {
476 return -1;
477 }
478 MockTimestamp that = (MockTimestamp) o;
Jonathan Hart72175c22015-03-24 18:55:58 -0700479 return this.value - that.value;
Ray Milkey5a7787a2015-02-23 11:44:30 -0800480 }
Yuta HIGUCHI4f8a3772017-05-16 20:23:49 -0700481
482 @Override
483 public int hashCode() {
484 return value;
485 }
486
487 @Override
488 public boolean equals(Object obj) {
489 if (obj instanceof MockTimestamp) {
490 return this.compareTo((MockTimestamp) obj) == 0;
491 }
492 return false;
493 }
Ray Milkey5a7787a2015-02-23 11:44:30 -0800494 }
495
Yi Tseng2a81c9d2016-09-14 10:14:24 -0700496 /**
497 * Mocks the device service so that a device appears available in the test.
498 */
499 public static class MockDeviceService extends DeviceServiceAdapter {
500 @Override
501 public boolean isAvailable(DeviceId deviceId) {
502 return true;
503 }
504 }
Ray Milkeye6684082014-10-16 16:59:47 -0700505}