### Question:
AttributeService { public ImmutableMap<String, Object> readAttributes(File file, String attributes) { String view = getViewName(attributes); List<String> attrs = getAttributeNames(attributes); if (attrs.size() > 1 && attrs.contains(ALL_ATTRIBUTES)) { throw new IllegalArgumentException("invalid attributes: " + attributes); } Map<String, Object> result = new HashMap<>(); if (attrs.size() == 1 && attrs.contains(ALL_ATTRIBUTES)) { AttributeProvider provider = providersByName.get(view); readAll(file, provider, result); for (String inheritedView : provider.inherits()) { AttributeProvider inheritedProvider = providersByName.get(inheritedView); readAll(file, inheritedProvider, result); } } else { for (String attr : attrs) { result.put(attr, getAttribute(file, view, attr)); } } return ImmutableMap.copyOf(result); } AttributeService(Configuration configuration);  AttributeService(
      Iterable<? extends AttributeProvider> providers, Map<String, ?> userProvidedDefaults); ImmutableSet<String> supportedFileAttributeViews(); boolean supportsFileAttributeView(Class<? extends FileAttributeView> type); void setInitialAttributes(File file, FileAttribute<?>... attrs); void copyAttributes(File file, File copy, AttributeCopyOption copyOption); Object getAttribute(File file, String attribute); Object getAttribute(File file, String view, String attribute); void setAttribute(File file, String attribute, Object value, boolean create); @SuppressWarnings("unchecked") @NullableDecl V getFileAttributeView(FileLookup lookup, Class<V> type); ImmutableMap<String, Object> readAttributes(File file, String attributes); @SuppressWarnings("unchecked") A readAttributes(File file, Class<A> type);  }### Answer:
@Test public void testReadAttributes_asMap_failsForInvalidAttributes() { File file = Directory.create(0); try { service.readAttributes(file, "basic:fileKey,isOther,*,creationTime"); fail(); } catch (IllegalArgumentException expected) { assertThat(expected.getMessage()).contains("invalid attributes"); } try { service.readAttributes(file, "basic:fileKey,isOther,foo"); fail(); } catch (IllegalArgumentException expected) { assertThat(expected.getMessage()).contains("invalid attribute"); } }
@Test public void testReadAttributes_failsForUnsupportedAttributesType() { File file = Directory.create(0); try { service.readAttributes(file, PosixFileAttributes.class); fail(); } catch (UnsupportedOperationException expected) { } }