MessageFileFilter implements FileFilter { @Override public boolean accept(final File file) { return file.isFile() && isMatchWithRegExp(file); }  @Override boolean accept(final File file);  }
@Test public void testAcceptShouldReturnFalseWhenParameterIsNotFile() { given(file.isFile()).willReturn(false); boolean result = underTest.accept(file); verify(file).isFile(); assertFalse(result); }
@Test public void testAcceptShouldReturnFalseWhenFileNameDoesNotMatchWithRegExp() { String example = "20130701132107.0025red.txt"; given(file.isFile()).willReturn(true); given(file.getName()).willReturn(example); boolean result = underTest.accept(file); assertFalse(result); }
@Test public void testAcceptShouldReturnTrueWhenParameterFileAndNameMatchWithRegExp() { String fileName = "20130701132107.0025req.txt"; given(file.isFile()).willReturn(true); given(file.getName()).willReturn(fileName); boolean result = underTest.accept(file); assertTrue(result); }