### Question:
AgeFileFilter implements FileFilter, Serializable { @Override public boolean accept(final FileSelectInfo fileInfo) throws FileSystemException { final boolean newer = isFileNewer(fileInfo.getFile(), cutoff); return acceptOlder ? !newer : newer; } AgeFileFilter(final Date cutoffDate);  AgeFileFilter(final Date cutoffDate, final boolean acceptOlder);  AgeFileFilter(final FileObject cutoffReference);  AgeFileFilter(final FileObject cutoffReference, final boolean acceptOlder);  AgeFileFilter(final long cutoff);  AgeFileFilter(final long cutoff, final boolean acceptOlder); @Override boolean accept(final FileSelectInfo fileInfo); @Override String toString();  }### Answer:
@Test public void testAgeFileFilterDate() throws FileSystemException { final AgeFileFilter testee = new AgeFileFilter(new Date()); Assert.assertTrue(testee.accept(oldFileInfo)); Assert.assertTrue(testee.accept(currentFileInfo)); Assert.assertFalse(testee.accept(newFileInfo)); }
@Test public void testAgeFileFilterDateBoolean() throws FileSystemException { AgeFileFilter testee; testee = new AgeFileFilter(new Date(), true); Assert.assertTrue(testee.accept(oldFileInfo)); Assert.assertTrue(testee.accept(currentFileInfo)); Assert.assertFalse(testee.accept(newFileInfo)); testee = new AgeFileFilter(new Date(), false); Assert.assertFalse(testee.accept(oldFileInfo)); Assert.assertFalse(testee.accept(currentFileInfo)); Assert.assertTrue(testee.accept(newFileInfo)); }
@Test public void testAgeFileFilterFile() throws FileSystemException { final AgeFileFilter testee = new AgeFileFilter(currentFileInfo.getFile()); Assert.assertTrue(testee.accept(oldFileInfo)); Assert.assertTrue(testee.accept(currentFileInfo)); Assert.assertFalse(testee.accept(newFileInfo)); }
@Test public void testAgeFileFilterFileBoolean() throws FileSystemException { AgeFileFilter testee; testee = new AgeFileFilter(currentFileInfo.getFile(), true); Assert.assertTrue(testee.accept(oldFileInfo)); Assert.assertTrue(testee.accept(currentFileInfo)); Assert.assertFalse(testee.accept(newFileInfo)); testee = new AgeFileFilter(currentFileInfo.getFile(), false); Assert.assertFalse(testee.accept(oldFileInfo)); Assert.assertFalse(testee.accept(currentFileInfo)); Assert.assertTrue(testee.accept(newFileInfo)); }
@Test public void testAgeFileFilterLong() throws FileSystemException { final AgeFileFilter testee = new AgeFileFilter(NOW); Assert.assertTrue(testee.accept(oldFileInfo)); Assert.assertTrue(testee.accept(currentFileInfo)); Assert.assertFalse(testee.accept(newFileInfo)); }
@Test public void testAgeFileFilterLongBoolean() throws FileSystemException { AgeFileFilter testee; testee = new AgeFileFilter(NOW, true); Assert.assertTrue(testee.accept(oldFileInfo)); Assert.assertTrue(testee.accept(currentFileInfo)); Assert.assertFalse(testee.accept(newFileInfo)); testee = new AgeFileFilter(NOW, false); Assert.assertFalse(testee.accept(oldFileInfo)); Assert.assertFalse(testee.accept(currentFileInfo)); Assert.assertTrue(testee.accept(newFileInfo)); FileObject[] files; files = zipFileObj.findFiles(new FileFilterSelector(new AgeFileFilter(NOW, true))); assertContains(files, oldFile.getName(), currentFile.getName()); Assert.assertEquals(2, files.length); files = zipFileObj.findFiles(new FileFilterSelector(new AgeFileFilter(NOW, false))); assertContains(files, newFile.getName()); Assert.assertEquals(1, files.length); }