### Question:
Group { public void replace(final Resource resource, final List<Resource> expandedResources) { LOG.debug("replacing resource {} with expanded resources: {}", resource, expandedResources); Validate.notNull(resource); Validate.notNull(expandedResources); synchronized (this) { boolean found = false; final Set<Resource> result = new LinkedHashSet<Resource>(); for (final Resource resourceItem : resources) { if (resourceItem.equals(resource)) { found = true; for (final Resource expandedResource : expandedResources) { expandedResource.setMinimize(resource.isMinimize()); result.add(expandedResource); } } else { result.add(resourceItem); } } if (!found) { throw new IllegalArgumentException("Cannot replace resource: " + resource + " for group: " + this + " because the resource is not a part of this group."); } setResources(new ArrayList<Resource>(result)); } } Group();  Group(final String name); final boolean hasResourcesOfType(final ResourceType resourceType); boolean hasResource(final String resourceUri); void replace(final Resource resource, final List<Resource> expandedResources); final Group collectResourcesOfType(final ResourceType type); List<Resource> getResources(); Group addResource(final Resource resource); final void setResources(final List<Resource> resources); @Override boolean equals(final Object obj); String getName(); @Override int hashCode(); @Override String toString();  }### Answer:
@Test(expected = IllegalArgumentException.class) public void cannotReplaceMissingResource() { final Group group = new Group("group"); group.replace(Resource.create("/path", ResourceType.JS), Arrays.asList(Resource.create("", ResourceType.JS))); }