diff --git a/main/filesystem-invariants-tests/src/test/java/org/cryptomator/filesystem/invariants/FolderChildrenTests.java b/main/filesystem-invariants-tests/src/test/java/org/cryptomator/filesystem/invariants/FolderChildrenTests.java index d0ca106ed..ba304b0ef 100644 --- a/main/filesystem-invariants-tests/src/test/java/org/cryptomator/filesystem/invariants/FolderChildrenTests.java +++ b/main/filesystem-invariants-tests/src/test/java/org/cryptomator/filesystem/invariants/FolderChildrenTests.java @@ -13,9 +13,9 @@ import java.io.UncheckedIOException; import org.cryptomator.filesystem.File; import org.cryptomator.filesystem.FileSystem; import org.cryptomator.filesystem.Folder; -import org.cryptomator.filesystem.invariants.FileBiFunctions.FileBiFunction; +import org.cryptomator.filesystem.invariants.WaysToObtainAFile.WayToObtainAFile; import org.cryptomator.filesystem.invariants.FileSystemFactories.FileSystemFactory; -import org.cryptomator.filesystem.invariants.FolderBiFunctions.FolderBiFunction; +import org.cryptomator.filesystem.invariants.WaysToObtainAFolder.WayToObtainAFolder; import org.junit.Rule; import org.junit.experimental.theories.DataPoints; import org.junit.experimental.theories.Theories; @@ -32,20 +32,20 @@ public class FolderChildrenTests { public static final Iterable FILE_SYSTEM_FACTORIES = new FileSystemFactories(); @DataPoints - public static final Iterable SUBFOLDER_BI_FUNCTIONS = new FolderBiFunctions(); + public static final Iterable WAYS_TO_OBTAIN_A_FOLDER = new WaysToObtainAFolder(); @DataPoints - public static final Iterable SUBFILE_BI_FUNCTIONS = new FileBiFunctions(); + public static final Iterable WAYS_TO_OBTAIN_A_FILE = new WaysToObtainAFile(); @Rule public final ExpectedException thrown = ExpectedException.none(); @Theory - public void testChildrenThrowsExceptionIfFolderDoesNotExist(FileSystemFactory fileSystemFactory, FolderBiFunction folderFunction) { + public void testChildrenThrowsExceptionIfFolderDoesNotExist(FileSystemFactory fileSystemFactory, WayToObtainAFolder folderFunction) { assumeThat(folderFunction.returnedFoldersExist(), is(false)); FileSystem fileSystem = fileSystemFactory.create(); - Folder nonExistingFolder = folderFunction.subfolderWithName(fileSystem, FOLDER_NAME); + Folder nonExistingFolder = folderFunction.folderWithName(fileSystem, FOLDER_NAME); thrown.expect(UncheckedIOException.class); @@ -53,11 +53,11 @@ public class FolderChildrenTests { } @Theory - public void testFilesThrowsExceptionIfFolderDoesNotExist(FileSystemFactory fileSystemFactory, FolderBiFunction folderFunction) { + public void testFilesThrowsExceptionIfFolderDoesNotExist(FileSystemFactory fileSystemFactory, WayToObtainAFolder folderFunction) { assumeThat(folderFunction.returnedFoldersExist(), is(false)); FileSystem fileSystem = fileSystemFactory.create(); - Folder nonExistingFolder = folderFunction.subfolderWithName(fileSystem, FOLDER_NAME); + Folder nonExistingFolder = folderFunction.folderWithName(fileSystem, FOLDER_NAME); thrown.expect(UncheckedIOException.class); @@ -65,11 +65,11 @@ public class FolderChildrenTests { } @Theory - public void testFoldersThrowsExceptionIfFolderDoesNotExist(FileSystemFactory fileSystemFactory, FolderBiFunction folderFunction) { + public void testFoldersThrowsExceptionIfFolderDoesNotExist(FileSystemFactory fileSystemFactory, WayToObtainAFolder folderFunction) { assumeThat(folderFunction.returnedFoldersExist(), is(false)); FileSystem fileSystem = fileSystemFactory.create(); - Folder nonExistingFolder = folderFunction.subfolderWithName(fileSystem, FOLDER_NAME); + Folder nonExistingFolder = folderFunction.folderWithName(fileSystem, FOLDER_NAME); thrown.expect(UncheckedIOException.class); @@ -77,87 +77,87 @@ public class FolderChildrenTests { } @Theory - public void testChildrenIsEmptyForEmptyFolder(FileSystemFactory fileSystemFactory, FolderBiFunction folderFunction) { + public void testChildrenIsEmptyForEmptyFolder(FileSystemFactory fileSystemFactory, WayToObtainAFolder folderFunction) { assumeThat(folderFunction.returnedFoldersExist(), is(true)); FileSystem fileSystem = fileSystemFactory.create(); - Folder existingFolder = folderFunction.subfolderWithName(fileSystem, FOLDER_NAME); + Folder existingFolder = folderFunction.folderWithName(fileSystem, FOLDER_NAME); assertThat(existingFolder.children().count(), is(0L)); } @Theory - public void testFilesIsEmptyForEmptyFolder(FileSystemFactory fileSystemFactory, FolderBiFunction folderFunction) { + public void testFilesIsEmptyForEmptyFolder(FileSystemFactory fileSystemFactory, WayToObtainAFolder folderFunction) { assumeThat(folderFunction.returnedFoldersExist(), is(true)); FileSystem fileSystem = fileSystemFactory.create(); - Folder existingFolder = folderFunction.subfolderWithName(fileSystem, FOLDER_NAME); + Folder existingFolder = folderFunction.folderWithName(fileSystem, FOLDER_NAME); assertThat(existingFolder.files().count(), is(0L)); } @Theory - public void testFoldersIsEmptyForEmptyFolder(FileSystemFactory fileSystemFactory, FolderBiFunction folderFunction) { + public void testFoldersIsEmptyForEmptyFolder(FileSystemFactory fileSystemFactory, WayToObtainAFolder folderFunction) { assumeThat(folderFunction.returnedFoldersExist(), is(true)); FileSystem fileSystem = fileSystemFactory.create(); - Folder existingFolder = folderFunction.subfolderWithName(fileSystem, FOLDER_NAME); + Folder existingFolder = folderFunction.folderWithName(fileSystem, FOLDER_NAME); assertThat(existingFolder.folders().count(), is(0L)); } @Theory - public void testChildrenContainsCreatedChildFolder(FileSystemFactory fileSystemFactory, FolderBiFunction existingFolderFunction, FolderBiFunction childExistingFolderFunction) { + public void testChildrenContainsCreatedChildFolder(FileSystemFactory fileSystemFactory, WayToObtainAFolder existingFolderFunction, WayToObtainAFolder childExistingFolderFunction) { assumeThat(existingFolderFunction.returnedFoldersExist(), is(true)); assumeThat(childExistingFolderFunction.returnedFoldersExist(), is(true)); String childName = "childFolderName"; FileSystem fileSystem = fileSystemFactory.create(); - Folder existingFolder = existingFolderFunction.subfolderWithName(fileSystem, FOLDER_NAME); - Folder childFolder = childExistingFolderFunction.subfolderWithName(existingFolder, childName); + Folder existingFolder = existingFolderFunction.folderWithName(fileSystem, FOLDER_NAME); + Folder childFolder = childExistingFolderFunction.folderWithName(existingFolder, childName); assertThat(existingFolder.children().collect(toList()), containsInAnyOrder(equalTo(childFolder))); } @Theory - public void testChildrenDoesNotContainCreatedAndDeletedChildFolder(FileSystemFactory fileSystemFactory, FolderBiFunction existingFolderFunction, FolderBiFunction childExistingFolderFunction) { + public void testChildrenDoesNotContainCreatedAndDeletedChildFolder(FileSystemFactory fileSystemFactory, WayToObtainAFolder existingFolderFunction, WayToObtainAFolder childExistingFolderFunction) { assumeThat(existingFolderFunction.returnedFoldersExist(), is(true)); assumeThat(childExistingFolderFunction.returnedFoldersExist(), is(true)); String childName = "childFolderName"; FileSystem fileSystem = fileSystemFactory.create(); - Folder existingFolder = existingFolderFunction.subfolderWithName(fileSystem, FOLDER_NAME); - Folder childFolder = childExistingFolderFunction.subfolderWithName(existingFolder, childName); + Folder existingFolder = existingFolderFunction.folderWithName(fileSystem, FOLDER_NAME); + Folder childFolder = childExistingFolderFunction.folderWithName(existingFolder, childName); childFolder.delete(); assertThat(existingFolder.children().collect(toList()), is(empty())); } @Theory - public void testChildrenContainsCreatedFile(FileSystemFactory fileSystemFactory, FolderBiFunction existingFolderFunction, FileBiFunction existingFileFunction) { + public void testChildrenContainsCreatedFile(FileSystemFactory fileSystemFactory, WayToObtainAFolder existingFolderFunction, WayToObtainAFile existingFileFunction) { assumeThat(existingFolderFunction.returnedFoldersExist(), is(true)); assumeThat(existingFileFunction.returnedFilesExist(), is(true)); String childName = "childFolderName"; FileSystem fileSystem = fileSystemFactory.create(); - Folder existingFolder = existingFolderFunction.subfolderWithName(fileSystem, FOLDER_NAME); + Folder existingFolder = existingFolderFunction.folderWithName(fileSystem, FOLDER_NAME); File file = existingFileFunction.fileWithName(existingFolder, childName); assertThat(existingFolder.children().collect(toList()), containsInAnyOrder(equalTo(file))); } @Theory - public void testChildrenDoesNotContainCreatedAndDeletedFile(FileSystemFactory fileSystemFactory, FolderBiFunction existingFolderFunction, FileBiFunction existingFileFunction) { + public void testChildrenDoesNotContainCreatedAndDeletedFile(FileSystemFactory fileSystemFactory, WayToObtainAFolder existingFolderFunction, WayToObtainAFile existingFileFunction) { assumeThat(existingFolderFunction.returnedFoldersExist(), is(true)); assumeThat(existingFileFunction.returnedFilesExist(), is(true)); String childName = "childFolderName"; FileSystem fileSystem = fileSystemFactory.create(); - Folder existingFolder = existingFolderFunction.subfolderWithName(fileSystem, FOLDER_NAME); + Folder existingFolder = existingFolderFunction.folderWithName(fileSystem, FOLDER_NAME); File file = existingFileFunction.fileWithName(existingFolder, childName); file.delete(); @@ -165,14 +165,14 @@ public class FolderChildrenTests { } @Theory - public void testFoldersDoesNotContainAndFilesContainsCreatedFile(FileSystemFactory fileSystemFactory, FolderBiFunction existingFolderFunction, FileBiFunction existingFileFunction) { + public void testFoldersDoesNotContainAndFilesContainsCreatedFile(FileSystemFactory fileSystemFactory, WayToObtainAFolder existingFolderFunction, WayToObtainAFile existingFileFunction) { assumeThat(existingFolderFunction.returnedFoldersExist(), is(true)); assumeThat(existingFileFunction.returnedFilesExist(), is(true)); String childName = "childFolderName"; FileSystem fileSystem = fileSystemFactory.create(); - Folder existingFolder = existingFolderFunction.subfolderWithName(fileSystem, FOLDER_NAME); + Folder existingFolder = existingFolderFunction.folderWithName(fileSystem, FOLDER_NAME); File file = existingFileFunction.fileWithName(existingFolder, childName); assertThat(existingFolder.folders().collect(toList()), is(empty())); @@ -180,14 +180,14 @@ public class FolderChildrenTests { } @Theory - public void testFoldersAndFilesDoesNotContainCreatedAndDeletedFile(FileSystemFactory fileSystemFactory, FolderBiFunction existingFolderFunction, FileBiFunction existingFileFunction) { + public void testFoldersAndFilesDoesNotContainCreatedAndDeletedFile(FileSystemFactory fileSystemFactory, WayToObtainAFolder existingFolderFunction, WayToObtainAFile existingFileFunction) { assumeThat(existingFolderFunction.returnedFoldersExist(), is(true)); assumeThat(existingFileFunction.returnedFilesExist(), is(true)); String childName = "childFolderName"; FileSystem fileSystem = fileSystemFactory.create(); - Folder existingFolder = existingFolderFunction.subfolderWithName(fileSystem, FOLDER_NAME); + Folder existingFolder = existingFolderFunction.folderWithName(fileSystem, FOLDER_NAME); File file = existingFileFunction.fileWithName(existingFolder, childName); file.delete(); @@ -196,30 +196,30 @@ public class FolderChildrenTests { } @Theory - public void testFoldersContainsAndFilesDoesNotContainCreatedChildFolder(FileSystemFactory fileSystemFactory, FolderBiFunction existingFolderFunction, FolderBiFunction childExistingFolderFunction) { + public void testFoldersContainsAndFilesDoesNotContainCreatedChildFolder(FileSystemFactory fileSystemFactory, WayToObtainAFolder existingFolderFunction, WayToObtainAFolder childExistingFolderFunction) { assumeThat(existingFolderFunction.returnedFoldersExist(), is(true)); assumeThat(childExistingFolderFunction.returnedFoldersExist(), is(true)); String childName = "childFolderName"; FileSystem fileSystem = fileSystemFactory.create(); - Folder existingFolder = existingFolderFunction.subfolderWithName(fileSystem, FOLDER_NAME); - Folder childFolder = childExistingFolderFunction.subfolderWithName(existingFolder, childName); + Folder existingFolder = existingFolderFunction.folderWithName(fileSystem, FOLDER_NAME); + Folder childFolder = childExistingFolderFunction.folderWithName(existingFolder, childName); assertThat(existingFolder.folders().collect(toList()), containsInAnyOrder(equalTo(childFolder))); assertThat(existingFolder.files().collect(toList()), is(empty())); } @Theory - public void testFoldersAndFilesDoesNotContainCreatedAndDeletedChildFolder(FileSystemFactory fileSystemFactory, FolderBiFunction existingFolderFunction, FolderBiFunction childExistingFolderFunction) { + public void testFoldersAndFilesDoesNotContainCreatedAndDeletedChildFolder(FileSystemFactory fileSystemFactory, WayToObtainAFolder existingFolderFunction, WayToObtainAFolder childExistingFolderFunction) { assumeThat(existingFolderFunction.returnedFoldersExist(), is(true)); assumeThat(childExistingFolderFunction.returnedFoldersExist(), is(true)); String childName = "childFolderName"; FileSystem fileSystem = fileSystemFactory.create(); - Folder existingFolder = existingFolderFunction.subfolderWithName(fileSystem, FOLDER_NAME); - Folder childFolder = childExistingFolderFunction.subfolderWithName(existingFolder, childName); + Folder existingFolder = existingFolderFunction.folderWithName(fileSystem, FOLDER_NAME); + Folder childFolder = childExistingFolderFunction.folderWithName(existingFolder, childName); childFolder.delete(); assertThat(existingFolder.folders().collect(toList()), is(empty())); diff --git a/main/filesystem-invariants-tests/src/test/java/org/cryptomator/filesystem/invariants/FolderTests.java b/main/filesystem-invariants-tests/src/test/java/org/cryptomator/filesystem/invariants/FolderTests.java index 123ffd569..0afd15dcd 100644 --- a/main/filesystem-invariants-tests/src/test/java/org/cryptomator/filesystem/invariants/FolderTests.java +++ b/main/filesystem-invariants-tests/src/test/java/org/cryptomator/filesystem/invariants/FolderTests.java @@ -12,7 +12,7 @@ import org.cryptomator.filesystem.File; import org.cryptomator.filesystem.FileSystem; import org.cryptomator.filesystem.Folder; import org.cryptomator.filesystem.invariants.FileSystemFactories.FileSystemFactory; -import org.cryptomator.filesystem.invariants.FolderBiFunctions.FolderBiFunction; +import org.cryptomator.filesystem.invariants.WaysToObtainAFolder.WayToObtainAFolder; import org.junit.Rule; import org.junit.experimental.theories.DataPoints; import org.junit.experimental.theories.Theories; @@ -36,7 +36,7 @@ public class FolderTests { public static final Iterable FILE_SYSTEM_FACTORIES = new FileSystemFactories(); @DataPoints - public static final Iterable SUBFOLDER_FACTORIES = new FolderBiFunctions(); + public static final Iterable WAYS_TO_OBTAIN_A_FOLDER = new WaysToObtainAFolder(); @Rule public final ExpectedException thrown = ExpectedException.none(); @@ -49,10 +49,10 @@ public class FolderTests { } @Theory - public void testFolderOnSubfolderReturnsFolder(FileSystemFactory fileSystemFactory, FolderBiFunction folderBiFunction) { + public void testFolderOnSubfolderReturnsFolder(FileSystemFactory fileSystemFactory, WayToObtainAFolder folderBiFunction) { FileSystem fileSystem = fileSystemFactory.create(); - Folder folder = folderBiFunction.subfolderWithName(fileSystem, FOLDER_NAME); + Folder folder = folderBiFunction.folderWithName(fileSystem, FOLDER_NAME); assertThat(folder.folder(FOLDER_NAME), is(notNullValue())); } @@ -69,10 +69,10 @@ public class FolderTests { } @Theory - public void testResolveFolderOnSubfolderReturnsFolder(FileSystemFactory fileSystemFactory, FolderBiFunction folderBiFunction) { + public void testResolveFolderOnSubfolderReturnsFolder(FileSystemFactory fileSystemFactory, WayToObtainAFolder folderBiFunction) { FileSystem fileSystem = fileSystemFactory.create(); - Folder folder = folderBiFunction.subfolderWithName(fileSystem, FOLDER_NAME); + Folder folder = folderBiFunction.folderWithName(fileSystem, FOLDER_NAME); Folder resolvedFolder = folder.resolveFolder(PATH); assertThat(resolvedFolder, is(folderWithName(PATH_NAME_2))); @@ -88,10 +88,10 @@ public class FolderTests { } @Theory - public void testFileOnSubfolderReturnsFile(FileSystemFactory fileSystemFactory, FolderBiFunction folderBiFunction) { + public void testFileOnSubfolderReturnsFile(FileSystemFactory fileSystemFactory, WayToObtainAFolder folderBiFunction) { FileSystem fileSystem = fileSystemFactory.create(); - Folder folder = folderBiFunction.subfolderWithName(fileSystem, FOLDER_NAME); + Folder folder = folderBiFunction.folderWithName(fileSystem, FOLDER_NAME); assertThat(folder.file(FILE_NAME), is(notNullValue())); } @@ -108,10 +108,10 @@ public class FolderTests { } @Theory - public void testResolveFileOnSubfolderReturnsFile(FileSystemFactory fileSystemFactory, FolderBiFunction folderBiFunction) { + public void testResolveFileOnSubfolderReturnsFile(FileSystemFactory fileSystemFactory, WayToObtainAFolder folderBiFunction) { FileSystem fileSystem = fileSystemFactory.create(); - Folder folder = folderBiFunction.subfolderWithName(fileSystem, FOLDER_NAME); + Folder folder = folderBiFunction.folderWithName(fileSystem, FOLDER_NAME); File resolvedFile = folder.resolveFile(PATH); assertThat(resolvedFile, is(fileWithName(PATH_NAME_2))); @@ -120,82 +120,82 @@ public class FolderTests { } @Theory - public void testExistingFolderExists(FileSystemFactory fileSystemFactory, FolderBiFunction folderBiFunction) { + public void testExistingFolderExists(FileSystemFactory fileSystemFactory, WayToObtainAFolder folderBiFunction) { assumeThat(folderBiFunction.returnedFoldersExist(), is(true)); FileSystem fileSystem = fileSystemFactory.create(); - Folder existingFolder = folderBiFunction.subfolderWithName(fileSystem, FOLDER_NAME); + Folder existingFolder = folderBiFunction.folderWithName(fileSystem, FOLDER_NAME); assertThat(existingFolder.exists(), is(true)); } @Theory - public void testNonExistingFolderDoesntExists(FileSystemFactory fileSystemFactory, FolderBiFunction folderBiFunction) { + public void testNonExistingFolderDoesntExists(FileSystemFactory fileSystemFactory, WayToObtainAFolder folderBiFunction) { assumeThat(folderBiFunction.returnedFoldersExist(), is(false)); FileSystem fileSystem = fileSystemFactory.create(); - Folder existingFolder = folderBiFunction.subfolderWithName(fileSystem, FOLDER_NAME); + Folder existingFolder = folderBiFunction.folderWithName(fileSystem, FOLDER_NAME); assertThat(existingFolder.exists(), is(false)); } @Theory - public void testFolderIsNotAncecstorOfItself(FileSystemFactory fileSystemFactory, FolderBiFunction folderBiFunction) { + public void testFolderIsNotAncecstorOfItself(FileSystemFactory fileSystemFactory, WayToObtainAFolder folderBiFunction) { FileSystem fileSystem = fileSystemFactory.create(); - Folder folder = folderBiFunction.subfolderWithName(fileSystem, FOLDER_NAME); + Folder folder = folderBiFunction.folderWithName(fileSystem, FOLDER_NAME); assertThat(folder.isAncestorOf(folder), is(false)); } @Theory - public void testFolderIsNotAncecstorOfItsParent(FileSystemFactory fileSystemFactory, FolderBiFunction folderBiFunction) { + public void testFolderIsNotAncecstorOfItsParent(FileSystemFactory fileSystemFactory, WayToObtainAFolder folderBiFunction) { FileSystem fileSystem = fileSystemFactory.create(); - Folder parent = folderBiFunction.subfolderWithName(fileSystem, FOLDER_NAME); - Folder child = folderBiFunction.subfolderWithName(parent, FOLDER_NAME); + Folder parent = folderBiFunction.folderWithName(fileSystem, FOLDER_NAME); + Folder child = folderBiFunction.folderWithName(parent, FOLDER_NAME); assertThat(child.isAncestorOf(parent), is(false)); } @Theory - public void testFolderIsNotAncecstorOfItsParentsParent(FileSystemFactory fileSystemFactory, FolderBiFunction folderBiFunction) { + public void testFolderIsNotAncecstorOfItsParentsParent(FileSystemFactory fileSystemFactory, WayToObtainAFolder folderBiFunction) { FileSystem fileSystem = fileSystemFactory.create(); - Folder parentsParent = folderBiFunction.subfolderWithName(fileSystem, FOLDER_NAME); - Folder parent = folderBiFunction.subfolderWithName(parentsParent, FOLDER_NAME); - Folder child = folderBiFunction.subfolderWithName(parent, FOLDER_NAME); + Folder parentsParent = folderBiFunction.folderWithName(fileSystem, FOLDER_NAME); + Folder parent = folderBiFunction.folderWithName(parentsParent, FOLDER_NAME); + Folder child = folderBiFunction.folderWithName(parent, FOLDER_NAME); assertThat(child.isAncestorOf(parentsParent), is(false)); } @Theory - public void testFolderIsNotAncecstorOfItsSibling(FileSystemFactory fileSystemFactory, FolderBiFunction folderBiFunction) { + public void testFolderIsNotAncecstorOfItsSibling(FileSystemFactory fileSystemFactory, WayToObtainAFolder folderBiFunction) { FileSystem fileSystem = fileSystemFactory.create(); - Folder folder = folderBiFunction.subfolderWithName(fileSystem, FOLDER_NAME); - Folder sibling = folderBiFunction.subfolderWithName(fileSystem, FOLDER_NAME_2); + Folder folder = folderBiFunction.folderWithName(fileSystem, FOLDER_NAME); + Folder sibling = folderBiFunction.folderWithName(fileSystem, FOLDER_NAME_2); assertThat(folder.isAncestorOf(sibling), is(false)); } @Theory - public void testFolderIsAncecstorOfItsChild(FileSystemFactory fileSystemFactory, FolderBiFunction folderBiFunction) { + public void testFolderIsAncecstorOfItsChild(FileSystemFactory fileSystemFactory, WayToObtainAFolder folderBiFunction) { FileSystem fileSystem = fileSystemFactory.create(); - Folder folder = folderBiFunction.subfolderWithName(fileSystem, FOLDER_NAME); - Folder child = folderBiFunction.subfolderWithName(folder, FOLDER_NAME); + Folder folder = folderBiFunction.folderWithName(fileSystem, FOLDER_NAME); + Folder child = folderBiFunction.folderWithName(folder, FOLDER_NAME); assertThat(folder.isAncestorOf(child), is(true)); } @Theory - public void testFolderIsAncecstorOfItsChildsChild(FileSystemFactory fileSystemFactory, FolderBiFunction folderBiFunction) { + public void testFolderIsAncecstorOfItsChildsChild(FileSystemFactory fileSystemFactory, WayToObtainAFolder folderBiFunction) { FileSystem fileSystem = fileSystemFactory.create(); - Folder folder = folderBiFunction.subfolderWithName(fileSystem, FOLDER_NAME); - Folder child = folderBiFunction.subfolderWithName(folder, FOLDER_NAME); - Folder childsChild = folderBiFunction.subfolderWithName(child, FOLDER_NAME); + Folder folder = folderBiFunction.folderWithName(fileSystem, FOLDER_NAME); + Folder child = folderBiFunction.folderWithName(folder, FOLDER_NAME); + Folder childsChild = folderBiFunction.folderWithName(child, FOLDER_NAME); assertThat(folder.isAncestorOf(childsChild), is(true)); } diff --git a/main/filesystem-invariants-tests/src/test/java/org/cryptomator/filesystem/invariants/FileBiFunctions.java b/main/filesystem-invariants-tests/src/test/java/org/cryptomator/filesystem/invariants/WaysToObtainAFile.java similarity index 64% rename from main/filesystem-invariants-tests/src/test/java/org/cryptomator/filesystem/invariants/FileBiFunctions.java rename to main/filesystem-invariants-tests/src/test/java/org/cryptomator/filesystem/invariants/WaysToObtainAFile.java index 313a2c227..ec150293b 100644 --- a/main/filesystem-invariants-tests/src/test/java/org/cryptomator/filesystem/invariants/FileBiFunctions.java +++ b/main/filesystem-invariants-tests/src/test/java/org/cryptomator/filesystem/invariants/WaysToObtainAFile.java @@ -8,13 +8,13 @@ import java.util.List; import org.cryptomator.filesystem.File; import org.cryptomator.filesystem.Folder; import org.cryptomator.filesystem.WritableFile; -import org.cryptomator.filesystem.invariants.FileBiFunctions.FileBiFunction; +import org.cryptomator.filesystem.invariants.WaysToObtainAFile.WayToObtainAFile; -class FileBiFunctions implements Iterable { +class WaysToObtainAFile implements Iterable { - private final List factories = new ArrayList<>(); + private final List values = new ArrayList<>(); - public FileBiFunctions() { + public WaysToObtainAFile() { addNonExisting("invoke file", this::invokeFile); addExisting("create file by writing to it", this::createFileUsingTouch); @@ -32,8 +32,8 @@ class FileBiFunctions implements Iterable { return result; } - private void addExisting(String name, ExistingFileBiFunction factory) { - factories.add(new ExistingFileBiFunction() { + private void addExisting(String name, WayToObtainAFileThatExists factory) { + values.add(new WayToObtainAFileThatExists() { @Override public File fileWithName(Folder parent, String name) { return factory.fileWithName(parent, name); @@ -46,8 +46,8 @@ class FileBiFunctions implements Iterable { }); } - private void addNonExisting(String name, NonExistingFileBiFunction factory) { - factories.add(new NonExistingFileBiFunction() { + private void addNonExisting(String name, WayToObtainAFileThatDoesntExist factory) { + values.add(new WayToObtainAFileThatDoesntExist() { @Override public File fileWithName(Folder parent, String name) { return factory.fileWithName(parent, name); @@ -60,7 +60,7 @@ class FileBiFunctions implements Iterable { }); } - public interface FileBiFunction { + public interface WayToObtainAFile { File fileWithName(Folder parent, String name); @@ -68,14 +68,14 @@ class FileBiFunctions implements Iterable { } - public interface ExistingFileBiFunction extends FileBiFunction { + public interface WayToObtainAFileThatExists extends WayToObtainAFile { @Override default boolean returnedFilesExist() { return true; } } - public interface NonExistingFileBiFunction extends FileBiFunction { + public interface WayToObtainAFileThatDoesntExist extends WayToObtainAFile { @Override default boolean returnedFilesExist() { return false; @@ -83,8 +83,8 @@ class FileBiFunctions implements Iterable { } @Override - public Iterator iterator() { - return factories.iterator(); + public Iterator iterator() { + return values.iterator(); } } diff --git a/main/filesystem-invariants-tests/src/test/java/org/cryptomator/filesystem/invariants/FolderBiFunctions.java b/main/filesystem-invariants-tests/src/test/java/org/cryptomator/filesystem/invariants/WaysToObtainAFolder.java similarity index 59% rename from main/filesystem-invariants-tests/src/test/java/org/cryptomator/filesystem/invariants/FolderBiFunctions.java rename to main/filesystem-invariants-tests/src/test/java/org/cryptomator/filesystem/invariants/WaysToObtainAFolder.java index a8510ac8d..17ec0f9ee 100644 --- a/main/filesystem-invariants-tests/src/test/java/org/cryptomator/filesystem/invariants/FolderBiFunctions.java +++ b/main/filesystem-invariants-tests/src/test/java/org/cryptomator/filesystem/invariants/WaysToObtainAFolder.java @@ -5,13 +5,13 @@ import java.util.Iterator; import java.util.List; import org.cryptomator.filesystem.Folder; -import org.cryptomator.filesystem.invariants.FolderBiFunctions.FolderBiFunction; +import org.cryptomator.filesystem.invariants.WaysToObtainAFolder.WayToObtainAFolder; -class FolderBiFunctions implements Iterable { +class WaysToObtainAFolder implements Iterable { - private final List factories = new ArrayList<>(); + private final List values = new ArrayList<>(); - public FolderBiFunctions() { + public WaysToObtainAFolder() { addNonExisting("invoke folder", this::invokeFolder); addNonExisting("create and delete", this::createAndDeleteFolder); addNonExisting("delete by moving", this::deleteFolderByMoving); @@ -41,14 +41,14 @@ class FolderBiFunctions implements Iterable { private Folder deleteFolderByMoving(Folder parent, String name) { Folder result = parent.folder(name); result.create(); - Folder target = parent.folder("subfolderFactoryMoveFolderAway"); + Folder target = parent.folder("willNotExistMoveFolderAway"); result.moveTo(target); target.delete(); return result; } private Folder createByMoving(Folder parent, String name) { - Folder temporary = parent.folder("subfolderFactoryCreateByMoving"); + Folder temporary = parent.folder("willNotExistCreateByMoving"); temporary.create(); Folder target = parent.folder(name); temporary.moveTo(target); @@ -56,7 +56,7 @@ class FolderBiFunctions implements Iterable { } private Folder createByCopying(Folder parent, String name) { - Folder temporary = parent.folder("subfolderFactoryCreateByCopying"); + Folder temporary = parent.folder("willNotExistCreateByCopying"); temporary.create(); Folder target = parent.folder(name); temporary.copyTo(target); @@ -64,11 +64,11 @@ class FolderBiFunctions implements Iterable { return target; } - private void addExisting(String name, ExistingSubfolderBiFunction factory) { - factories.add(new ExistingSubfolderBiFunction() { + private void addExisting(String name, WayToObtainAFolderThatExists factory) { + values.add(new WayToObtainAFolderThatExists() { @Override - public Folder subfolderWithName(Folder parent, String name) { - return factory.subfolderWithName(parent, name); + public Folder folderWithName(Folder parent, String name) { + return factory.folderWithName(parent, name); } @Override @@ -78,11 +78,11 @@ class FolderBiFunctions implements Iterable { }); } - private void addNonExisting(String name, NonExistingSubfolderSubfolderBiFunction factory) { - factories.add(new NonExistingSubfolderSubfolderBiFunction() { + private void addNonExisting(String name, WayToObtainAFolderThatDoesntExists factory) { + values.add(new WayToObtainAFolderThatDoesntExists() { @Override - public Folder subfolderWithName(Folder parent, String name) { - return factory.subfolderWithName(parent, name); + public Folder folderWithName(Folder parent, String name) { + return factory.folderWithName(parent, name); } @Override @@ -92,22 +92,22 @@ class FolderBiFunctions implements Iterable { }); } - public interface FolderBiFunction { + public interface WayToObtainAFolder { - Folder subfolderWithName(Folder parent, String name); + Folder folderWithName(Folder parent, String name); boolean returnedFoldersExist(); } - public interface ExistingSubfolderBiFunction extends FolderBiFunction { + public interface WayToObtainAFolderThatExists extends WayToObtainAFolder { @Override default boolean returnedFoldersExist() { return true; } } - public interface NonExistingSubfolderSubfolderBiFunction extends FolderBiFunction { + public interface WayToObtainAFolderThatDoesntExists extends WayToObtainAFolder { @Override default boolean returnedFoldersExist() { return false; @@ -115,8 +115,8 @@ class FolderBiFunctions implements Iterable { } @Override - public Iterator iterator() { - return factories.iterator(); + public Iterator iterator() { + return values.iterator(); } }