use of ch.cyberduck.core.s3.S3VersionedObjectListService in project cyberduck by iterate-ch.
the class MoveWorkerTest method testMoveVersionedDirectory.
@Test
public void testMoveVersionedDirectory() throws Exception {
final Path bucket = new Path("versioning-test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
final Path sourceDirectory = new S3DirectoryFeature(session, new S3WriteFeature(session)).mkdir(new Path(bucket, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
final Path targetDirectory = new S3DirectoryFeature(session, new S3WriteFeature(session)).mkdir(new Path(bucket, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
final S3TouchFeature touch = new S3TouchFeature(session);
Path test = touch.touch(new Path(sourceDirectory, new AsciiRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
assertTrue(new S3FindFeature(session).find(test));
final S3DefaultDeleteFeature delete = new S3DefaultDeleteFeature(session);
delete.delete(Collections.singletonList(new Path(test).withAttributes(PathAttributes.EMPTY)), new DisabledPasswordCallback(), new Delete.DisabledCallback());
assertTrue(new S3FindFeature(session).find(test));
test = touch.touch(test, new TransferStatus());
assertTrue(new S3FindFeature(session).find(test));
final S3VersionedObjectListService list = new S3VersionedObjectListService(session);
final AttributedList<Path> versioned = list.list(sourceDirectory, new DisabledListProgressListener());
final Map<Path, Path> files = new HashMap<>();
for (Path source : versioned) {
files.put(source, new Path(targetDirectory, source.getName(), source.getType(), source.attributes()));
}
final Map<Path, Path> result = new MoveWorker(files, new SessionPool.SingleSessionPool(session), PathCache.empty(), new DisabledProgressListener(), new DisabledLoginCallback()).run(session);
assertEquals(3, result.size());
for (Map.Entry<Path, Path> entry : result.entrySet()) {
assertFalse(new S3FindFeature(session).find(entry.getKey()));
assertTrue(new S3FindFeature(session).find(entry.getValue()));
}
new DeleteWorker(new DisabledLoginCallback(), Collections.singletonList(targetDirectory), PathCache.empty(), new DisabledProgressListener()).run(session);
session.close();
}
Aggregations