### Question:
AttributeService { public void setInitialAttributes(File file, FileAttribute<?>... attrs) { for (int i = 0; i < defaultValues.size(); i++) { FileAttribute<?> attribute = defaultValues.get(i); int separatorIndex = attribute.name().indexOf(':'); String view = attribute.name().substring(0, separatorIndex); String attr = attribute.name().substring(separatorIndex + 1); file.setAttribute(view, attr, attribute.value()); } for (FileAttribute<?> attr : attrs) { setAttribute(file, attr.name(), attr.value(), true); } } 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 testSetInitialAttributes() { File file = Directory.create(0); service.setInitialAttributes(file); assertThat(file.getAttributeNames("test")).containsExactly("bar", "baz"); assertThat(file.getAttributeNames("owner")).containsExactly("owner"); assertThat(service.getAttribute(file, "basic:lastModifiedTime")).isInstanceOf(FileTime.class); assertThat(file.getAttribute("test", "bar")).isEqualTo(0L); assertThat(file.getAttribute("test", "baz")).isEqualTo(1); }
@Test public void testSetAttribute_onCreate_failsForAttributeThatIsNotSettableOnCreate() { File file = Directory.create(0); try { service.setInitialAttributes(file, new BasicFileAttribute<>("test:foo", "world")); fail(); } catch (UnsupportedOperationException expected) { } try { service.setInitialAttributes(file, new BasicFileAttribute<>("test:bar", 5)); fail(); } catch (UnsupportedOperationException expected) { } }