mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-21 12:11:28 +00:00
Renamed classes [ci skip]
This commit is contained in:
@@ -13,7 +13,7 @@ import java.io.UncheckedIOException;
|
||||
import org.cryptomator.filesystem.FileSystem;
|
||||
import org.cryptomator.filesystem.Folder;
|
||||
import org.cryptomator.filesystem.invariants.FileSystemFactories.FileSystemFactory;
|
||||
import org.cryptomator.filesystem.invariants.SubfolderFactories.SubfolderFactory;
|
||||
import org.cryptomator.filesystem.invariants.SubfolderBiFunctions.SubfolderBiFunction;
|
||||
import org.junit.Rule;
|
||||
import org.junit.experimental.theories.DataPoints;
|
||||
import org.junit.experimental.theories.Theories;
|
||||
@@ -30,17 +30,17 @@ public class FolderChildrenTests {
|
||||
public static final Iterable<FileSystemFactory> FILE_SYSTEM_FACTORIES = new FileSystemFactories();
|
||||
|
||||
@DataPoints
|
||||
public static final Iterable<SubfolderFactory> SUBFOLDER_FACTORIES = new SubfolderFactories();
|
||||
public static final Iterable<SubfolderBiFunction> SUBFOLDER_BI_FUNCTIONS = new SubfolderBiFunctions();
|
||||
|
||||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Theory
|
||||
public void testChildrenThrowsExceptionIfFolderDoesNotExist(FileSystemFactory fileSystemFactory, SubfolderFactory subfolderFactory) {
|
||||
assumeThat(subfolderFactory.createsExistingFolder(), is(false));
|
||||
public void testChildrenThrowsExceptionIfFolderDoesNotExist(FileSystemFactory fileSystemFactory, SubfolderBiFunction subfolderFunction) {
|
||||
assumeThat(subfolderFunction.returnedFoldersExist(), is(false));
|
||||
|
||||
FileSystem fileSystem = fileSystemFactory.create();
|
||||
Folder nonExistingFolder = subfolderFactory.subfolderWithName(fileSystem, FOLDER_NAME);
|
||||
Folder nonExistingFolder = subfolderFunction.subfolderWithName(fileSystem, FOLDER_NAME);
|
||||
|
||||
thrown.expect(UncheckedIOException.class);
|
||||
|
||||
@@ -48,11 +48,11 @@ public class FolderChildrenTests {
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void testFilesThrowsExceptionIfFolderDoesNotExist(FileSystemFactory fileSystemFactory, SubfolderFactory subfolderFactory) {
|
||||
assumeThat(subfolderFactory.createsExistingFolder(), is(false));
|
||||
public void testFilesThrowsExceptionIfFolderDoesNotExist(FileSystemFactory fileSystemFactory, SubfolderBiFunction subfolderFunction) {
|
||||
assumeThat(subfolderFunction.returnedFoldersExist(), is(false));
|
||||
|
||||
FileSystem fileSystem = fileSystemFactory.create();
|
||||
Folder nonExistingFolder = subfolderFactory.subfolderWithName(fileSystem, FOLDER_NAME);
|
||||
Folder nonExistingFolder = subfolderFunction.subfolderWithName(fileSystem, FOLDER_NAME);
|
||||
|
||||
thrown.expect(UncheckedIOException.class);
|
||||
|
||||
@@ -60,11 +60,11 @@ public class FolderChildrenTests {
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void testFoldersThrowsExceptionIfFolderDoesNotExist(FileSystemFactory fileSystemFactory, SubfolderFactory subfolderFactory) {
|
||||
assumeThat(subfolderFactory.createsExistingFolder(), is(false));
|
||||
public void testFoldersThrowsExceptionIfFolderDoesNotExist(FileSystemFactory fileSystemFactory, SubfolderBiFunction subfolderFunction) {
|
||||
assumeThat(subfolderFunction.returnedFoldersExist(), is(false));
|
||||
|
||||
FileSystem fileSystem = fileSystemFactory.create();
|
||||
Folder nonExistingFolder = subfolderFactory.subfolderWithName(fileSystem, FOLDER_NAME);
|
||||
Folder nonExistingFolder = subfolderFunction.subfolderWithName(fileSystem, FOLDER_NAME);
|
||||
|
||||
thrown.expect(UncheckedIOException.class);
|
||||
|
||||
@@ -72,62 +72,93 @@ public class FolderChildrenTests {
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void testChildrenIsEmptyForEmptyFolder(FileSystemFactory fileSystemFactory, SubfolderFactory subfolderFactory) {
|
||||
assumeThat(subfolderFactory.createsExistingFolder(), is(true));
|
||||
public void testChildrenIsEmptyForEmptyFolder(FileSystemFactory fileSystemFactory, SubfolderBiFunction subfolderFunction) {
|
||||
assumeThat(subfolderFunction.returnedFoldersExist(), is(true));
|
||||
|
||||
FileSystem fileSystem = fileSystemFactory.create();
|
||||
Folder existingFolder = subfolderFactory.subfolderWithName(fileSystem, FOLDER_NAME);
|
||||
Folder existingFolder = subfolderFunction.subfolderWithName(fileSystem, FOLDER_NAME);
|
||||
|
||||
assertThat(existingFolder.children().count(), is(0L));
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void testFilesIsEmptyForEmptyFolder(FileSystemFactory fileSystemFactory, SubfolderFactory subfolderFactory) {
|
||||
assumeThat(subfolderFactory.createsExistingFolder(), is(true));
|
||||
public void testFilesIsEmptyForEmptyFolder(FileSystemFactory fileSystemFactory, SubfolderBiFunction subfolderFunction) {
|
||||
assumeThat(subfolderFunction.returnedFoldersExist(), is(true));
|
||||
|
||||
FileSystem fileSystem = fileSystemFactory.create();
|
||||
Folder existingFolder = subfolderFactory.subfolderWithName(fileSystem, FOLDER_NAME);
|
||||
Folder existingFolder = subfolderFunction.subfolderWithName(fileSystem, FOLDER_NAME);
|
||||
|
||||
assertThat(existingFolder.files().count(), is(0L));
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void testFoldersIsEmptyForEmptyFolder(FileSystemFactory fileSystemFactory, SubfolderFactory subfolderFactory) {
|
||||
assumeThat(subfolderFactory.createsExistingFolder(), is(true));
|
||||
public void testFoldersIsEmptyForEmptyFolder(FileSystemFactory fileSystemFactory, SubfolderBiFunction subfolderFunction) {
|
||||
assumeThat(subfolderFunction.returnedFoldersExist(), is(true));
|
||||
|
||||
FileSystem fileSystem = fileSystemFactory.create();
|
||||
Folder existingFolder = subfolderFactory.subfolderWithName(fileSystem, FOLDER_NAME);
|
||||
Folder existingFolder = subfolderFunction.subfolderWithName(fileSystem, FOLDER_NAME);
|
||||
|
||||
assertThat(existingFolder.folders().count(), is(0L));
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void testChildrenContainsCreatedChildFolder(FileSystemFactory fileSystemFactory, SubfolderFactory existingFolderFactory, SubfolderFactory childExistingFolderFactory) {
|
||||
assumeThat(existingFolderFactory.createsExistingFolder(), is(true));
|
||||
assumeThat(childExistingFolderFactory.createsExistingFolder(), is(true));
|
||||
public void testChildrenContainsCreatedChildFolder(FileSystemFactory fileSystemFactory, SubfolderBiFunction existingFolderFunction, SubfolderBiFunction childExistingFolderFunction) {
|
||||
assumeThat(existingFolderFunction.returnedFoldersExist(), is(true));
|
||||
assumeThat(childExistingFolderFunction.returnedFoldersExist(), is(true));
|
||||
|
||||
String childName = "childFolderName";
|
||||
|
||||
FileSystem fileSystem = fileSystemFactory.create();
|
||||
Folder existingFolder = existingFolderFactory.subfolderWithName(fileSystem, FOLDER_NAME);
|
||||
Folder childFolder = childExistingFolderFactory.subfolderWithName(existingFolder, childName);
|
||||
Folder existingFolder = existingFolderFunction.subfolderWithName(fileSystem, FOLDER_NAME);
|
||||
Folder childFolder = childExistingFolderFunction.subfolderWithName(existingFolder, childName);
|
||||
|
||||
assertThat(existingFolder.children().collect(toList()), containsInAnyOrder(equalTo(childFolder)));
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void testChildrenDoesNotContainsCreatedAndDeletedChildFolder(FileSystemFactory fileSystemFactory, SubfolderFactory existingFolderFactory, SubfolderFactory childExistingFolderFactory) {
|
||||
assumeThat(existingFolderFactory.createsExistingFolder(), is(true));
|
||||
assumeThat(childExistingFolderFactory.createsExistingFolder(), is(true));
|
||||
public void testChildrenDoesNotContainCreatedAndDeletedChildFolder(FileSystemFactory fileSystemFactory, SubfolderBiFunction existingFolderFunction, SubfolderBiFunction childExistingFolderFunction) {
|
||||
assumeThat(existingFolderFunction.returnedFoldersExist(), is(true));
|
||||
assumeThat(childExistingFolderFunction.returnedFoldersExist(), is(true));
|
||||
|
||||
String childName = "childFolderName";
|
||||
|
||||
FileSystem fileSystem = fileSystemFactory.create();
|
||||
Folder existingFolder = existingFolderFactory.subfolderWithName(fileSystem, FOLDER_NAME);
|
||||
Folder childFolder = childExistingFolderFactory.subfolderWithName(existingFolder, childName);
|
||||
Folder existingFolder = existingFolderFunction.subfolderWithName(fileSystem, FOLDER_NAME);
|
||||
Folder childFolder = childExistingFolderFunction.subfolderWithName(existingFolder, childName);
|
||||
childFolder.delete();
|
||||
|
||||
assertThat(existingFolder.children().collect(toList()), is(empty()));
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void testFoldersContainsAndFilesDoesNotContainCreatedChildFolder(FileSystemFactory fileSystemFactory, SubfolderBiFunction existingFolderFunction, SubfolderBiFunction 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);
|
||||
|
||||
assertThat(existingFolder.folders().collect(toList()), containsInAnyOrder(equalTo(childFolder)));
|
||||
assertThat(existingFolder.files().collect(toList()), is(empty()));
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void testFoldersAndFilesDoesNotContainCreatedAndDeletedChildFolder(FileSystemFactory fileSystemFactory, SubfolderBiFunction existingFolderFunction, SubfolderBiFunction 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);
|
||||
childFolder.delete();
|
||||
|
||||
assertThat(existingFolder.folders().collect(toList()), is(empty()));
|
||||
assertThat(existingFolder.files().collect(toList()), is(empty()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import static org.junit.Assume.assumeThat;
|
||||
import org.cryptomator.filesystem.FileSystem;
|
||||
import org.cryptomator.filesystem.Folder;
|
||||
import org.cryptomator.filesystem.invariants.FileSystemFactories.FileSystemFactory;
|
||||
import org.cryptomator.filesystem.invariants.SubfolderFactories.SubfolderFactory;
|
||||
import org.cryptomator.filesystem.invariants.SubfolderBiFunctions.SubfolderBiFunction;
|
||||
import org.junit.Rule;
|
||||
import org.junit.experimental.theories.DataPoints;
|
||||
import org.junit.experimental.theories.Theories;
|
||||
@@ -24,14 +24,14 @@ public class FolderTests {
|
||||
public static final Iterable<FileSystemFactory> FILE_SYSTEM_FACTORIES = new FileSystemFactories();
|
||||
|
||||
@DataPoints
|
||||
public static final Iterable<SubfolderFactory> SUBFOLDER_FACTORIES = new SubfolderFactories();
|
||||
public static final Iterable<SubfolderBiFunction> SUBFOLDER_FACTORIES = new SubfolderBiFunctions();
|
||||
|
||||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Theory
|
||||
public void testExistingFolderExists(FileSystemFactory fileSystemFactory, SubfolderFactory subfolderFactory) {
|
||||
assumeThat(subfolderFactory.createsExistingFolder(), is(true));
|
||||
public void testExistingFolderExists(FileSystemFactory fileSystemFactory, SubfolderBiFunction subfolderFactory) {
|
||||
assumeThat(subfolderFactory.returnedFoldersExist(), is(true));
|
||||
|
||||
FileSystem fileSystem = fileSystemFactory.create();
|
||||
Folder existingFolder = subfolderFactory.subfolderWithName(fileSystem, FOLDER_NAME);
|
||||
@@ -40,8 +40,8 @@ public class FolderTests {
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void testNonExistingFolderDoesntExists(FileSystemFactory fileSystemFactory, SubfolderFactory subfolderFactory) {
|
||||
assumeThat(subfolderFactory.createsExistingFolder(), is(false));
|
||||
public void testNonExistingFolderDoesntExists(FileSystemFactory fileSystemFactory, SubfolderBiFunction subfolderFactory) {
|
||||
assumeThat(subfolderFactory.returnedFoldersExist(), is(false));
|
||||
|
||||
FileSystem fileSystem = fileSystemFactory.create();
|
||||
Folder existingFolder = subfolderFactory.subfolderWithName(fileSystem, FOLDER_NAME);
|
||||
|
||||
@@ -5,13 +5,13 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.cryptomator.filesystem.Folder;
|
||||
import org.cryptomator.filesystem.invariants.SubfolderFactories.SubfolderFactory;
|
||||
import org.cryptomator.filesystem.invariants.SubfolderBiFunctions.SubfolderBiFunction;
|
||||
|
||||
class SubfolderFactories implements Iterable<SubfolderFactory> {
|
||||
class SubfolderBiFunctions implements Iterable<SubfolderBiFunction> {
|
||||
|
||||
private final List<SubfolderFactory> factories = new ArrayList<>();
|
||||
private final List<SubfolderBiFunction> factories = new ArrayList<>();
|
||||
|
||||
public SubfolderFactories() {
|
||||
public SubfolderBiFunctions() {
|
||||
addNonExisting("invoke folder", this::invokeFolder);
|
||||
addNonExisting("create and delete", this::createAndDeleteFolder);
|
||||
addNonExisting("delete by moving", this::moveFolderAway);
|
||||
@@ -54,8 +54,8 @@ class SubfolderFactories implements Iterable<SubfolderFactory> {
|
||||
return target;
|
||||
}
|
||||
|
||||
private void addExisting(String name, ExistingSubfolderFactory factory) {
|
||||
factories.add(new ExistingSubfolderFactory() {
|
||||
private void addExisting(String name, ExistingSubfolderBiFunction factory) {
|
||||
factories.add(new ExistingSubfolderBiFunction() {
|
||||
@Override
|
||||
public Folder subfolderWithName(Folder parent, String name) {
|
||||
return factory.subfolderWithName(parent, name);
|
||||
@@ -68,8 +68,8 @@ class SubfolderFactories implements Iterable<SubfolderFactory> {
|
||||
});
|
||||
}
|
||||
|
||||
private void addNonExisting(String name, NonExistingSubfolderFactory factory) {
|
||||
factories.add(new NonExistingSubfolderFactory() {
|
||||
private void addNonExisting(String name, NonExistingSubfolderSubfolderBiFunction factory) {
|
||||
factories.add(new NonExistingSubfolderSubfolderBiFunction() {
|
||||
@Override
|
||||
public Folder subfolderWithName(Folder parent, String name) {
|
||||
return factory.subfolderWithName(parent, name);
|
||||
@@ -82,30 +82,30 @@ class SubfolderFactories implements Iterable<SubfolderFactory> {
|
||||
});
|
||||
}
|
||||
|
||||
public interface SubfolderFactory {
|
||||
public interface SubfolderBiFunction {
|
||||
|
||||
Folder subfolderWithName(Folder parent, String name);
|
||||
|
||||
boolean createsExistingFolder();
|
||||
boolean returnedFoldersExist();
|
||||
|
||||
}
|
||||
|
||||
public interface ExistingSubfolderFactory extends SubfolderFactory {
|
||||
public interface ExistingSubfolderBiFunction extends SubfolderBiFunction {
|
||||
@Override
|
||||
default boolean createsExistingFolder() {
|
||||
default boolean returnedFoldersExist() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public interface NonExistingSubfolderFactory extends SubfolderFactory {
|
||||
public interface NonExistingSubfolderSubfolderBiFunction extends SubfolderBiFunction {
|
||||
@Override
|
||||
default boolean createsExistingFolder() {
|
||||
default boolean returnedFoldersExist() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<SubfolderFactory> iterator() {
|
||||
public Iterator<SubfolderBiFunction> iterator() {
|
||||
return factories.iterator();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user