### Question:
NameFileFilter implements FileFilter, Serializable { @Override public boolean accept(final FileSelectInfo fileInfo) { final String name = fileInfo.getFile().getName().getBaseName(); for (final String name2 : this.names) { if (caseSensitivity.checkEquals(name, name2)) { return true; } } return false; } NameFileFilter(final List<String> names);  NameFileFilter(final IOCase caseSensitivity, final List<String> names);  NameFileFilter(final String... names);  NameFileFilter(final IOCase caseSensitivity, final String... names); @Override boolean accept(final FileSelectInfo fileInfo); @Override String toString();  }### Answer:
@Test public void testAcceptList() throws FileSystemException { final List<String> list = new ArrayList<>(); list.add("test1.txt"); list.add("test2.txt"); final NameFileFilter filter = new NameFileFilter(list); Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test1.txt")))); Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); Assert.assertFalse(filter.accept(createFileSelectInfo(new File("Test2.txt")))); Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); }
@Test public void testAcceptListIOCaseInsensitive() throws FileSystemException { final List<String> list = new ArrayList<>(); list.add("test1.txt"); list.add("test2.txt"); final NameFileFilter filter = new NameFileFilter(IOCase.INSENSITIVE, list); Assert.assertTrue(filter.accept(createFileSelectInfo(new File("TEST1.txt")))); Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); Assert.assertTrue(filter.accept(createFileSelectInfo(new File("Test2.txt")))); Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); }
@Test public void testAcceptListIOCaseSensitive() throws FileSystemException { final List<String> list = new ArrayList<>(); list.add("test1.txt"); list.add("test2.txt"); final NameFileFilter filter = new NameFileFilter(IOCase.SENSITIVE, list); Assert.assertFalse(filter.accept(createFileSelectInfo(new File("TEST1.txt")))); Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); Assert.assertFalse(filter.accept(createFileSelectInfo(new File("Test2.txt")))); Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); }
@Test public void testAcceptString() throws FileSystemException { final NameFileFilter filter = new NameFileFilter("test1.txt"); Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test1.txt")))); Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test2.txt")))); Assert.assertFalse(filter.accept(createFileSelectInfo(new File("Test2.txt")))); Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); }
@Test public void testAcceptStringIOCaseInsensitive() throws FileSystemException { final NameFileFilter filter = new NameFileFilter(IOCase.INSENSITIVE, "test2.txt"); Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test1.txt")))); Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); Assert.assertTrue(filter.accept(createFileSelectInfo(new File("Test2.txt")))); Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); }
@Test public void testAcceptStringIOCaseSensitive() throws FileSystemException { final NameFileFilter filter = new NameFileFilter(IOCase.SENSITIVE, "test2.txt"); Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test1.txt")))); Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); Assert.assertFalse(filter.accept(createFileSelectInfo(new File("Test2.txt")))); Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); }