blob: bfb1c0bec3a7f902d4fd72731b96e16a8a41b877 [file] [log] [blame]
Carolina Fernandezad893432016-07-18 11:11:34 +02001/*
2 * Copyright 2016-present 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 */
16
17package org.onosproject.sdxl2;
18
19import org.junit.After;
20import org.junit.Before;
21import org.junit.Test;
22import org.onlab.packet.VlanId;
23import org.onosproject.TestApplicationId;
24import org.onosproject.core.ApplicationId;
25import org.onosproject.net.ConnectPoint;
Carolina Fernandezad893432016-07-18 11:11:34 +020026import org.onosproject.net.flow.TrafficSelector;
27import org.onosproject.net.flow.TrafficTreatment;
28import org.onosproject.net.intent.AbstractIntentTest;
29import org.onosproject.net.intent.Constraint;
30import org.onosproject.net.intent.Intent;
31import org.onosproject.net.intent.IntentUtils;
32import org.onosproject.net.intent.Key;
33import org.onosproject.net.intent.PointToPointIntent;
Carolina Fernandezad893432016-07-18 11:11:34 +020034
35import java.util.ArrayList;
36import java.util.Arrays;
37import java.util.Collections;
38import java.util.Iterator;
Carolina Fernandezad893432016-07-18 11:11:34 +020039import java.util.List;
40import java.util.Optional;
41
42import static java.lang.String.format;
43import static org.junit.Assert.assertEquals;
44import static org.junit.Assert.assertTrue;
45
46/**
47 * Unit tests for SdxL2VlanVCManager.
48 */
49public class SdxL2VlanVCManagerTest extends AbstractIntentTest {
50
51 private static final String SDXL2_2 = "sdxl2_test2";
52 private static final String CP1 = "of:00000000000001/1";
53 private static final String CP2 = "of:00000000000002/1";
54 private static final String CP5 = "of:00000000000002/4";
55 private static final String CP6 = "of:00000000000004/4";
56 private static final String CP7 = "of:0000000000000a/4";
57 private static final String CP8 = "of:00000000000009/4";
58 private static final String CP9 = "of:0000000000000a/4";
59 private static final String CP10 = "of:00000000000009/4";
60 private static final String VLANS1 = "2,3,4";
Carolina Fernandezad893432016-07-18 11:11:34 +020061 private static final String VLANS2 = "4,5,6";
Carolina Fernandezad893432016-07-18 11:11:34 +020062 private static final String VLANS5 = "100";
63 private static final String VLANS6 = "1";
64 private static final String VLANS7 = "1";
65 private static final String VLANS8 = "111";
66 private static final String VLANS9 = "1";
67 private static final String VLANS10 = "1";
68 private static final String NAME_FORMAT = "%s:%s-%s";
69 private static final String KEY_FORMAT = "%s,%s";
70 private static final ApplicationId APPID = TestApplicationId.create("foo");
Carolina Fernandezad893432016-07-18 11:11:34 +020071 private SdxL2VlanVCManager manager;
72 private List<PointToPointIntent> intentList;
73
74 /**
Carolina Fernandezb31adee2016-08-31 11:29:38 +020075 * Prepares environment before starting testing.
76 *
77 * @throws Exception when set-up fails
Carolina Fernandezad893432016-07-18 11:11:34 +020078 */
Yuta HIGUCHIc9fae9f2017-01-31 15:21:51 -080079 @Override
Carolina Fernandezad893432016-07-18 11:11:34 +020080 @Before
81 public void setUp() throws Exception {
82 super.setUp();
83 SdxL2DistributedStore store = new SdxL2DistributedStore();
84 store.initForTest();
85 manager = new SdxL2VlanVCManager(
86 APPID, store, new IntentServiceTest());
87 intentList = setIntents();
88 }
89
90 /**
Carolina Fernandezb31adee2016-08-31 11:29:38 +020091 * Cleans up environment after finishing testing.
Carolina Fernandezad893432016-07-18 11:11:34 +020092 */
Yuta HIGUCHIc9fae9f2017-01-31 15:21:51 -080093 @Override
Carolina Fernandezad893432016-07-18 11:11:34 +020094 @After
95 public void tearDown() {
96 super.tearDown();
97 }
98
Carolina Fernandezb31adee2016-08-31 11:29:38 +020099 /**
100 * Defines the intents to be used when testing the VC.
101 *
102 * @return List of point-to-point intents
103 */
104 private List<PointToPointIntent> setIntents() {
105 List<PointToPointIntent> intents = new ArrayList<>();
106 intents.addAll(setupConnectionPoints1To2());
107 intents.addAll(setupConnectionPoints5To6());
108 intents.addAll(setupConnectionPoints7To8());
109 intents.addAll(setupConnectionPoints9To10());
Carolina Fernandezad893432016-07-18 11:11:34 +0200110 return intents;
111 }
112
Carolina Fernandezb31adee2016-08-31 11:29:38 +0200113 /**
114 * Returns the traffic treatment, used in the definition of the intents.
115 *
116 * @param setVlan VLAN to set
117 * @param pushVlan VLAN to push
118 * @param popVlan boolean to indicate whether a popVlan action is
119 * performed (true) or not (false)
120 * @return TrafficTreatment object
121 */
Carolina Fernandezad893432016-07-18 11:11:34 +0200122 private TrafficTreatment buildTreatment(VlanId setVlan,
123 VlanId pushVlan,
124 boolean popVlan) {
Carolina Fernandezb31adee2016-08-31 11:29:38 +0200125 return manager.buildTreatment(setVlan, pushVlan, popVlan);
Carolina Fernandezad893432016-07-18 11:11:34 +0200126 }
127
Carolina Fernandezb31adee2016-08-31 11:29:38 +0200128 /**
129 * Returns the traffic selector, used in the definition of the intents.
130 *
131 * @param ethertype name of the Ethernet type used (e.g. of SDX-L2
132 * @param ingresstag VLAN id used at the ingress
133 * @return TrafficSelector object
134 */
Carolina Fernandezad893432016-07-18 11:11:34 +0200135 private TrafficSelector buildSelector(Short ethertype,
136 VlanId ingresstag) {
Carolina Fernandezb31adee2016-08-31 11:29:38 +0200137 return manager.buildSelector(ethertype, ingresstag);
Carolina Fernandezad893432016-07-18 11:11:34 +0200138 }
139
Carolina Fernandezb31adee2016-08-31 11:29:38 +0200140 /**
141 * Returns constraints depending on the encapsulation used on the VC.
142 *
143 * @return list of constraints to be used in the intents
144 */
145 private List<Constraint> buildConstraints() {
146 return manager.buildConstraints();
Carolina Fernandezad893432016-07-18 11:11:34 +0200147 }
148
Carolina Fernandezb31adee2016-08-31 11:29:38 +0200149 /**
150 * Returns Intent key from SDX-L2 and two SDX-L2 Connection Points.
151 *
152 * @param sdxl2 name of SDX-L2
153 * @param cpOne sdxl2 connection point one
154 * @param cpTwo sdxl2 connection point two
155 * @param index digit used to help identify Intent
156 * @return canonical intent string key
157 */
158 private Key generateIntentKey(String sdxl2, SdxL2ConnectionPoint cpOne, SdxL2ConnectionPoint cpTwo, String index) {
159 return manager.generateIntentKey(sdxl2, cpOne, cpTwo, index);
Carolina Fernandezad893432016-07-18 11:11:34 +0200160 }
161
Carolina Fernandezb31adee2016-08-31 11:29:38 +0200162 /**
163 * Ensures that when adding a VC its related intents are inserted.
164 */
Carolina Fernandezad893432016-07-18 11:11:34 +0200165 @Test
166 public void testConnectionSetup() {
167 Iterator<SdxL2ConnectionPoint> lhs = setupLhsCPs().iterator();
168 Iterator<SdxL2ConnectionPoint> rhs = setupRhsCPs().iterator();
169 while (lhs.hasNext() && rhs.hasNext()) {
170 manager.addVC(SDXL2_2, lhs.next(), rhs.next());
171 }
172
173 assertEquals(intentList.size(), manager.intentService.getIntentCount());
174
175 for (Intent emulatedIntent : intentList) {
176 boolean found = false;
177 for (Intent realIntent : manager.intentService.getIntents()) {
178 if (emulatedIntent.key().equals(realIntent.key())) {
179 found = true;
180 assertTrue(format("Comparing %s and %s", emulatedIntent, realIntent),
181 IntentUtils.intentsAreEqual(emulatedIntent, realIntent));
182 break;
183 }
184 }
185 assertTrue(found);
186 }
187 }
188
Carolina Fernandezb31adee2016-08-31 11:29:38 +0200189 /**
190 * Defines the left-hand side endpoints, each with a specific VLAN.
191 *
192 * @return list of SdxL2ConnectionPoint objects
193 */
194 private List<SdxL2ConnectionPoint> setupLhsCPs() {
195 List<SdxL2ConnectionPoint> cps = new ArrayList<>();
Carolina Fernandezad893432016-07-18 11:11:34 +0200196 SdxL2ConnectionPoint cpone = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1);
197 cps.add(cpone);
198 SdxL2ConnectionPoint cpfive = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST5", CP5, VLANS5);
199 cps.add(cpfive);
200 SdxL2ConnectionPoint cpseven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST7", CP7, VLANS7);
201 cps.add(cpseven);
202 SdxL2ConnectionPoint cpnine = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST9", CP9, VLANS9);
203 cps.add(cpnine);
204 return cps;
205 }
206
Carolina Fernandezb31adee2016-08-31 11:29:38 +0200207 /**
208 * Defines the right-hand side endpoints, each with a specific VLAN.
209 *
210 * @return list of SdxL2ConnectionPoint objects
211 */
212 private List<SdxL2ConnectionPoint> setupRhsCPs() {
213 List<SdxL2ConnectionPoint> cps = new ArrayList<>();
Carolina Fernandezad893432016-07-18 11:11:34 +0200214 SdxL2ConnectionPoint cptwo = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST2", CP2, VLANS2);
215 cps.add(cptwo);
216 SdxL2ConnectionPoint cpsix = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST6", CP6, VLANS6);
217 cps.add(cpsix);
218 SdxL2ConnectionPoint cpeight = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST8", CP8, VLANS8);
219 cps.add(cpeight);
220 SdxL2ConnectionPoint cpten = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST10", CP10, VLANS10);
221 cps.add(cpten);
222 return cps;
223 }
224
Carolina Fernandezb31adee2016-08-31 11:29:38 +0200225 /**
226 * Creates the intents from the information of couple of endpoints.
227 *
228 * @param keyIndex identifier of the intent
229 * @param lhs left-hand side Connection Point
230 * @param lhsID DPID of the left-hand side CP
231 * @param lhsVlan VLAN of the left-hand side CP
232 * @param lhsBuiltTreatment specific treatment for the left-hand side CP
233 * @param rhs right-hand side Connection Point
234 * @param rhsID DPID of the right-hand side CP
235 * @param rhsVlan VLAN of the right-hand side CP
236 * @param rhsBuiltTreatment specific treatment for the right-hand side CP
237 * @return List of point-to-point intents
238 */
239 private List<PointToPointIntent> setupConnectionPoints(String keyIndex,
240 SdxL2ConnectionPoint lhs, String lhsID,
241 String lhsVlan,
242 TrafficTreatment lhsBuiltTreatment,
243 SdxL2ConnectionPoint rhs, String rhsID,
244 String rhsVlan,
245 TrafficTreatment rhsBuiltTreatment) {
246 List<PointToPointIntent> intents = new ArrayList<>();
247 VlanId lhsVlanValue = null, rhsVlanValue = null;
248 if (lhsVlan != null) {
249 lhsVlanValue = VlanId.vlanId(Short.parseShort(lhsVlan));
250 }
251 if (rhsVlan != null) {
252 rhsVlanValue = VlanId.vlanId(Short.parseShort(rhsVlan));
253 }
Carolina Fernandezad893432016-07-18 11:11:34 +0200254
Carolina Fernandezb31adee2016-08-31 11:29:38 +0200255 intents.add(PointToPointIntent.builder()
256 .appId(APPID)
257 .key(generateIntentKey(SDXL2_2, lhs, rhs, keyIndex))
258 .selector(buildSelector(null, lhsVlanValue))
259 .treatment(lhsBuiltTreatment)
260 .constraints(buildConstraints())
261 .ingressPoint(ConnectPoint.deviceConnectPoint(lhsID))
262 .egressPoint(ConnectPoint.deviceConnectPoint(rhsID))
263 .priority(2000)
264 .build());
265 intents.add(PointToPointIntent.builder()
266 .appId(APPID)
267 .key(generateIntentKey(SDXL2_2, rhs, lhs, keyIndex))
268 .selector(buildSelector(null, rhsVlanValue))
269 .treatment(rhsBuiltTreatment)
270 .constraints(buildConstraints())
271 .ingressPoint(ConnectPoint.deviceConnectPoint(rhsID))
272 .egressPoint(ConnectPoint.deviceConnectPoint(lhsID))
273 .priority(2000)
274 .build());
275 return intents;
276 }
277
278 /**
279 * Defines three pairs of Connection Points, each with a specific VLAN.
280 * The intents are created aftewards, from this input.
281 *
282 * @return list of point-to-point intents
283 */
284 private List<PointToPointIntent> setupConnectionPoints1To2() {
285 List<PointToPointIntent> intents = new ArrayList<>();
286 String lhsID = CP1;
287 ArrayList<String> lhsVlan = new ArrayList<>(Arrays.asList(VLANS1.split(",")));
288 String rhsID = CP2;
289 ArrayList<String> rhsVlan = new ArrayList<>(Arrays.asList(VLANS2.split(",")));
290 SdxL2ConnectionPoint lhs = SdxL2ConnectionPoint.sdxl2ConnectionPoint(
291 "TEST1", lhsID, VLANS1);
292 SdxL2ConnectionPoint rhs = SdxL2ConnectionPoint.sdxl2ConnectionPoint(
293 "TEST2", rhsID, VLANS2);
294 TrafficTreatment lhsBuiltTreatment, rhsBuiltTreatment;
295
296 for (int i = 0; i < 3; i++) {
297 lhsBuiltTreatment = buildTreatment(VlanId.vlanId(rhsVlan.get(i)), null, false);
298 rhsBuiltTreatment = buildTreatment(VlanId.vlanId(lhsVlan.get(i)), null, false);
299 intents.addAll(setupConnectionPoints(Integer.toString(i + 1),
300 lhs, lhsID, lhsVlan.get(i), lhsBuiltTreatment,
301 rhs, rhsID, rhsVlan.get(i), rhsBuiltTreatment));
302 }
303 return intents;
304 }
305
306 /**
307 * Defines a couple of Connection Points, each with a specific VLAN.
308 * The intents are created aftewards, from this input.
309 *
310 * @return list of point-to-point intents
311 */
312 private List<PointToPointIntent> setupConnectionPoints5To6() {
313 String lhsID = CP5;
314 String lhsVlan = VLANS5;
315 SdxL2ConnectionPoint lhs = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST5", lhsID, lhsVlan);
316 String rhsID = CP6;
317 String rhsVlan = VLANS6;
318 SdxL2ConnectionPoint rhs = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST6", rhsID, rhsVlan);
319 TrafficTreatment lhsBuiltTreatment = buildTreatment(null, null, true);
320 TrafficTreatment rhsBuiltTreatment = buildTreatment(null, VlanId.vlanId(Short.parseShort(lhsVlan)), false);
321 return setupConnectionPoints("1", lhs, lhsID, lhsVlan, lhsBuiltTreatment,
322 rhs, rhsID, null, rhsBuiltTreatment);
323 }
324
325 /**
326 * Defines a couple of Connection Points, each with a specific VLAN.
327 * The intents are created aftewards, from this input.
328 *
329 * @return list of point-to-point intents
330 */
331 private List<PointToPointIntent> setupConnectionPoints7To8() {
332 String lhsID = CP7;
333 String lhsVlan = VLANS7;
334 SdxL2ConnectionPoint lhs = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST7", lhsID, lhsVlan);
335 String rhsID = CP8;
336 String rhsVlan = VLANS8;
337 SdxL2ConnectionPoint rhs = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST8", rhsID, rhsVlan);
338 TrafficTreatment lhsBuiltTreatment = buildTreatment(null, VlanId.vlanId(Short.parseShort(rhsVlan)), false);
339 TrafficTreatment rhsBuiltTreatment = buildTreatment(null, null, true);
340 return setupConnectionPoints("1", lhs, lhsID, null, lhsBuiltTreatment,
341 rhs, rhsID, rhsVlan, rhsBuiltTreatment);
342 }
343
344 /**
345 * Defines a couple of Connection Points, each with a specific VLAN.
346 * The intents are created aftewards, from this input.
347 *
348 * @return list of point-to-point intents
349 */
350 private List<PointToPointIntent> setupConnectionPoints9To10() {
351 String lhsID = CP9;
352 String lhsVlan = VLANS9;
353 SdxL2ConnectionPoint lhs = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST9", lhsID, lhsVlan);
354 String rhsID = CP10;
355 String rhsVlan = VLANS10;
356 SdxL2ConnectionPoint rhs = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST10", rhsID, rhsVlan);
357 TrafficTreatment nullTreatment = buildTreatment(null, null, false);
358 return setupConnectionPoints("1", lhs, lhsID, null, nullTreatment,
359 rhs, rhsID, null, nullTreatment);
360 }
361
362 /**
363 * Ensures that when removing a VC its related intents are deleted.
364 */
Carolina Fernandezad893432016-07-18 11:11:34 +0200365 @Test
Carolina Fernandezb31adee2016-08-31 11:29:38 +0200366 public void removeVCAndIntents() {
Carolina Fernandezad893432016-07-18 11:11:34 +0200367 testConnectionSetup();
368
Carolina Fernandezb31adee2016-08-31 11:29:38 +0200369 List<PointToPointIntent> removedIntents = new ArrayList<>();
Carolina Fernandezad893432016-07-18 11:11:34 +0200370 SdxL2ConnectionPoint cpone = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1);
371 SdxL2ConnectionPoint cptwo = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST2", CP2, VLANS2);
Carolina Fernandezb31adee2016-08-31 11:29:38 +0200372 removedIntents.addAll(setupConnectionPoints1To2());
Carolina Fernandezad893432016-07-18 11:11:34 +0200373
374 SdxL2ConnectionPoint cpfive = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST5", CP5, VLANS5);
375 SdxL2ConnectionPoint cpsix = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST6", CP6, VLANS6);
Carolina Fernandezb31adee2016-08-31 11:29:38 +0200376 removedIntents.addAll(setupConnectionPoints5To6());
Carolina Fernandezad893432016-07-18 11:11:34 +0200377
378 SdxL2ConnectionPoint cpseven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST7", CP7, VLANS7);
379 SdxL2ConnectionPoint cpeight = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST8", CP8, VLANS8);
Carolina Fernandezb31adee2016-08-31 11:29:38 +0200380 removedIntents.addAll(setupConnectionPoints7To8());
Carolina Fernandezad893432016-07-18 11:11:34 +0200381
382 manager.removeVC(cpone, cptwo);
383 manager.removeVC(cpfive, cpsix);
384 manager.removeVC(cpseven, cpeight);
385
386 assertEquals(2, manager.intentService.getIntentCount());
387
388 for (Intent removedIntent : removedIntents) {
389 boolean found = false;
390 for (Intent existingIntent : manager.intentService.getIntents()) {
391 if (removedIntent.key().equals(existingIntent.key())) {
392 found = true;
393 assertTrue(format("Intent %s equal %s", removedIntent, existingIntent),
394 !IntentUtils.intentsAreEqual(removedIntent, existingIntent));
395 break;
396 }
397 }
398 assertTrue(!found);
399 }
Carolina Fernandezad893432016-07-18 11:11:34 +0200400 }
401
Carolina Fernandezb31adee2016-08-31 11:29:38 +0200402 /**
403 * Ensures that when removing a CP its related VCs and intents are also deleted.
404 */
Carolina Fernandezad893432016-07-18 11:11:34 +0200405 @Test
406 public void testRemoveVCbyCP() {
407 testConnectionSetup();
408
Carolina Fernandezb31adee2016-08-31 11:29:38 +0200409 List<PointToPointIntent> removedIntents = new ArrayList<>();
Carolina Fernandezad893432016-07-18 11:11:34 +0200410 SdxL2ConnectionPoint cpone = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1);
Carolina Fernandezb31adee2016-08-31 11:29:38 +0200411 removedIntents.addAll(setupConnectionPoints1To2());
Carolina Fernandezad893432016-07-18 11:11:34 +0200412 SdxL2ConnectionPoint cpsix = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST6", CP6, VLANS6);
Carolina Fernandezb31adee2016-08-31 11:29:38 +0200413 removedIntents.addAll(setupConnectionPoints5To6());
Carolina Fernandezad893432016-07-18 11:11:34 +0200414 SdxL2ConnectionPoint cpseven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST7", CP7, VLANS7);
Carolina Fernandezb31adee2016-08-31 11:29:38 +0200415 removedIntents.addAll(setupConnectionPoints7To8());
Carolina Fernandezad893432016-07-18 11:11:34 +0200416 SdxL2ConnectionPoint cpten = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST10", CP10, VLANS10);
Carolina Fernandezb31adee2016-08-31 11:29:38 +0200417 removedIntents.addAll(setupConnectionPoints9To10());
Carolina Fernandezad893432016-07-18 11:11:34 +0200418
419 manager.removeVC(cpone);
420 manager.removeVC(cpsix);
421 manager.removeVC(cpseven);
422 manager.removeVC(cpten);
423
Carolina Fernandezb31adee2016-08-31 11:29:38 +0200424 assertEquals(Collections.emptySet(), manager.getVCs(Optional.empty()));
Carolina Fernandezad893432016-07-18 11:11:34 +0200425
426 assertEquals(0, manager.intentService.getIntentCount());
427
428 for (Intent removedIntent : removedIntents) {
429 boolean found = false;
430 for (Intent existingIntent : manager.intentService.getIntents()) {
431 if (removedIntent.key().equals(existingIntent.key())) {
432 found = true;
433 assertTrue(format("Intent %s equal %s", removedIntent, existingIntent),
434 !IntentUtils.intentsAreEqual(removedIntent, existingIntent));
435 break;
436 }
437 }
438 assertTrue(!found);
439 }
Carolina Fernandezad893432016-07-18 11:11:34 +0200440 }
441
Carolina Fernandezb31adee2016-08-31 11:29:38 +0200442 /**
443 * Ensures that when removing a SDX its related VCs and intents are also deleted.
444 */
Carolina Fernandezad893432016-07-18 11:11:34 +0200445 @Test
446 public void testremoveVCbySdx() {
447 testConnectionSetup();
448
Carolina Fernandezb31adee2016-08-31 11:29:38 +0200449 List<PointToPointIntent> removedIntents = new ArrayList<>();
450 removedIntents.addAll(setupConnectionPoints1To2());
451 removedIntents.addAll(setupConnectionPoints5To6());
452 removedIntents.addAll(setupConnectionPoints7To8());
453 removedIntents.addAll(setupConnectionPoints9To10());
Carolina Fernandezad893432016-07-18 11:11:34 +0200454
455 manager.removeVCs(SDXL2_2);
Carolina Fernandezb31adee2016-08-31 11:29:38 +0200456 assertEquals(Collections.emptySet(), manager.getVCs(Optional.empty()));
Carolina Fernandezad893432016-07-18 11:11:34 +0200457 assertEquals(Collections.emptySet(), manager.getVCs(Optional.of(SDXL2_2)));
458
459 for (Intent removedIntent : removedIntents) {
460 boolean found = false;
461 for (Intent existingIntent : manager.intentService.getIntents()) {
462 if (removedIntent.key().equals(existingIntent.key())) {
463 found = true;
464 assertTrue(format("Intent %s equal %s", removedIntent, existingIntent),
465 !IntentUtils.intentsAreEqual(removedIntent, existingIntent));
466 break;
467 }
468 }
469 assertTrue(!found);
470 }
Carolina Fernandezad893432016-07-18 11:11:34 +0200471 }
Yuta HIGUCHIc9fae9f2017-01-31 15:21:51 -0800472}