@Test public void testPrepare() throws Exception { final Path test = new Path("/t/a", EnumSet.of(Path.Type.file)); Session session = new NullSession(new Host(new TestProtocol())); final NullLocal local = new NullLocal(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()) { @Override public boolean isSymbolicLink() { return false; } @Override public LocalAttributes attributes() { return new LocalAttributes(this.getAbsolute()) { @Override public long getSize() { return 1L; } }; } @Override public boolean isFile() { return true; } @Override public boolean exists() { return true; } }; final SynchronizationPathFilter mirror = new SynchronizationPathFilter( new ComparisonServiceFilter(session, TimeZone.getDefault(), new DisabledProgressListener()), new OverwriteFilter(new DownloadSymlinkResolver(Collections.<TransferItem>emptyList()), session), new ch.cyberduck.core.transfer.upload.OverwriteFilter(new UploadSymlinkResolver(null, Collections.<TransferItem>emptyList()), session), TransferAction.mirror); assertTrue(mirror.accept(test, local, new TransferStatus().exists(true))); final TransferStatus status = mirror.prepare(test, local, new TransferStatus().exists(true), new DisabledProgressListener()); assertNotNull(status); assertEquals(1L, status.getLength()); final SynchronizationPathFilter download = new SynchronizationPathFilter( new ComparisonServiceFilter(session, TimeZone.getDefault(), new DisabledProgressListener()), new OverwriteFilter(new DownloadSymlinkResolver(Collections.<TransferItem>emptyList()), session), new ch.cyberduck.core.transfer.upload.OverwriteFilter(new UploadSymlinkResolver(null, Collections.<TransferItem>emptyList()), session), TransferAction.download); assertFalse(download.accept(test, local, new TransferStatus().exists(true))); final SynchronizationPathFilter upload = new SynchronizationPathFilter( new ComparisonServiceFilter(session, TimeZone.getDefault(), new DisabledProgressListener()), new OverwriteFilter(new DownloadSymlinkResolver(Collections.<TransferItem>emptyList()), session), new ch.cyberduck.core.transfer.upload.OverwriteFilter(new UploadSymlinkResolver(null, Collections.<TransferItem>emptyList()), session), TransferAction.upload); assertTrue(upload.accept(test, local, new TransferStatus().exists(true))); }
@Override public TransferStatus prepare(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress) throws BackgroundException { switch(comparison.compare(file, local)) { case remote: return downloadFilter.prepare(file, local, parent, progress); case local: return uploadFilter.prepare(file, local, parent, progress); } return uploadFilter.prepare(file, local, parent, progress).exists(true); }
SynchronizationPathFilter implements TransferPathFilter { @Override public TransferStatus prepare(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress) throws BackgroundException { switch(comparison.compare(file, local)) { case remote: return downloadFilter.prepare(file, local, parent, progress); case local: return uploadFilter.prepare(file, local, parent, progress); } return uploadFilter.prepare(file, local, parent, progress).exists(true); } }
SynchronizationPathFilter implements TransferPathFilter { @Override public TransferStatus prepare(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress) throws BackgroundException { switch(comparison.compare(file, local)) { case remote: return downloadFilter.prepare(file, local, parent, progress); case local: return uploadFilter.prepare(file, local, parent, progress); } return uploadFilter.prepare(file, local, parent, progress).exists(true); } SynchronizationPathFilter(final ComparePathFilter comparison,
                                     final TransferPathFilter downloadFilter,
                                     final TransferPathFilter uploadFilter,
                                     final TransferAction action); }
SynchronizationPathFilter implements TransferPathFilter { @Override public TransferStatus prepare(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress) throws BackgroundException { switch(comparison.compare(file, local)) { case remote: return downloadFilter.prepare(file, local, parent, progress); case local: return uploadFilter.prepare(file, local, parent, progress); } return uploadFilter.prepare(file, local, parent, progress).exists(true); } SynchronizationPathFilter(final ComparePathFilter comparison,
                                     final TransferPathFilter downloadFilter,
                                     final TransferPathFilter uploadFilter,
                                     final TransferAction action); @Override TransferPathFilter withCache(final Cache<Path> cache); @Override TransferStatus prepare(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress); @Override boolean accept(final Path file, final Local local, final TransferStatus parent); @Override void apply(final Path file, final Local local, final TransferStatus status, final ProgressListener listener); @Override void complete(final Path file, final Local local, final TransferOptions options, final TransferStatus status,
                         final ProgressListener listener); }
SynchronizationPathFilter implements TransferPathFilter { @Override public TransferStatus prepare(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress) throws BackgroundException { switch(comparison.compare(file, local)) { case remote: return downloadFilter.prepare(file, local, parent, progress); case local: return uploadFilter.prepare(file, local, parent, progress); } return uploadFilter.prepare(file, local, parent, progress).exists(true); } SynchronizationPathFilter(final ComparePathFilter comparison,
                                     final TransferPathFilter downloadFilter,
                                     final TransferPathFilter uploadFilter,
                                     final TransferAction action); @Override TransferPathFilter withCache(final Cache<Path> cache); @Override TransferStatus prepare(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress); @Override boolean accept(final Path file, final Local local, final TransferStatus parent); @Override void apply(final Path file, final Local local, final TransferStatus status, final ProgressListener listener); @Override void complete(final Path file, final Local local, final TransferOptions options, final TransferStatus status,
                         final ProgressListener listener);  }