Source:
<code>public ResourcePools validateAndMerge(ResourcePools existing, ResourcePools toBeUpdated) { if(!existing.getResourceTypeSet().containsAll(toBeUpdated.getResourceTypeSet())) { throw new IllegalArgumentException("Pools to be updated cannot contain previously undefined resources pools"); } if(toBeUpdated.getResourceTypeSet().contains(ResourceType.Core.OFFHEAP)) { throw new UnsupportedOperationException("Updating OFFHEAP resource is not supported"); } for(ResourceType currentResourceType : toBeUpdated.getResourceTypeSet()) { if (toBeUpdated.getPoolForResource(currentResourceType).getSize() <= 0) { throw new IllegalArgumentException("Unacceptable size for resource pools provided"); } if (toBeUpdated.getPoolForResource(currentResourceType).isPersistent() != existing.getPoolForResource(currentResourceType).isPersistent()) { throw new IllegalArgumentException("Persistence configuration cannot be updated"); } <START> if(toBeUpdated.getPoolForResource(currentResourceType).getUnit() instanceof MemoryUnit) { <END> throw new UnsupportedOperationException("Updating resources with MemoryUnit as unit of measure is not supported"); } } ResourcePoolsBuilder mergedPoolsBuilder = ResourcePoolsBuilder.newResourcePoolsBuilder(existing); for(ResourceType currentResourceType : toBeUpdated.getResourceTypeSet()) { mergedPoolsBuilder = mergedPoolsBuilder.with(currentResourceType, toBeUpdated.getPoolForResource(currentResourceType).getSize(), toBeUpdated.getPoolForResource(currentResourceType).getUnit(), toBeUpdated.getPoolForResource(currentResourceType).isPersistent()); } ResourcePools mergedResourcePools = mergedPoolsBuilder.build(); if(mergedResourcePools.getPoolForResource(ResourceType.Core.DISK) != null && checkForTierSizingViolation(mergedResourcePools)) { throw new IllegalArgumentException("Updating resource pools leads authoritative tier being smaller than caching tier"); } return mergedResourcePools; }</code><technical_language>While this test sense long #40 is implemented, I expressed in persistent check is - disallow changing resource unit altogether</technical_language>

Target:
public ResourcePools validateAndMerge(ResourcePools existing, ResourcePools toBeUpdated) { if(!existing.getResourceTypeSet().containsAll(toBeUpdated.getResourceTypeSet())) { throw new IllegalArgumentException("Pools to be updated cannot contain previously undefined resources pools"); } if(toBeUpdated.getResourceTypeSet().contains(ResourceType.Core.OFFHEAP)) { throw new UnsupportedOperationException("Updating OFFHEAP resource is not supported"); } for(ResourceType currentResourceType : toBeUpdated.getResourceTypeSet()) { if (toBeUpdated.getPoolForResource(currentResourceType).getSize() <= 0) { throw new IllegalArgumentException("Unacceptable size for resource pools provided"); } if (toBeUpdated.getPoolForResource(currentResourceType).isPersistent() != existing.getPoolForResource(currentResourceType).isPersistent()) { throw new IllegalArgumentException("Persistence configuration cannot be updated"); } if(!toBeUpdated.getPoolForResource(currentResourceType).getUnit() .equals(existing.getPoolForResource(currentResourceType).getUnit())) { throw new UnsupportedOperationException("Updating ResourceUnit is not supported"); } } ResourcePoolsBuilder mergedPoolsBuilder = ResourcePoolsBuilder.newResourcePoolsBuilder(existing); for(ResourceType currentResourceType : toBeUpdated.getResourceTypeSet()) { mergedPoolsBuilder = mergedPoolsBuilder.with(currentResourceType, toBeUpdated.getPoolForResource(currentResourceType).getSize(), toBeUpdated.getPoolForResource(currentResourceType).getUnit(), toBeUpdated.getPoolForResource(currentResourceType).isPersistent()); } ResourcePools mergedResourcePools = mergedPoolsBuilder.build(); if(mergedResourcePools.getPoolForResource(ResourceType.Core.DISK) != null && checkForTierSizingViolation(mergedResourcePools)) { throw new IllegalArgumentException("Updating resource pools leads authoritative tier being smaller than caching tier"); } return mergedResourcePools; }