@Test public void testRun() throws Exception { final PathCache cache = new PathCache(Integer.MAX_VALUE); final AttributedList<Path> root = new AttributedList<>(); root.add(new Path("/t1.png", EnumSet.of(Path.Type.file))); root.add(new Path("/t1.gif", EnumSet.of(Path.Type.file))); root.add(new Path("/folder", EnumSet.of(Path.Type.directory))); root.add(new Path("/folder2", EnumSet.of(Path.Type.directory))); cache.put(new Path("/", EnumSet.of(Path.Type.directory)), root); final AttributedList<Path> folder = new AttributedList<>(); folder.add(new Path(new Path("/folder", EnumSet.of(Path.Type.directory)), "/t2.png", EnumSet.of(Path.Type.file))); folder.add(new Path(new Path("/folder", EnumSet.of(Path.Type.directory)), "/t2.gif", EnumSet.of(Path.Type.file))); cache.put(new Path("/folder", EnumSet.of(Path.Type.directory)), folder); final SearchWorker search = new SearchWorker(new Path("/", EnumSet.of(Path.Type.directory)), new SearchFilter(".png"), cache, new DisabledListProgressListener()); final AttributedList<Path> found = search.run(new NullSession(new Host(new TestProtocol()))); assertTrue(found.contains(new Path("/t1.png", EnumSet.of(Path.Type.file)))); assertFalse(found.contains(new Path("/t1.gif", EnumSet.of(Path.Type.file)))); assertFalse(found.contains(new Path("/t2.png", EnumSet.of(Path.Type.file)))); assertFalse(found.contains(new Path("/t2.gif", EnumSet.of(Path.Type.file)))); assertTrue(found.contains(new Path("/folder", EnumSet.of(Path.Type.directory)))); assertTrue(found.contains(new Path(new Path("/folder", EnumSet.of(Path.Type.directory)), "/t2.png", EnumSet.of(Path.Type.file)))); assertFalse(found.contains(new Path(new Path("/folder2", EnumSet.of(Path.Type.directory)), "/t2.gif", EnumSet.of(Path.Type.file)))); assertFalse(found.contains(new Path("/folder2", EnumSet.of(Path.Type.directory)))); }
@Override public AttributedList<Path> run(final Session<?> session) throws BackgroundException { final Search feature = session.getFeature(Search.class).withCache(cache); if(log.isDebugEnabled()) { log.debug(String.format("Run with feature %s", feature)); } return this.search(feature, directory); }
SearchWorker extends Worker<AttributedList<Path>> { @Override public AttributedList<Path> run(final Session<?> session) throws BackgroundException { final Search feature = session.getFeature(Search.class).withCache(cache); if(log.isDebugEnabled()) { log.debug(String.format("Run with feature %s", feature)); } return this.search(feature, directory); } }
SearchWorker extends Worker<AttributedList<Path>> { @Override public AttributedList<Path> run(final Session<?> session) throws BackgroundException { final Search feature = session.getFeature(Search.class).withCache(cache); if(log.isDebugEnabled()) { log.debug(String.format("Run with feature %s", feature)); } return this.search(feature, directory); } SearchWorker(final Path directory, final Filter<Path> filter, final Cache<Path> cache, final ListProgressListener listener); }
SearchWorker extends Worker<AttributedList<Path>> { @Override public AttributedList<Path> run(final Session<?> session) throws BackgroundException { final Search feature = session.getFeature(Search.class).withCache(cache); if(log.isDebugEnabled()) { log.debug(String.format("Run with feature %s", feature)); } return this.search(feature, directory); } SearchWorker(final Path directory, final Filter<Path> filter, final Cache<Path> cache, final ListProgressListener listener); @Override AttributedList<Path> run(final Session<?> session); @Override AttributedList<Path> initialize(); @Override String getActivity(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); }
SearchWorker extends Worker<AttributedList<Path>> { @Override public AttributedList<Path> run(final Session<?> session) throws BackgroundException { final Search feature = session.getFeature(Search.class).withCache(cache); if(log.isDebugEnabled()) { log.debug(String.format("Run with feature %s", feature)); } return this.search(feature, directory); } SearchWorker(final Path directory, final Filter<Path> filter, final Cache<Path> cache, final ListProgressListener listener); @Override AttributedList<Path> run(final Session<?> session); @Override AttributedList<Path> initialize(); @Override String getActivity(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }