SdxL2MacVCManager extends SdxL2VCManager { @Override public void removeVC(SdxL2ConnectionPoint sdxl2cplhs, SdxL2ConnectionPoint sdxl2cprhs) { String action = "deleted"; checkState(!(isNullMac(sdxl2cplhs.macAddress()) && isNullMac(sdxl2cprhs.macAddress())), errorMacNull, action, sdxl2cplhs.name() + " and " + sdxl2cprhs.name()); checkState(!sdxl2cplhs.macAddress().equals(MacAddress.ZERO), errorMacNull, action, sdxl2cplhs.name()); checkState(!sdxl2cprhs.macAddress().equals(MacAddress.ZERO), errorMacNull, action, sdxl2cprhs.name()); checkState(!sdxl2cplhs.macAddress().equals(sdxl2cprhs.macAddress()), errorMacEqual, action); super.removeVC(sdxl2cplhs, sdxl2cprhs); } SdxL2MacVCManager(ApplicationId sdxl2id,
                             SdxL2Store store,
                             IntentService intentService); @Override Collection<Intent> buildIntents(String sdxl2, SdxL2ConnectionPoint ingress, SdxL2ConnectionPoint egress); @Override void addVC(String sdxl2, SdxL2ConnectionPoint sdxl2cplhs, SdxL2ConnectionPoint sdxl2cprhs); @Override void removeVC(SdxL2ConnectionPoint sdxl2cplhs, SdxL2ConnectionPoint sdxl2cprhs); @Override void removeVC(SdxL2ConnectionPoint cp);  }
@Test public void removeVCAndIntents() { testConnectionSetup(); List<PointToPointIntent> removedIntents = new ArrayList<>(); SdxL2ConnectionPoint cpone = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1, CEMAC1); SdxL2ConnectionPoint cptwo = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST2", CP2, VLANS2, CEMAC2); removedIntents.addAll(setupConnectionPoints1To2()); SdxL2ConnectionPoint cpfive = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST5", CP5, VLANS5, CEMAC5); SdxL2ConnectionPoint cpsix = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST6", CP6, VLANS6, CEMAC6); removedIntents.addAll(setupConnectionPoints5To6()); SdxL2ConnectionPoint cpseven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST7", CP7, VLANS7, CEMAC7); SdxL2ConnectionPoint cpeight = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST8", CP8, VLANS8, CEMAC8); removedIntents.addAll(setupConnectionPoints7To8()); manager.removeVC(cpone, cptwo); manager.removeVC(cpfive, cpsix); manager.removeVC(cpseven, cpeight); assertEquals(2, manager.intentService.getIntentCount()); for (Intent removedIntent : removedIntents) { boolean found = false; for (Intent existingIntent : manager.intentService.getIntents()) { if (removedIntent.key().equals(existingIntent.key())) { found = true; assertTrue(format("Intent %s equal %s", removedIntent, existingIntent), !IntentUtils.intentsAreEqual(removedIntent, existingIntent)); break; } } assertTrue(!found); } }
@Test public void testRemoveVCbyCP() { testConnectionSetup(); List<PointToPointIntent> removedIntents = new ArrayList<>(); SdxL2ConnectionPoint cpone = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1, CEMAC1); removedIntents.addAll(setupConnectionPoints1To2()); SdxL2ConnectionPoint cpsix = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST6", CP6, VLANS6, CEMAC6); removedIntents.addAll(setupConnectionPoints5To6()); SdxL2ConnectionPoint cpseven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST7", CP7, VLANS7, CEMAC7); removedIntents.addAll(setupConnectionPoints7To8()); SdxL2ConnectionPoint cpten = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST10", CP10, VLANS10, CEMAC10); removedIntents.addAll(setupConnectionPoints9To10()); manager.removeVC(cpone); manager.removeVC(cpsix); manager.removeVC(cpseven); manager.removeVC(cpten); assertEquals(Collections.emptySet(), manager.getVCs(Optional.empty())); assertEquals(0, manager.intentService.getIntentCount()); for (Intent removedIntent : removedIntents) { boolean found = false; for (Intent existingIntent : manager.intentService.getIntents()) { if (removedIntent.key().equals(existingIntent.key())) { found = true; assertTrue(format("Intent %s equal %s", removedIntent, existingIntent), !IntentUtils.intentsAreEqual(removedIntent, existingIntent)); break; } } assertTrue(!found); } }