MulticastDemand extends NetworkElement implements IMonitorizableElement { public void remove() { checkAttachedToNetPlanObject(); netPlan.checkIsModifiable(); if (this.coupledUpperLayerLinks != null) this.decouple (); for (MulticastTree tree : new TreeSet<MulticastTree> (cache_multicastTrees)) tree.remove(); netPlan.cache_id2MulticastDemandMap.remove(id); NetPlan.removeNetworkElementAndShiftIndexes (layer.multicastDemands , index); ingressNode.cache_nodeOutgoingMulticastDemands.remove (this); for (Node egressNode : egressNodes) egressNode.cache_nodeIncomingMulticastDemands.remove (this); for (String tag : tags) netPlan.cache_taggedElements.get(tag).remove(this); final Pair<SortedSet<Demand>,SortedSet<MulticastDemand>> qosInfo = layer.cache_qosTypes2DemandMap.get(qosType); assert qosInfo != null; final boolean removed = qosInfo.getSecond().remove(this); assert removed; if (qosInfo.getFirst().isEmpty() && qosInfo.getSecond().isEmpty()) layer.cache_qosTypes2DemandMap.remove(qosType); final NetPlan npOld = this.netPlan; removeId(); if (ErrorHandling.isDebugEnabled()) npOld.checkCachesConsistency(); } MulticastDemand(NetPlan netPlan , long id , int index , NetworkLayer layer , Node ingressNode , Set<Node> egressNodes , double offeredTraffic , AttributeMap attributes); void setMaximumAcceptableE2EWorstCaseLatencyInMs(double maxLatencyMs); double getMaximumAcceptableE2EWorstCaseLatencyInMs(); void setQoSType(String newQosType); String getQosType(); void setOfferedTrafficPerPeriodGrowthFactor(double growthFactor); double getOfferedTrafficPerPeriodGrowthFactor(); NetworkLayer getLayer(); double getWorseCasePropagationTimeInMs(); double getWorstCaseLengthInKm(); boolean isTraversingOversubscribedLinks(); Node getIngressNode(); SortedSet<Node> getEgressNodes(); double getOfferedTraffic(); double getCarriedTraffic(); double getBlockedTraffic(); Pair<SortedSet<MulticastTree>,Double> computeMinimumCostMulticastTrees(double [] costs); boolean isBifurcated(); boolean isBlocked(); SortedSet<MulticastTree> getMulticastTrees(); boolean isAllTreesReachingAllEgressNodes(); void couple(Set<Link> links); SortedSet<Link> coupleToNewLinksCreated(NetworkLayer newLinkLayer); SortedSet<Link> getCoupledLinks(); boolean isCoupled(); void decouple(); void remove(); void setOfferedTraffic(double offeredTraffic); String toString(); SortedMap<Link, Double> getTraversedLinksAndCarriedTraffic(final boolean normalizedToOfferedTraffic); SortedSet<Link> getLinksNoDownPropagationPotentiallyCarryingTraffic(Node egressNode); TrafficSeries getMonitoredOrForecastedOfferedTraffic(); void setMonitoredOrForecastedOfferedTraffic(TrafficSeries newTimeSeries); @Override TrafficSeries getMonitoredOrForecastedCarriedTraffic(); @Override void setMonitoredOrForecastedCarriedTraffic(TrafficSeries newTimeSeries); @Override double getCurrentTrafficToAddMonitSample(); @Override boolean isPossibleToSetCurrentTrafficAsGivenMonitSample(); @Override void setCurrentTrafficToGivenMonitSample(double traffic); @Override Optional<TrafficPredictor> getTrafficPredictor(); @Override void setTrafficPredictor(TrafficPredictor tp); @Override void removeTrafficPredictor();  }
@Test public void testRemove() { d123.remove(); assertEquals(np.getMulticastDemands(lowerLayer) , Arrays.asList()); assertEquals(np.getMulticastDemands(upperLayer) , Arrays.asList(upperMd123)); upperMd123.remove(); assertEquals(np.getMulticastDemands(lowerLayer) , Arrays.asList()); assertEquals(np.getMulticastDemands(upperLayer) , Arrays.asList()); }