Resource extends NetworkElement { @Override void checkCachesConsistency () { super.checkCachesConsistency (); if (!netPlan.cache_type2Resources.get(this.type).contains(this)) throw new RuntimeException ("Bad"); if (!this.iAttachedToANode()) assert getTraversingRoutes().isEmpty(); if (!this.iAttachedToANode()) assert getBaseResources().isEmpty(); double accumOccupCap = 0; for (Entry<Resource,Double> upperEntry : capacityUpperResourcesOccupyInMe.entrySet()) { final Resource upperResource = upperEntry.getKey(); final double val = upperEntry.getValue(); if (upperResource.capacityIOccupyInBaseResource.get(this) != val) throw new RuntimeException ("Bad"); accumOccupCap += val; } for (Entry<Resource,Double> lowerEntry : capacityIOccupyInBaseResource.entrySet()) { final Resource lowerResource = lowerEntry.getKey(); final double val = lowerEntry.getValue(); if (lowerResource.capacityUpperResourcesOccupyInMe.get(this) != val) throw new RuntimeException ("Bad"); } for (Entry<Route,Double> travRoute : cache_traversingRoutesAndOccupiedCapacitiesIfNotFailingRoute.entrySet()) { final Route r = travRoute.getKey(); final double val = travRoute.getValue(); if (r.cache_linkAndResourcesTraversedOccupiedCapIfnotFailMap.get(this) != val) throw new RuntimeException ("Bad"); if (!r.isDown()) accumOccupCap += val; } if (accumOccupCap != cache_totalOccupiedCapacity) { if (cache_totalOccupiedCapacity != 0) { if ((accumOccupCap / cache_totalOccupiedCapacity) > 0.001) throw new RuntimeException(); } else { if (accumOccupCap > 0.001 || accumOccupCap < -0.001) throw new RuntimeException(); } } } Resource(NetPlan netPlan , long id , int index , String type , String name , Optional<Node> hostNode , 
			double capacity , String capacityMeasurementUnits,
			Map<Resource,Double> capacityIOccupyInBaseResource , double processingTimeToTraversingTraffic , 
			AttributeMap attributes); double getUtilization(); boolean isOversubscribed(); double getProcessingTimeToTraversingTrafficInMs(); void setProcessingTimeToTraversingTrafficInMs(double time); URL getUrlIcon(); void setUrlIcon(URL url); String getType(); Optional<Node> getHostNode(); boolean iAttachedToANode(); String getCapacityMeasurementUnits(); void setCapacityMeasurementUnits(String units); double getCapacity(); double getOccupiedCapacity(); boolean isHavingMoreThanOneBaseResourceWithTheSameType(); SortedSet<Resource> getBaseResources(); SortedSet<Resource> getUpperResources(); double getCapacityOccupiedInBaseResource(Resource baseResource); double getCapacityOccupiedByUpperResource(Resource upperResource); SortedMap<Resource, Double> getCapacityOccupiedInBaseResourcesMap(); SortedMap<Resource, Double> getCapacityOccupiedByUpperResourcesMap(); SortedSet<Demand> getTraversingDemands(); SortedSet<Route> getTraversingRoutes(); double getTraversingRouteOccupiedCapacity(Route route); SortedMap<Route,Double> getTraversingRouteOccupiedCapacityMap(); void setCapacity(double newCapacity , Map<Resource,Double> newCapacityIOccupyInBaseResourcesMap); void remove(); @Override String toString(); void dettachFromNode(); void attachToNode(Node node);  }
@Test public void testCheckCaches() { np.checkCachesConsistency(); }