Search in sources :

Example 1 with GraphMoveFeature

use of ch.cyberduck.core.onedrive.features.GraphMoveFeature in project cyberduck by iterate-ch.

the class GraphMoveFeatureTest method testMove.

@Test
public void testMove() throws Exception {
    final Path home = new OneDriveHomeFinderService().find();
    final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final Path folder = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final CryptoVault cryptomator = new CryptoVault(vault);
    cryptomator.create(session, new VaultCredentials("test"), new DisabledPasswordStore(), vaultVersion);
    session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    cryptomator.getFeature(session, Directory.class, new GraphDirectoryFeature(session, fileid)).mkdir(folder, new TransferStatus());
    final String filename = new AlphanumericRandomStringService().random();
    final Path file = new CryptoTouchFeature<>(session, new DefaultTouchFeature<>(new GraphWriteFeature(session, fileid)), new GraphWriteFeature(session, fileid), cryptomator).touch(new Path(folder, filename, EnumSet.of(Path.Type.file)), new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(file));
    final Move move = cryptomator.getFeature(session, Move.class, new GraphMoveFeature(session, fileid));
    // rename file
    final Path fileRenamed = move.move(file, new Path(folder, "f1", EnumSet.of(Path.Type.file)), new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback());
    assertEquals(file.attributes().getFileId(), fileRenamed.attributes().getFileId());
    assertFalse(new CryptoFindFeature(session, new GraphFindFeature(session, fileid), cryptomator).find(new Path(folder, filename, EnumSet.of(Path.Type.file))));
    assertTrue(new CryptoFindFeature(session, new GraphFindFeature(session, fileid), cryptomator).find(fileRenamed));
    assertEquals(fileRenamed.attributes().getModificationDate(), new CryptoAttributesFeature(session, new GraphAttributesFinderFeature(session, fileid), cryptomator).find(fileRenamed).getModificationDate());
    // rename folder
    final Path folderRenamed = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    move.move(folder, folderRenamed, new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback());
    assertFalse(new CryptoFindFeature(session, new GraphFindFeature(session, fileid), cryptomator).find(folder));
    assertTrue(new CryptoFindFeature(session, new GraphFindFeature(session, fileid), cryptomator).find(folderRenamed));
    final Path fileRenamedInRenamedFolder = new Path(folderRenamed, "f1", EnumSet.of(Path.Type.file));
    assertTrue(new CryptoFindFeature(session, new GraphFindFeature(session, fileid), cryptomator).find(fileRenamedInRenamedFolder));
    cryptomator.getFeature(session, Delete.class, new GraphDeleteFeature(session, fileid)).delete(Arrays.asList(fileRenamedInRenamedFolder, folderRenamed, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Delete(ch.cyberduck.core.features.Delete) GraphMoveFeature(ch.cyberduck.core.onedrive.features.GraphMoveFeature) GraphDirectoryFeature(ch.cyberduck.core.onedrive.features.GraphDirectoryFeature) OneDriveHomeFinderService(ch.cyberduck.core.onedrive.OneDriveHomeFinderService) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DefaultFindFeature(ch.cyberduck.core.shared.DefaultFindFeature) Move(ch.cyberduck.core.features.Move) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) Directory(ch.cyberduck.core.features.Directory) Path(ch.cyberduck.core.Path) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) GraphWriteFeature(ch.cyberduck.core.onedrive.features.GraphWriteFeature) GraphAttributesFinderFeature(ch.cyberduck.core.onedrive.features.GraphAttributesFinderFeature) CryptoFindFeature(ch.cyberduck.core.cryptomator.features.CryptoFindFeature) CryptoAttributesFeature(ch.cyberduck.core.cryptomator.features.CryptoAttributesFeature) DefaultTouchFeature(ch.cyberduck.core.shared.DefaultTouchFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) GraphDeleteFeature(ch.cyberduck.core.onedrive.features.GraphDeleteFeature) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) GraphFindFeature(ch.cyberduck.core.onedrive.features.GraphFindFeature) AbstractOneDriveTest(ch.cyberduck.core.onedrive.AbstractOneDriveTest) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 2 with GraphMoveFeature

use of ch.cyberduck.core.onedrive.features.GraphMoveFeature in project cyberduck by iterate-ch.

the class GraphMoveFeatureTest method testMoveToRoot.

@Test
public void testMoveToRoot() throws BackgroundException {
    final Directory directory = new GraphDirectoryFeature(session, fileid);
    final Touch touch = new GraphTouchFeature(session, fileid);
    final Move move = new GraphMoveFeature(session, fileid);
    final Delete delete = new GraphDeleteFeature(session, fileid);
    final AttributesFinder attributesFinder = new GraphAttributesFinderFeature(session, fileid);
    final Path drive = new OneDriveHomeFinderService().find();
    Path targetDirectory = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    directory.mkdir(targetDirectory, new TransferStatus());
    assertNotNull(attributesFinder.find(targetDirectory));
    Path touchedFile = new Path(targetDirectory, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    touch.touch(touchedFile, new TransferStatus().withMime("x-application/cyberduck"));
    assertNotNull(attributesFinder.find(touchedFile));
    Path rename = new Path(drive, touchedFile.getName(), EnumSet.of(Path.Type.file));
    assertTrue(move.isSupported(touchedFile, rename));
    move.move(touchedFile, rename, new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback());
    assertNotNull(attributesFinder.find(rename));
    delete.delete(Collections.singletonList(targetDirectory), new DisabledLoginCallback(), new Delete.DisabledCallback());
    delete.delete(Collections.singletonList(rename), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Delete(ch.cyberduck.core.features.Delete) Path(ch.cyberduck.core.Path) GraphAttributesFinderFeature(ch.cyberduck.core.onedrive.features.GraphAttributesFinderFeature) AttributesFinder(ch.cyberduck.core.features.AttributesFinder) GraphMoveFeature(ch.cyberduck.core.onedrive.features.GraphMoveFeature) Touch(ch.cyberduck.core.features.Touch) GraphTouchFeature(ch.cyberduck.core.onedrive.features.GraphTouchFeature) GraphDirectoryFeature(ch.cyberduck.core.onedrive.features.GraphDirectoryFeature) Move(ch.cyberduck.core.features.Move) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) GraphDeleteFeature(ch.cyberduck.core.onedrive.features.GraphDeleteFeature) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) Directory(ch.cyberduck.core.features.Directory) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 3 with GraphMoveFeature

use of ch.cyberduck.core.onedrive.features.GraphMoveFeature in project cyberduck by iterate-ch.

the class GraphMoveFeatureTest method testMoveRename.

@Test
public void testMoveRename() throws BackgroundException {
    final Directory directory = new GraphDirectoryFeature(session, fileid);
    final Touch touch = new GraphTouchFeature(session, fileid);
    final Move move = new GraphMoveFeature(session, fileid);
    final Delete delete = new GraphDeleteFeature(session, fileid);
    final AttributesFinder attributesFinder = new GraphAttributesFinderFeature(session, fileid);
    final Path drive = new OneDriveHomeFinderService().find();
    Path targetDirectory = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    directory.mkdir(targetDirectory, new TransferStatus());
    assertNotNull(attributesFinder.find(targetDirectory));
    Path touchedFile = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    touch.touch(touchedFile, new TransferStatus().withMime("x-application/cyberduck"));
    assertNotNull(attributesFinder.find(touchedFile));
    Path rename = new Path(targetDirectory, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    assertTrue(move.isSupported(touchedFile, rename));
    move.move(touchedFile, rename, new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback());
    assertNotNull(attributesFinder.find(rename));
    delete.delete(Collections.singletonList(targetDirectory), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Delete(ch.cyberduck.core.features.Delete) Path(ch.cyberduck.core.Path) GraphAttributesFinderFeature(ch.cyberduck.core.onedrive.features.GraphAttributesFinderFeature) AttributesFinder(ch.cyberduck.core.features.AttributesFinder) GraphMoveFeature(ch.cyberduck.core.onedrive.features.GraphMoveFeature) Touch(ch.cyberduck.core.features.Touch) GraphTouchFeature(ch.cyberduck.core.onedrive.features.GraphTouchFeature) GraphDirectoryFeature(ch.cyberduck.core.onedrive.features.GraphDirectoryFeature) Move(ch.cyberduck.core.features.Move) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) GraphDeleteFeature(ch.cyberduck.core.onedrive.features.GraphDeleteFeature) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) Directory(ch.cyberduck.core.features.Directory) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 4 with GraphMoveFeature

use of ch.cyberduck.core.onedrive.features.GraphMoveFeature in project cyberduck by iterate-ch.

the class GraphMoveFeatureTest method testMove.

@Test
public void testMove() throws BackgroundException {
    final Directory directory = new GraphDirectoryFeature(session, fileid);
    final Touch touch = new GraphTouchFeature(session, fileid);
    final Move move = new GraphMoveFeature(session, fileid);
    final Delete delete = new GraphDeleteFeature(session, fileid);
    final AttributesFinder attributesFinder = new GraphAttributesFinderFeature(session, fileid);
    final Path drive = new OneDriveHomeFinderService().find();
    Path targetDirectory = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    directory.mkdir(targetDirectory, new TransferStatus());
    assertNotNull(attributesFinder.find(targetDirectory));
    Path touchedFile = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    touch.touch(touchedFile, new TransferStatus().withMime("x-application/cyberduck"));
    assertNotNull(attributesFinder.find(touchedFile));
    Path rename = new Path(targetDirectory, touchedFile.getName(), EnumSet.of(Path.Type.file));
    assertTrue(move.isSupported(touchedFile, rename));
    move.move(touchedFile, rename, new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback());
    assertNotNull(attributesFinder.find(rename));
    delete.delete(Collections.singletonList(targetDirectory), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Delete(ch.cyberduck.core.features.Delete) Path(ch.cyberduck.core.Path) GraphAttributesFinderFeature(ch.cyberduck.core.onedrive.features.GraphAttributesFinderFeature) AttributesFinder(ch.cyberduck.core.features.AttributesFinder) GraphMoveFeature(ch.cyberduck.core.onedrive.features.GraphMoveFeature) Touch(ch.cyberduck.core.features.Touch) GraphTouchFeature(ch.cyberduck.core.onedrive.features.GraphTouchFeature) GraphDirectoryFeature(ch.cyberduck.core.onedrive.features.GraphDirectoryFeature) Move(ch.cyberduck.core.features.Move) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) GraphDeleteFeature(ch.cyberduck.core.onedrive.features.GraphDeleteFeature) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) Directory(ch.cyberduck.core.features.Directory) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 5 with GraphMoveFeature

use of ch.cyberduck.core.onedrive.features.GraphMoveFeature in project cyberduck by iterate-ch.

the class GraphMoveFeatureTest method testMoveToExistingFile.

@Test
public void testMoveToExistingFile() throws Exception {
    final Path folder = new GraphDirectoryFeature(session, fileid).mkdir(new Path(new OneDriveHomeFinderService().find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
    final String name = new AlphanumericRandomStringService().random();
    final Path test = new GraphTouchFeature(session, fileid).touch(new Path(folder, name, EnumSet.of(Path.Type.file)), new TransferStatus());
    final Path temp = new GraphTouchFeature(session, fileid).touch(new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
    new GraphMoveFeature(session, fileid).move(temp, new Path(folder, name, EnumSet.of(Path.Type.file)), new TransferStatus().exists(true), new Delete.DisabledCallback(), new DisabledConnectionCallback());
    final Find find = new DefaultFindFeature(session);
    final AttributedList<Path> files = new GraphItemListService(session, fileid).list(folder, new DisabledListProgressListener());
    assertEquals(1, files.size());
    assertFalse(find.find(temp));
    assertTrue(find.find(test));
    new GraphDeleteFeature(session, fileid).delete(Collections.singletonList(folder), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) GraphMoveFeature(ch.cyberduck.core.onedrive.features.GraphMoveFeature) GraphTouchFeature(ch.cyberduck.core.onedrive.features.GraphTouchFeature) GraphDirectoryFeature(ch.cyberduck.core.onedrive.features.GraphDirectoryFeature) DefaultFindFeature(ch.cyberduck.core.shared.DefaultFindFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) Find(ch.cyberduck.core.features.Find) GraphDeleteFeature(ch.cyberduck.core.onedrive.features.GraphDeleteFeature) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Aggregations

AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)6 DisabledConnectionCallback (ch.cyberduck.core.DisabledConnectionCallback)6 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)6 Path (ch.cyberduck.core.Path)6 Delete (ch.cyberduck.core.features.Delete)6 GraphDeleteFeature (ch.cyberduck.core.onedrive.features.GraphDeleteFeature)6 GraphMoveFeature (ch.cyberduck.core.onedrive.features.GraphMoveFeature)6 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)6 IntegrationTest (ch.cyberduck.test.IntegrationTest)6 Test (org.junit.Test)6 Move (ch.cyberduck.core.features.Move)5 GraphAttributesFinderFeature (ch.cyberduck.core.onedrive.features.GraphAttributesFinderFeature)5 GraphDirectoryFeature (ch.cyberduck.core.onedrive.features.GraphDirectoryFeature)5 GraphTouchFeature (ch.cyberduck.core.onedrive.features.GraphTouchFeature)5 AttributesFinder (ch.cyberduck.core.features.AttributesFinder)4 Directory (ch.cyberduck.core.features.Directory)4 Touch (ch.cyberduck.core.features.Touch)4 DefaultFindFeature (ch.cyberduck.core.shared.DefaultFindFeature)2 DisabledListProgressListener (ch.cyberduck.core.DisabledListProgressListener)1 DisabledPasswordCallback (ch.cyberduck.core.DisabledPasswordCallback)1