use of org.apache.commons.vfs2.FileSelectInfo in project pentaho-metaverse by pentaho.
the class VfsDateRangeFilterTest method testAccept_startDateSet_endDateSet.
@Test
public void testAccept_startDateSet_endDateSet() throws Exception {
filter = new VfsDateRangeFilter(format, start, end);
FileSelectInfo fsi = mock(FileSelectInfo.class);
FileObject fo = mock(FileObject.class);
FileName fn = mock(FileName.class);
when(fn.getBaseName()).thenReturn(end);
when(fo.getType()).thenReturn(FileType.FOLDER);
when(fo.getName()).thenReturn(fn);
when(fsi.getFile()).thenReturn(fo);
when(fsi.getDepth()).thenReturn(1);
assertTrue("End date is not inclusive", filter.includeFile(fsi));
when(fn.getBaseName()).thenReturn(start);
assertTrue("Start date is not inclusive", filter.includeFile(fsi));
when(fn.getBaseName()).thenReturn(between);
assertTrue("Between start and end date is not accepted", filter.includeFile(fsi));
when(fn.getBaseName()).thenReturn("20000101");
assertFalse("Before start date was accepted", filter.includeFile(fsi));
when(fn.getBaseName()).thenReturn("21000101");
assertFalse("After end date was accepted", filter.includeFile(fsi));
}
use of org.apache.commons.vfs2.FileSelectInfo in project spoofax by metaborg.
the class SpoofaxIgnoresSelector method traverseDescendents.
@Override
public boolean traverseDescendents(FileSelectInfo fileInfo) throws Exception {
final int depth = fileInfo.getDepth();
final FileObject resource = fileInfo.getFile();
final FileName name = resource.getName();
final String base = name.getBaseName();
switch(depth) {
case 1:
switch(base) {
case "bin":
case "include":
case "target":
case ".cache":
case ".settings":
case ".mvn":
return false;
}
break;
case 3:
switch(base) {
// Ignore editor/java/trans and src-gen/stratego-java/trans.
case "trans":
{
final FileObject parent1 = resource.getParent();
if (parent1 != null) {
final String parent1base = parent1.getName().getBaseName();
if (parent1base.equals("java") || parent1base.equals("stratego-java")) {
final FileObject parent2 = parent1.getParent();
if (parent2 != null) {
final String parent2base = parent2.getName().getBaseName();
return !(parent2base.equals("editor") || parent2base.equals("src-gen"));
}
}
}
break;
}
}
break;
}
return true;
}
use of org.apache.commons.vfs2.FileSelectInfo in project pentaho-metaverse by pentaho.
the class VfsDateRangeFilterTest method testAccept_notFolder.
@Test
public void testAccept_notFolder() throws Exception {
filter = new VfsDateRangeFilter(format, start);
FileSelectInfo fsi = mock(FileSelectInfo.class);
FileObject fo = mock(FileObject.class);
when(fo.getType()).thenReturn(FileType.FILE);
when(fsi.getFile()).thenReturn(fo);
when(fsi.getDepth()).thenReturn(1);
assertFalse(filter.includeFile(fsi));
}
use of org.apache.commons.vfs2.FileSelectInfo in project pentaho-metaverse by pentaho.
the class VfsDateRangeFilterTest method testAccept_invalidDateStringFolder.
@Test
public void testAccept_invalidDateStringFolder() throws Exception {
filter = new VfsDateRangeFilter(format, start, end);
filter = new VfsDateRangeFilter(format, null, end);
FileSelectInfo fsi = mock(FileSelectInfo.class);
FileObject fo = mock(FileObject.class);
FileName fn = mock(FileName.class);
when(fn.getBaseName()).thenReturn("not a date");
when(fo.getType()).thenReturn(FileType.FOLDER);
when(fo.getName()).thenReturn(fn);
when(fsi.getFile()).thenReturn(fo);
when(fsi.getDepth()).thenReturn(1);
assertFalse("Invalid date was accepted", filter.includeFile(fsi));
}
use of org.apache.commons.vfs2.FileSelectInfo in project pentaho-metaverse by pentaho.
the class VfsDateRangeFilterTest method testAccept_startDateNull_endDateSet.
@Test
public void testAccept_startDateNull_endDateSet() throws Exception {
filter = new VfsDateRangeFilter(format, null, end);
FileSelectInfo fsi = mock(FileSelectInfo.class);
FileObject fo = mock(FileObject.class);
FileName fn = mock(FileName.class);
when(fn.getBaseName()).thenReturn(end);
when(fo.getType()).thenReturn(FileType.FOLDER);
when(fo.getName()).thenReturn(fn);
when(fsi.getFile()).thenReturn(fo);
when(fsi.getDepth()).thenReturn(1);
assertTrue("End date is not inclusive", filter.includeFile(fsi));
when(fn.getBaseName()).thenReturn("20000101");
assertTrue("Before end date was not accepted", filter.includeFile(fsi));
when(fn.getBaseName()).thenReturn("21000101");
assertFalse("After end date was accepted", filter.includeFile(fsi));
}
Aggregations