### Question:
PrefixFileFilter implements FileFilter, Serializable { @Override public boolean accept(final FileSelectInfo fileInfo) { final String name = fileInfo.getFile().getName().getBaseName(); for (final String prefix : this.prefixes) { if (caseSensitivity.checkStartsWith(name, prefix)) { return true; } } return false; } PrefixFileFilter(final List<String> prefixes);  PrefixFileFilter(final IOCase caseSensitivity, final List<String> prefixes);  PrefixFileFilter(final String... prefixes);  PrefixFileFilter(final IOCase caseSensitivity, final String... prefixes); @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"); list.add("test2"); final PrefixFileFilter filter = new PrefixFileFilter(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"); list.add("test2"); final PrefixFileFilter filter = new PrefixFileFilter(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"); list.add("test2"); final PrefixFileFilter filter = new PrefixFileFilter(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 PrefixFileFilter filter = new PrefixFileFilter("test"); 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.assertTrue(filter.accept(createFileSelectInfo(new File("test.xxx")))); }
@Test public void testAcceptStringIOCaseInsensitive() throws FileSystemException { final PrefixFileFilter filter = new PrefixFileFilter(IOCase.INSENSITIVE, "test"); 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.assertTrue(filter.accept(createFileSelectInfo(new File("test.xxx")))); }
@Test public void testAcceptStringIOCaseSensitive() throws FileSystemException { final PrefixFileFilter filter = new PrefixFileFilter(IOCase.SENSITIVE, "test"); 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.assertTrue(filter.accept(createFileSelectInfo(new File("test.xxx")))); }