Search in sources :

Example 1 with S3VersionedObjectListService

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();
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) S3FindFeature(ch.cyberduck.core.s3.S3FindFeature) S3TouchFeature(ch.cyberduck.core.s3.S3TouchFeature) AsciiRandomStringService(ch.cyberduck.core.AsciiRandomStringService) S3DefaultDeleteFeature(ch.cyberduck.core.s3.S3DefaultDeleteFeature) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) HashMap(java.util.HashMap) S3DirectoryFeature(ch.cyberduck.core.s3.S3DirectoryFeature) S3VersionedObjectListService(ch.cyberduck.core.s3.S3VersionedObjectListService) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) S3WriteFeature(ch.cyberduck.core.s3.S3WriteFeature) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) HashMap(java.util.HashMap) Map(java.util.Map) AbstractS3Test(ch.cyberduck.core.s3.AbstractS3Test) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Aggregations

AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)1 AsciiRandomStringService (ch.cyberduck.core.AsciiRandomStringService)1 DisabledListProgressListener (ch.cyberduck.core.DisabledListProgressListener)1 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)1 DisabledPasswordCallback (ch.cyberduck.core.DisabledPasswordCallback)1 DisabledProgressListener (ch.cyberduck.core.DisabledProgressListener)1 Path (ch.cyberduck.core.Path)1 Delete (ch.cyberduck.core.features.Delete)1 AbstractS3Test (ch.cyberduck.core.s3.AbstractS3Test)1 S3DefaultDeleteFeature (ch.cyberduck.core.s3.S3DefaultDeleteFeature)1 S3DirectoryFeature (ch.cyberduck.core.s3.S3DirectoryFeature)1 S3FindFeature (ch.cyberduck.core.s3.S3FindFeature)1 S3TouchFeature (ch.cyberduck.core.s3.S3TouchFeature)1 S3VersionedObjectListService (ch.cyberduck.core.s3.S3VersionedObjectListService)1 S3WriteFeature (ch.cyberduck.core.s3.S3WriteFeature)1 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)1 IntegrationTest (ch.cyberduck.test.IntegrationTest)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Test (org.junit.Test)1