### Question:
AttributeService { @SuppressWarnings("unchecked") @NullableDecl public <V extends FileAttributeView> V getFileAttributeView(FileLookup lookup, Class<V> type) { AttributeProvider provider = providersByViewType.get(type); if (provider != null) { return (V) provider.view(lookup, createInheritedViews(lookup, provider)); } return null; } 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:
@SuppressWarnings("ConstantConditions") @Test public void testGetFileAttributeView() throws IOException { final File file = Directory.create(0); service.setInitialAttributes(file); FileLookup fileLookup = new FileLookup() { @Override public File lookup() throws IOException { return file; } }; assertThat(service.getFileAttributeView(fileLookup, TestAttributeView.class)).isNotNull(); assertThat(service.getFileAttributeView(fileLookup, BasicFileAttributeView.class)).isNotNull(); TestAttributes attrs = service.getFileAttributeView(fileLookup, TestAttributeView.class).readAttributes(); assertThat(attrs.foo()).isEqualTo("hello"); assertThat(attrs.bar()).isEqualTo(0); assertThat(attrs.baz()).isEqualTo(1); }
@Test public void testGetFileAttributeView_isNullForUnsupportedView() { final File file = Directory.create(0); FileLookup fileLookup = new FileLookup() { @Override public File lookup() throws IOException { return file; } }; assertThat(service.getFileAttributeView(fileLookup, PosixFileAttributeView.class)).isNull(); }