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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations