diff --git a/docs/diagrams/ArchitectureSequenceDiagram.puml b/docs/diagrams/ArchitectureSequenceDiagram.puml index ef81d18c337..91b60f94478 100644 --- a/docs/diagrams/ArchitectureSequenceDiagram.puml +++ b/docs/diagrams/ArchitectureSequenceDiagram.puml @@ -19,7 +19,7 @@ activate model MODEL_COLOR model -[MODEL_COLOR]-> logic deactivate model -logic -[LOGIC_COLOR]> storage : saveAddressBook(addressBook) +logic -[LOGIC_COLOR]> storage : saveAddressBook(cliniCal) activate storage STORAGE_COLOR storage -[STORAGE_COLOR]> storage : Save to file diff --git a/src/main/java/seedu/address/MainApp.java b/src/main/java/seedu/address/MainApp.java index e5cfb161b73..698675bf194 100644 --- a/src/main/java/seedu/address/MainApp.java +++ b/src/main/java/seedu/address/MainApp.java @@ -15,15 +15,15 @@ import seedu.address.commons.util.StringUtil; import seedu.address.logic.Logic; import seedu.address.logic.LogicManager; -import seedu.address.model.AddressBook; +import seedu.address.model.CliniCal; import seedu.address.model.Model; import seedu.address.model.ModelManager; -import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.ReadOnlyCliniCal; import seedu.address.model.ReadOnlyUserPrefs; import seedu.address.model.UserPrefs; import seedu.address.model.util.SampleDataUtil; -import seedu.address.storage.AddressBookStorage; -import seedu.address.storage.JsonAddressBookStorage; +import seedu.address.storage.CliniCalStorage; +import seedu.address.storage.JsonCliniCalStorage; import seedu.address.storage.JsonUserPrefsStorage; import seedu.address.storage.Storage; import seedu.address.storage.StorageManager; @@ -48,7 +48,7 @@ public class MainApp extends Application { @Override public void init() throws Exception { - logger.info("=============================[ Initializing AddressBook ]==========================="); + logger.info("=============================[ Initializing CliniCal ]==========================="); super.init(); AppParameters appParameters = AppParameters.parse(getParameters()); @@ -56,8 +56,8 @@ public void init() throws Exception { UserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(config.getUserPrefsFilePath()); UserPrefs userPrefs = initPrefs(userPrefsStorage); - AddressBookStorage addressBookStorage = new JsonAddressBookStorage(userPrefs.getAddressBookFilePath()); - storage = new StorageManager(addressBookStorage, userPrefsStorage); + CliniCalStorage cliniCalStorage = new JsonCliniCalStorage(userPrefs.getCliniCalFilePath()); + storage = new StorageManager(cliniCalStorage, userPrefsStorage); initLogging(config); @@ -74,20 +74,20 @@ public void init() throws Exception { * or an empty address book will be used instead if errors occur when reading {@code storage}'s address book. */ private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) { - Optional addressBookOptional; - ReadOnlyAddressBook initialData; + Optional cliniCalOptional; + ReadOnlyCliniCal initialData; try { - addressBookOptional = storage.readAddressBook(); - if (!addressBookOptional.isPresent()) { - logger.info("Data file not found. Will be starting with a sample AddressBook"); + cliniCalOptional = storage.readCliniCal(); + if (!cliniCalOptional.isPresent()) { + logger.info("Data file not found. Will be starting with a sample CliniCal"); } - initialData = addressBookOptional.orElseGet(SampleDataUtil::getSampleAddressBook); + initialData = cliniCalOptional.orElseGet(SampleDataUtil::getSampleCliniCal); } catch (DataConversionException e) { - logger.warning("Data file not in the correct format. Will be starting with an empty AddressBook"); - initialData = new AddressBook(); + logger.warning("Data file not in the correct format. Will be starting with an empty CliniCal"); + initialData = new CliniCal(); } catch (IOException e) { - logger.warning("Problem while reading from the file. Will be starting with an empty AddressBook"); - initialData = new AddressBook(); + logger.warning("Problem while reading from the file. Will be starting with an empty CliniCal"); + initialData = new CliniCal(); } return new ModelManager(initialData, userPrefs); @@ -151,7 +151,7 @@ protected UserPrefs initPrefs(UserPrefsStorage storage) { + "Using default user prefs"); initializedPrefs = new UserPrefs(); } catch (IOException e) { - logger.warning("Problem while reading from the file. Will be starting with an empty AddressBook"); + logger.warning("Problem while reading from the file. Will be starting with an empty CliniCal"); initializedPrefs = new UserPrefs(); } @@ -167,7 +167,7 @@ protected UserPrefs initPrefs(UserPrefsStorage storage) { @Override public void start(Stage primaryStage) { - logger.info("Starting AddressBook " + MainApp.VERSION); + logger.info("Starting CliniCal " + MainApp.VERSION); ui.start(primaryStage); } diff --git a/src/main/java/seedu/address/commons/core/LogsCenter.java b/src/main/java/seedu/address/commons/core/LogsCenter.java index 431e7185e76..b1700f956a9 100644 --- a/src/main/java/seedu/address/commons/core/LogsCenter.java +++ b/src/main/java/seedu/address/commons/core/LogsCenter.java @@ -18,7 +18,7 @@ public class LogsCenter { private static final int MAX_FILE_COUNT = 5; private static final int MAX_FILE_SIZE_IN_BYTES = (int) (Math.pow(2, 20) * 5); // 5MB - private static final String LOG_FILE = "addressbook.log"; + private static final String LOG_FILE = "clinical.log"; private static Level currentLogLevel = Level.INFO; private static final Logger logger = LogsCenter.getLogger(LogsCenter.class); private static FileHandler fileHandler; diff --git a/src/main/java/seedu/address/logic/Logic.java b/src/main/java/seedu/address/logic/Logic.java index 6bf20698272..622120c4fe3 100644 --- a/src/main/java/seedu/address/logic/Logic.java +++ b/src/main/java/seedu/address/logic/Logic.java @@ -7,7 +7,7 @@ import seedu.address.logic.commands.CommandResult; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.ReadOnlyCliniCal; import seedu.address.model.patient.Patient; /** @@ -24,11 +24,11 @@ public interface Logic { CommandResult execute(String commandText) throws CommandException, ParseException; /** - * Returns the AddressBook. + * Returns the CliniCal. * - * @see seedu.address.model.Model#getAddressBook() + * @see seedu.address.model.Model#getCliniCal() */ - ReadOnlyAddressBook getAddressBook(); + ReadOnlyCliniCal getCliniCal(); /** Returns an unmodifiable view of the filtered list of patients */ ObservableList getFilteredPatientList(); @@ -36,7 +36,7 @@ public interface Logic { /** * Returns the user prefs' address book file path. */ - Path getAddressBookFilePath(); + Path getCliniCalFilePath(); /** * Returns the user prefs' GUI settings. diff --git a/src/main/java/seedu/address/logic/LogicManager.java b/src/main/java/seedu/address/logic/LogicManager.java index f6d98585fc1..abda6b5ab7e 100644 --- a/src/main/java/seedu/address/logic/LogicManager.java +++ b/src/main/java/seedu/address/logic/LogicManager.java @@ -10,10 +10,10 @@ import seedu.address.logic.commands.Command; import seedu.address.logic.commands.CommandResult; import seedu.address.logic.commands.exceptions.CommandException; -import seedu.address.logic.parser.AddressBookParser; +import seedu.address.logic.parser.CliniCalParser; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.Model; -import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.ReadOnlyCliniCal; import seedu.address.model.patient.Patient; import seedu.address.storage.Storage; @@ -26,7 +26,7 @@ public class LogicManager implements Logic { private final Model model; private final Storage storage; - private final AddressBookParser addressBookParser; + private final CliniCalParser cliniCalParser; /** * Constructs a {@code LogicManager} with the given {@code Model} and {@code Storage}. @@ -34,7 +34,7 @@ public class LogicManager implements Logic { public LogicManager(Model model, Storage storage) { this.model = model; this.storage = storage; - addressBookParser = new AddressBookParser(); + cliniCalParser = new CliniCalParser(); } @Override @@ -44,14 +44,14 @@ public CommandResult execute(String commandText) throws CommandException, ParseE CommandResult commandResult; //Parse user input from String to a Command - Command command = addressBookParser.parseCommand(commandText); + Command command = cliniCalParser.parseCommand(commandText); //Executes the Command and stores the result commandResult = command.execute(model); try { //We can deduce that the previous line of code modifies model in some way // since it's being stored here. - storage.saveAddressBook(model.getAddressBook()); + storage.saveCliniCal(model.getCliniCal()); } catch (IOException ioe) { throw new CommandException(FILE_OPS_ERROR_MESSAGE + ioe, ioe); } @@ -60,8 +60,8 @@ public CommandResult execute(String commandText) throws CommandException, ParseE } @Override - public ReadOnlyAddressBook getAddressBook() { - return model.getAddressBook(); + public ReadOnlyCliniCal getCliniCal() { + return model.getCliniCal(); } @Override @@ -70,8 +70,8 @@ public ObservableList getFilteredPatientList() { } @Override - public Path getAddressBookFilePath() { - return model.getAddressBookFilePath(); + public Path getCliniCalFilePath() { + return model.getCliniCalFilePath(); } @Override diff --git a/src/main/java/seedu/address/logic/commands/ClearCommand.java b/src/main/java/seedu/address/logic/commands/ClearCommand.java index 9c86b1fa6e4..27ad326e51f 100644 --- a/src/main/java/seedu/address/logic/commands/ClearCommand.java +++ b/src/main/java/seedu/address/logic/commands/ClearCommand.java @@ -2,7 +2,7 @@ import static java.util.Objects.requireNonNull; -import seedu.address.model.AddressBook; +import seedu.address.model.CliniCal; import seedu.address.model.Model; /** @@ -17,7 +17,7 @@ public class ClearCommand extends Command { @Override public CommandResult execute(Model model) { requireNonNull(model); - model.setAddressBook(new AddressBook()); + model.setCliniCal(new CliniCal()); return new CommandResult(MESSAGE_SUCCESS); } } diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/CliniCalParser.java similarity index 98% rename from src/main/java/seedu/address/logic/parser/AddressBookParser.java rename to src/main/java/seedu/address/logic/parser/CliniCalParser.java index 70fe048ec47..e7e213426ba 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/CliniCalParser.java @@ -20,7 +20,7 @@ /** * Parses user input. */ -public class AddressBookParser { +public class CliniCalParser { /** * Used for initial separation of command word and args. diff --git a/src/main/java/seedu/address/model/AddressBook.java b/src/main/java/seedu/address/model/CliniCal.java similarity index 83% rename from src/main/java/seedu/address/model/AddressBook.java rename to src/main/java/seedu/address/model/CliniCal.java index 603b25bdbc5..da249f88b23 100644 --- a/src/main/java/seedu/address/model/AddressBook.java +++ b/src/main/java/seedu/address/model/CliniCal.java @@ -12,7 +12,7 @@ * Wraps all data at the address-book level * Duplicates are not allowed (by .isSamePatient comparison) */ -public class AddressBook implements ReadOnlyAddressBook { +public class CliniCal implements ReadOnlyCliniCal { private final UniquePatientList patients; @@ -27,12 +27,12 @@ public class AddressBook implements ReadOnlyAddressBook { patients = new UniquePatientList(); } - public AddressBook() {} + public CliniCal() {} /** - * Creates an AddressBook using the Patients in the {@code toBeCopied} + * Creates a CliniCal using the Patients in the {@code toBeCopied} */ - public AddressBook(ReadOnlyAddressBook toBeCopied) { + public CliniCal(ReadOnlyCliniCal toBeCopied) { this(); resetData(toBeCopied); } @@ -48,9 +48,9 @@ public void setPatients(List patients) { } /** - * Resets the existing data of this {@code AddressBook} with {@code newData}. + * Resets the existing data of this {@code CliniCal} with {@code newData}. */ - public void resetData(ReadOnlyAddressBook newData) { + public void resetData(ReadOnlyCliniCal newData) { requireNonNull(newData); setPatients(newData.getPatientList()); @@ -87,7 +87,7 @@ public void setPatient(Patient target, Patient editedPatient) { } /** - * Removes {@code key} from this {@code AddressBook}. + * Removes {@code key} from this {@code CliniCal}. * {@code key} must exist in the address book. */ public void removePatient(Patient key) { @@ -110,8 +110,8 @@ public ObservableList getPatientList() { @Override public boolean equals(Object other) { return other == this // short circuit if same object - || (other instanceof AddressBook // instanceof handles nulls - && patients.equals(((AddressBook) other).patients)); + || (other instanceof CliniCal // instanceof handles nulls + && patients.equals(((CliniCal) other).patients)); } @Override diff --git a/src/main/java/seedu/address/model/Model.java b/src/main/java/seedu/address/model/Model.java index d6a62a2dd56..76f15169b56 100644 --- a/src/main/java/seedu/address/model/Model.java +++ b/src/main/java/seedu/address/model/Model.java @@ -37,20 +37,20 @@ public interface Model { /** * Returns the user prefs' address book file path. */ - Path getAddressBookFilePath(); + Path getCliniCalFilePath(); /** * Sets the user prefs' address book file path. */ - void setAddressBookFilePath(Path addressBookFilePath); + void setCliniCalFilePath(Path cliniCalFilePath); /** - * Replaces address book data with the data in {@code addressBook}. + * Replaces address book data with the data in {@code cliniCal}. */ - void setAddressBook(ReadOnlyAddressBook addressBook); + void setCliniCal(ReadOnlyCliniCal cliniCal); - /** Returns the AddressBook */ - ReadOnlyAddressBook getAddressBook(); + /** Returns the CliniCal */ + ReadOnlyCliniCal getCliniCal(); /** * Returns true if a patient with the same identity as {@code patient} exists in the address book. diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java index 931f9e04128..6f41e5fd53b 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -19,26 +19,26 @@ public class ModelManager implements Model { private static final Logger logger = LogsCenter.getLogger(ModelManager.class); - private final AddressBook addressBook; + private final CliniCal cliniCal; private final UserPrefs userPrefs; private final FilteredList filteredPatients; /** - * Initializes a ModelManager with the given addressBook and userPrefs. + * Initializes a ModelManager with the given cliniCal and userPrefs. */ - public ModelManager(ReadOnlyAddressBook addressBook, ReadOnlyUserPrefs userPrefs) { + public ModelManager(ReadOnlyCliniCal cliniCal, ReadOnlyUserPrefs userPrefs) { super(); - requireAllNonNull(addressBook, userPrefs); + requireAllNonNull(cliniCal, userPrefs); - logger.fine("Initializing with address book: " + addressBook + " and user prefs " + userPrefs); + logger.fine("Initializing with address book: " + cliniCal + " and user prefs " + userPrefs); - this.addressBook = new AddressBook(addressBook); + this.cliniCal = new CliniCal(cliniCal); this.userPrefs = new UserPrefs(userPrefs); - filteredPatients = new FilteredList<>(this.addressBook.getPatientList()); + filteredPatients = new FilteredList<>(this.cliniCal.getPatientList()); } public ModelManager() { - this(new AddressBook(), new UserPrefs()); + this(new CliniCal(), new UserPrefs()); } //=========== UserPrefs ================================================================================== @@ -66,42 +66,42 @@ public void setGuiSettings(GuiSettings guiSettings) { } @Override - public Path getAddressBookFilePath() { - return userPrefs.getAddressBookFilePath(); + public Path getCliniCalFilePath() { + return userPrefs.getCliniCalFilePath(); } @Override - public void setAddressBookFilePath(Path addressBookFilePath) { - requireNonNull(addressBookFilePath); - userPrefs.setAddressBookFilePath(addressBookFilePath); + public void setCliniCalFilePath(Path cliniCalFilePath) { + requireNonNull(cliniCalFilePath); + userPrefs.setCliniCalFilePath(cliniCalFilePath); } - //=========== AddressBook ================================================================================ + //=========== CliniCal ================================================================================ @Override - public void setAddressBook(ReadOnlyAddressBook addressBook) { - this.addressBook.resetData(addressBook); + public void setCliniCal(ReadOnlyCliniCal cliniCal) { + this.cliniCal.resetData(cliniCal); } @Override - public ReadOnlyAddressBook getAddressBook() { - return addressBook; + public ReadOnlyCliniCal getCliniCal() { + return cliniCal; } @Override public boolean hasPatient(Patient patient) { requireNonNull(patient); - return addressBook.hasPatient(patient); + return cliniCal.hasPatient(patient); } @Override public void deletePatient(Patient target) { - addressBook.removePatient(target); + cliniCal.removePatient(target); } @Override public void addPatient(Patient patient) { - addressBook.addPatient(patient); + cliniCal.addPatient(patient); updateFilteredPatientList(PREDICATE_SHOW_ALL_PATIENTS); } @@ -109,14 +109,14 @@ public void addPatient(Patient patient) { public void setPatient(Patient target, Patient editedPatient) { requireAllNonNull(target, editedPatient); - addressBook.setPatient(target, editedPatient); + cliniCal.setPatient(target, editedPatient); } //=========== Filtered Patient List Accessors ============================================================= /** * Returns an unmodifiable view of the list of {@code Patient} backed by the internal list of - * {@code versionedAddressBook} + * {@code versionedCliniCal} */ @Override public ObservableList getFilteredPatientList() { @@ -143,7 +143,7 @@ public boolean equals(Object obj) { // state check ModelManager other = (ModelManager) obj; - return addressBook.equals(other.addressBook) + return cliniCal.equals(other.cliniCal) && userPrefs.equals(other.userPrefs) && filteredPatients.equals(other.filteredPatients); } diff --git a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java b/src/main/java/seedu/address/model/ReadOnlyCliniCal.java similarity index 89% rename from src/main/java/seedu/address/model/ReadOnlyAddressBook.java rename to src/main/java/seedu/address/model/ReadOnlyCliniCal.java index c151e987079..0f585df1205 100644 --- a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java +++ b/src/main/java/seedu/address/model/ReadOnlyCliniCal.java @@ -6,7 +6,7 @@ /** * Unmodifiable view of an address book */ -public interface ReadOnlyAddressBook { +public interface ReadOnlyCliniCal { /** * Returns an unmodifiable view of the patients list. diff --git a/src/main/java/seedu/address/model/ReadOnlyUserPrefs.java b/src/main/java/seedu/address/model/ReadOnlyUserPrefs.java index befd58a4c73..9f5ba9955bf 100644 --- a/src/main/java/seedu/address/model/ReadOnlyUserPrefs.java +++ b/src/main/java/seedu/address/model/ReadOnlyUserPrefs.java @@ -11,6 +11,6 @@ public interface ReadOnlyUserPrefs { GuiSettings getGuiSettings(); - Path getAddressBookFilePath(); + Path getCliniCalFilePath(); } diff --git a/src/main/java/seedu/address/model/UserPrefs.java b/src/main/java/seedu/address/model/UserPrefs.java index 25a5fd6eab9..75d2286f291 100644 --- a/src/main/java/seedu/address/model/UserPrefs.java +++ b/src/main/java/seedu/address/model/UserPrefs.java @@ -14,7 +14,7 @@ public class UserPrefs implements ReadOnlyUserPrefs { private GuiSettings guiSettings = new GuiSettings(); - private Path addressBookFilePath = Paths.get("data" , "addressbook.json"); + private Path cliniCalFilePath = Paths.get("data" , "clinical.json"); /** * Creates a {@code UserPrefs} with default values. @@ -35,7 +35,7 @@ public UserPrefs(ReadOnlyUserPrefs userPrefs) { public void resetData(ReadOnlyUserPrefs newUserPrefs) { requireNonNull(newUserPrefs); setGuiSettings(newUserPrefs.getGuiSettings()); - setAddressBookFilePath(newUserPrefs.getAddressBookFilePath()); + setCliniCalFilePath(newUserPrefs.getCliniCalFilePath()); } public GuiSettings getGuiSettings() { @@ -47,13 +47,13 @@ public void setGuiSettings(GuiSettings guiSettings) { this.guiSettings = guiSettings; } - public Path getAddressBookFilePath() { - return addressBookFilePath; + public Path getCliniCalFilePath() { + return cliniCalFilePath; } - public void setAddressBookFilePath(Path addressBookFilePath) { - requireNonNull(addressBookFilePath); - this.addressBookFilePath = addressBookFilePath; + public void setCliniCalFilePath(Path cliniCalFilePath) { + requireNonNull(cliniCalFilePath); + this.cliniCalFilePath = cliniCalFilePath; } @Override @@ -68,19 +68,19 @@ public boolean equals(Object other) { UserPrefs o = (UserPrefs) other; return guiSettings.equals(o.guiSettings) - && addressBookFilePath.equals(o.addressBookFilePath); + && cliniCalFilePath.equals(o.cliniCalFilePath); } @Override public int hashCode() { - return Objects.hash(guiSettings, addressBookFilePath); + return Objects.hash(guiSettings, cliniCalFilePath); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Gui Settings : " + guiSettings); - sb.append("\nLocal data file location : " + addressBookFilePath); + sb.append("\nLocal data file location : " + cliniCalFilePath); return sb.toString(); } diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index 521c5c24c2c..35f2174bd33 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -4,8 +4,8 @@ import java.util.Set; import java.util.stream.Collectors; -import seedu.address.model.AddressBook; -import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.CliniCal; +import seedu.address.model.ReadOnlyCliniCal; import seedu.address.model.patient.Address; import seedu.address.model.patient.Email; import seedu.address.model.patient.Name; @@ -14,7 +14,7 @@ import seedu.address.model.tag.Tag; /** - * Contains utility methods for populating {@code AddressBook} with sample data. + * Contains utility methods for populating {@code CliniCal} with sample data. */ public class SampleDataUtil { public static Patient[] getSamplePatients() { @@ -40,8 +40,8 @@ public static Patient[] getSamplePatients() { }; } - public static ReadOnlyAddressBook getSampleAddressBook() { - AddressBook sampleAb = new AddressBook(); + public static ReadOnlyCliniCal getSampleCliniCal() { + CliniCal sampleAb = new CliniCal(); for (Patient samplePatient : getSamplePatients()) { sampleAb.addPatient(samplePatient); } diff --git a/src/main/java/seedu/address/storage/AddressBookStorage.java b/src/main/java/seedu/address/storage/AddressBookStorage.java deleted file mode 100644 index 4599182b3f9..00000000000 --- a/src/main/java/seedu/address/storage/AddressBookStorage.java +++ /dev/null @@ -1,45 +0,0 @@ -package seedu.address.storage; - -import java.io.IOException; -import java.nio.file.Path; -import java.util.Optional; - -import seedu.address.commons.exceptions.DataConversionException; -import seedu.address.model.ReadOnlyAddressBook; - -/** - * Represents a storage for {@link seedu.address.model.AddressBook}. - */ -public interface AddressBookStorage { - - /** - * Returns the file path of the data file. - */ - Path getAddressBookFilePath(); - - /** - * Returns AddressBook data as a {@link ReadOnlyAddressBook}. - * Returns {@code Optional.empty()} if storage file is not found. - * @throws DataConversionException if the data in storage is not in the expected format. - * @throws IOException if there was any problem when reading from the storage. - */ - Optional readAddressBook() throws DataConversionException, IOException; - - /** - * @see #getAddressBookFilePath() - */ - Optional readAddressBook(Path filePath) throws DataConversionException, IOException; - - /** - * Saves the given {@link ReadOnlyAddressBook} to the storage. - * @param addressBook cannot be null. - * @throws IOException if there was any problem writing to the file. - */ - void saveAddressBook(ReadOnlyAddressBook addressBook) throws IOException; - - /** - * @see #saveAddressBook(ReadOnlyAddressBook) - */ - void saveAddressBook(ReadOnlyAddressBook addressBook, Path filePath) throws IOException; - -} diff --git a/src/main/java/seedu/address/storage/CliniCalStorage.java b/src/main/java/seedu/address/storage/CliniCalStorage.java new file mode 100644 index 00000000000..9f64acc1416 --- /dev/null +++ b/src/main/java/seedu/address/storage/CliniCalStorage.java @@ -0,0 +1,46 @@ +package seedu.address.storage; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.Optional; + +import seedu.address.commons.exceptions.DataConversionException; +import seedu.address.model.CliniCal; +import seedu.address.model.ReadOnlyCliniCal; + +/** + * Represents a storage for {@link CliniCal}. + */ +public interface CliniCalStorage { + + /** + * Returns the file path of the data file. + */ + Path getCliniCalFilePath(); + + /** + * Returns CliniCal data as a {@link ReadOnlyCliniCal}. + * Returns {@code Optional.empty()} if storage file is not found. + * @throws DataConversionException if the data in storage is not in the expected format. + * @throws IOException if there was any problem when reading from the storage. + */ + Optional readCliniCal() throws DataConversionException, IOException; + + /** + * @see #getCliniCalFilePath() + */ + Optional readCliniCal(Path filePath) throws DataConversionException, IOException; + + /** + * Saves the given {@link ReadOnlyCliniCal} to the storage. + * @param cliniCal cannot be null. + * @throws IOException if there was any problem writing to the file. + */ + void saveCliniCal(ReadOnlyCliniCal cliniCal) throws IOException; + + /** + * @see #saveCliniCal(ReadOnlyCliniCal) + */ + void saveCliniCal(ReadOnlyCliniCal cliniCal, Path filePath) throws IOException; + +} diff --git a/src/main/java/seedu/address/storage/JsonAddressBookStorage.java b/src/main/java/seedu/address/storage/JsonCliniCalStorage.java similarity index 50% rename from src/main/java/seedu/address/storage/JsonAddressBookStorage.java rename to src/main/java/seedu/address/storage/JsonCliniCalStorage.java index dfab9daaa0d..8052f98da63 100644 --- a/src/main/java/seedu/address/storage/JsonAddressBookStorage.java +++ b/src/main/java/seedu/address/storage/JsonCliniCalStorage.java @@ -12,47 +12,47 @@ import seedu.address.commons.exceptions.IllegalValueException; import seedu.address.commons.util.FileUtil; import seedu.address.commons.util.JsonUtil; -import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.ReadOnlyCliniCal; /** - * A class to access AddressBook data stored as a json file on the hard disk. + * A class to access CliniCal data stored as a json file on the hard disk. */ -public class JsonAddressBookStorage implements AddressBookStorage { +public class JsonCliniCalStorage implements CliniCalStorage { - private static final Logger logger = LogsCenter.getLogger(JsonAddressBookStorage.class); + private static final Logger logger = LogsCenter.getLogger(JsonCliniCalStorage.class); private Path filePath; - public JsonAddressBookStorage(Path filePath) { + public JsonCliniCalStorage(Path filePath) { this.filePath = filePath; } - public Path getAddressBookFilePath() { + public Path getCliniCalFilePath() { return filePath; } @Override - public Optional readAddressBook() throws DataConversionException { - return readAddressBook(filePath); + public Optional readCliniCal() throws DataConversionException { + return readCliniCal(filePath); } /** - * Similar to {@link #readAddressBook()}. + * Similar to {@link #readCliniCal()}. * * @param filePath location of the data. Cannot be null. * @throws DataConversionException if the file is not in the correct format. */ - public Optional readAddressBook(Path filePath) throws DataConversionException { + public Optional readCliniCal(Path filePath) throws DataConversionException { requireNonNull(filePath); - Optional jsonAddressBook = JsonUtil.readJsonFile( - filePath, JsonSerializableAddressBook.class); - if (!jsonAddressBook.isPresent()) { + Optional jsonCliniCal = JsonUtil.readJsonFile( + filePath, JsonSerializableCliniCal.class); + if (!jsonCliniCal.isPresent()) { return Optional.empty(); } try { - return Optional.of(jsonAddressBook.get().toModelType()); + return Optional.of(jsonCliniCal.get().toModelType()); } catch (IllegalValueException ive) { logger.info("Illegal values found in " + filePath + ": " + ive.getMessage()); throw new DataConversionException(ive); @@ -60,21 +60,21 @@ public Optional readAddressBook(Path filePath) throws DataC } @Override - public void saveAddressBook(ReadOnlyAddressBook addressBook) throws IOException { - saveAddressBook(addressBook, filePath); + public void saveCliniCal(ReadOnlyCliniCal cliniCal) throws IOException { + saveCliniCal(cliniCal, filePath); } /** - * Similar to {@link #saveAddressBook(ReadOnlyAddressBook)}. + * Similar to {@link #saveCliniCal(ReadOnlyCliniCal)}. * * @param filePath location of the data. Cannot be null. */ - public void saveAddressBook(ReadOnlyAddressBook addressBook, Path filePath) throws IOException { - requireNonNull(addressBook); + public void saveCliniCal(ReadOnlyCliniCal cliniCal, Path filePath) throws IOException { + requireNonNull(cliniCal); requireNonNull(filePath); FileUtil.createIfMissing(filePath); - JsonUtil.saveJsonFile(new JsonSerializableAddressBook(addressBook), filePath); + JsonUtil.saveJsonFile(new JsonSerializableCliniCal(cliniCal), filePath); } } diff --git a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java b/src/main/java/seedu/address/storage/JsonSerializableCliniCal.java similarity index 56% rename from src/main/java/seedu/address/storage/JsonSerializableAddressBook.java rename to src/main/java/seedu/address/storage/JsonSerializableCliniCal.java index c3323e76334..428b1332b99 100644 --- a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java +++ b/src/main/java/seedu/address/storage/JsonSerializableCliniCal.java @@ -9,52 +9,52 @@ import com.fasterxml.jackson.annotation.JsonRootName; import seedu.address.commons.exceptions.IllegalValueException; -import seedu.address.model.AddressBook; -import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.CliniCal; +import seedu.address.model.ReadOnlyCliniCal; import seedu.address.model.patient.Patient; /** - * An Immutable AddressBook that is serializable to JSON format. + * An Immutable CliniCal that is serializable to JSON format. */ -@JsonRootName(value = "addressbook") -class JsonSerializableAddressBook { +@JsonRootName(value = "clinical") +class JsonSerializableCliniCal { public static final String MESSAGE_DUPLICATE_PATIENT = "Patients list contains duplicate patient(s)."; private final List patients = new ArrayList<>(); /** - * Constructs a {@code JsonSerializableAddressBook} with the given patients. + * Constructs a {@code JsonSerializableCliniCal} with the given patients. */ @JsonCreator - public JsonSerializableAddressBook(@JsonProperty("patients") List patients) { + public JsonSerializableCliniCal(@JsonProperty("patients") List patients) { this.patients.addAll(patients); } /** - * Converts a given {@code ReadOnlyAddressBook} into this class for Jackson use. + * Converts a given {@code ReadOnlyCliniCal} into this class for Jackson use. * - * @param source future changes to this will not affect the created {@code JsonSerializableAddressBook}. + * @param source future changes to this will not affect the created {@code JsonSerializableCliniCal}. */ - public JsonSerializableAddressBook(ReadOnlyAddressBook source) { + public JsonSerializableCliniCal(ReadOnlyCliniCal source) { patients.addAll(source.getPatientList().stream().map(JsonAdaptedPatient::new).collect(Collectors.toList())); } /** - * Converts this address book into the model's {@code AddressBook} object. + * Converts this address book into the model's {@code CliniCal} object. * * @throws IllegalValueException if there were any data constraints violated. */ - public AddressBook toModelType() throws IllegalValueException { - AddressBook addressBook = new AddressBook(); + public CliniCal toModelType() throws IllegalValueException { + CliniCal cliniCal = new CliniCal(); for (JsonAdaptedPatient jsonAdaptedPatient : patients) { Patient patient = jsonAdaptedPatient.toModelType(); - if (addressBook.hasPatient(patient)) { + if (cliniCal.hasPatient(patient)) { throw new IllegalValueException(MESSAGE_DUPLICATE_PATIENT); } - addressBook.addPatient(patient); + cliniCal.addPatient(patient); } - return addressBook; + return cliniCal; } } diff --git a/src/main/java/seedu/address/storage/Storage.java b/src/main/java/seedu/address/storage/Storage.java index beda8bd9f11..d319401bdf0 100644 --- a/src/main/java/seedu/address/storage/Storage.java +++ b/src/main/java/seedu/address/storage/Storage.java @@ -5,14 +5,14 @@ import java.util.Optional; import seedu.address.commons.exceptions.DataConversionException; -import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.ReadOnlyCliniCal; import seedu.address.model.ReadOnlyUserPrefs; import seedu.address.model.UserPrefs; /** * API of the Storage component */ -public interface Storage extends AddressBookStorage, UserPrefsStorage { +public interface Storage extends CliniCalStorage, UserPrefsStorage { @Override Optional readUserPrefs() throws DataConversionException, IOException; @@ -21,12 +21,12 @@ public interface Storage extends AddressBookStorage, UserPrefsStorage { void saveUserPrefs(ReadOnlyUserPrefs userPrefs) throws IOException; @Override - Path getAddressBookFilePath(); + Path getCliniCalFilePath(); @Override - Optional readAddressBook() throws DataConversionException, IOException; + Optional readCliniCal() throws DataConversionException, IOException; @Override - void saveAddressBook(ReadOnlyAddressBook addressBook) throws IOException; + void saveCliniCal(ReadOnlyCliniCal cliniCal) throws IOException; } diff --git a/src/main/java/seedu/address/storage/StorageManager.java b/src/main/java/seedu/address/storage/StorageManager.java index 79868290974..082c521e90c 100644 --- a/src/main/java/seedu/address/storage/StorageManager.java +++ b/src/main/java/seedu/address/storage/StorageManager.java @@ -7,25 +7,25 @@ import seedu.address.commons.core.LogsCenter; import seedu.address.commons.exceptions.DataConversionException; -import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.ReadOnlyCliniCal; import seedu.address.model.ReadOnlyUserPrefs; import seedu.address.model.UserPrefs; /** - * Manages storage of AddressBook data in local storage. + * Manages storage of CliniCal data in local storage. */ public class StorageManager implements Storage { private static final Logger logger = LogsCenter.getLogger(StorageManager.class); - private AddressBookStorage addressBookStorage; + private CliniCalStorage cliniCalStorage; private UserPrefsStorage userPrefsStorage; /** - * Creates a {@code StorageManager} with the given {@code AddressBookStorage} and {@code UserPrefStorage}. + * Creates a {@code StorageManager} with the given {@code CliniCalStorage} and {@code UserPrefStorage}. */ - public StorageManager(AddressBookStorage addressBookStorage, UserPrefsStorage userPrefsStorage) { + public StorageManager(CliniCalStorage cliniCalStorage, UserPrefsStorage userPrefsStorage) { super(); - this.addressBookStorage = addressBookStorage; + this.cliniCalStorage = cliniCalStorage; this.userPrefsStorage = userPrefsStorage; } @@ -47,33 +47,33 @@ public void saveUserPrefs(ReadOnlyUserPrefs userPrefs) throws IOException { } - // ================ AddressBook methods ============================== + // ================ CliniCal methods ============================== @Override - public Path getAddressBookFilePath() { - return addressBookStorage.getAddressBookFilePath(); + public Path getCliniCalFilePath() { + return cliniCalStorage.getCliniCalFilePath(); } @Override - public Optional readAddressBook() throws DataConversionException, IOException { - return readAddressBook(addressBookStorage.getAddressBookFilePath()); + public Optional readCliniCal() throws DataConversionException, IOException { + return readCliniCal(cliniCalStorage.getCliniCalFilePath()); } @Override - public Optional readAddressBook(Path filePath) throws DataConversionException, IOException { + public Optional readCliniCal(Path filePath) throws DataConversionException, IOException { logger.fine("Attempting to read data from file: " + filePath); - return addressBookStorage.readAddressBook(filePath); + return cliniCalStorage.readCliniCal(filePath); } @Override - public void saveAddressBook(ReadOnlyAddressBook addressBook) throws IOException { - saveAddressBook(addressBook, addressBookStorage.getAddressBookFilePath()); + public void saveCliniCal(ReadOnlyCliniCal cliniCal) throws IOException { + saveCliniCal(cliniCal, cliniCalStorage.getCliniCalFilePath()); } @Override - public void saveAddressBook(ReadOnlyAddressBook addressBook, Path filePath) throws IOException { + public void saveCliniCal(ReadOnlyCliniCal cliniCal, Path filePath) throws IOException { logger.fine("Attempting to write to data file: " + filePath); - addressBookStorage.saveAddressBook(addressBook, filePath); + cliniCalStorage.saveCliniCal(cliniCal, filePath); } } diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java index fa2e69dbfd2..39429bab285 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/seedu/address/ui/MainWindow.java @@ -116,7 +116,7 @@ void fillInnerParts() { resultDisplay = new ResultDisplay(); resultDisplayPlaceholder.getChildren().add(resultDisplay.getRoot()); - StatusBarFooter statusBarFooter = new StatusBarFooter(logic.getAddressBookFilePath()); + StatusBarFooter statusBarFooter = new StatusBarFooter(logic.getCliniCalFilePath()); statusbarPlaceholder.getChildren().add(statusBarFooter.getRoot()); CommandBox commandBox = new CommandBox(this::executeCommand); diff --git a/src/main/java/seedu/address/ui/UiManager.java b/src/main/java/seedu/address/ui/UiManager.java index 882027e4537..280114361c2 100644 --- a/src/main/java/seedu/address/ui/UiManager.java +++ b/src/main/java/seedu/address/ui/UiManager.java @@ -20,7 +20,7 @@ public class UiManager implements Ui { public static final String ALERT_DIALOG_PANE_FIELD_ID = "alertDialogPane"; private static final Logger logger = LogsCenter.getLogger(UiManager.class); - private static final String ICON_APPLICATION = "/images/address_book_32.png"; + private static final String ICON_APPLICATION = "/images/stethoscope.png"; private Logic logic; private MainWindow mainWindow; diff --git a/src/main/resources/images/stethoscope.png b/src/main/resources/images/stethoscope.png new file mode 100644 index 00000000000..23b613d630b Binary files /dev/null and b/src/main/resources/images/stethoscope.png differ diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml index 53958b1979b..b59ea335bd2 100644 --- a/src/main/resources/view/MainWindow.fxml +++ b/src/main/resources/view/MainWindow.fxml @@ -12,9 +12,9 @@ + title="CliniCal" minWidth="450" minHeight="600" onCloseRequest="#handleExit"> - + diff --git a/src/test/data/JsonAddressBookStorageTest/invalidAndValidPatientAddressBook.json b/src/test/data/JsonCliniCalStorageTest/invalidAndValidPatientCliniCal.json similarity index 100% rename from src/test/data/JsonAddressBookStorageTest/invalidAndValidPatientAddressBook.json rename to src/test/data/JsonCliniCalStorageTest/invalidAndValidPatientCliniCal.json diff --git a/src/test/data/JsonAddressBookStorageTest/invalidPatientAddressBook.json b/src/test/data/JsonCliniCalStorageTest/invalidPatientCliniCal.json similarity index 100% rename from src/test/data/JsonAddressBookStorageTest/invalidPatientAddressBook.json rename to src/test/data/JsonCliniCalStorageTest/invalidPatientCliniCal.json diff --git a/src/test/data/JsonAddressBookStorageTest/notJsonFormatAddressBook.json b/src/test/data/JsonCliniCalStorageTest/notJsonFormatCliniCal.json similarity index 100% rename from src/test/data/JsonAddressBookStorageTest/notJsonFormatAddressBook.json rename to src/test/data/JsonCliniCalStorageTest/notJsonFormatCliniCal.json diff --git a/src/test/data/JsonSerializableAddressBookTest/duplicatePatientAddressBook.json b/src/test/data/JsonSerializableCliniCalTest/duplicatePatientCliniCal.json similarity index 100% rename from src/test/data/JsonSerializableAddressBookTest/duplicatePatientAddressBook.json rename to src/test/data/JsonSerializableCliniCalTest/duplicatePatientCliniCal.json diff --git a/src/test/data/JsonSerializableAddressBookTest/invalidPatientAddressBook.json b/src/test/data/JsonSerializableCliniCalTest/invalidPatientCliniCal.json similarity index 100% rename from src/test/data/JsonSerializableAddressBookTest/invalidPatientAddressBook.json rename to src/test/data/JsonSerializableCliniCalTest/invalidPatientCliniCal.json diff --git a/src/test/data/JsonSerializableAddressBookTest/typicalPatientsAddressBook.json b/src/test/data/JsonSerializableCliniCalTest/typicalPatientsCliniCal.json similarity index 90% rename from src/test/data/JsonSerializableAddressBookTest/typicalPatientsAddressBook.json rename to src/test/data/JsonSerializableCliniCalTest/typicalPatientsCliniCal.json index bce10d54a0b..182a55e21d1 100644 --- a/src/test/data/JsonSerializableAddressBookTest/typicalPatientsAddressBook.json +++ b/src/test/data/JsonSerializableCliniCalTest/typicalPatientsCliniCal.json @@ -1,5 +1,5 @@ { - "_comment": "AddressBook save file which contains the same Patient values as in TypicalPatients#getTypicalAddressBook()", + "_comment": "CliniCal save file which contains the same Patient values as in TypicalPatients#getTypicalCliniCal()", "patients" : [ { "name" : "Alice Pauline", "phone" : "94351253", diff --git a/src/test/data/JsonUserPrefsStorageTest/ExtraValuesUserPref.json b/src/test/data/JsonUserPrefsStorageTest/ExtraValuesUserPref.json index 1037548a9cd..3a34ed54e3b 100644 --- a/src/test/data/JsonUserPrefsStorageTest/ExtraValuesUserPref.json +++ b/src/test/data/JsonUserPrefsStorageTest/ExtraValuesUserPref.json @@ -9,5 +9,5 @@ "z" : 99 } }, - "addressBookFilePath" : "addressbook.json" + "cliniCalFilePath" : "clinical.json" } diff --git a/src/test/data/JsonUserPrefsStorageTest/TypicalUserPref.json b/src/test/data/JsonUserPrefsStorageTest/TypicalUserPref.json index b819bed900a..d14f90f98c3 100644 --- a/src/test/data/JsonUserPrefsStorageTest/TypicalUserPref.json +++ b/src/test/data/JsonUserPrefsStorageTest/TypicalUserPref.json @@ -7,5 +7,5 @@ "y" : 100 } }, - "addressBookFilePath" : "addressbook.json" + "cliniCalFilePath" : "clinical.json" } diff --git a/src/test/java/seedu/address/commons/util/AppUtilTest.java b/src/test/java/seedu/address/commons/util/AppUtilTest.java index 594de1e6365..70ce5529558 100644 --- a/src/test/java/seedu/address/commons/util/AppUtilTest.java +++ b/src/test/java/seedu/address/commons/util/AppUtilTest.java @@ -9,7 +9,7 @@ public class AppUtilTest { @Test public void getImage_exitingImage() { - assertNotNull(AppUtil.getImage("/images/address_book_32.png")); + assertNotNull(AppUtil.getImage("/images/stethoscope.png")); } @Test diff --git a/src/test/java/seedu/address/logic/LogicManagerTest.java b/src/test/java/seedu/address/logic/LogicManagerTest.java index bb7e50bcedf..919bc3396f9 100644 --- a/src/test/java/seedu/address/logic/LogicManagerTest.java +++ b/src/test/java/seedu/address/logic/LogicManagerTest.java @@ -24,10 +24,10 @@ import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.Model; import seedu.address.model.ModelManager; -import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.ReadOnlyCliniCal; import seedu.address.model.UserPrefs; import seedu.address.model.patient.Patient; -import seedu.address.storage.JsonAddressBookStorage; +import seedu.address.storage.JsonCliniCalStorage; import seedu.address.storage.JsonUserPrefsStorage; import seedu.address.storage.StorageManager; import seedu.address.testutil.PatientBuilder; @@ -43,10 +43,10 @@ public class LogicManagerTest { @BeforeEach public void setUp() { - JsonAddressBookStorage addressBookStorage = - new JsonAddressBookStorage(temporaryFolder.resolve("addressBook.json")); + JsonCliniCalStorage cliniCalStorage = + new JsonCliniCalStorage(temporaryFolder.resolve("cliniCal.json")); JsonUserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(temporaryFolder.resolve("userPrefs.json")); - StorageManager storage = new StorageManager(addressBookStorage, userPrefsStorage); + StorageManager storage = new StorageManager(cliniCalStorage, userPrefsStorage); logic = new LogicManager(model, storage); } @@ -70,12 +70,12 @@ public void execute_validCommand_success() throws Exception { @Test public void execute_storageThrowsIoException_throwsCommandException() { - // Setup LogicManager with JsonAddressBookIoExceptionThrowingStub - JsonAddressBookStorage addressBookStorage = - new JsonAddressBookIoExceptionThrowingStub(temporaryFolder.resolve("ioExceptionAddressBook.json")); + // Setup LogicManager with JsonCliniCalIoExceptionThrowingStub + JsonCliniCalStorage cliniCalStorage = + new JsonCliniCalIoExceptionThrowingStub(temporaryFolder.resolve("ioExceptionCliniCal.json")); JsonUserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(temporaryFolder.resolve("ioExceptionUserPrefs.json")); - StorageManager storage = new StorageManager(addressBookStorage, userPrefsStorage); + StorageManager storage = new StorageManager(cliniCalStorage, userPrefsStorage); logic = new LogicManager(model, storage); // Execute add command @@ -129,7 +129,7 @@ private void assertCommandException(String inputCommand, String expectedMessage) */ private void assertCommandFailure(String inputCommand, Class expectedException, String expectedMessage) { - Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); + Model expectedModel = new ModelManager(model.getCliniCal(), new UserPrefs()); assertCommandFailure(inputCommand, expectedException, expectedMessage, expectedModel); } @@ -149,13 +149,13 @@ private void assertCommandFailure(String inputCommand, Class * - a {@code CommandException} is thrown
* - the CommandException message matches {@code expectedMessage}
- * - the address book, filtered patient list and selected patient in {@code actualModel} remain unchanged + * - the clinical, filtered patient list and selected patient in {@code actualModel} remain unchanged */ public static void assertCommandFailure(Command command, Model actualModel, String expectedMessage) { // we are unable to defensively copy the model for comparison later, so we can // only do so by copying its components. - AddressBook expectedAddressBook = new AddressBook(actualModel.getAddressBook()); + CliniCal expectedCliniCal = new CliniCal(actualModel.getCliniCal()); List expectedFilteredList = new ArrayList<>(actualModel.getFilteredPatientList()); assertThrows(CommandException.class, expectedMessage, () -> command.execute(actualModel)); - assertEquals(expectedAddressBook, actualModel.getAddressBook()); + assertEquals(expectedCliniCal, actualModel.getCliniCal()); assertEquals(expectedFilteredList, actualModel.getFilteredPatientList()); } /** * Updates {@code model}'s filtered list to show only the patient at the given {@code targetIndex} in the - * {@code model}'s address book. + * {@code model}'s clinical. */ public static void showPatientAtIndex(Model model, Index targetIndex) { assertTrue(targetIndex.getZeroBased() < model.getFilteredPatientList().size()); diff --git a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java b/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java index 24c33040dc6..8224ae70896 100644 --- a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java @@ -7,7 +7,7 @@ import static seedu.address.logic.commands.CommandTestUtil.showPatientAtIndex; import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PATIENT; import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PATIENT; -import static seedu.address.testutil.TypicalPatients.getTypicalAddressBook; +import static seedu.address.testutil.TypicalPatients.getTypicalCliniCal; import org.junit.jupiter.api.Test; @@ -24,7 +24,7 @@ */ public class DeleteCommandTest { - private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + private Model model = new ModelManager(getTypicalCliniCal(), new UserPrefs()); @Test public void execute_validIndexUnfilteredList_success() { @@ -33,7 +33,7 @@ public void execute_validIndexUnfilteredList_success() { String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PATIENT_SUCCESS, patientToDelete); - ModelManager expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); + ModelManager expectedModel = new ModelManager(model.getCliniCal(), new UserPrefs()); expectedModel.deletePatient(patientToDelete); assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); @@ -56,7 +56,7 @@ public void execute_validIndexFilteredList_success() { String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PATIENT_SUCCESS, patientToDelete); - Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); + Model expectedModel = new ModelManager(model.getCliniCal(), new UserPrefs()); expectedModel.deletePatient(patientToDelete); showNoPatient(expectedModel); @@ -68,8 +68,8 @@ public void execute_invalidIndexFilteredList_throwsCommandException() { showPatientAtIndex(model, INDEX_FIRST_PATIENT); Index outOfBoundIndex = INDEX_SECOND_PATIENT; - // ensures that outOfBoundIndex is still in bounds of address book list - assertTrue(outOfBoundIndex.getZeroBased() < model.getAddressBook().getPatientList().size()); + // ensures that outOfBoundIndex is still in bounds of clinical list + assertTrue(outOfBoundIndex.getZeroBased() < model.getCliniCal().getPatientList().size()); DeleteCommand deleteCommand = new DeleteCommand(outOfBoundIndex); diff --git a/src/test/java/seedu/address/logic/commands/EditCommandTest.java b/src/test/java/seedu/address/logic/commands/EditCommandTest.java index c99ae0e8557..81a8e1aaebc 100644 --- a/src/test/java/seedu/address/logic/commands/EditCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/EditCommandTest.java @@ -12,14 +12,14 @@ import static seedu.address.logic.commands.CommandTestUtil.showPatientAtIndex; import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PATIENT; import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PATIENT; -import static seedu.address.testutil.TypicalPatients.getTypicalAddressBook; +import static seedu.address.testutil.TypicalPatients.getTypicalCliniCal; import org.junit.jupiter.api.Test; import seedu.address.commons.core.Messages; import seedu.address.commons.core.index.Index; import seedu.address.logic.commands.EditCommand.EditPatientDescriptor; -import seedu.address.model.AddressBook; +import seedu.address.model.CliniCal; import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; @@ -32,7 +32,7 @@ */ public class EditCommandTest { - private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + private Model model = new ModelManager(getTypicalCliniCal(), new UserPrefs()); @Test public void execute_allFieldsSpecifiedUnfilteredList_success() { @@ -42,7 +42,7 @@ public void execute_allFieldsSpecifiedUnfilteredList_success() { String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PATIENT_SUCCESS, editedPatient); - Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); + Model expectedModel = new ModelManager(new CliniCal(model.getCliniCal()), new UserPrefs()); expectedModel.setPatient(model.getFilteredPatientList().get(0), editedPatient); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); @@ -63,7 +63,7 @@ public void execute_someFieldsSpecifiedUnfilteredList_success() { String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PATIENT_SUCCESS, editedPatient); - Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); + Model expectedModel = new ModelManager(new CliniCal(model.getCliniCal()), new UserPrefs()); expectedModel.setPatient(lastPatient, editedPatient); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); @@ -76,7 +76,7 @@ public void execute_noFieldSpecifiedUnfilteredList_success() { String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PATIENT_SUCCESS, editedPatient); - Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); + Model expectedModel = new ModelManager(new CliniCal(model.getCliniCal()), new UserPrefs()); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); } @@ -92,7 +92,7 @@ public void execute_filteredList_success() { String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PATIENT_SUCCESS, editedPatient); - Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); + Model expectedModel = new ModelManager(new CliniCal(model.getCliniCal()), new UserPrefs()); expectedModel.setPatient(model.getFilteredPatientList().get(0), editedPatient); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); @@ -111,8 +111,8 @@ public void execute_duplicatePatientUnfilteredList_failure() { public void execute_duplicatePatientFilteredList_failure() { showPatientAtIndex(model, INDEX_FIRST_PATIENT); - // edit patient in filtered list into a duplicate in address book - Patient patientInList = model.getAddressBook().getPatientList().get(INDEX_SECOND_PATIENT.getZeroBased()); + // edit patient in filtered list into a duplicate in clinical + Patient patientInList = model.getCliniCal().getPatientList().get(INDEX_SECOND_PATIENT.getZeroBased()); EditCommand editCommand = new EditCommand(INDEX_FIRST_PATIENT, new EditPatientDescriptorBuilder(patientInList).build()); @@ -131,14 +131,14 @@ public void execute_invalidPatientIndexUnfilteredList_failure() { /** * Edit filtered list where index is larger than size of filtered list, - * but smaller than size of address book + * but smaller than size of clinical */ @Test public void execute_invalidPatientIndexFilteredList_failure() { showPatientAtIndex(model, INDEX_FIRST_PATIENT); Index outOfBoundIndex = INDEX_SECOND_PATIENT; - // ensures that outOfBoundIndex is still in bounds of address book list - assertTrue(outOfBoundIndex.getZeroBased() < model.getAddressBook().getPatientList().size()); + // ensures that outOfBoundIndex is still in bounds of clinical list + assertTrue(outOfBoundIndex.getZeroBased() < model.getCliniCal().getPatientList().size()); EditCommand editCommand = new EditCommand(outOfBoundIndex, new EditPatientDescriptorBuilder().withName(VALID_NAME_BOB).build()); diff --git a/src/test/java/seedu/address/logic/commands/FindCommandTest.java b/src/test/java/seedu/address/logic/commands/FindCommandTest.java index 8d1874a2a33..72cee209c11 100644 --- a/src/test/java/seedu/address/logic/commands/FindCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/FindCommandTest.java @@ -8,7 +8,7 @@ import static seedu.address.testutil.TypicalPatients.CARL; import static seedu.address.testutil.TypicalPatients.ELLE; import static seedu.address.testutil.TypicalPatients.FIONA; -import static seedu.address.testutil.TypicalPatients.getTypicalAddressBook; +import static seedu.address.testutil.TypicalPatients.getTypicalCliniCal; import java.util.Arrays; import java.util.Collections; @@ -24,8 +24,8 @@ * Contains integration tests (interaction with the Model) for {@code FindCommand}. */ public class FindCommandTest { - private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); - private Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + private Model model = new ModelManager(getTypicalCliniCal(), new UserPrefs()); + private Model expectedModel = new ModelManager(getTypicalCliniCal(), new UserPrefs()); @Test public void equals() { diff --git a/src/test/java/seedu/address/logic/commands/ListCommandTest.java b/src/test/java/seedu/address/logic/commands/ListCommandTest.java index 1a05bc24247..da172871069 100644 --- a/src/test/java/seedu/address/logic/commands/ListCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/ListCommandTest.java @@ -3,7 +3,7 @@ import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; import static seedu.address.logic.commands.CommandTestUtil.showPatientAtIndex; import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PATIENT; -import static seedu.address.testutil.TypicalPatients.getTypicalAddressBook; +import static seedu.address.testutil.TypicalPatients.getTypicalCliniCal; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -22,8 +22,8 @@ public class ListCommandTest { @BeforeEach public void setUp() { - model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); - expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); + model = new ModelManager(getTypicalCliniCal(), new UserPrefs()); + expectedModel = new ModelManager(model.getCliniCal(), new UserPrefs()); } @Test diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/seedu/address/logic/parser/CliniCalParserTest.java similarity index 97% rename from src/test/java/seedu/address/logic/parser/AddressBookParserTest.java rename to src/test/java/seedu/address/logic/parser/CliniCalParserTest.java index 88505cb0368..764361ebc49 100644 --- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java +++ b/src/test/java/seedu/address/logic/parser/CliniCalParserTest.java @@ -28,9 +28,9 @@ import seedu.address.testutil.PatientBuilder; import seedu.address.testutil.PatientUtil; -public class AddressBookParserTest { +public class CliniCalParserTest { - private final AddressBookParser parser = new AddressBookParser(); + private final CliniCalParser parser = new CliniCalParser(); @Test public void parseCommand_add() throws Exception { diff --git a/src/test/java/seedu/address/model/AddressBookTest.java b/src/test/java/seedu/address/model/CliniCalTest.java similarity index 58% rename from src/test/java/seedu/address/model/AddressBookTest.java rename to src/test/java/seedu/address/model/CliniCalTest.java index 083553ff73a..f0e782e36ac 100644 --- a/src/test/java/seedu/address/model/AddressBookTest.java +++ b/src/test/java/seedu/address/model/CliniCalTest.java @@ -7,7 +7,7 @@ import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; import static seedu.address.testutil.Assert.assertThrows; import static seedu.address.testutil.TypicalPatients.ALICE; -import static seedu.address.testutil.TypicalPatients.getTypicalAddressBook; +import static seedu.address.testutil.TypicalPatients.getTypicalCliniCal; import java.util.Arrays; import java.util.Collection; @@ -22,25 +22,25 @@ import seedu.address.model.patient.exceptions.DuplicatePatientException; import seedu.address.testutil.PatientBuilder; -public class AddressBookTest { +public class CliniCalTest { - private final AddressBook addressBook = new AddressBook(); + private final CliniCal cliniCal = new CliniCal(); @Test public void constructor() { - assertEquals(Collections.emptyList(), addressBook.getPatientList()); + assertEquals(Collections.emptyList(), cliniCal.getPatientList()); } @Test public void resetData_null_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> addressBook.resetData(null)); + assertThrows(NullPointerException.class, () -> cliniCal.resetData(null)); } @Test - public void resetData_withValidReadOnlyAddressBook_replacesData() { - AddressBook newData = getTypicalAddressBook(); - addressBook.resetData(newData); - assertEquals(newData, addressBook); + public void resetData_withValidReadOnlyCliniCal_replacesData() { + CliniCal newData = getTypicalCliniCal(); + cliniCal.resetData(newData); + assertEquals(newData, cliniCal); } @Test @@ -49,47 +49,47 @@ public void resetData_withDuplicatePatients_throwsDuplicatePatientException() { Patient editedAlice = new PatientBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) .build(); List newPatients = Arrays.asList(ALICE, editedAlice); - AddressBookStub newData = new AddressBookStub(newPatients); + CliniCalStub newData = new CliniCalStub(newPatients); - assertThrows(DuplicatePatientException.class, () -> addressBook.resetData(newData)); + assertThrows(DuplicatePatientException.class, () -> cliniCal.resetData(newData)); } @Test public void hasPatient_nullPatient_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> addressBook.hasPatient(null)); + assertThrows(NullPointerException.class, () -> cliniCal.hasPatient(null)); } @Test - public void hasPatient_patientNotInAddressBook_returnsFalse() { - assertFalse(addressBook.hasPatient(ALICE)); + public void hasPatient_patientNotInCliniCal_returnsFalse() { + assertFalse(cliniCal.hasPatient(ALICE)); } @Test - public void hasPatient_patientInAddressBook_returnsTrue() { - addressBook.addPatient(ALICE); - assertTrue(addressBook.hasPatient(ALICE)); + public void hasPatient_patientInCliniCal_returnsTrue() { + cliniCal.addPatient(ALICE); + assertTrue(cliniCal.hasPatient(ALICE)); } @Test - public void hasPatient_patientWithSameIdentityFieldsInAddressBook_returnsTrue() { - addressBook.addPatient(ALICE); + public void hasPatient_patientWithSameIdentityFieldsInCliniCal_returnsTrue() { + cliniCal.addPatient(ALICE); Patient editedAlice = new PatientBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) .build(); - assertTrue(addressBook.hasPatient(editedAlice)); + assertTrue(cliniCal.hasPatient(editedAlice)); } @Test public void getPatientList_modifyList_throwsUnsupportedOperationException() { - assertThrows(UnsupportedOperationException.class, () -> addressBook.getPatientList().remove(0)); + assertThrows(UnsupportedOperationException.class, () -> cliniCal.getPatientList().remove(0)); } /** - * A stub ReadOnlyAddressBook whose patients list can violate interface constraints. + * A stub ReadOnlyCliniCal whose patients list can violate interface constraints. */ - private static class AddressBookStub implements ReadOnlyAddressBook { + private static class CliniCalStub implements ReadOnlyCliniCal { private final ObservableList patients = FXCollections.observableArrayList(); - AddressBookStub(Collection patients) { + CliniCalStub(Collection patients) { this.patients.setAll(patients); } diff --git a/src/test/java/seedu/address/model/ModelManagerTest.java b/src/test/java/seedu/address/model/ModelManagerTest.java index 1cd4fc781fd..0b808e7cf8d 100644 --- a/src/test/java/seedu/address/model/ModelManagerTest.java +++ b/src/test/java/seedu/address/model/ModelManagerTest.java @@ -16,7 +16,7 @@ import seedu.address.commons.core.GuiSettings; import seedu.address.model.patient.NameContainsKeywordsPredicate; -import seedu.address.testutil.AddressBookBuilder; +import seedu.address.testutil.CliniCalBuilder; public class ModelManagerTest { @@ -26,7 +26,7 @@ public class ModelManagerTest { public void constructor() { assertEquals(new UserPrefs(), modelManager.getUserPrefs()); assertEquals(new GuiSettings(), modelManager.getGuiSettings()); - assertEquals(new AddressBook(), new AddressBook(modelManager.getAddressBook())); + assertEquals(new CliniCal(), new CliniCal(modelManager.getCliniCal())); } @Test @@ -37,14 +37,14 @@ public void setUserPrefs_nullUserPrefs_throwsNullPointerException() { @Test public void setUserPrefs_validUserPrefs_copiesUserPrefs() { UserPrefs userPrefs = new UserPrefs(); - userPrefs.setAddressBookFilePath(Paths.get("address/book/file/path")); + userPrefs.setCliniCalFilePath(Paths.get("address/book/file/path")); userPrefs.setGuiSettings(new GuiSettings(1, 2, 3, 4)); modelManager.setUserPrefs(userPrefs); assertEquals(userPrefs, modelManager.getUserPrefs()); // Modifying userPrefs should not modify modelManager's userPrefs UserPrefs oldUserPrefs = new UserPrefs(userPrefs); - userPrefs.setAddressBookFilePath(Paths.get("new/address/book/file/path")); + userPrefs.setCliniCalFilePath(Paths.get("new/address/book/file/path")); assertEquals(oldUserPrefs, modelManager.getUserPrefs()); } @@ -61,15 +61,15 @@ public void setGuiSettings_validGuiSettings_setsGuiSettings() { } @Test - public void setAddressBookFilePath_nullPath_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> modelManager.setAddressBookFilePath(null)); + public void setCliniCalFilePath_nullPath_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> modelManager.setCliniCalFilePath(null)); } @Test - public void setAddressBookFilePath_validPath_setsAddressBookFilePath() { + public void setCliniCalFilePath_validPath_setsCliniCalFilePath() { Path path = Paths.get("address/book/file/path"); - modelManager.setAddressBookFilePath(path); - assertEquals(path, modelManager.getAddressBookFilePath()); + modelManager.setCliniCalFilePath(path); + assertEquals(path, modelManager.getCliniCalFilePath()); } @Test @@ -78,12 +78,12 @@ public void hasPatient_nullPatient_throwsNullPointerException() { } @Test - public void hasPatient_patientNotInAddressBook_returnsFalse() { + public void hasPatient_patientNotInCliniCal_returnsFalse() { assertFalse(modelManager.hasPatient(ALICE)); } @Test - public void hasPatient_patientInAddressBook_returnsTrue() { + public void hasPatient_patientInCliniCal_returnsTrue() { modelManager.addPatient(ALICE); assertTrue(modelManager.hasPatient(ALICE)); } @@ -95,13 +95,13 @@ public void getFilteredPatientList_modifyList_throwsUnsupportedOperationExceptio @Test public void equals() { - AddressBook addressBook = new AddressBookBuilder().withPatient(ALICE).withPatient(BENSON).build(); - AddressBook differentAddressBook = new AddressBook(); + CliniCal cliniCal = new CliniCalBuilder().withPatient(ALICE).withPatient(BENSON).build(); + CliniCal differentCliniCal = new CliniCal(); UserPrefs userPrefs = new UserPrefs(); // same values -> returns true - modelManager = new ModelManager(addressBook, userPrefs); - ModelManager modelManagerCopy = new ModelManager(addressBook, userPrefs); + modelManager = new ModelManager(cliniCal, userPrefs); + ModelManager modelManagerCopy = new ModelManager(cliniCal, userPrefs); assertTrue(modelManager.equals(modelManagerCopy)); // same object -> returns true @@ -113,20 +113,20 @@ public void equals() { // different types -> returns false assertFalse(modelManager.equals(5)); - // different addressBook -> returns false - assertFalse(modelManager.equals(new ModelManager(differentAddressBook, userPrefs))); + // different cliniCal -> returns false + assertFalse(modelManager.equals(new ModelManager(differentCliniCal, userPrefs))); // different filteredList -> returns false String[] keywords = ALICE.getName().fullName.split("\\s+"); modelManager.updateFilteredPatientList(new NameContainsKeywordsPredicate(Arrays.asList(keywords))); - assertFalse(modelManager.equals(new ModelManager(addressBook, userPrefs))); + assertFalse(modelManager.equals(new ModelManager(cliniCal, userPrefs))); // resets modelManager to initial state for upcoming tests modelManager.updateFilteredPatientList(PREDICATE_SHOW_ALL_PATIENTS); // different userPrefs -> returns false UserPrefs differentUserPrefs = new UserPrefs(); - differentUserPrefs.setAddressBookFilePath(Paths.get("differentFilePath")); - assertFalse(modelManager.equals(new ModelManager(addressBook, differentUserPrefs))); + differentUserPrefs.setCliniCalFilePath(Paths.get("differentFilePath")); + assertFalse(modelManager.equals(new ModelManager(cliniCal, differentUserPrefs))); } } diff --git a/src/test/java/seedu/address/model/UserPrefsTest.java b/src/test/java/seedu/address/model/UserPrefsTest.java index b1307a70d52..385f9384edd 100644 --- a/src/test/java/seedu/address/model/UserPrefsTest.java +++ b/src/test/java/seedu/address/model/UserPrefsTest.java @@ -13,9 +13,9 @@ public void setGuiSettings_nullGuiSettings_throwsNullPointerException() { } @Test - public void setAddressBookFilePath_nullPath_throwsNullPointerException() { + public void setCliniCalFilePath_nullPath_throwsNullPointerException() { UserPrefs userPrefs = new UserPrefs(); - assertThrows(NullPointerException.class, () -> userPrefs.setAddressBookFilePath(null)); + assertThrows(NullPointerException.class, () -> userPrefs.setCliniCalFilePath(null)); } } diff --git a/src/test/java/seedu/address/storage/JsonAddressBookStorageTest.java b/src/test/java/seedu/address/storage/JsonAddressBookStorageTest.java deleted file mode 100644 index 53f34f28142..00000000000 --- a/src/test/java/seedu/address/storage/JsonAddressBookStorageTest.java +++ /dev/null @@ -1,110 +0,0 @@ -package seedu.address.storage; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static seedu.address.testutil.Assert.assertThrows; -import static seedu.address.testutil.TypicalPatients.ALICE; -import static seedu.address.testutil.TypicalPatients.HOON; -import static seedu.address.testutil.TypicalPatients.IDA; -import static seedu.address.testutil.TypicalPatients.getTypicalAddressBook; - -import java.io.IOException; -import java.nio.file.Path; -import java.nio.file.Paths; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; - -import seedu.address.commons.exceptions.DataConversionException; -import seedu.address.model.AddressBook; -import seedu.address.model.ReadOnlyAddressBook; - -public class JsonAddressBookStorageTest { - private static final Path TEST_DATA_FOLDER = Paths.get("src", "test", "data", "JsonAddressBookStorageTest"); - - @TempDir - public Path testFolder; - - @Test - public void readAddressBook_nullFilePath_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> readAddressBook(null)); - } - - private java.util.Optional readAddressBook(String filePath) throws Exception { - return new JsonAddressBookStorage(Paths.get(filePath)).readAddressBook(addToTestDataPathIfNotNull(filePath)); - } - - private Path addToTestDataPathIfNotNull(String prefsFileInTestDataFolder) { - return prefsFileInTestDataFolder != null - ? TEST_DATA_FOLDER.resolve(prefsFileInTestDataFolder) - : null; - } - - @Test - public void read_missingFile_emptyResult() throws Exception { - assertFalse(readAddressBook("NonExistentFile.json").isPresent()); - } - - @Test - public void read_notJsonFormat_exceptionThrown() { - assertThrows(DataConversionException.class, () -> readAddressBook("notJsonFormatAddressBook.json")); - } - - @Test - public void readAddressBook_invalidPatientAddressBook_throwDataConversionException() { - assertThrows(DataConversionException.class, () -> readAddressBook("invalidPatientAddressBook.json")); - } - - @Test - public void readAddressBook_invalidAndValidPatientAddressBook_throwDataConversionException() { - assertThrows(DataConversionException.class, () -> readAddressBook("invalidAndValidPatientAddressBook.json")); - } - - @Test - public void readAndSaveAddressBook_allInOrder_success() throws Exception { - Path filePath = testFolder.resolve("TempAddressBook.json"); - AddressBook original = getTypicalAddressBook(); - JsonAddressBookStorage jsonAddressBookStorage = new JsonAddressBookStorage(filePath); - - // Save in new file and read back - jsonAddressBookStorage.saveAddressBook(original, filePath); - ReadOnlyAddressBook readBack = jsonAddressBookStorage.readAddressBook(filePath).get(); - assertEquals(original, new AddressBook(readBack)); - - // Modify data, overwrite exiting file, and read back - original.addPatient(HOON); - original.removePatient(ALICE); - jsonAddressBookStorage.saveAddressBook(original, filePath); - readBack = jsonAddressBookStorage.readAddressBook(filePath).get(); - assertEquals(original, new AddressBook(readBack)); - - // Save and read without specifying file path - original.addPatient(IDA); - jsonAddressBookStorage.saveAddressBook(original); // file path not specified - readBack = jsonAddressBookStorage.readAddressBook().get(); // file path not specified - assertEquals(original, new AddressBook(readBack)); - - } - - @Test - public void saveAddressBook_nullAddressBook_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> saveAddressBook(null, "SomeFile.json")); - } - - /** - * Saves {@code addressBook} at the specified {@code filePath}. - */ - private void saveAddressBook(ReadOnlyAddressBook addressBook, String filePath) { - try { - new JsonAddressBookStorage(Paths.get(filePath)) - .saveAddressBook(addressBook, addToTestDataPathIfNotNull(filePath)); - } catch (IOException ioe) { - throw new AssertionError("There should not be an error writing to the file.", ioe); - } - } - - @Test - public void saveAddressBook_nullFilePath_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> saveAddressBook(new AddressBook(), null)); - } -} diff --git a/src/test/java/seedu/address/storage/JsonCliniCalStorageTest.java b/src/test/java/seedu/address/storage/JsonCliniCalStorageTest.java new file mode 100644 index 00000000000..e4590f2d3d8 --- /dev/null +++ b/src/test/java/seedu/address/storage/JsonCliniCalStorageTest.java @@ -0,0 +1,110 @@ +package seedu.address.storage; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static seedu.address.testutil.Assert.assertThrows; +import static seedu.address.testutil.TypicalPatients.ALICE; +import static seedu.address.testutil.TypicalPatients.HOON; +import static seedu.address.testutil.TypicalPatients.IDA; +import static seedu.address.testutil.TypicalPatients.getTypicalCliniCal; + +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +import seedu.address.commons.exceptions.DataConversionException; +import seedu.address.model.CliniCal; +import seedu.address.model.ReadOnlyCliniCal; + +public class JsonCliniCalStorageTest { + private static final Path TEST_DATA_FOLDER = Paths.get("src", "test", "data", "JsonCliniCalStorageTest"); + + @TempDir + public Path testFolder; + + @Test + public void readCliniCal_nullFilePath_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> readCliniCal(null)); + } + + private java.util.Optional readCliniCal(String filePath) throws Exception { + return new JsonCliniCalStorage(Paths.get(filePath)).readCliniCal(addToTestDataPathIfNotNull(filePath)); + } + + private Path addToTestDataPathIfNotNull(String prefsFileInTestDataFolder) { + return prefsFileInTestDataFolder != null + ? TEST_DATA_FOLDER.resolve(prefsFileInTestDataFolder) + : null; + } + + @Test + public void read_missingFile_emptyResult() throws Exception { + assertFalse(readCliniCal("NonExistentFile.json").isPresent()); + } + + @Test + public void read_notJsonFormat_exceptionThrown() { + assertThrows(DataConversionException.class, () -> readCliniCal("notJsonFormatCliniCal.json")); + } + + @Test + public void readCliniCal_invalidPatientCliniCal_throwDataConversionException() { + assertThrows(DataConversionException.class, () -> readCliniCal("invalidPatientCliniCal.json")); + } + + @Test + public void readCliniCal_invalidAndValidPatientCliniCal_throwDataConversionException() { + assertThrows(DataConversionException.class, () -> readCliniCal("invalidAndValidPatientCliniCal.json")); + } + + @Test + public void readAndSaveCliniCal_allInOrder_success() throws Exception { + Path filePath = testFolder.resolve("TempCliniCal.json"); + CliniCal original = getTypicalCliniCal(); + JsonCliniCalStorage jsonCliniCalStorage = new JsonCliniCalStorage(filePath); + + // Save in new file and read back + jsonCliniCalStorage.saveCliniCal(original, filePath); + ReadOnlyCliniCal readBack = jsonCliniCalStorage.readCliniCal(filePath).get(); + assertEquals(original, new CliniCal(readBack)); + + // Modify data, overwrite exiting file, and read back + original.addPatient(HOON); + original.removePatient(ALICE); + jsonCliniCalStorage.saveCliniCal(original, filePath); + readBack = jsonCliniCalStorage.readCliniCal(filePath).get(); + assertEquals(original, new CliniCal(readBack)); + + // Save and read without specifying file path + original.addPatient(IDA); + jsonCliniCalStorage.saveCliniCal(original); // file path not specified + readBack = jsonCliniCalStorage.readCliniCal().get(); // file path not specified + assertEquals(original, new CliniCal(readBack)); + + } + + @Test + public void saveCliniCal_nullCliniCal_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> saveCliniCal(null, "SomeFile.json")); + } + + /** + * Saves {@code cliniCal} at the specified {@code filePath}. + */ + private void saveCliniCal(ReadOnlyCliniCal cliniCal, String filePath) { + try { + new JsonCliniCalStorage(Paths.get(filePath)) + .saveCliniCal(cliniCal, addToTestDataPathIfNotNull(filePath)); + } catch (IOException ioe) { + throw new AssertionError("There should not be an error writing to the file.", ioe); + } + } + + @Test + public void saveCliniCal_nullFilePath_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> saveCliniCal(new CliniCal(), null)); + } +} diff --git a/src/test/java/seedu/address/storage/JsonSerializableAddressBookTest.java b/src/test/java/seedu/address/storage/JsonSerializableCliniCalTest.java similarity index 53% rename from src/test/java/seedu/address/storage/JsonSerializableAddressBookTest.java rename to src/test/java/seedu/address/storage/JsonSerializableCliniCalTest.java index 14b438cd8f3..d494999dd17 100644 --- a/src/test/java/seedu/address/storage/JsonSerializableAddressBookTest.java +++ b/src/test/java/seedu/address/storage/JsonSerializableCliniCalTest.java @@ -10,37 +10,37 @@ import seedu.address.commons.exceptions.IllegalValueException; import seedu.address.commons.util.JsonUtil; -import seedu.address.model.AddressBook; +import seedu.address.model.CliniCal; import seedu.address.testutil.TypicalPatients; -public class JsonSerializableAddressBookTest { +public class JsonSerializableCliniCalTest { - private static final Path TEST_DATA_FOLDER = Paths.get("src", "test", "data", "JsonSerializableAddressBookTest"); - private static final Path TYPICAL_PATIENTS_FILE = TEST_DATA_FOLDER.resolve("typicalPatientsAddressBook.json"); - private static final Path INVALID_PATIENT_FILE = TEST_DATA_FOLDER.resolve("invalidPatientAddressBook.json"); - private static final Path DUPLICATE_PATIENT_FILE = TEST_DATA_FOLDER.resolve("duplicatePatientAddressBook.json"); + private static final Path TEST_DATA_FOLDER = Paths.get("src", "test", "data", "JsonSerializableCliniCalTest"); + private static final Path TYPICAL_PATIENTS_FILE = TEST_DATA_FOLDER.resolve("typicalPatientsCliniCal.json"); + private static final Path INVALID_PATIENT_FILE = TEST_DATA_FOLDER.resolve("invalidPatientCliniCal.json"); + private static final Path DUPLICATE_PATIENT_FILE = TEST_DATA_FOLDER.resolve("duplicatePatientCliniCal.json"); @Test public void toModelType_typicalPatientsFile_success() throws Exception { - JsonSerializableAddressBook dataFromFile = JsonUtil.readJsonFile(TYPICAL_PATIENTS_FILE, - JsonSerializableAddressBook.class).get(); - AddressBook addressBookFromFile = dataFromFile.toModelType(); - AddressBook typicalPatientsAddressBook = TypicalPatients.getTypicalAddressBook(); - assertEquals(addressBookFromFile, typicalPatientsAddressBook); + JsonSerializableCliniCal dataFromFile = JsonUtil.readJsonFile(TYPICAL_PATIENTS_FILE, + JsonSerializableCliniCal.class).get(); + CliniCal cliniCalFromFile = dataFromFile.toModelType(); + CliniCal typicalPatientsCliniCal = TypicalPatients.getTypicalCliniCal(); + assertEquals(cliniCalFromFile, typicalPatientsCliniCal); } @Test public void toModelType_invalidPatientFile_throwsIllegalValueException() throws Exception { - JsonSerializableAddressBook dataFromFile = JsonUtil.readJsonFile(INVALID_PATIENT_FILE, - JsonSerializableAddressBook.class).get(); + JsonSerializableCliniCal dataFromFile = JsonUtil.readJsonFile(INVALID_PATIENT_FILE, + JsonSerializableCliniCal.class).get(); assertThrows(IllegalValueException.class, dataFromFile::toModelType); } @Test public void toModelType_duplicatePatients_throwsIllegalValueException() throws Exception { - JsonSerializableAddressBook dataFromFile = JsonUtil.readJsonFile(DUPLICATE_PATIENT_FILE, - JsonSerializableAddressBook.class).get(); - assertThrows(IllegalValueException.class, JsonSerializableAddressBook.MESSAGE_DUPLICATE_PATIENT, + JsonSerializableCliniCal dataFromFile = JsonUtil.readJsonFile(DUPLICATE_PATIENT_FILE, + JsonSerializableCliniCal.class).get(); + assertThrows(IllegalValueException.class, JsonSerializableCliniCal.MESSAGE_DUPLICATE_PATIENT, dataFromFile::toModelType); } diff --git a/src/test/java/seedu/address/storage/JsonUserPrefsStorageTest.java b/src/test/java/seedu/address/storage/JsonUserPrefsStorageTest.java index 16f33f4a6bb..41677b8309d 100644 --- a/src/test/java/seedu/address/storage/JsonUserPrefsStorageTest.java +++ b/src/test/java/seedu/address/storage/JsonUserPrefsStorageTest.java @@ -73,7 +73,7 @@ public void readUserPrefs_extraValuesInFile_extraValuesIgnored() throws DataConv private UserPrefs getTypicalUserPrefs() { UserPrefs userPrefs = new UserPrefs(); userPrefs.setGuiSettings(new GuiSettings(1000, 500, 300, 100)); - userPrefs.setAddressBookFilePath(Paths.get("addressbook.json")); + userPrefs.setCliniCalFilePath(Paths.get("clinical.json")); return userPrefs; } diff --git a/src/test/java/seedu/address/storage/StorageManagerTest.java b/src/test/java/seedu/address/storage/StorageManagerTest.java index 7c3845d3b97..248f5dc67a2 100644 --- a/src/test/java/seedu/address/storage/StorageManagerTest.java +++ b/src/test/java/seedu/address/storage/StorageManagerTest.java @@ -2,7 +2,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static seedu.address.testutil.TypicalPatients.getTypicalAddressBook; +import static seedu.address.testutil.TypicalPatients.getTypicalCliniCal; import java.nio.file.Path; @@ -11,8 +11,8 @@ import org.junit.jupiter.api.io.TempDir; import seedu.address.commons.core.GuiSettings; -import seedu.address.model.AddressBook; -import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.CliniCal; +import seedu.address.model.ReadOnlyCliniCal; import seedu.address.model.UserPrefs; public class StorageManagerTest { @@ -24,9 +24,9 @@ public class StorageManagerTest { @BeforeEach public void setUp() { - JsonAddressBookStorage addressBookStorage = new JsonAddressBookStorage(getTempFilePath("ab")); + JsonCliniCalStorage cliniCalStorage = new JsonCliniCalStorage(getTempFilePath("ab")); JsonUserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(getTempFilePath("prefs")); - storageManager = new StorageManager(addressBookStorage, userPrefsStorage); + storageManager = new StorageManager(cliniCalStorage, userPrefsStorage); } private Path getTempFilePath(String fileName) { @@ -48,21 +48,21 @@ public void prefsReadSave() throws Exception { } @Test - public void addressBookReadSave() throws Exception { + public void cliniCalReadSave() throws Exception { /* * Note: This is an integration test that verifies the StorageManager is properly wired to the - * {@link JsonAddressBookStorage} class. - * More extensive testing of UserPref saving/reading is done in {@link JsonAddressBookStorageTest} class. + * {@link JsonCliniCalStorage} class. + * More extensive testing of UserPref saving/reading is done in {@link JsonCliniCalStorageTest} class. */ - AddressBook original = getTypicalAddressBook(); - storageManager.saveAddressBook(original); - ReadOnlyAddressBook retrieved = storageManager.readAddressBook().get(); - assertEquals(original, new AddressBook(retrieved)); + CliniCal original = getTypicalCliniCal(); + storageManager.saveCliniCal(original); + ReadOnlyCliniCal retrieved = storageManager.readCliniCal().get(); + assertEquals(original, new CliniCal(retrieved)); } @Test - public void getAddressBookFilePath() { - assertNotNull(storageManager.getAddressBookFilePath()); + public void getCliniCalFilePath() { + assertNotNull(storageManager.getCliniCalFilePath()); } } diff --git a/src/test/java/seedu/address/testutil/AddressBookBuilder.java b/src/test/java/seedu/address/testutil/AddressBookBuilder.java deleted file mode 100644 index dce68da40b8..00000000000 --- a/src/test/java/seedu/address/testutil/AddressBookBuilder.java +++ /dev/null @@ -1,34 +0,0 @@ -package seedu.address.testutil; - -import seedu.address.model.AddressBook; -import seedu.address.model.patient.Patient; - -/** - * A utility class to help with building Addressbook objects. - * Example usage:
- * {@code AddressBook ab = new AddressBookBuilder().withPatient("John", "Doe").build();} - */ -public class AddressBookBuilder { - - private AddressBook addressBook; - - public AddressBookBuilder() { - addressBook = new AddressBook(); - } - - public AddressBookBuilder(AddressBook addressBook) { - this.addressBook = addressBook; - } - - /** - * Adds a new {@code Patient} to the {@code AddressBook} that we are building. - */ - public AddressBookBuilder withPatient(Patient patient) { - addressBook.addPatient(patient); - return this; - } - - public AddressBook build() { - return addressBook; - } -} diff --git a/src/test/java/seedu/address/testutil/CliniCalBuilder.java b/src/test/java/seedu/address/testutil/CliniCalBuilder.java new file mode 100644 index 00000000000..b13eaf49077 --- /dev/null +++ b/src/test/java/seedu/address/testutil/CliniCalBuilder.java @@ -0,0 +1,34 @@ +package seedu.address.testutil; + +import seedu.address.model.CliniCal; +import seedu.address.model.patient.Patient; + +/** + * A utility class to help with building CliniCal objects. + * Example usage:
+ * {@code CliniCal ab = new CliniCalBuilder().withPatient("John", "Doe").build();} + */ +public class CliniCalBuilder { + + private CliniCal cliniCal; + + public CliniCalBuilder() { + cliniCal = new CliniCal(); + } + + public CliniCalBuilder(CliniCal cliniCal) { + this.cliniCal = cliniCal; + } + + /** + * Adds a new {@code Patient} to the {@code CliniCal} that we are building. + */ + public CliniCalBuilder withPatient(Patient patient) { + cliniCal.addPatient(patient); + return this; + } + + public CliniCal build() { + return cliniCal; + } +} diff --git a/src/test/java/seedu/address/testutil/TypicalPatients.java b/src/test/java/seedu/address/testutil/TypicalPatients.java index cb26142db02..159467806c9 100644 --- a/src/test/java/seedu/address/testutil/TypicalPatients.java +++ b/src/test/java/seedu/address/testutil/TypicalPatients.java @@ -15,7 +15,7 @@ import java.util.Arrays; import java.util.List; -import seedu.address.model.AddressBook; +import seedu.address.model.CliniCal; import seedu.address.model.patient.Patient; /** @@ -60,10 +60,10 @@ public class TypicalPatients { private TypicalPatients() {} // prevents instantiation /** - * Returns an {@code AddressBook} with all the typical patients. + * Returns an {@code CliniCal} with all the typical patients. */ - public static AddressBook getTypicalAddressBook() { - AddressBook ab = new AddressBook(); + public static CliniCal getTypicalCliniCal() { + CliniCal ab = new CliniCal(); for (Patient patient : getTypicalPatients()) { ab.addPatient(patient); }