### Question:
Group { public final Group collectResourcesOfType(final ResourceType type) { Validate.notNull(type); final List<Resource> allResources = new ArrayList<Resource>(); allResources.addAll(getResources()); final List<Resource> filteredResources = new ArrayList<Resource>(); for (final Resource resource : getResources()) { if (type == resource.getType()) { if (filteredResources.contains(resource)) { LOG.warn("Duplicated resource detected: " + resource + ". This resource won't be included more than once!"); } else { filteredResources.add(resource); } } } final Group filteredGroup = new Group(getName()); filteredGroup.setResources(filteredResources); return filteredGroup; } 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 = NullPointerException.class) public void cannotCollectResourcesWithNullType() { final Group group = new Group("group"); group.collectResourcesOfType(null); }