blob: c9e211575d0784d43b0642f433c8fbca1ab9dbad [file] [log] [blame]
Jonathan Hartaa380972014-04-03 10:24:46 -07001package net.onrc.onos.core.intent.runtime;
Ray Milkey6688cd82014-03-11 16:40:46 -07002
Jonathan Harta88fd242014-04-03 11:24:54 -07003import static org.easymock.EasyMock.anyObject;
4import static org.easymock.EasyMock.createMock;
5import static org.easymock.EasyMock.eq;
6import static org.easymock.EasyMock.expect;
7import static org.easymock.EasyMock.expectLastCall;
8import static org.easymock.EasyMock.replay;
9import static org.easymock.EasyMock.verify;
10import static org.hamcrest.MatcherAssert.assertThat;
11import static org.hamcrest.Matchers.equalTo;
12import static org.hamcrest.Matchers.hasItem;
13import static org.hamcrest.Matchers.hasSize;
14import static org.hamcrest.Matchers.notNullValue;
15
16import java.util.Collection;
17import java.util.LinkedList;
18import java.util.List;
19
Ray Milkey6688cd82014-03-11 16:40:46 -070020import net.floodlightcontroller.core.module.FloodlightModuleContext;
21import net.floodlightcontroller.core.module.FloodlightModuleException;
Pavlin Radoslavov13669052014-05-13 10:33:39 -070022import net.floodlightcontroller.restserver.IRestApiService;
Jonathan Hart6df90172014-04-03 10:13:11 -070023import net.onrc.onos.core.datagrid.IDatagridService;
24import net.onrc.onos.core.datagrid.IEventChannel;
25import net.onrc.onos.core.datagrid.IEventChannelListener;
Jonathan Hartaa380972014-04-03 10:24:46 -070026import net.onrc.onos.core.intent.Intent;
Jonathan Harta88fd242014-04-03 11:24:54 -070027import net.onrc.onos.core.intent.Intent.IntentState;
Jonathan Hartaa380972014-04-03 10:24:46 -070028import net.onrc.onos.core.intent.IntentMap;
Jonathan Harta88fd242014-04-03 11:24:54 -070029import net.onrc.onos.core.intent.IntentOperation.Operator;
Jonathan Hartaa380972014-04-03 10:24:46 -070030import net.onrc.onos.core.intent.IntentOperationList;
Jonathan Harte37e4e22014-05-13 19:12:02 -070031import net.onrc.onos.core.intent.MockTopology;
Jonathan Hartaa380972014-04-03 10:24:46 -070032import net.onrc.onos.core.intent.ShortestPathIntent;
Pavlin Radoslavov13669052014-05-13 10:33:39 -070033import net.onrc.onos.core.intent.runtime.web.IntentWebRoutable;
Jonathan Hartdeda0ba2014-04-03 11:14:12 -070034import net.onrc.onos.core.registry.IControllerRegistryService;
Jonathan Hart472062d2014-04-03 10:56:48 -070035import net.onrc.onos.core.topology.DeviceEvent;
Jonathan Harte37e4e22014-05-13 19:12:02 -070036import net.onrc.onos.core.topology.ITopologyListener;
37import net.onrc.onos.core.topology.ITopologyService;
Jonathan Hart472062d2014-04-03 10:56:48 -070038import net.onrc.onos.core.topology.LinkEvent;
39import net.onrc.onos.core.topology.PortEvent;
40import net.onrc.onos.core.topology.SwitchEvent;
Ray Milkey6688cd82014-03-11 16:40:46 -070041
Ray Milkey9d671002014-05-29 17:24:29 -070042import net.onrc.onos.core.topology.Topology;
Jonathan Harta88fd242014-04-03 11:24:54 -070043import org.hamcrest.Description;
44import org.hamcrest.Factory;
45import org.hamcrest.Matcher;
46import org.hamcrest.Matchers;
47import org.hamcrest.TypeSafeMatcher;
Ray Milkey6688cd82014-03-11 16:40:46 -070048import org.junit.After;
49import org.junit.Before;
50import org.junit.Test;
51import org.junit.runner.RunWith;
52import org.powermock.api.easymock.PowerMock;
53import org.powermock.core.classloader.annotations.PrepareForTest;
54import org.powermock.modules.junit4.PowerMockRunner;
55
Ray Milkey6688cd82014-03-11 16:40:46 -070056/**
57 * @author Ray Milkey (ray@onlab.us)
Ray Milkey269ffb92014-04-03 14:43:30 -070058 * <p/>
59 * Unit tests for the Path Calculation Runtime module (PathCalcRuntimeModule).
60 * These test cases check the results of creating paths, deleting paths, and
Jonathan Harte37e4e22014-05-13 19:12:02 -070061 * rerouting paths. The topology, controller registry, and data grid are
Ray Milkey269ffb92014-04-03 14:43:30 -070062 * mocked out. The individual tests check the high level intents and the
63 * resulting operation lists to be sure they match the intended APIs.
Ray Milkey6688cd82014-03-11 16:40:46 -070064 */
65@RunWith(PowerMockRunner.class)
66@PrepareForTest(PathCalcRuntimeModule.class)
67public class PathCalcRuntimeModuleTest {
Ray Milkeydc659c42014-03-28 16:30:42 -070068 private static final Long LOCAL_PORT = 0xFFFEL;
69
Ray Milkey9d671002014-05-29 17:24:29 -070070 private IntentTestMocks mocks;
71 private PathCalcRuntimeModule runtime;
Ray Milkey6688cd82014-03-11 16:40:46 -070072
Ray Milkey6688cd82014-03-11 16:40:46 -070073 @Before
74 public void setUp() throws Exception {
Ray Milkey9d671002014-05-29 17:24:29 -070075 mocks = new IntentTestMocks();
76 mocks.setUpIntentMocks();
Ray Milkey6688cd82014-03-11 16:40:46 -070077
Ray Milkey9d671002014-05-29 17:24:29 -070078 runtime = new PathCalcRuntimeModule();
79 final FloodlightModuleContext moduleContext = mocks.getModuleContext();
80 runtime.init(moduleContext);
81 runtime.startUp(moduleContext);
Ray Milkey6688cd82014-03-11 16:40:46 -070082 }
83
Ray Milkeydc659c42014-03-28 16:30:42 -070084
85 /**
86 * Hamcrest matcher to check that a collection of Intents contains an
87 * Intent with the specified Intent Id.
88 */
89 public static class EntryForIntentMatcher extends TypeSafeMatcher<Collection<Intent>> {
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -070090 private final String id;
Ray Milkeydc659c42014-03-28 16:30:42 -070091
92 public EntryForIntentMatcher(String idValue) {
93 id = idValue;
94 }
95
96 @Override
97 public boolean matchesSafely(Collection<Intent> intents) {
98 assertThat(intents,
Ray Milkey269ffb92014-04-03 14:43:30 -070099 hasItem(Matchers.<Intent>hasProperty("id", equalTo(id))));
Ray Milkeydc659c42014-03-28 16:30:42 -0700100 return true;
101 }
102
103 @Override
104 public void describeTo(Description description) {
105 description.appendText("an intent with id \" ").
106 appendText(id).
107 appendText("\"");
108 }
109 }
110
111
112 /**
113 * Factory method to create an Intent entry Matcher. Returns a matcher
114 * for the Intent with the given id.
Ray Milkey269ffb92014-04-03 14:43:30 -0700115 *
Ray Milkeydc659c42014-03-28 16:30:42 -0700116 * @param id id of the intent to match
117 * @return Matcher object
118 */
119 @Factory
120 public static Matcher<Collection<Intent>> hasIntentWithId(String id) {
121 return new EntryForIntentMatcher(id);
122 }
123
124
125 /**
126 * Matcher to determine if an IntentMap contains an entry with a given id,
127 * and that entry has a given state.
128 */
129 public static class IntentsHaveIntentWithStateMatcher extends TypeSafeMatcher<IntentMap> {
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700130 private final String id;
131 private final IntentState state;
Ray Milkeydc659c42014-03-28 16:30:42 -0700132 private Intent intent;
133
134 public IntentsHaveIntentWithStateMatcher(String idValue,
135 IntentState stateValue) {
136 id = idValue;
137 state = stateValue;
138 }
139
140 @Override
141 public boolean matchesSafely(IntentMap intents) {
142 intent = intents.getIntent(id);
143
144 return intent != null && intent.getState() == state;
145 }
146
147 @Override
148 public void describeTo(Description description) {
149 if (intent == null) {
150 description.appendText("intent lookup for id \"");
151 description.appendText(id);
152 description.appendText("\"");
153 } else {
154 description.appendText("state ");
155 description.appendText(state.toString());
156 }
157 }
158
159 @Override
160 public void describeMismatchSafely(IntentMap intents,
161 Description mismatchDescription) {
162 if (intent != null) {
163 mismatchDescription.appendText("was ").
Ray Milkey269ffb92014-04-03 14:43:30 -0700164 appendText(intent.getState().toString());
Ray Milkeydc659c42014-03-28 16:30:42 -0700165 } else {
166 mismatchDescription.appendText("that intent was not found");
167 }
168 }
169 }
170
171
172 /**
173 * Factory method to create a Matcher for an IntentMap that looks for an
174 * Intent with a given id and state.
175 *
Ray Milkey269ffb92014-04-03 14:43:30 -0700176 * @param id id of the Intent to match
Ray Milkeydc659c42014-03-28 16:30:42 -0700177 * @param state if the Intent is found, its state must match this
178 * @return Matcher object
179 */
180 @Factory
181 public static Matcher<IntentMap> hasIntentWithIdAndState(String id,
182 IntentState state) {
183 return new IntentsHaveIntentWithStateMatcher(id, state);
184 }
185
186
Ray Milkey6688cd82014-03-11 16:40:46 -0700187 @After
188 public void tearDown() {
Ray Milkey9d671002014-05-29 17:24:29 -0700189 mocks.tearDownIntentMocks();
Ray Milkey6688cd82014-03-11 16:40:46 -0700190 }
191
192 /**
193 * Test the result of executing a path calculation on an
194 * Intent Operation List which contains a path that references a
195 * non-existent switch.
Ray Milkey269ffb92014-04-03 14:43:30 -0700196 * <p/>
Ray Milkey6688cd82014-03-11 16:40:46 -0700197 * A 3 path list is created where one of the paths references a switch
198 * that is not in the topology. The test checks that the resulting
199 * Operation List has entries for the 2 correct paths, and that the
200 * high level intents contain a proper error entry for the bad path.
201 */
202 @Test
203 public void testInvalidSwitchName() throws FloodlightModuleException {
Ray Milkey6688cd82014-03-11 16:40:46 -0700204 final String BAD_SWITCH_INTENT_NAME = "No Such Switch Intent";
205
206 // create shortest path intents
207 final IntentOperationList opList = new IntentOperationList();
208 opList.add(Operator.ADD,
209 new ShortestPathIntent(BAD_SWITCH_INTENT_NAME, 111L, 12L,
210 LOCAL_PORT, 2L, 21L, LOCAL_PORT));
211 opList.add(Operator.ADD,
212 new ShortestPathIntent("2", 1L, 14L, LOCAL_PORT, 4L, 41L,
213 LOCAL_PORT));
214 opList.add(Operator.ADD,
215 new ShortestPathIntent("3", 2L, 23L, LOCAL_PORT, 3L, 32L,
216 LOCAL_PORT));
217
218 // compile high-level intent operations into low-level intent
219 // operations (calculate paths)
Ray Milkey6688cd82014-03-11 16:40:46 -0700220 final IntentOperationList pathIntentOpList =
221 runtime.executeIntentOperations(opList);
222 assertThat(pathIntentOpList, notNullValue());
223
224 final IntentMap highLevelIntents = runtime.getHighLevelIntents();
225 assertThat(highLevelIntents, notNullValue());
226
227 final Collection<Intent> allIntents = highLevelIntents.getAllIntents();
228 assertThat(allIntents, notNullValue());
229
230 // One intent had an error and should not create a path list entry
231 assertThat(pathIntentOpList, hasSize(opList.size() - 1));
232
233 // Should be a high level intent for each operation
Ray Milkeydc659c42014-03-28 16:30:42 -0700234 assertThat(allIntents, hasSize(opList.size()));
Ray Milkey6688cd82014-03-11 16:40:46 -0700235
236 // Check that we got a high level intent for each operation
Ray Milkeydc659c42014-03-28 16:30:42 -0700237 assertThat(allIntents, hasIntentWithId("3"));
238 assertThat(allIntents, hasIntentWithId("2"));
239 assertThat(allIntents, hasIntentWithId(BAD_SWITCH_INTENT_NAME));
Ray Milkey6688cd82014-03-11 16:40:46 -0700240
241 // Check that the non existent switch was NACKed
Ray Milkeydc659c42014-03-28 16:30:42 -0700242 assertThat(highLevelIntents, hasIntentWithIdAndState(BAD_SWITCH_INTENT_NAME, IntentState.INST_NACK));
Ray Milkey6688cd82014-03-11 16:40:46 -0700243
244 // Check that switch 2 was correctly processed
Ray Milkeydc659c42014-03-28 16:30:42 -0700245 assertThat(highLevelIntents, hasIntentWithIdAndState("2", IntentState.INST_REQ));
Ray Milkey6688cd82014-03-11 16:40:46 -0700246
247 // Check that switch 3 was correctly processed
Ray Milkeydc659c42014-03-28 16:30:42 -0700248 assertThat(highLevelIntents, hasIntentWithIdAndState("3", IntentState.INST_REQ));
249
250 }
251
252
253 /**
254 * Test the result of executing a path calculation on an
255 * Intent Operation List and then removing one of the switches.
Ray Milkey269ffb92014-04-03 14:43:30 -0700256 * <p/>
Ray Milkeydc659c42014-03-28 16:30:42 -0700257 * A 3 path list is created and then one of the paths is removed.
258 * The test checks that the resulting Operation List is correct,
259 * and that the high level intents contain a proper "delete requested"
260 * entry for the deleted path.
261 */
262 @Test
263 public void testIntentRemoval() throws FloodlightModuleException {
264
265 // create shortest path intents
266 final IntentOperationList opList = new IntentOperationList();
267 opList.add(Operator.ADD,
268 new ShortestPathIntent("1", 1L, 12L, LOCAL_PORT, 2L, 21L,
Ray Milkey269ffb92014-04-03 14:43:30 -0700269 LOCAL_PORT));
Ray Milkeydc659c42014-03-28 16:30:42 -0700270 opList.add(Operator.ADD,
271 new ShortestPathIntent("2", 1L, 14L, LOCAL_PORT, 4L, 41L,
Ray Milkey269ffb92014-04-03 14:43:30 -0700272 LOCAL_PORT));
Ray Milkeydc659c42014-03-28 16:30:42 -0700273 opList.add(Operator.ADD,
274 new ShortestPathIntent("3", 2L, 23L, LOCAL_PORT, 3L, 32L,
Ray Milkey269ffb92014-04-03 14:43:30 -0700275 LOCAL_PORT));
Ray Milkeydc659c42014-03-28 16:30:42 -0700276
277 // compile high-level intent operations into low-level intent
278 // operations (calculate paths)
Ray Milkeydc659c42014-03-28 16:30:42 -0700279 final IntentOperationList pathIntentOpList =
280 runtime.executeIntentOperations(opList);
281 assertThat(pathIntentOpList, notNullValue());
282
283 final IntentMap highLevelIntents = runtime.getHighLevelIntents();
284 assertThat(highLevelIntents, notNullValue());
285
286 final Collection<Intent> allIntents = highLevelIntents.getAllIntents();
287 assertThat(allIntents, notNullValue());
288
289 // Should be one operation per path
290 assertThat(pathIntentOpList, hasSize(opList.size()));
291
292 // Should be a high level intent for each operation
293 assertThat(allIntents, hasSize(opList.size()));
294
295 // Check that we got a high level intent for each operation
296 assertThat(allIntents, hasIntentWithId("3"));
297 assertThat(allIntents, hasIntentWithId("2"));
298 assertThat(allIntents, hasIntentWithId("1"));
299
300 // Check that switch 1 was correctly processed
301 assertThat(highLevelIntents,
Ray Milkey269ffb92014-04-03 14:43:30 -0700302 hasIntentWithIdAndState("1", IntentState.INST_REQ));
Ray Milkeydc659c42014-03-28 16:30:42 -0700303
304 // Check that switch 2 was correctly processed
305 assertThat(highLevelIntents,
Ray Milkey269ffb92014-04-03 14:43:30 -0700306 hasIntentWithIdAndState("2", IntentState.INST_REQ));
Ray Milkeydc659c42014-03-28 16:30:42 -0700307
308 // Check that switch 3 was correctly processed
309 assertThat(highLevelIntents,
Ray Milkey269ffb92014-04-03 14:43:30 -0700310 hasIntentWithIdAndState("3", IntentState.INST_REQ));
Ray Milkeydc659c42014-03-28 16:30:42 -0700311
312 // Now delete one path and check the results
313 final IntentOperationList opListForRemoval = new IntentOperationList();
314 opListForRemoval.add(Operator.REMOVE,
315 new ShortestPathIntent("1", 1L, 12L, LOCAL_PORT, 2L, 21L,
316 LOCAL_PORT));
317
318 final IntentOperationList pathIntentOpListAfterRemoval =
319 runtime.executeIntentOperations(opListForRemoval);
320 assertThat(pathIntentOpListAfterRemoval, notNullValue());
321 assertThat(pathIntentOpListAfterRemoval, hasSize(1));
322
323 // Check the high level intents.
324 final IntentMap highLevelIntentsAfterRemoval = runtime.getHighLevelIntents();
325 assertThat(highLevelIntentsAfterRemoval, notNullValue());
326
327 final Collection<Intent> allIntentsAfterRemoval = highLevelIntentsAfterRemoval.getAllIntents();
328 assertThat(allIntentsAfterRemoval, notNullValue());
329 assertThat(allIntentsAfterRemoval, hasSize(3));
330
331 // Check that we got a high level intent for each operation
332 assertThat(allIntentsAfterRemoval, hasIntentWithId("3"));
333 assertThat(allIntentsAfterRemoval, hasIntentWithId("2"));
334 assertThat(allIntentsAfterRemoval, hasIntentWithId("1"));
335
336 // Check the states of the high level intents
337 // Check that switch 1 was correctly processed
338 assertThat(highLevelIntents,
339 hasIntentWithIdAndState("1", IntentState.DEL_REQ));
340
341 // Check that switch 2 was correctly processed
342 assertThat(highLevelIntents,
343 hasIntentWithIdAndState("2", IntentState.INST_REQ));
344
345 // Check that switch 3 was correctly processed
346 assertThat(highLevelIntents,
347 hasIntentWithIdAndState("3", IntentState.INST_REQ));
348 }
349
350 /**
351 * Test the result of executing a path calculation on an
352 * Intent Operation List and then forcing a reroute.
Ray Milkey269ffb92014-04-03 14:43:30 -0700353 * <p/>
Ray Milkeydc659c42014-03-28 16:30:42 -0700354 * A 3 path list is created and then one of the links is removed.
355 * The test checks that the resulting Operation List is correct,
356 * and that the high level intents contain a proper "reroute requested"
357 * entry for the deleted link.
358 */
359 @Test
360 public void testIntentReroute() throws FloodlightModuleException {
361
362 // create shortest path intents
363 final IntentOperationList opList = new IntentOperationList();
364 final ShortestPathIntent pathIntent1 =
365 new ShortestPathIntent("1", 1L, 12L, LOCAL_PORT, 2L, 21L,
Ray Milkey269ffb92014-04-03 14:43:30 -0700366 LOCAL_PORT);
Ray Milkeydc659c42014-03-28 16:30:42 -0700367
368 opList.add(Operator.ADD, pathIntent1);
369 opList.add(Operator.ADD,
370 new ShortestPathIntent("2", 1L, 14L, LOCAL_PORT, 4L, 41L,
Ray Milkey269ffb92014-04-03 14:43:30 -0700371 LOCAL_PORT));
Ray Milkeydc659c42014-03-28 16:30:42 -0700372 opList.add(Operator.ADD,
373 new ShortestPathIntent("3", 2L, 23L, LOCAL_PORT, 3L, 32L,
Ray Milkey269ffb92014-04-03 14:43:30 -0700374 LOCAL_PORT));
Ray Milkeydc659c42014-03-28 16:30:42 -0700375
376 // compile high-level intent operations into low-level intent
377 // operations (calculate paths)
Ray Milkeydc659c42014-03-28 16:30:42 -0700378 final IntentOperationList pathIntentOpList =
379 runtime.executeIntentOperations(opList);
380 assertThat(pathIntentOpList, notNullValue());
381
382 final IntentMap highLevelIntents = runtime.getHighLevelIntents();
383 assertThat(highLevelIntents, notNullValue());
384
385 final Collection<Intent> allIntents = highLevelIntents.getAllIntents();
386 assertThat(allIntents, notNullValue());
387
388 // Should be one operation per path
389 assertThat(pathIntentOpList, hasSize(opList.size()));
390
391 // Should be a high level intent for each operation
392 assertThat(allIntents, hasSize(opList.size()));
393
394 // Check that we got a high level intent for each operation
395 assertThat(allIntents, hasIntentWithId("3"));
396 assertThat(allIntents, hasIntentWithId("2"));
397 assertThat(allIntents, hasIntentWithId("1"));
398
399 // Check that switch 1 was correctly processed
400 assertThat(highLevelIntents,
Ray Milkey269ffb92014-04-03 14:43:30 -0700401 hasIntentWithIdAndState("1", IntentState.INST_REQ));
Ray Milkeydc659c42014-03-28 16:30:42 -0700402
403 // Check that switch 2 was correctly processed
404 assertThat(highLevelIntents,
Ray Milkey269ffb92014-04-03 14:43:30 -0700405 hasIntentWithIdAndState("2", IntentState.INST_REQ));
Ray Milkeydc659c42014-03-28 16:30:42 -0700406
407 // Check that switch 3 was correctly processed
408 assertThat(highLevelIntents,
Ray Milkey269ffb92014-04-03 14:43:30 -0700409 hasIntentWithIdAndState("3", IntentState.INST_REQ));
Ray Milkeydc659c42014-03-28 16:30:42 -0700410
411 // Now add a different path to one of the switches path and check
412 // the results
413 IntentStateList states = new IntentStateList();
414 states.put("1", IntentState.INST_ACK);
415 states.put("2", IntentState.INST_ACK);
416 states.put("3", IntentState.INST_ACK);
417 runtime.getHighLevelIntents().changeStates(states);
418 states.clear();
419 states.put("1___0", IntentState.INST_ACK);
420 states.put("2___0", IntentState.INST_ACK);
421 states.put("3___0", IntentState.INST_ACK);
422 runtime.getPathIntents().changeStates(states);
423
424 final List<SwitchEvent> emptySwitchEvents = new LinkedList<>();
425 final List<PortEvent> emptyPortEvents = new LinkedList<>();
426 final List<DeviceEvent> emptyDeviceEvents = new LinkedList<>();
427 final List<LinkEvent> addedLinkEvents = new LinkedList<>();
428 final List<LinkEvent> removedLinkEvents = new LinkedList<>();
429
Ray Milkey9d671002014-05-29 17:24:29 -0700430 final MockTopology topology = mocks.getTopology();
Jonathan Harte37e4e22014-05-13 19:12:02 -0700431 topology.removeLink(1L, 12L, 2L, 21L); // This link is used by the intent "1"
432 topology.removeLink(2L, 21L, 1L, 12L);
Ray Milkeydc659c42014-03-28 16:30:42 -0700433 LinkEvent linkEvent1 = new LinkEvent(1L, 12L, 2L, 21L);
434 LinkEvent linkEvent2 = new LinkEvent(2L, 21L, 1L, 12L);
435 removedLinkEvents.add(linkEvent1);
436 removedLinkEvents.add(linkEvent2);
Jonathan Harte37e4e22014-05-13 19:12:02 -0700437 runtime.topologyEvents(
Ray Milkeydc659c42014-03-28 16:30:42 -0700438 emptySwitchEvents,
439 emptySwitchEvents,
440 emptyPortEvents,
441 emptyPortEvents,
442 addedLinkEvents,
443 removedLinkEvents,
444 emptyDeviceEvents,
445 emptyDeviceEvents);
446 final IntentOperationList opListForReroute = new IntentOperationList();
447 opListForReroute.add(Operator.ADD, pathIntent1);
448
449 final IntentOperationList pathIntentOpListAfterReroute =
450 runtime.executeIntentOperations(opListForReroute);
451 assertThat(pathIntentOpListAfterReroute, notNullValue());
452 assertThat(pathIntentOpListAfterReroute, hasSize(2));
453
454 // Check the high level intents.
455 final IntentMap highLevelIntentsAfterReroute = runtime.getHighLevelIntents();
456 assertThat(highLevelIntentsAfterReroute, notNullValue());
457
458 final Collection<Intent> allIntentsAfterReroute = highLevelIntentsAfterReroute.getAllIntents();
459 assertThat(allIntentsAfterReroute, notNullValue());
460 assertThat(allIntentsAfterReroute, hasSize(3));
461
462 // Check that we got a high level intent for each operation
463 assertThat(allIntentsAfterReroute, hasIntentWithId("3"));
464 assertThat(allIntentsAfterReroute, hasIntentWithId("2"));
465 assertThat(allIntentsAfterReroute, hasIntentWithId("1"));
466
467 // Check the states of the high level intents
468 // Check that switch 1 was correctly processed
469 assertThat(highLevelIntents,
470 hasIntentWithIdAndState("1", IntentState.REROUTE_REQ));
471
472 // Check that switch 2 was correctly processed
473 assertThat(highLevelIntents,
474 hasIntentWithIdAndState("2", IntentState.INST_ACK));
475
476 // Check that switch 3 was correctly processed
477 assertThat(highLevelIntents,
478 hasIntentWithIdAndState("3", IntentState.INST_ACK));
479
Ray Milkey6688cd82014-03-11 16:40:46 -0700480
481 }
482
483
484}