diff --git a/app/src/main/java/lightcontainer/storage/AppData.java b/app/src/main/java/lightcontainer/storage/AppData.java index 10ddeb8..2b5db46 100644 --- a/app/src/main/java/lightcontainer/storage/AppData.java +++ b/app/src/main/java/lightcontainer/storage/AppData.java @@ -68,8 +68,6 @@ public class AppData { } - - /** * Use this method when a user signs up. * @@ -98,15 +96,15 @@ public class AppData { * True indicates the success of the operation. * False indicates the failure of the operation. * - * @param file The file to add - * @param user The user who wants to add the file + * @param file The file to add + * @param userName The name of the user who wants to add the file * @return True if the user is found and a file with the same name doesn't already exist for this user. False otherwise. */ - public boolean addFileFor(File file, User user) { - if (!this.users.containsKey(user.getName())) { + public boolean addFileFor(File file, String userName) { + if (!this.users.containsKey(userName)) { return false; } else { - this.users.get(user.getName()).addFile(file); + this.users.get(userName).addFile(file); return true; } } @@ -119,28 +117,28 @@ public class AppData { * False indicates the failure of the operation. * * @param fileName The name of the file to delete - * @param user The user who wants to delete the file + * @param userName The name of the user who wants to delete the file * @return True if the user is found and the file was deleted. False otherwise. */ - public boolean deleteFileOf(String fileName, User user) { - if (!this.users.containsKey(user.getName())) { + public boolean deleteFileOf(String fileName, String userName) { + if (!this.users.containsKey(userName)) { return false; } else { - return this.users.get(user.getName()).deleteFile(fileName); + return this.users.get(userName).deleteFile(fileName); } } /** - * @param user The user who wants to add a storage for their file - * @param file The file that needs a new storage - * @param storage The storage to add + * @param userName The name of the user who wants to add a storage for their file + * @param file The file that needs a new storage + * @param storage The storage to add * @return True if the storage was added. False otherwise. */ - public boolean addStorage(User user, File file, String storage) { - if (!this.users.containsKey(user.getName())) { + public boolean addStorage(String userName, File file, String storage) { + if (!this.users.containsKey(userName)) { return false; } else { - return this.users.get(user.getName()).addStorage(file, storage); + return this.users.get(userName).addStorage(file, storage); } } diff --git a/app/src/test/java/lightcontainer/storage/RepositoryTests.java b/app/src/test/java/lightcontainer/storage/RepositoryTests.java index 77913f8..d94a0f7 100644 --- a/app/src/test/java/lightcontainer/storage/RepositoryTests.java +++ b/app/src/test/java/lightcontainer/storage/RepositoryTests.java @@ -40,9 +40,8 @@ public class RepositoryTests { storage.add("StorBackEnd1"); File file1 = new File("File1", 15, "8d8d8d8d", storage); files.put(file1.getName(), file1); - User user1 = new User("User1", "Password", "djdjjdj", files); appData.setAppConfig(appConfig); - //appData.addUser(user1); + appData.addUser("User1", "Password", "djdjjdj"); JsonAdapter jsonAdapter = new JsonAdapter(appData); //WHEN Repository calls save method String filePath = "src/test/resources/test.json";