VfsTableModelHiddenFileRowFilter extends RowFilter<VfsTableModel, Integer> { protected boolean checkIfInclude(FileObject fileObject) { if (!showHidden) { try { if (fileObject.getName().getBaseName().startsWith(".") || fileObject.isHidden()) { return false; } } catch (FileSystemException e) { } } return true; } VfsTableModelHiddenFileRowFilter(boolean showHidden); @Override boolean include(Entry<? extends VfsTableModel, ? extends Integer> entry);  }
@Test(dataProvider = "candidateFiles") public void testCheckIfInclude(String path, boolean hiddenAttribute, boolean showHidden, boolean expected) throws Exception { VfsTableModelHiddenFileRowFilter rowFilter = new VfsTableModelHiddenFileRowFilter(showHidden); FileObject fileObject = mock(FileObject.class); FileName fileName = mock(FileName.class); when(fileObject.getName()).thenReturn(fileName); when(fileName.getBaseName()).thenReturn(path); when(fileObject.isHidden()).thenReturn(hiddenAttribute); boolean result = rowFilter.checkIfInclude(fileObject); Assert.assertEquals(result, expected, String.format("Result for file \"%s\" with hidden attribute %s and showHidden checked %s should " + "be %s, was %s", path, hiddenAttribute, showHidden, result, expected)); }