From 390ab6fa166ddee3a5181443765846db30a0e4b4 Mon Sep 17 00:00:00 2001 From: tsulim Date: Sun, 10 Mar 2024 06:45:13 +0800 Subject: [PATCH 01/16] Refactor `AddressBook` class to `StaffConnect` class --- .../diagrams/ArchitectureSequenceDiagram.puml | 2 +- src/main/java/seedu/address/MainApp.java | 12 +++--- src/main/java/seedu/address/logic/Logic.java | 2 +- .../address/logic/commands/ClearCommand.java | 4 +- src/main/java/seedu/address/model/Model.java | 2 +- .../seedu/address/model/ModelManager.java | 26 ++++++------ .../{AddressBook.java => StaffConnect.java} | 32 +++++++-------- .../address/model/util/SampleDataUtil.java | 6 +-- .../address/storage/AddressBookStorage.java | 4 +- .../storage/JsonAddressBookStorage.java | 2 +- .../storage/JsonSerializableAddressBook.java | 16 ++++---- .../seedu/address/storage/StorageManager.java | 4 +- .../logic/commands/AddCommandTest.java | 4 +- .../logic/commands/ClearCommandTest.java | 4 +- .../logic/commands/CommandTestUtil.java | 6 +-- .../logic/commands/EditCommandTest.java | 10 ++--- ...rTest.java => StaffConnectParserTest.java} | 2 +- .../seedu/address/model/ModelManagerTest.java | 18 ++++----- ...essBookTest.java => StaffConnectTest.java} | 40 +++++++++---------- ... => JsonSerializableStaffConnectTest.java} | 12 +++--- ....java => JsonStaffConnectStorageTest.java} | 16 ++++---- .../address/storage/StorageManagerTest.java | 8 ++-- .../address/testutil/AddressBookBuilder.java | 20 +++++----- .../address/testutil/TypicalPersons.java | 8 ++-- 24 files changed, 130 insertions(+), 130 deletions(-) rename src/main/java/seedu/address/model/{AddressBook.java => StaffConnect.java} (75%) rename src/test/java/seedu/address/logic/parser/{AddressBookParserTest.java => StaffConnectParserTest.java} (99%) rename src/test/java/seedu/address/model/{AddressBookTest.java => StaffConnectTest.java} (67%) rename src/test/java/seedu/address/storage/{JsonSerializableAddressBookTest.java => JsonSerializableStaffConnectTest.java} (82%) rename src/test/java/seedu/address/storage/{JsonAddressBookStorageTest.java => JsonStaffConnectStorageTest.java} (90%) diff --git a/docs/diagrams/ArchitectureSequenceDiagram.puml b/docs/diagrams/ArchitectureSequenceDiagram.puml index 48b6cc4333c..a8d42245707 100644 --- a/docs/diagrams/ArchitectureSequenceDiagram.puml +++ b/docs/diagrams/ArchitectureSequenceDiagram.puml @@ -20,7 +20,7 @@ activate model MODEL_COLOR model -[MODEL_COLOR]-> logic deactivate model -logic -[LOGIC_COLOR]> storage : saveAddressBook(addressBook) +logic -[LOGIC_COLOR]> storage : saveAddressBook(staffConnect) 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 3d6bd06d5af..6800ef84c76 100644 --- a/src/main/java/seedu/address/MainApp.java +++ b/src/main/java/seedu/address/MainApp.java @@ -15,7 +15,7 @@ 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.StaffConnect; import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.ReadOnlyAddressBook; @@ -48,7 +48,7 @@ public class MainApp extends Application { @Override public void init() throws Exception { - logger.info("=============================[ Initializing AddressBook ]==========================="); + logger.info("=============================[ Initializing StaffConnect ]==========================="); super.init(); AppParameters appParameters = AppParameters.parse(getParameters()); @@ -81,13 +81,13 @@ private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) { addressBookOptional = storage.readAddressBook(); if (!addressBookOptional.isPresent()) { logger.info("Creating a new data file " + storage.getAddressBookFilePath() - + " populated with a sample AddressBook."); + + " populated with a sample StaffConnect."); } initialData = addressBookOptional.orElseGet(SampleDataUtil::getSampleAddressBook); } catch (DataLoadingException e) { logger.warning("Data file at " + storage.getAddressBookFilePath() + " could not be loaded." - + " Will be starting with an empty AddressBook."); - initialData = new AddressBook(); + + " Will be starting with an empty StaffConnect."); + initialData = new StaffConnect(); } return new ModelManager(initialData, userPrefs); @@ -170,7 +170,7 @@ protected UserPrefs initPrefs(UserPrefsStorage storage) { @Override public void start(Stage primaryStage) { - logger.info("Starting AddressBook " + MainApp.VERSION); + logger.info("Starting StaffConnect " + MainApp.VERSION); ui.start(primaryStage); } diff --git a/src/main/java/seedu/address/logic/Logic.java b/src/main/java/seedu/address/logic/Logic.java index 92cd8fa605a..e1b7d79cd2d 100644 --- a/src/main/java/seedu/address/logic/Logic.java +++ b/src/main/java/seedu/address/logic/Logic.java @@ -24,7 +24,7 @@ public interface Logic { CommandResult execute(String commandText) throws CommandException, ParseException; /** - * Returns the AddressBook. + * Returns the StaffConnect. * * @see seedu.address.model.Model#getAddressBook() */ diff --git a/src/main/java/seedu/address/logic/commands/ClearCommand.java b/src/main/java/seedu/address/logic/commands/ClearCommand.java index 9c86b1fa6e4..201e4f03c1b 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.StaffConnect; 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.setAddressBook(new StaffConnect()); return new CommandResult(MESSAGE_SUCCESS); } } diff --git a/src/main/java/seedu/address/model/Model.java b/src/main/java/seedu/address/model/Model.java index d54df471c1f..37aaa3fe1c8 100644 --- a/src/main/java/seedu/address/model/Model.java +++ b/src/main/java/seedu/address/model/Model.java @@ -49,7 +49,7 @@ public interface Model { */ void setAddressBook(ReadOnlyAddressBook addressBook); - /** Returns the AddressBook */ + /** Returns the StaffConnect */ ReadOnlyAddressBook getAddressBook(); /** diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java index 57bc563fde6..511e3d198ab 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -19,25 +19,25 @@ public class ModelManager implements Model { private static final Logger logger = LogsCenter.getLogger(ModelManager.class); - private final AddressBook addressBook; + private final StaffConnect staffConnect; private final UserPrefs userPrefs; private final FilteredList filteredPersons; /** - * Initializes a ModelManager with the given addressBook and userPrefs. + * Initializes a ModelManager with the given staffConnect and userPrefs. */ public ModelManager(ReadOnlyAddressBook addressBook, ReadOnlyUserPrefs userPrefs) { requireAllNonNull(addressBook, userPrefs); logger.fine("Initializing with address book: " + addressBook + " and user prefs " + userPrefs); - this.addressBook = new AddressBook(addressBook); + this.staffConnect = new StaffConnect(addressBook); this.userPrefs = new UserPrefs(userPrefs); - filteredPersons = new FilteredList<>(this.addressBook.getPersonList()); + filteredPersons = new FilteredList<>(this.staffConnect.getPersonList()); } public ModelManager() { - this(new AddressBook(), new UserPrefs()); + this(new StaffConnect(), new UserPrefs()); } //=========== UserPrefs ================================================================================== @@ -75,32 +75,32 @@ public void setAddressBookFilePath(Path addressBookFilePath) { userPrefs.setAddressBookFilePath(addressBookFilePath); } - //=========== AddressBook ================================================================================ + //=========== StaffConnect ================================================================================ @Override public void setAddressBook(ReadOnlyAddressBook addressBook) { - this.addressBook.resetData(addressBook); + this.staffConnect.resetData(addressBook); } @Override public ReadOnlyAddressBook getAddressBook() { - return addressBook; + return staffConnect; } @Override public boolean hasPerson(Person person) { requireNonNull(person); - return addressBook.hasPerson(person); + return staffConnect.hasPerson(person); } @Override public void deletePerson(Person target) { - addressBook.removePerson(target); + staffConnect.removePerson(target); } @Override public void addPerson(Person person) { - addressBook.addPerson(person); + staffConnect.addPerson(person); updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); } @@ -108,7 +108,7 @@ public void addPerson(Person person) { public void setPerson(Person target, Person editedPerson) { requireAllNonNull(target, editedPerson); - addressBook.setPerson(target, editedPerson); + staffConnect.setPerson(target, editedPerson); } //=========== Filtered Person List Accessors ============================================================= @@ -140,7 +140,7 @@ public boolean equals(Object other) { } ModelManager otherModelManager = (ModelManager) other; - return addressBook.equals(otherModelManager.addressBook) + return staffConnect.equals(otherModelManager.staffConnect) && userPrefs.equals(otherModelManager.userPrefs) && filteredPersons.equals(otherModelManager.filteredPersons); } diff --git a/src/main/java/seedu/address/model/AddressBook.java b/src/main/java/seedu/address/model/StaffConnect.java similarity index 75% rename from src/main/java/seedu/address/model/AddressBook.java rename to src/main/java/seedu/address/model/StaffConnect.java index 73397161e84..77eb50db1d6 100644 --- a/src/main/java/seedu/address/model/AddressBook.java +++ b/src/main/java/seedu/address/model/StaffConnect.java @@ -10,10 +10,10 @@ import seedu.address.model.person.UniquePersonList; /** - * Wraps all data at the address-book level + * Wraps all data at the fundamental level * Duplicates are not allowed (by .isSamePerson comparison) */ -public class AddressBook implements ReadOnlyAddressBook { +public class StaffConnect implements ReadOnlyAddressBook { private final UniquePersonList persons; @@ -28,12 +28,12 @@ public class AddressBook implements ReadOnlyAddressBook { persons = new UniquePersonList(); } - public AddressBook() {} + public StaffConnect() {} /** - * Creates an AddressBook using the Persons in the {@code toBeCopied} + * Creates an StaffConnect using the Persons in the {@code toBeCopied} */ - public AddressBook(ReadOnlyAddressBook toBeCopied) { + public StaffConnect(ReadOnlyAddressBook toBeCopied) { this(); resetData(toBeCopied); } @@ -49,7 +49,7 @@ public void setPersons(List persons) { } /** - * Resets the existing data of this {@code AddressBook} with {@code newData}. + * Resets the existing data of this {@code StaffConnect} with {@code newData}. */ public void resetData(ReadOnlyAddressBook newData) { requireNonNull(newData); @@ -60,7 +60,7 @@ public void resetData(ReadOnlyAddressBook newData) { //// person-level operations /** - * Returns true if a person with the same identity as {@code person} exists in the address book. + * Returns true if a person with the same identity as {@code person} exists in the staffconnect. */ public boolean hasPerson(Person person) { requireNonNull(person); @@ -68,8 +68,8 @@ public boolean hasPerson(Person person) { } /** - * Adds a person to the address book. - * The person must not already exist in the address book. + * Adds a person to the staffconnect. + * The person must not already exist in the staffconnect. */ public void addPerson(Person p) { persons.add(p); @@ -77,8 +77,8 @@ public void addPerson(Person p) { /** * Replaces the given person {@code target} in the list with {@code editedPerson}. - * {@code target} must exist in the address book. - * The person identity of {@code editedPerson} must not be the same as another existing person in the address book. + * {@code target} must exist in the staffconnect. + * The person identity of {@code editedPerson} must not be the same as another existing person in the staffconnect. */ public void setPerson(Person target, Person editedPerson) { requireNonNull(editedPerson); @@ -87,8 +87,8 @@ public void setPerson(Person target, Person editedPerson) { } /** - * Removes {@code key} from this {@code AddressBook}. - * {@code key} must exist in the address book. + * Removes {@code key} from this {@code StaffConnect}. + * {@code key} must exist in the staffconnect. */ public void removePerson(Person key) { persons.remove(key); @@ -115,12 +115,12 @@ public boolean equals(Object other) { } // instanceof handles nulls - if (!(other instanceof AddressBook)) { + if (!(other instanceof StaffConnect)) { return false; } - AddressBook otherAddressBook = (AddressBook) other; - return persons.equals(otherAddressBook.persons); + StaffConnect otherStaffConnect = (StaffConnect) other; + return persons.equals(otherStaffConnect.persons); } @Override diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index 1806da4facf..742f19245a2 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -4,7 +4,7 @@ import java.util.Set; import java.util.stream.Collectors; -import seedu.address.model.AddressBook; +import seedu.address.model.StaffConnect; import seedu.address.model.ReadOnlyAddressBook; import seedu.address.model.person.Address; import seedu.address.model.person.Email; @@ -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 StaffConnect} with sample data. */ public class SampleDataUtil { public static Person[] getSamplePersons() { @@ -41,7 +41,7 @@ public static Person[] getSamplePersons() { } public static ReadOnlyAddressBook getSampleAddressBook() { - AddressBook sampleAb = new AddressBook(); + StaffConnect sampleAb = new StaffConnect(); for (Person samplePerson : getSamplePersons()) { sampleAb.addPerson(samplePerson); } diff --git a/src/main/java/seedu/address/storage/AddressBookStorage.java b/src/main/java/seedu/address/storage/AddressBookStorage.java index f2e015105ae..260ee8acbe9 100644 --- a/src/main/java/seedu/address/storage/AddressBookStorage.java +++ b/src/main/java/seedu/address/storage/AddressBookStorage.java @@ -8,7 +8,7 @@ import seedu.address.model.ReadOnlyAddressBook; /** - * Represents a storage for {@link seedu.address.model.AddressBook}. + * Represents a storage for {@link seedu.address.model.StaffConnect}. */ public interface AddressBookStorage { @@ -18,7 +18,7 @@ public interface AddressBookStorage { Path getAddressBookFilePath(); /** - * Returns AddressBook data as a {@link ReadOnlyAddressBook}. + * Returns StaffConnect data as a {@link ReadOnlyAddressBook}. * Returns {@code Optional.empty()} if storage file is not found. * * @throws DataLoadingException if loading the data from storage failed. diff --git a/src/main/java/seedu/address/storage/JsonAddressBookStorage.java b/src/main/java/seedu/address/storage/JsonAddressBookStorage.java index 41e06f264e1..840f340d7f2 100644 --- a/src/main/java/seedu/address/storage/JsonAddressBookStorage.java +++ b/src/main/java/seedu/address/storage/JsonAddressBookStorage.java @@ -15,7 +15,7 @@ import seedu.address.model.ReadOnlyAddressBook; /** - * A class to access AddressBook data stored as a json file on the hard disk. + * A class to access StaffConnect data stored as a json file on the hard disk. */ public class JsonAddressBookStorage implements AddressBookStorage { diff --git a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java b/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java index 5efd834091d..24d4d0829bc 100644 --- a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java +++ b/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java @@ -9,12 +9,12 @@ import com.fasterxml.jackson.annotation.JsonRootName; import seedu.address.commons.exceptions.IllegalValueException; -import seedu.address.model.AddressBook; +import seedu.address.model.StaffConnect; import seedu.address.model.ReadOnlyAddressBook; import seedu.address.model.person.Person; /** - * An Immutable AddressBook that is serializable to JSON format. + * An Immutable StaffConnect that is serializable to JSON format. */ @JsonRootName(value = "addressbook") class JsonSerializableAddressBook { @@ -41,20 +41,20 @@ public JsonSerializableAddressBook(ReadOnlyAddressBook source) { } /** - * Converts this address book into the model's {@code AddressBook} object. + * Converts this address book into the model's {@code StaffConnect} object. * * @throws IllegalValueException if there were any data constraints violated. */ - public AddressBook toModelType() throws IllegalValueException { - AddressBook addressBook = new AddressBook(); + public StaffConnect toModelType() throws IllegalValueException { + StaffConnect staffConnect = new StaffConnect(); for (JsonAdaptedPerson jsonAdaptedPerson : persons) { Person person = jsonAdaptedPerson.toModelType(); - if (addressBook.hasPerson(person)) { + if (staffConnect.hasPerson(person)) { throw new IllegalValueException(MESSAGE_DUPLICATE_PERSON); } - addressBook.addPerson(person); + staffConnect.addPerson(person); } - return addressBook; + return staffConnect; } } diff --git a/src/main/java/seedu/address/storage/StorageManager.java b/src/main/java/seedu/address/storage/StorageManager.java index 8b84a9024d5..1df8f8f0f93 100644 --- a/src/main/java/seedu/address/storage/StorageManager.java +++ b/src/main/java/seedu/address/storage/StorageManager.java @@ -12,7 +12,7 @@ import seedu.address.model.UserPrefs; /** - * Manages storage of AddressBook data in local storage. + * Manages storage of StaffConnect data in local storage. */ public class StorageManager implements Storage { @@ -46,7 +46,7 @@ public void saveUserPrefs(ReadOnlyUserPrefs userPrefs) throws IOException { } - // ================ AddressBook methods ============================== + // ================ StaffConnect methods ============================== @Override public Path getAddressBookFilePath() { diff --git a/src/test/java/seedu/address/logic/commands/AddCommandTest.java b/src/test/java/seedu/address/logic/commands/AddCommandTest.java index 90e8253f48e..9c7c9c4a740 100644 --- a/src/test/java/seedu/address/logic/commands/AddCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/AddCommandTest.java @@ -18,7 +18,7 @@ import seedu.address.commons.core.GuiSettings; import seedu.address.logic.Messages; import seedu.address.logic.commands.exceptions.CommandException; -import seedu.address.model.AddressBook; +import seedu.address.model.StaffConnect; import seedu.address.model.Model; import seedu.address.model.ReadOnlyAddressBook; import seedu.address.model.ReadOnlyUserPrefs; @@ -197,7 +197,7 @@ public void addPerson(Person person) { @Override public ReadOnlyAddressBook getAddressBook() { - return new AddressBook(); + return new StaffConnect(); } } diff --git a/src/test/java/seedu/address/logic/commands/ClearCommandTest.java b/src/test/java/seedu/address/logic/commands/ClearCommandTest.java index 80d9110c03a..a8e81bf1b07 100644 --- a/src/test/java/seedu/address/logic/commands/ClearCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/ClearCommandTest.java @@ -5,7 +5,7 @@ import org.junit.jupiter.api.Test; -import seedu.address.model.AddressBook; +import seedu.address.model.StaffConnect; import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; @@ -24,7 +24,7 @@ public void execute_emptyAddressBook_success() { public void execute_nonEmptyAddressBook_success() { Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs()); - expectedModel.setAddressBook(new AddressBook()); + expectedModel.setAddressBook(new StaffConnect()); assertCommandSuccess(new ClearCommand(), model, ClearCommand.MESSAGE_SUCCESS, expectedModel); } diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 643a1d08069..8901c7c981e 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -15,7 +15,7 @@ import seedu.address.commons.core.index.Index; import seedu.address.logic.commands.exceptions.CommandException; -import seedu.address.model.AddressBook; +import seedu.address.model.StaffConnect; import seedu.address.model.Model; import seedu.address.model.person.NameContainsKeywordsPredicate; import seedu.address.model.person.Person; @@ -104,11 +104,11 @@ public static void assertCommandSuccess(Command command, Model actualModel, Stri 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()); + StaffConnect expectedStaffConnect = new StaffConnect(actualModel.getAddressBook()); List expectedFilteredList = new ArrayList<>(actualModel.getFilteredPersonList()); assertThrows(CommandException.class, expectedMessage, () -> command.execute(actualModel)); - assertEquals(expectedAddressBook, actualModel.getAddressBook()); + assertEquals(expectedStaffConnect, actualModel.getAddressBook()); assertEquals(expectedFilteredList, actualModel.getFilteredPersonList()); } /** diff --git a/src/test/java/seedu/address/logic/commands/EditCommandTest.java b/src/test/java/seedu/address/logic/commands/EditCommandTest.java index 469dd97daa7..2a2e3e2fa4b 100644 --- a/src/test/java/seedu/address/logic/commands/EditCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/EditCommandTest.java @@ -20,7 +20,7 @@ import seedu.address.commons.core.index.Index; import seedu.address.logic.Messages; import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; -import seedu.address.model.AddressBook; +import seedu.address.model.StaffConnect; import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; @@ -43,7 +43,7 @@ public void execute_allFieldsSpecifiedUnfilteredList_success() { String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)); - Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); + Model expectedModel = new ModelManager(new StaffConnect(model.getAddressBook()), new UserPrefs()); expectedModel.setPerson(model.getFilteredPersonList().get(0), editedPerson); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); @@ -64,7 +64,7 @@ public void execute_someFieldsSpecifiedUnfilteredList_success() { String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)); - Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); + Model expectedModel = new ModelManager(new StaffConnect(model.getAddressBook()), new UserPrefs()); expectedModel.setPerson(lastPerson, editedPerson); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); @@ -77,7 +77,7 @@ public void execute_noFieldSpecifiedUnfilteredList_success() { String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)); - Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); + Model expectedModel = new ModelManager(new StaffConnect(model.getAddressBook()), new UserPrefs()); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); } @@ -93,7 +93,7 @@ public void execute_filteredList_success() { String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)); - Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); + Model expectedModel = new ModelManager(new StaffConnect(model.getAddressBook()), new UserPrefs()); expectedModel.setPerson(model.getFilteredPersonList().get(0), editedPerson); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/seedu/address/logic/parser/StaffConnectParserTest.java similarity index 99% rename from src/test/java/seedu/address/logic/parser/AddressBookParserTest.java rename to src/test/java/seedu/address/logic/parser/StaffConnectParserTest.java index 5a1ab3dbc0c..7f3aa25fbe4 100644 --- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java +++ b/src/test/java/seedu/address/logic/parser/StaffConnectParserTest.java @@ -29,7 +29,7 @@ import seedu.address.testutil.PersonBuilder; import seedu.address.testutil.PersonUtil; -public class AddressBookParserTest { +public class StaffConnectParserTest { private final AddressBookParser parser = new AddressBookParser(); diff --git a/src/test/java/seedu/address/model/ModelManagerTest.java b/src/test/java/seedu/address/model/ModelManagerTest.java index 2cf1418d116..3c5770b5923 100644 --- a/src/test/java/seedu/address/model/ModelManagerTest.java +++ b/src/test/java/seedu/address/model/ModelManagerTest.java @@ -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 StaffConnect(), new StaffConnect(modelManager.getAddressBook())); } @Test @@ -95,13 +95,13 @@ public void getFilteredPersonList_modifyList_throwsUnsupportedOperationException @Test public void equals() { - AddressBook addressBook = new AddressBookBuilder().withPerson(ALICE).withPerson(BENSON).build(); - AddressBook differentAddressBook = new AddressBook(); + StaffConnect staffConnect = new AddressBookBuilder().withPerson(ALICE).withPerson(BENSON).build(); + StaffConnect differentStaffConnect = new StaffConnect(); UserPrefs userPrefs = new UserPrefs(); // same values -> returns true - modelManager = new ModelManager(addressBook, userPrefs); - ModelManager modelManagerCopy = new ModelManager(addressBook, userPrefs); + modelManager = new ModelManager(staffConnect, userPrefs); + ModelManager modelManagerCopy = new ModelManager(staffConnect, userPrefs); assertTrue(modelManager.equals(modelManagerCopy)); // same object -> returns true @@ -113,13 +113,13 @@ public void equals() { // different types -> returns false assertFalse(modelManager.equals(5)); - // different addressBook -> returns false - assertFalse(modelManager.equals(new ModelManager(differentAddressBook, userPrefs))); + // different staffConnect -> returns false + assertFalse(modelManager.equals(new ModelManager(differentStaffConnect, userPrefs))); // different filteredList -> returns false String[] keywords = ALICE.getName().fullName.split("\\s+"); modelManager.updateFilteredPersonList(new NameContainsKeywordsPredicate(Arrays.asList(keywords))); - assertFalse(modelManager.equals(new ModelManager(addressBook, userPrefs))); + assertFalse(modelManager.equals(new ModelManager(staffConnect, userPrefs))); // resets modelManager to initial state for upcoming tests modelManager.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); @@ -127,6 +127,6 @@ public void equals() { // different userPrefs -> returns false UserPrefs differentUserPrefs = new UserPrefs(); differentUserPrefs.setAddressBookFilePath(Paths.get("differentFilePath")); - assertFalse(modelManager.equals(new ModelManager(addressBook, differentUserPrefs))); + assertFalse(modelManager.equals(new ModelManager(staffConnect, differentUserPrefs))); } } diff --git a/src/test/java/seedu/address/model/AddressBookTest.java b/src/test/java/seedu/address/model/StaffConnectTest.java similarity index 67% rename from src/test/java/seedu/address/model/AddressBookTest.java rename to src/test/java/seedu/address/model/StaffConnectTest.java index 68c8c5ba4d5..49f7624e8d2 100644 --- a/src/test/java/seedu/address/model/AddressBookTest.java +++ b/src/test/java/seedu/address/model/StaffConnectTest.java @@ -22,25 +22,25 @@ import seedu.address.model.person.exceptions.DuplicatePersonException; import seedu.address.testutil.PersonBuilder; -public class AddressBookTest { +public class StaffConnectTest { - private final AddressBook addressBook = new AddressBook(); + private final StaffConnect staffConnect = new StaffConnect(); @Test public void constructor() { - assertEquals(Collections.emptyList(), addressBook.getPersonList()); + assertEquals(Collections.emptyList(), staffConnect.getPersonList()); } @Test public void resetData_null_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> addressBook.resetData(null)); + assertThrows(NullPointerException.class, () -> staffConnect.resetData(null)); } @Test public void resetData_withValidReadOnlyAddressBook_replacesData() { - AddressBook newData = getTypicalAddressBook(); - addressBook.resetData(newData); - assertEquals(newData, addressBook); + StaffConnect newData = getTypicalAddressBook(); + staffConnect.resetData(newData); + assertEquals(newData, staffConnect); } @Test @@ -49,53 +49,53 @@ public void resetData_withDuplicatePersons_throwsDuplicatePersonException() { Person editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) .build(); List newPersons = Arrays.asList(ALICE, editedAlice); - AddressBookStub newData = new AddressBookStub(newPersons); + StaffConnectStub newData = new StaffConnectStub(newPersons); - assertThrows(DuplicatePersonException.class, () -> addressBook.resetData(newData)); + assertThrows(DuplicatePersonException.class, () -> staffConnect.resetData(newData)); } @Test public void hasPerson_nullPerson_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> addressBook.hasPerson(null)); + assertThrows(NullPointerException.class, () -> staffConnect.hasPerson(null)); } @Test public void hasPerson_personNotInAddressBook_returnsFalse() { - assertFalse(addressBook.hasPerson(ALICE)); + assertFalse(staffConnect.hasPerson(ALICE)); } @Test public void hasPerson_personInAddressBook_returnsTrue() { - addressBook.addPerson(ALICE); - assertTrue(addressBook.hasPerson(ALICE)); + staffConnect.addPerson(ALICE); + assertTrue(staffConnect.hasPerson(ALICE)); } @Test public void hasPerson_personWithSameIdentityFieldsInAddressBook_returnsTrue() { - addressBook.addPerson(ALICE); + staffConnect.addPerson(ALICE); Person editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) .build(); - assertTrue(addressBook.hasPerson(editedAlice)); + assertTrue(staffConnect.hasPerson(editedAlice)); } @Test public void getPersonList_modifyList_throwsUnsupportedOperationException() { - assertThrows(UnsupportedOperationException.class, () -> addressBook.getPersonList().remove(0)); + assertThrows(UnsupportedOperationException.class, () -> staffConnect.getPersonList().remove(0)); } @Test public void toStringMethod() { - String expected = AddressBook.class.getCanonicalName() + "{persons=" + addressBook.getPersonList() + "}"; - assertEquals(expected, addressBook.toString()); + String expected = StaffConnect.class.getCanonicalName() + "{persons=" + staffConnect.getPersonList() + "}"; + assertEquals(expected, staffConnect.toString()); } /** * A stub ReadOnlyAddressBook whose persons list can violate interface constraints. */ - private static class AddressBookStub implements ReadOnlyAddressBook { + private static class StaffConnectStub implements ReadOnlyAddressBook { private final ObservableList persons = FXCollections.observableArrayList(); - AddressBookStub(Collection persons) { + StaffConnectStub(Collection persons) { this.persons.setAll(persons); } diff --git a/src/test/java/seedu/address/storage/JsonSerializableAddressBookTest.java b/src/test/java/seedu/address/storage/JsonSerializableStaffConnectTest.java similarity index 82% rename from src/test/java/seedu/address/storage/JsonSerializableAddressBookTest.java rename to src/test/java/seedu/address/storage/JsonSerializableStaffConnectTest.java index 188c9058d20..99f741c0642 100644 --- a/src/test/java/seedu/address/storage/JsonSerializableAddressBookTest.java +++ b/src/test/java/seedu/address/storage/JsonSerializableStaffConnectTest.java @@ -10,12 +10,12 @@ import seedu.address.commons.exceptions.IllegalValueException; import seedu.address.commons.util.JsonUtil; -import seedu.address.model.AddressBook; +import seedu.address.model.StaffConnect; import seedu.address.testutil.TypicalPersons; -public class JsonSerializableAddressBookTest { +public class JsonSerializableStaffConnectTest { - private static final Path TEST_DATA_FOLDER = Paths.get("src", "test", "data", "JsonSerializableAddressBookTest"); + private static final Path TEST_DATA_FOLDER = Paths.get("src", "test", "data", "JsonSerializableStaffConnectTest"); private static final Path TYPICAL_PERSONS_FILE = TEST_DATA_FOLDER.resolve("typicalPersonsAddressBook.json"); private static final Path INVALID_PERSON_FILE = TEST_DATA_FOLDER.resolve("invalidPersonAddressBook.json"); private static final Path DUPLICATE_PERSON_FILE = TEST_DATA_FOLDER.resolve("duplicatePersonAddressBook.json"); @@ -24,9 +24,9 @@ public class JsonSerializableAddressBookTest { public void toModelType_typicalPersonsFile_success() throws Exception { JsonSerializableAddressBook dataFromFile = JsonUtil.readJsonFile(TYPICAL_PERSONS_FILE, JsonSerializableAddressBook.class).get(); - AddressBook addressBookFromFile = dataFromFile.toModelType(); - AddressBook typicalPersonsAddressBook = TypicalPersons.getTypicalAddressBook(); - assertEquals(addressBookFromFile, typicalPersonsAddressBook); + StaffConnect staffConnectFromFile = dataFromFile.toModelType(); + StaffConnect typicalPersonsStaffConnect = TypicalPersons.getTypicalAddressBook(); + assertEquals(staffConnectFromFile, typicalPersonsStaffConnect); } @Test diff --git a/src/test/java/seedu/address/storage/JsonAddressBookStorageTest.java b/src/test/java/seedu/address/storage/JsonStaffConnectStorageTest.java similarity index 90% rename from src/test/java/seedu/address/storage/JsonAddressBookStorageTest.java rename to src/test/java/seedu/address/storage/JsonStaffConnectStorageTest.java index 4e5ce9200c8..58e986d8f65 100644 --- a/src/test/java/seedu/address/storage/JsonAddressBookStorageTest.java +++ b/src/test/java/seedu/address/storage/JsonStaffConnectStorageTest.java @@ -16,11 +16,11 @@ import org.junit.jupiter.api.io.TempDir; import seedu.address.commons.exceptions.DataLoadingException; -import seedu.address.model.AddressBook; +import seedu.address.model.StaffConnect; import seedu.address.model.ReadOnlyAddressBook; -public class JsonAddressBookStorageTest { - private static final Path TEST_DATA_FOLDER = Paths.get("src", "test", "data", "JsonAddressBookStorageTest"); +public class JsonStaffConnectStorageTest { + private static final Path TEST_DATA_FOLDER = Paths.get("src", "test", "data", "JsonStaffConnectStorageTest"); @TempDir public Path testFolder; @@ -63,26 +63,26 @@ public void readAddressBook_invalidAndValidPersonAddressBook_throwDataLoadingExc @Test public void readAndSaveAddressBook_allInOrder_success() throws Exception { Path filePath = testFolder.resolve("TempAddressBook.json"); - AddressBook original = getTypicalAddressBook(); + StaffConnect 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)); + assertEquals(original, new StaffConnect(readBack)); // Modify data, overwrite exiting file, and read back original.addPerson(HOON); original.removePerson(ALICE); jsonAddressBookStorage.saveAddressBook(original, filePath); readBack = jsonAddressBookStorage.readAddressBook(filePath).get(); - assertEquals(original, new AddressBook(readBack)); + assertEquals(original, new StaffConnect(readBack)); // Save and read without specifying file path original.addPerson(IDA); jsonAddressBookStorage.saveAddressBook(original); // file path not specified readBack = jsonAddressBookStorage.readAddressBook().get(); // file path not specified - assertEquals(original, new AddressBook(readBack)); + assertEquals(original, new StaffConnect(readBack)); } @@ -105,6 +105,6 @@ private void saveAddressBook(ReadOnlyAddressBook addressBook, String filePath) { @Test public void saveAddressBook_nullFilePath_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> saveAddressBook(new AddressBook(), null)); + assertThrows(NullPointerException.class, () -> saveAddressBook(new StaffConnect(), null)); } } diff --git a/src/test/java/seedu/address/storage/StorageManagerTest.java b/src/test/java/seedu/address/storage/StorageManagerTest.java index 99a16548970..d613364b697 100644 --- a/src/test/java/seedu/address/storage/StorageManagerTest.java +++ b/src/test/java/seedu/address/storage/StorageManagerTest.java @@ -11,7 +11,7 @@ import org.junit.jupiter.api.io.TempDir; import seedu.address.commons.core.GuiSettings; -import seedu.address.model.AddressBook; +import seedu.address.model.StaffConnect; import seedu.address.model.ReadOnlyAddressBook; import seedu.address.model.UserPrefs; @@ -52,12 +52,12 @@ public void addressBookReadSave() 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. + * More extensive testing of UserPref saving/reading is done in {@link JsonStaffConnectStorageTest} class. */ - AddressBook original = getTypicalAddressBook(); + StaffConnect original = getTypicalAddressBook(); storageManager.saveAddressBook(original); ReadOnlyAddressBook retrieved = storageManager.readAddressBook().get(); - assertEquals(original, new AddressBook(retrieved)); + assertEquals(original, new StaffConnect(retrieved)); } @Test diff --git a/src/test/java/seedu/address/testutil/AddressBookBuilder.java b/src/test/java/seedu/address/testutil/AddressBookBuilder.java index d53799fd110..4dcd19f4948 100644 --- a/src/test/java/seedu/address/testutil/AddressBookBuilder.java +++ b/src/test/java/seedu/address/testutil/AddressBookBuilder.java @@ -1,34 +1,34 @@ package seedu.address.testutil; -import seedu.address.model.AddressBook; +import seedu.address.model.StaffConnect; import seedu.address.model.person.Person; /** * A utility class to help with building Addressbook objects. * Example usage:
- * {@code AddressBook ab = new AddressBookBuilder().withPerson("John", "Doe").build();} + * {@code StaffConnect ab = new AddressBookBuilder().withPerson("John", "Doe").build();} */ public class AddressBookBuilder { - private AddressBook addressBook; + private StaffConnect staffConnect; public AddressBookBuilder() { - addressBook = new AddressBook(); + staffConnect = new StaffConnect(); } - public AddressBookBuilder(AddressBook addressBook) { - this.addressBook = addressBook; + public AddressBookBuilder(StaffConnect staffConnect) { + this.staffConnect = staffConnect; } /** - * Adds a new {@code Person} to the {@code AddressBook} that we are building. + * Adds a new {@code Person} to the {@code StaffConnect} that we are building. */ public AddressBookBuilder withPerson(Person person) { - addressBook.addPerson(person); + staffConnect.addPerson(person); return this; } - public AddressBook build() { - return addressBook; + public StaffConnect build() { + return staffConnect; } } diff --git a/src/test/java/seedu/address/testutil/TypicalPersons.java b/src/test/java/seedu/address/testutil/TypicalPersons.java index fec76fb7129..e1e61867e61 100644 --- a/src/test/java/seedu/address/testutil/TypicalPersons.java +++ b/src/test/java/seedu/address/testutil/TypicalPersons.java @@ -15,7 +15,7 @@ import java.util.Arrays; import java.util.List; -import seedu.address.model.AddressBook; +import seedu.address.model.StaffConnect; import seedu.address.model.person.Person; /** @@ -60,10 +60,10 @@ public class TypicalPersons { private TypicalPersons() {} // prevents instantiation /** - * Returns an {@code AddressBook} with all the typical persons. + * Returns an {@code StaffConnect} with all the typical persons. */ - public static AddressBook getTypicalAddressBook() { - AddressBook ab = new AddressBook(); + public static StaffConnect getTypicalAddressBook() { + StaffConnect ab = new StaffConnect(); for (Person person : getTypicalPersons()) { ab.addPerson(person); } From 860802f49608e0ffc83e70398033c03570687008 Mon Sep 17 00:00:00 2001 From: tsulim Date: Sun, 10 Mar 2024 06:55:36 +0800 Subject: [PATCH 02/16] Refactor `ReadOnlyAddressBook` class to `ReadOnlyStaffConnect` class --- src/main/java/seedu/address/MainApp.java | 8 ++++---- src/main/java/seedu/address/logic/Logic.java | 4 ++-- .../java/seedu/address/logic/LogicManager.java | 4 ++-- src/main/java/seedu/address/model/Model.java | 4 ++-- .../java/seedu/address/model/ModelManager.java | 14 +++++++------- ...ddressBook.java => ReadOnlyStaffConnect.java} | 2 +- .../java/seedu/address/model/StaffConnect.java | 6 +++--- .../seedu/address/model/util/SampleDataUtil.java | 10 +++++----- .../address/storage/AddressBookStorage.java | 16 ++++++++-------- .../address/storage/JsonAddressBookStorage.java | 12 ++++++------ .../storage/JsonSerializableAddressBook.java | 6 +++--- src/main/java/seedu/address/storage/Storage.java | 6 +++--- .../seedu/address/storage/StorageManager.java | 10 +++++----- .../seedu/address/logic/LogicManagerTest.java | 4 ++-- .../address/logic/commands/AddCommandTest.java | 8 ++++---- .../seedu/address/model/StaffConnectTest.java | 4 ++-- .../storage/JsonStaffConnectStorageTest.java | 10 +++++----- .../address/storage/StorageManagerTest.java | 4 ++-- 18 files changed, 66 insertions(+), 66 deletions(-) rename src/main/java/seedu/address/model/{ReadOnlyAddressBook.java => ReadOnlyStaffConnect.java} (89%) diff --git a/src/main/java/seedu/address/MainApp.java b/src/main/java/seedu/address/MainApp.java index 6800ef84c76..cb4e13c7659 100644 --- a/src/main/java/seedu/address/MainApp.java +++ b/src/main/java/seedu/address/MainApp.java @@ -15,11 +15,11 @@ import seedu.address.commons.util.StringUtil; import seedu.address.logic.Logic; import seedu.address.logic.LogicManager; -import seedu.address.model.StaffConnect; import seedu.address.model.Model; import seedu.address.model.ModelManager; -import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.ReadOnlyStaffConnect; import seedu.address.model.ReadOnlyUserPrefs; +import seedu.address.model.StaffConnect; import seedu.address.model.UserPrefs; import seedu.address.model.util.SampleDataUtil; import seedu.address.storage.AddressBookStorage; @@ -75,8 +75,8 @@ public void init() throws Exception { private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) { logger.info("Using data file : " + storage.getAddressBookFilePath()); - Optional addressBookOptional; - ReadOnlyAddressBook initialData; + Optional addressBookOptional; + ReadOnlyStaffConnect initialData; try { addressBookOptional = storage.readAddressBook(); if (!addressBookOptional.isPresent()) { diff --git a/src/main/java/seedu/address/logic/Logic.java b/src/main/java/seedu/address/logic/Logic.java index e1b7d79cd2d..6094744f604 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.ReadOnlyStaffConnect; import seedu.address.model.person.Person; /** @@ -28,7 +28,7 @@ public interface Logic { * * @see seedu.address.model.Model#getAddressBook() */ - ReadOnlyAddressBook getAddressBook(); + ReadOnlyStaffConnect getAddressBook(); /** Returns an unmodifiable view of the filtered list of persons */ ObservableList getFilteredPersonList(); diff --git a/src/main/java/seedu/address/logic/LogicManager.java b/src/main/java/seedu/address/logic/LogicManager.java index 5aa3b91c7d0..995a1316cec 100644 --- a/src/main/java/seedu/address/logic/LogicManager.java +++ b/src/main/java/seedu/address/logic/LogicManager.java @@ -14,7 +14,7 @@ import seedu.address.logic.parser.AddressBookParser; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.Model; -import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.ReadOnlyStaffConnect; import seedu.address.model.person.Person; import seedu.address.storage.Storage; @@ -62,7 +62,7 @@ public CommandResult execute(String commandText) throws CommandException, ParseE } @Override - public ReadOnlyAddressBook getAddressBook() { + public ReadOnlyStaffConnect getAddressBook() { return model.getAddressBook(); } diff --git a/src/main/java/seedu/address/model/Model.java b/src/main/java/seedu/address/model/Model.java index 37aaa3fe1c8..3e1682c5428 100644 --- a/src/main/java/seedu/address/model/Model.java +++ b/src/main/java/seedu/address/model/Model.java @@ -47,10 +47,10 @@ public interface Model { /** * Replaces address book data with the data in {@code addressBook}. */ - void setAddressBook(ReadOnlyAddressBook addressBook); + void setAddressBook(ReadOnlyStaffConnect staffConnect); /** Returns the StaffConnect */ - ReadOnlyAddressBook getAddressBook(); + ReadOnlyStaffConnect getAddressBook(); /** * Returns true if a person with the same identity as {@code person} 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 511e3d198ab..5f5307dce74 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -26,12 +26,12 @@ public class ModelManager implements Model { /** * Initializes a ModelManager with the given staffConnect and userPrefs. */ - public ModelManager(ReadOnlyAddressBook addressBook, ReadOnlyUserPrefs userPrefs) { - requireAllNonNull(addressBook, userPrefs); + public ModelManager(ReadOnlyStaffConnect staffConnect, ReadOnlyUserPrefs userPrefs) { + requireAllNonNull(staffConnect, userPrefs); - logger.fine("Initializing with address book: " + addressBook + " and user prefs " + userPrefs); + logger.fine("Initializing with address book: " + staffConnect + " and user prefs " + userPrefs); - this.staffConnect = new StaffConnect(addressBook); + this.staffConnect = new StaffConnect(staffConnect); this.userPrefs = new UserPrefs(userPrefs); filteredPersons = new FilteredList<>(this.staffConnect.getPersonList()); } @@ -78,12 +78,12 @@ public void setAddressBookFilePath(Path addressBookFilePath) { //=========== StaffConnect ================================================================================ @Override - public void setAddressBook(ReadOnlyAddressBook addressBook) { - this.staffConnect.resetData(addressBook); + public void setAddressBook(ReadOnlyStaffConnect staffConnect) { + this.staffConnect.resetData(staffConnect); } @Override - public ReadOnlyAddressBook getAddressBook() { + public ReadOnlyStaffConnect getAddressBook() { return staffConnect; } diff --git a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java b/src/main/java/seedu/address/model/ReadOnlyStaffConnect.java similarity index 89% rename from src/main/java/seedu/address/model/ReadOnlyAddressBook.java rename to src/main/java/seedu/address/model/ReadOnlyStaffConnect.java index 6ddc2cd9a29..f4671dc8a00 100644 --- a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java +++ b/src/main/java/seedu/address/model/ReadOnlyStaffConnect.java @@ -6,7 +6,7 @@ /** * Unmodifiable view of an address book */ -public interface ReadOnlyAddressBook { +public interface ReadOnlyStaffConnect { /** * Returns an unmodifiable view of the persons list. diff --git a/src/main/java/seedu/address/model/StaffConnect.java b/src/main/java/seedu/address/model/StaffConnect.java index 77eb50db1d6..3dfbf1bd8ba 100644 --- a/src/main/java/seedu/address/model/StaffConnect.java +++ b/src/main/java/seedu/address/model/StaffConnect.java @@ -13,7 +13,7 @@ * Wraps all data at the fundamental level * Duplicates are not allowed (by .isSamePerson comparison) */ -public class StaffConnect implements ReadOnlyAddressBook { +public class StaffConnect implements ReadOnlyStaffConnect { private final UniquePersonList persons; @@ -33,7 +33,7 @@ public StaffConnect() {} /** * Creates an StaffConnect using the Persons in the {@code toBeCopied} */ - public StaffConnect(ReadOnlyAddressBook toBeCopied) { + public StaffConnect(ReadOnlyStaffConnect toBeCopied) { this(); resetData(toBeCopied); } @@ -51,7 +51,7 @@ public void setPersons(List persons) { /** * Resets the existing data of this {@code StaffConnect} with {@code newData}. */ - public void resetData(ReadOnlyAddressBook newData) { + public void resetData(ReadOnlyStaffConnect newData) { requireNonNull(newData); setPersons(newData.getPersonList()); diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index 742f19245a2..7c3afc21bb4 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.ReadOnlyStaffConnect; import seedu.address.model.StaffConnect; -import seedu.address.model.ReadOnlyAddressBook; import seedu.address.model.person.Address; import seedu.address.model.person.Email; import seedu.address.model.person.Name; @@ -40,12 +40,12 @@ public static Person[] getSamplePersons() { }; } - public static ReadOnlyAddressBook getSampleAddressBook() { - StaffConnect sampleAb = new StaffConnect(); + public static ReadOnlyStaffConnect getSampleAddressBook() { + StaffConnect sampleSc = new StaffConnect(); for (Person samplePerson : getSamplePersons()) { - sampleAb.addPerson(samplePerson); + sampleSc.addPerson(samplePerson); } - return sampleAb; + return sampleSc; } /** diff --git a/src/main/java/seedu/address/storage/AddressBookStorage.java b/src/main/java/seedu/address/storage/AddressBookStorage.java index 260ee8acbe9..b638711590d 100644 --- a/src/main/java/seedu/address/storage/AddressBookStorage.java +++ b/src/main/java/seedu/address/storage/AddressBookStorage.java @@ -5,7 +5,7 @@ import java.util.Optional; import seedu.address.commons.exceptions.DataLoadingException; -import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.ReadOnlyStaffConnect; /** * Represents a storage for {@link seedu.address.model.StaffConnect}. @@ -18,28 +18,28 @@ public interface AddressBookStorage { Path getAddressBookFilePath(); /** - * Returns StaffConnect data as a {@link ReadOnlyAddressBook}. + * Returns StaffConnect data as a {@link ReadOnlyStaffConnect}. * Returns {@code Optional.empty()} if storage file is not found. * * @throws DataLoadingException if loading the data from storage failed. */ - Optional readAddressBook() throws DataLoadingException; + Optional readAddressBook() throws DataLoadingException; /** * @see #getAddressBookFilePath() */ - Optional readAddressBook(Path filePath) throws DataLoadingException; + Optional readAddressBook(Path filePath) throws DataLoadingException; /** - * Saves the given {@link ReadOnlyAddressBook} to the storage. + * Saves the given {@link ReadOnlyStaffConnect} 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; + void saveAddressBook(ReadOnlyStaffConnect addressBook) throws IOException; /** - * @see #saveAddressBook(ReadOnlyAddressBook) + * @see #saveAddressBook(ReadOnlyStaffConnect) */ - void saveAddressBook(ReadOnlyAddressBook addressBook, Path filePath) throws IOException; + void saveAddressBook(ReadOnlyStaffConnect addressBook, Path filePath) throws IOException; } diff --git a/src/main/java/seedu/address/storage/JsonAddressBookStorage.java b/src/main/java/seedu/address/storage/JsonAddressBookStorage.java index 840f340d7f2..a6bad3fee37 100644 --- a/src/main/java/seedu/address/storage/JsonAddressBookStorage.java +++ b/src/main/java/seedu/address/storage/JsonAddressBookStorage.java @@ -12,7 +12,7 @@ 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.ReadOnlyStaffConnect; /** * A class to access StaffConnect data stored as a json file on the hard disk. @@ -32,7 +32,7 @@ public Path getAddressBookFilePath() { } @Override - public Optional readAddressBook() throws DataLoadingException { + public Optional readAddressBook() throws DataLoadingException { return readAddressBook(filePath); } @@ -42,7 +42,7 @@ public Optional readAddressBook() throws DataLoadingExcepti * @param filePath location of the data. Cannot be null. * @throws DataLoadingException if loading the data from storage failed. */ - public Optional readAddressBook(Path filePath) throws DataLoadingException { + public Optional readAddressBook(Path filePath) throws DataLoadingException { requireNonNull(filePath); Optional jsonAddressBook = JsonUtil.readJsonFile( @@ -60,16 +60,16 @@ public Optional readAddressBook(Path filePath) throws DataL } @Override - public void saveAddressBook(ReadOnlyAddressBook addressBook) throws IOException { + public void saveAddressBook(ReadOnlyStaffConnect addressBook) throws IOException { saveAddressBook(addressBook, filePath); } /** - * Similar to {@link #saveAddressBook(ReadOnlyAddressBook)}. + * Similar to {@link #saveAddressBook(ReadOnlyStaffConnect)}. * * @param filePath location of the data. Cannot be null. */ - public void saveAddressBook(ReadOnlyAddressBook addressBook, Path filePath) throws IOException { + public void saveAddressBook(ReadOnlyStaffConnect addressBook, Path filePath) throws IOException { requireNonNull(addressBook); requireNonNull(filePath); diff --git a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java b/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java index 24d4d0829bc..74737a526f1 100644 --- a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java +++ b/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java @@ -9,8 +9,8 @@ import com.fasterxml.jackson.annotation.JsonRootName; import seedu.address.commons.exceptions.IllegalValueException; +import seedu.address.model.ReadOnlyStaffConnect; import seedu.address.model.StaffConnect; -import seedu.address.model.ReadOnlyAddressBook; import seedu.address.model.person.Person; /** @@ -32,11 +32,11 @@ public JsonSerializableAddressBook(@JsonProperty("persons") List readAddressBook() throws DataLoadingException; + Optional readAddressBook() throws DataLoadingException; @Override - void saveAddressBook(ReadOnlyAddressBook addressBook) throws IOException; + void saveAddressBook(ReadOnlyStaffConnect addressBook) throws IOException; } diff --git a/src/main/java/seedu/address/storage/StorageManager.java b/src/main/java/seedu/address/storage/StorageManager.java index 1df8f8f0f93..d16ba55a16e 100644 --- a/src/main/java/seedu/address/storage/StorageManager.java +++ b/src/main/java/seedu/address/storage/StorageManager.java @@ -7,7 +7,7 @@ import seedu.address.commons.core.LogsCenter; import seedu.address.commons.exceptions.DataLoadingException; -import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.ReadOnlyStaffConnect; import seedu.address.model.ReadOnlyUserPrefs; import seedu.address.model.UserPrefs; @@ -54,23 +54,23 @@ public Path getAddressBookFilePath() { } @Override - public Optional readAddressBook() throws DataLoadingException { + public Optional readAddressBook() throws DataLoadingException { return readAddressBook(addressBookStorage.getAddressBookFilePath()); } @Override - public Optional readAddressBook(Path filePath) throws DataLoadingException { + public Optional readAddressBook(Path filePath) throws DataLoadingException { logger.fine("Attempting to read data from file: " + filePath); return addressBookStorage.readAddressBook(filePath); } @Override - public void saveAddressBook(ReadOnlyAddressBook addressBook) throws IOException { + public void saveAddressBook(ReadOnlyStaffConnect addressBook) throws IOException { saveAddressBook(addressBook, addressBookStorage.getAddressBookFilePath()); } @Override - public void saveAddressBook(ReadOnlyAddressBook addressBook, Path filePath) throws IOException { + public void saveAddressBook(ReadOnlyStaffConnect addressBook, Path filePath) throws IOException { logger.fine("Attempting to write to data file: " + filePath); addressBookStorage.saveAddressBook(addressBook, filePath); } diff --git a/src/test/java/seedu/address/logic/LogicManagerTest.java b/src/test/java/seedu/address/logic/LogicManagerTest.java index baf8ce336a2..a137a61c656 100644 --- a/src/test/java/seedu/address/logic/LogicManagerTest.java +++ b/src/test/java/seedu/address/logic/LogicManagerTest.java @@ -25,7 +25,7 @@ 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.ReadOnlyStaffConnect; import seedu.address.model.UserPrefs; import seedu.address.model.person.Person; import seedu.address.storage.JsonAddressBookStorage; @@ -152,7 +152,7 @@ private void assertCommandFailureForExceptionFromStorage(IOException e, String e // Inject LogicManager with an AddressBookStorage that throws the IOException e when saving JsonAddressBookStorage addressBookStorage = new JsonAddressBookStorage(prefPath) { @Override - public void saveAddressBook(ReadOnlyAddressBook addressBook, Path filePath) + public void saveAddressBook(ReadOnlyStaffConnect staffConnect, Path filePath) throws IOException { throw e; } diff --git a/src/test/java/seedu/address/logic/commands/AddCommandTest.java b/src/test/java/seedu/address/logic/commands/AddCommandTest.java index 9c7c9c4a740..99a552cbe16 100644 --- a/src/test/java/seedu/address/logic/commands/AddCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/AddCommandTest.java @@ -18,9 +18,9 @@ import seedu.address.commons.core.GuiSettings; import seedu.address.logic.Messages; import seedu.address.logic.commands.exceptions.CommandException; +import seedu.address.model.ReadOnlyStaffConnect; import seedu.address.model.StaffConnect; import seedu.address.model.Model; -import seedu.address.model.ReadOnlyAddressBook; import seedu.address.model.ReadOnlyUserPrefs; import seedu.address.model.person.Person; import seedu.address.testutil.PersonBuilder; @@ -124,12 +124,12 @@ public void addPerson(Person person) { } @Override - public void setAddressBook(ReadOnlyAddressBook newData) { + public void setAddressBook(ReadOnlyStaffConnect newData) { throw new AssertionError("This method should not be called."); } @Override - public ReadOnlyAddressBook getAddressBook() { + public ReadOnlyStaffConnect getAddressBook() { throw new AssertionError("This method should not be called."); } @@ -196,7 +196,7 @@ public void addPerson(Person person) { } @Override - public ReadOnlyAddressBook getAddressBook() { + public ReadOnlyStaffConnect getAddressBook() { return new StaffConnect(); } } diff --git a/src/test/java/seedu/address/model/StaffConnectTest.java b/src/test/java/seedu/address/model/StaffConnectTest.java index 49f7624e8d2..2e2e5840f21 100644 --- a/src/test/java/seedu/address/model/StaffConnectTest.java +++ b/src/test/java/seedu/address/model/StaffConnectTest.java @@ -90,9 +90,9 @@ public void toStringMethod() { } /** - * A stub ReadOnlyAddressBook whose persons list can violate interface constraints. + * A stub ReadOnlyStaffConnect whose persons list can violate interface constraints. */ - private static class StaffConnectStub implements ReadOnlyAddressBook { + private static class StaffConnectStub implements ReadOnlyStaffConnect { private final ObservableList persons = FXCollections.observableArrayList(); StaffConnectStub(Collection persons) { diff --git a/src/test/java/seedu/address/storage/JsonStaffConnectStorageTest.java b/src/test/java/seedu/address/storage/JsonStaffConnectStorageTest.java index 58e986d8f65..ddcd1aa5c28 100644 --- a/src/test/java/seedu/address/storage/JsonStaffConnectStorageTest.java +++ b/src/test/java/seedu/address/storage/JsonStaffConnectStorageTest.java @@ -16,8 +16,8 @@ import org.junit.jupiter.api.io.TempDir; import seedu.address.commons.exceptions.DataLoadingException; +import seedu.address.model.ReadOnlyStaffConnect; import seedu.address.model.StaffConnect; -import seedu.address.model.ReadOnlyAddressBook; public class JsonStaffConnectStorageTest { private static final Path TEST_DATA_FOLDER = Paths.get("src", "test", "data", "JsonStaffConnectStorageTest"); @@ -30,7 +30,7 @@ public void readAddressBook_nullFilePath_throwsNullPointerException() { assertThrows(NullPointerException.class, () -> readAddressBook(null)); } - private java.util.Optional readAddressBook(String filePath) throws Exception { + private java.util.Optional readAddressBook(String filePath) throws Exception { return new JsonAddressBookStorage(Paths.get(filePath)).readAddressBook(addToTestDataPathIfNotNull(filePath)); } @@ -68,7 +68,7 @@ public void readAndSaveAddressBook_allInOrder_success() throws Exception { // Save in new file and read back jsonAddressBookStorage.saveAddressBook(original, filePath); - ReadOnlyAddressBook readBack = jsonAddressBookStorage.readAddressBook(filePath).get(); + ReadOnlyStaffConnect readBack = jsonAddressBookStorage.readAddressBook(filePath).get(); assertEquals(original, new StaffConnect(readBack)); // Modify data, overwrite exiting file, and read back @@ -94,10 +94,10 @@ public void saveAddressBook_nullAddressBook_throwsNullPointerException() { /** * Saves {@code addressBook} at the specified {@code filePath}. */ - private void saveAddressBook(ReadOnlyAddressBook addressBook, String filePath) { + private void saveAddressBook(ReadOnlyStaffConnect staffConnect, String filePath) { try { new JsonAddressBookStorage(Paths.get(filePath)) - .saveAddressBook(addressBook, addToTestDataPathIfNotNull(filePath)); + .saveAddressBook(staffConnect, addToTestDataPathIfNotNull(filePath)); } catch (IOException ioe) { throw new AssertionError("There should not be an error writing to the file.", ioe); } diff --git a/src/test/java/seedu/address/storage/StorageManagerTest.java b/src/test/java/seedu/address/storage/StorageManagerTest.java index d613364b697..2d104131f30 100644 --- a/src/test/java/seedu/address/storage/StorageManagerTest.java +++ b/src/test/java/seedu/address/storage/StorageManagerTest.java @@ -12,7 +12,7 @@ import seedu.address.commons.core.GuiSettings; import seedu.address.model.StaffConnect; -import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.ReadOnlyStaffConnect; import seedu.address.model.UserPrefs; public class StorageManagerTest { @@ -56,7 +56,7 @@ public void addressBookReadSave() throws Exception { */ StaffConnect original = getTypicalAddressBook(); storageManager.saveAddressBook(original); - ReadOnlyAddressBook retrieved = storageManager.readAddressBook().get(); + ReadOnlyStaffConnect retrieved = storageManager.readAddressBook().get(); assertEquals(original, new StaffConnect(retrieved)); } From 583f504ddf7ff26856d3d48c1969d281071ef070 Mon Sep 17 00:00:00 2001 From: tsulim Date: Mon, 11 Mar 2024 02:22:13 +0800 Subject: [PATCH 03/16] Refactor `AddressBookStorage` class to `StaffConnectStorage` class --- src/main/java/seedu/address/MainApp.java | 8 ++++---- ...orage.java => JsonStaffConnectStorage.java} | 6 +++--- ...okStorage.java => StaffConnectStorage.java} | 2 +- .../java/seedu/address/storage/Storage.java | 2 +- .../seedu/address/storage/StorageManager.java | 18 +++++++++--------- .../seedu/address/logic/LogicManagerTest.java | 10 +++++----- .../storage/JsonStaffConnectStorageTest.java | 6 +++--- .../address/storage/StorageManagerTest.java | 4 ++-- 8 files changed, 28 insertions(+), 28 deletions(-) rename src/main/java/seedu/address/storage/{JsonAddressBookStorage.java => JsonStaffConnectStorage.java} (94%) rename src/main/java/seedu/address/storage/{AddressBookStorage.java => StaffConnectStorage.java} (97%) diff --git a/src/main/java/seedu/address/MainApp.java b/src/main/java/seedu/address/MainApp.java index cb4e13c7659..a04c329a494 100644 --- a/src/main/java/seedu/address/MainApp.java +++ b/src/main/java/seedu/address/MainApp.java @@ -22,8 +22,8 @@ import seedu.address.model.StaffConnect; 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.JsonStaffConnectStorage; +import seedu.address.storage.StaffConnectStorage; import seedu.address.storage.JsonUserPrefsStorage; import seedu.address.storage.Storage; import seedu.address.storage.StorageManager; @@ -57,8 +57,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); + StaffConnectStorage staffConnectStorage = new JsonStaffConnectStorage(userPrefs.getAddressBookFilePath()); + storage = new StorageManager(staffConnectStorage, userPrefsStorage); model = initModelManager(storage, userPrefs); diff --git a/src/main/java/seedu/address/storage/JsonAddressBookStorage.java b/src/main/java/seedu/address/storage/JsonStaffConnectStorage.java similarity index 94% rename from src/main/java/seedu/address/storage/JsonAddressBookStorage.java rename to src/main/java/seedu/address/storage/JsonStaffConnectStorage.java index a6bad3fee37..35c1916e02b 100644 --- a/src/main/java/seedu/address/storage/JsonAddressBookStorage.java +++ b/src/main/java/seedu/address/storage/JsonStaffConnectStorage.java @@ -17,13 +17,13 @@ /** * A class to access StaffConnect data stored as a json file on the hard disk. */ -public class JsonAddressBookStorage implements AddressBookStorage { +public class JsonStaffConnectStorage implements StaffConnectStorage { - private static final Logger logger = LogsCenter.getLogger(JsonAddressBookStorage.class); + private static final Logger logger = LogsCenter.getLogger(JsonStaffConnectStorage.class); private Path filePath; - public JsonAddressBookStorage(Path filePath) { + public JsonStaffConnectStorage(Path filePath) { this.filePath = filePath; } diff --git a/src/main/java/seedu/address/storage/AddressBookStorage.java b/src/main/java/seedu/address/storage/StaffConnectStorage.java similarity index 97% rename from src/main/java/seedu/address/storage/AddressBookStorage.java rename to src/main/java/seedu/address/storage/StaffConnectStorage.java index b638711590d..2007eb52eaa 100644 --- a/src/main/java/seedu/address/storage/AddressBookStorage.java +++ b/src/main/java/seedu/address/storage/StaffConnectStorage.java @@ -10,7 +10,7 @@ /** * Represents a storage for {@link seedu.address.model.StaffConnect}. */ -public interface AddressBookStorage { +public interface StaffConnectStorage { /** * Returns the file path of the data file. diff --git a/src/main/java/seedu/address/storage/Storage.java b/src/main/java/seedu/address/storage/Storage.java index 71937aa7bf5..4d8d795246b 100644 --- a/src/main/java/seedu/address/storage/Storage.java +++ b/src/main/java/seedu/address/storage/Storage.java @@ -12,7 +12,7 @@ /** * API of the Storage component */ -public interface Storage extends AddressBookStorage, UserPrefsStorage { +public interface Storage extends StaffConnectStorage, UserPrefsStorage { @Override Optional readUserPrefs() throws DataLoadingException; diff --git a/src/main/java/seedu/address/storage/StorageManager.java b/src/main/java/seedu/address/storage/StorageManager.java index d16ba55a16e..27e7b9d2489 100644 --- a/src/main/java/seedu/address/storage/StorageManager.java +++ b/src/main/java/seedu/address/storage/StorageManager.java @@ -17,14 +17,14 @@ public class StorageManager implements Storage { private static final Logger logger = LogsCenter.getLogger(StorageManager.class); - private AddressBookStorage addressBookStorage; + private StaffConnectStorage staffConnectStorage; private UserPrefsStorage userPrefsStorage; /** - * Creates a {@code StorageManager} with the given {@code AddressBookStorage} and {@code UserPrefStorage}. + * Creates a {@code StorageManager} with the given {@code StaffConnectStorage} and {@code UserPrefStorage}. */ - public StorageManager(AddressBookStorage addressBookStorage, UserPrefsStorage userPrefsStorage) { - this.addressBookStorage = addressBookStorage; + public StorageManager(StaffConnectStorage staffConnectStorage, UserPrefsStorage userPrefsStorage) { + this.staffConnectStorage = staffConnectStorage; this.userPrefsStorage = userPrefsStorage; } @@ -50,29 +50,29 @@ public void saveUserPrefs(ReadOnlyUserPrefs userPrefs) throws IOException { @Override public Path getAddressBookFilePath() { - return addressBookStorage.getAddressBookFilePath(); + return staffConnectStorage.getAddressBookFilePath(); } @Override public Optional readAddressBook() throws DataLoadingException { - return readAddressBook(addressBookStorage.getAddressBookFilePath()); + return readAddressBook(staffConnectStorage.getAddressBookFilePath()); } @Override public Optional readAddressBook(Path filePath) throws DataLoadingException { logger.fine("Attempting to read data from file: " + filePath); - return addressBookStorage.readAddressBook(filePath); + return staffConnectStorage.readAddressBook(filePath); } @Override public void saveAddressBook(ReadOnlyStaffConnect addressBook) throws IOException { - saveAddressBook(addressBook, addressBookStorage.getAddressBookFilePath()); + saveAddressBook(addressBook, staffConnectStorage.getAddressBookFilePath()); } @Override public void saveAddressBook(ReadOnlyStaffConnect addressBook, Path filePath) throws IOException { logger.fine("Attempting to write to data file: " + filePath); - addressBookStorage.saveAddressBook(addressBook, filePath); + staffConnectStorage.saveAddressBook(addressBook, filePath); } } diff --git a/src/test/java/seedu/address/logic/LogicManagerTest.java b/src/test/java/seedu/address/logic/LogicManagerTest.java index a137a61c656..8e9fae58ae0 100644 --- a/src/test/java/seedu/address/logic/LogicManagerTest.java +++ b/src/test/java/seedu/address/logic/LogicManagerTest.java @@ -28,7 +28,7 @@ import seedu.address.model.ReadOnlyStaffConnect; import seedu.address.model.UserPrefs; import seedu.address.model.person.Person; -import seedu.address.storage.JsonAddressBookStorage; +import seedu.address.storage.JsonStaffConnectStorage; import seedu.address.storage.JsonUserPrefsStorage; import seedu.address.storage.StorageManager; import seedu.address.testutil.PersonBuilder; @@ -45,8 +45,8 @@ public class LogicManagerTest { @BeforeEach public void setUp() { - JsonAddressBookStorage addressBookStorage = - new JsonAddressBookStorage(temporaryFolder.resolve("addressBook.json")); + JsonStaffConnectStorage addressBookStorage = + new JsonStaffConnectStorage(temporaryFolder.resolve("addressBook.json")); JsonUserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(temporaryFolder.resolve("userPrefs.json")); StorageManager storage = new StorageManager(addressBookStorage, userPrefsStorage); logic = new LogicManager(model, storage); @@ -149,8 +149,8 @@ private void assertCommandFailure(String inputCommand, Class readAddressBook(String filePath) throws Exception { - return new JsonAddressBookStorage(Paths.get(filePath)).readAddressBook(addToTestDataPathIfNotNull(filePath)); + return new JsonStaffConnectStorage(Paths.get(filePath)).readAddressBook(addToTestDataPathIfNotNull(filePath)); } private Path addToTestDataPathIfNotNull(String prefsFileInTestDataFolder) { @@ -64,7 +64,7 @@ public void readAddressBook_invalidAndValidPersonAddressBook_throwDataLoadingExc public void readAndSaveAddressBook_allInOrder_success() throws Exception { Path filePath = testFolder.resolve("TempAddressBook.json"); StaffConnect original = getTypicalAddressBook(); - JsonAddressBookStorage jsonAddressBookStorage = new JsonAddressBookStorage(filePath); + JsonStaffConnectStorage jsonAddressBookStorage = new JsonStaffConnectStorage(filePath); // Save in new file and read back jsonAddressBookStorage.saveAddressBook(original, filePath); @@ -96,7 +96,7 @@ public void saveAddressBook_nullAddressBook_throwsNullPointerException() { */ private void saveAddressBook(ReadOnlyStaffConnect staffConnect, String filePath) { try { - new JsonAddressBookStorage(Paths.get(filePath)) + new JsonStaffConnectStorage(Paths.get(filePath)) .saveAddressBook(staffConnect, addToTestDataPathIfNotNull(filePath)); } catch (IOException ioe) { throw new AssertionError("There should not be an error writing to the file.", ioe); diff --git a/src/test/java/seedu/address/storage/StorageManagerTest.java b/src/test/java/seedu/address/storage/StorageManagerTest.java index 2d104131f30..cc7844be2c1 100644 --- a/src/test/java/seedu/address/storage/StorageManagerTest.java +++ b/src/test/java/seedu/address/storage/StorageManagerTest.java @@ -24,7 +24,7 @@ public class StorageManagerTest { @BeforeEach public void setUp() { - JsonAddressBookStorage addressBookStorage = new JsonAddressBookStorage(getTempFilePath("ab")); + JsonStaffConnectStorage addressBookStorage = new JsonStaffConnectStorage(getTempFilePath("ab")); JsonUserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(getTempFilePath("prefs")); storageManager = new StorageManager(addressBookStorage, userPrefsStorage); } @@ -51,7 +51,7 @@ public void prefsReadSave() throws Exception { public void addressBookReadSave() throws Exception { /* * Note: This is an integration test that verifies the StorageManager is properly wired to the - * {@link JsonAddressBookStorage} class. + * {@link JsonStaffConnectStorage} class. * More extensive testing of UserPref saving/reading is done in {@link JsonStaffConnectStorageTest} class. */ StaffConnect original = getTypicalAddressBook(); From b42d4d481eef7d4f54842019219e6f7a71c54e14 Mon Sep 17 00:00:00 2001 From: tsulim Date: Mon, 11 Mar 2024 02:23:37 +0800 Subject: [PATCH 04/16] Refactor `JsonSerializableAddressBook` to `JsonSerializableStaffConnect` --- ...Book.java => JsonSerializableStaffConnect.java} | 12 ++++++------ .../address/storage/JsonStaffConnectStorage.java | 6 +++--- .../storage/JsonSerializableStaffConnectTest.java | 14 +++++++------- 3 files changed, 16 insertions(+), 16 deletions(-) rename src/main/java/seedu/address/storage/{JsonSerializableAddressBook.java => JsonSerializableStaffConnect.java} (82%) diff --git a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java b/src/main/java/seedu/address/storage/JsonSerializableStaffConnect.java similarity index 82% rename from src/main/java/seedu/address/storage/JsonSerializableAddressBook.java rename to src/main/java/seedu/address/storage/JsonSerializableStaffConnect.java index 74737a526f1..b4a1d75f403 100644 --- a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java +++ b/src/main/java/seedu/address/storage/JsonSerializableStaffConnect.java @@ -16,27 +16,27 @@ /** * An Immutable StaffConnect that is serializable to JSON format. */ -@JsonRootName(value = "addressbook") -class JsonSerializableAddressBook { +@JsonRootName(value = "staffconnect") +class JsonSerializableStaffConnect { public static final String MESSAGE_DUPLICATE_PERSON = "Persons list contains duplicate person(s)."; private final List persons = new ArrayList<>(); /** - * Constructs a {@code JsonSerializableAddressBook} with the given persons. + * Constructs a {@code JsonSerializableStaffConnect} with the given persons. */ @JsonCreator - public JsonSerializableAddressBook(@JsonProperty("persons") List persons) { + public JsonSerializableStaffConnect(@JsonProperty("persons") List persons) { this.persons.addAll(persons); } /** * Converts a given {@code ReadOnlyStaffConnect} 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 JsonSerializableStaffConnect}. */ - public JsonSerializableAddressBook(ReadOnlyStaffConnect source) { + public JsonSerializableStaffConnect(ReadOnlyStaffConnect source) { persons.addAll(source.getPersonList().stream().map(JsonAdaptedPerson::new).collect(Collectors.toList())); } diff --git a/src/main/java/seedu/address/storage/JsonStaffConnectStorage.java b/src/main/java/seedu/address/storage/JsonStaffConnectStorage.java index 35c1916e02b..5303ef80b89 100644 --- a/src/main/java/seedu/address/storage/JsonStaffConnectStorage.java +++ b/src/main/java/seedu/address/storage/JsonStaffConnectStorage.java @@ -45,8 +45,8 @@ public Optional readAddressBook() throws DataLoadingExcept public Optional readAddressBook(Path filePath) throws DataLoadingException { requireNonNull(filePath); - Optional jsonAddressBook = JsonUtil.readJsonFile( - filePath, JsonSerializableAddressBook.class); + Optional jsonAddressBook = JsonUtil.readJsonFile( + filePath, JsonSerializableStaffConnect.class); if (!jsonAddressBook.isPresent()) { return Optional.empty(); } @@ -74,7 +74,7 @@ public void saveAddressBook(ReadOnlyStaffConnect addressBook, Path filePath) thr requireNonNull(filePath); FileUtil.createIfMissing(filePath); - JsonUtil.saveJsonFile(new JsonSerializableAddressBook(addressBook), filePath); + JsonUtil.saveJsonFile(new JsonSerializableStaffConnect(addressBook), filePath); } } diff --git a/src/test/java/seedu/address/storage/JsonSerializableStaffConnectTest.java b/src/test/java/seedu/address/storage/JsonSerializableStaffConnectTest.java index 99f741c0642..b6a368e7587 100644 --- a/src/test/java/seedu/address/storage/JsonSerializableStaffConnectTest.java +++ b/src/test/java/seedu/address/storage/JsonSerializableStaffConnectTest.java @@ -22,8 +22,8 @@ public class JsonSerializableStaffConnectTest { @Test public void toModelType_typicalPersonsFile_success() throws Exception { - JsonSerializableAddressBook dataFromFile = JsonUtil.readJsonFile(TYPICAL_PERSONS_FILE, - JsonSerializableAddressBook.class).get(); + JsonSerializableStaffConnect dataFromFile = JsonUtil.readJsonFile(TYPICAL_PERSONS_FILE, + JsonSerializableStaffConnect.class).get(); StaffConnect staffConnectFromFile = dataFromFile.toModelType(); StaffConnect typicalPersonsStaffConnect = TypicalPersons.getTypicalAddressBook(); assertEquals(staffConnectFromFile, typicalPersonsStaffConnect); @@ -31,16 +31,16 @@ public void toModelType_typicalPersonsFile_success() throws Exception { @Test public void toModelType_invalidPersonFile_throwsIllegalValueException() throws Exception { - JsonSerializableAddressBook dataFromFile = JsonUtil.readJsonFile(INVALID_PERSON_FILE, - JsonSerializableAddressBook.class).get(); + JsonSerializableStaffConnect dataFromFile = JsonUtil.readJsonFile(INVALID_PERSON_FILE, + JsonSerializableStaffConnect.class).get(); assertThrows(IllegalValueException.class, dataFromFile::toModelType); } @Test public void toModelType_duplicatePersons_throwsIllegalValueException() throws Exception { - JsonSerializableAddressBook dataFromFile = JsonUtil.readJsonFile(DUPLICATE_PERSON_FILE, - JsonSerializableAddressBook.class).get(); - assertThrows(IllegalValueException.class, JsonSerializableAddressBook.MESSAGE_DUPLICATE_PERSON, + JsonSerializableStaffConnect dataFromFile = JsonUtil.readJsonFile(DUPLICATE_PERSON_FILE, + JsonSerializableStaffConnect.class).get(); + assertThrows(IllegalValueException.class, JsonSerializableStaffConnect.MESSAGE_DUPLICATE_PERSON, dataFromFile::toModelType); } From 415419b07685675cf4bc168991b40734d61f8a95 Mon Sep 17 00:00:00 2001 From: tsulim Date: Mon, 11 Mar 2024 02:35:17 +0800 Subject: [PATCH 05/16] Refactor `AddressBookParser` to `StaffConnectParser` --- src/main/java/seedu/address/logic/LogicManager.java | 8 ++++---- .../{AddressBookParser.java => StaffConnectParser.java} | 4 ++-- .../address/logic/parser/StaffConnectParserTest.java | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) rename src/main/java/seedu/address/logic/parser/{AddressBookParser.java => StaffConnectParser.java} (96%) diff --git a/src/main/java/seedu/address/logic/LogicManager.java b/src/main/java/seedu/address/logic/LogicManager.java index 995a1316cec..8253b9d0cf3 100644 --- a/src/main/java/seedu/address/logic/LogicManager.java +++ b/src/main/java/seedu/address/logic/LogicManager.java @@ -11,7 +11,7 @@ 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.StaffConnectParser; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.Model; import seedu.address.model.ReadOnlyStaffConnect; @@ -31,7 +31,7 @@ public class LogicManager implements Logic { private final Model model; private final Storage storage; - private final AddressBookParser addressBookParser; + private final StaffConnectParser staffConnectParser; /** * Constructs a {@code LogicManager} with the given {@code Model} and {@code Storage}. @@ -39,7 +39,7 @@ public class LogicManager implements Logic { public LogicManager(Model model, Storage storage) { this.model = model; this.storage = storage; - addressBookParser = new AddressBookParser(); + staffConnectParser = new StaffConnectParser(); } @Override @@ -47,7 +47,7 @@ public CommandResult execute(String commandText) throws CommandException, ParseE logger.info("----------------[USER COMMAND][" + commandText + "]"); CommandResult commandResult; - Command command = addressBookParser.parseCommand(commandText); + Command command = staffConnectParser.parseCommand(commandText); commandResult = command.execute(model); try { diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/StaffConnectParser.java similarity index 96% rename from src/main/java/seedu/address/logic/parser/AddressBookParser.java rename to src/main/java/seedu/address/logic/parser/StaffConnectParser.java index 3149ee07e0b..43115d5ef11 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/StaffConnectParser.java @@ -22,13 +22,13 @@ /** * Parses user input. */ -public class AddressBookParser { +public class StaffConnectParser { /** * Used for initial separation of command word and args. */ private static final Pattern BASIC_COMMAND_FORMAT = Pattern.compile("(?\\S+)(?.*)"); - private static final Logger logger = LogsCenter.getLogger(AddressBookParser.class); + private static final Logger logger = LogsCenter.getLogger(StaffConnectParser.class); /** * Parses user input into command for execution. diff --git a/src/test/java/seedu/address/logic/parser/StaffConnectParserTest.java b/src/test/java/seedu/address/logic/parser/StaffConnectParserTest.java index 7f3aa25fbe4..2551b7f667c 100644 --- a/src/test/java/seedu/address/logic/parser/StaffConnectParserTest.java +++ b/src/test/java/seedu/address/logic/parser/StaffConnectParserTest.java @@ -31,7 +31,7 @@ public class StaffConnectParserTest { - private final AddressBookParser parser = new AddressBookParser(); + private final StaffConnectParser parser = new StaffConnectParser(); @Test public void parseCommand_add() throws Exception { From 5ff15a1aa5fcb096364e03624cdca811a985f93d Mon Sep 17 00:00:00 2001 From: tsulim Date: Mon, 11 Mar 2024 02:36:32 +0800 Subject: [PATCH 06/16] Refactor `AddressBookBuilder` to `StaffConnectBuilder` --- .../java/seedu/address/model/ModelManagerTest.java | 4 ++-- ...ddressBookBuilder.java => StaffConnectBuilder.java} | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) rename src/test/java/seedu/address/testutil/{AddressBookBuilder.java => StaffConnectBuilder.java} (67%) diff --git a/src/test/java/seedu/address/model/ModelManagerTest.java b/src/test/java/seedu/address/model/ModelManagerTest.java index 3c5770b5923..f57064cf2fe 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.person.NameContainsKeywordsPredicate; -import seedu.address.testutil.AddressBookBuilder; +import seedu.address.testutil.StaffConnectBuilder; public class ModelManagerTest { @@ -95,7 +95,7 @@ public void getFilteredPersonList_modifyList_throwsUnsupportedOperationException @Test public void equals() { - StaffConnect staffConnect = new AddressBookBuilder().withPerson(ALICE).withPerson(BENSON).build(); + StaffConnect staffConnect = new StaffConnectBuilder().withPerson(ALICE).withPerson(BENSON).build(); StaffConnect differentStaffConnect = new StaffConnect(); UserPrefs userPrefs = new UserPrefs(); diff --git a/src/test/java/seedu/address/testutil/AddressBookBuilder.java b/src/test/java/seedu/address/testutil/StaffConnectBuilder.java similarity index 67% rename from src/test/java/seedu/address/testutil/AddressBookBuilder.java rename to src/test/java/seedu/address/testutil/StaffConnectBuilder.java index 4dcd19f4948..d44ff7b3324 100644 --- a/src/test/java/seedu/address/testutil/AddressBookBuilder.java +++ b/src/test/java/seedu/address/testutil/StaffConnectBuilder.java @@ -6,24 +6,24 @@ /** * A utility class to help with building Addressbook objects. * Example usage:
- * {@code StaffConnect ab = new AddressBookBuilder().withPerson("John", "Doe").build();} + * {@code StaffConnect ab = new StaffConnectBuilder().withPerson("John", "Doe").build();} */ -public class AddressBookBuilder { +public class StaffConnectBuilder { private StaffConnect staffConnect; - public AddressBookBuilder() { + public StaffConnectBuilder() { staffConnect = new StaffConnect(); } - public AddressBookBuilder(StaffConnect staffConnect) { + public StaffConnectBuilder(StaffConnect staffConnect) { this.staffConnect = staffConnect; } /** * Adds a new {@code Person} to the {@code StaffConnect} that we are building. */ - public AddressBookBuilder withPerson(Person person) { + public StaffConnectBuilder withPerson(Person person) { staffConnect.addPerson(person); return this; } From 8a1820b2a00c702a9b8663fa09e280fd1bd6557d Mon Sep 17 00:00:00 2001 From: tsulim Date: Mon, 11 Mar 2024 12:09:44 +0800 Subject: [PATCH 07/16] Remove redundant files --- src/main/java/staffconnect/logic/parser/AddressBookParser.java | 0 src/main/java/staffconnect/model/AddressBook.java | 0 src/main/java/staffconnect/model/ReadOnlyAddressBook.java | 0 src/main/java/staffconnect/storage/AddressBookStorage.java | 0 src/main/java/staffconnect/storage/JsonAddressBookStorage.java | 0 .../java/staffconnect/storage/JsonSerializableAddressBook.java | 0 .../java/staffconnect/logic/parser/AddressBookParserTest.java | 0 src/test/java/staffconnect/model/AddressBookTest.java | 0 .../java/staffconnect/storage/JsonAddressBookStorageTest.java | 0 src/test/java/staffconnect/testutil/AddressBookBuilder.java | 0 10 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/main/java/staffconnect/logic/parser/AddressBookParser.java delete mode 100644 src/main/java/staffconnect/model/AddressBook.java delete mode 100644 src/main/java/staffconnect/model/ReadOnlyAddressBook.java delete mode 100644 src/main/java/staffconnect/storage/AddressBookStorage.java delete mode 100644 src/main/java/staffconnect/storage/JsonAddressBookStorage.java delete mode 100644 src/main/java/staffconnect/storage/JsonSerializableAddressBook.java delete mode 100644 src/test/java/staffconnect/logic/parser/AddressBookParserTest.java delete mode 100644 src/test/java/staffconnect/model/AddressBookTest.java delete mode 100644 src/test/java/staffconnect/storage/JsonAddressBookStorageTest.java delete mode 100644 src/test/java/staffconnect/testutil/AddressBookBuilder.java diff --git a/src/main/java/staffconnect/logic/parser/AddressBookParser.java b/src/main/java/staffconnect/logic/parser/AddressBookParser.java deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/main/java/staffconnect/model/AddressBook.java b/src/main/java/staffconnect/model/AddressBook.java deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/main/java/staffconnect/model/ReadOnlyAddressBook.java b/src/main/java/staffconnect/model/ReadOnlyAddressBook.java deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/main/java/staffconnect/storage/AddressBookStorage.java b/src/main/java/staffconnect/storage/AddressBookStorage.java deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/main/java/staffconnect/storage/JsonAddressBookStorage.java b/src/main/java/staffconnect/storage/JsonAddressBookStorage.java deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/main/java/staffconnect/storage/JsonSerializableAddressBook.java b/src/main/java/staffconnect/storage/JsonSerializableAddressBook.java deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/test/java/staffconnect/logic/parser/AddressBookParserTest.java b/src/test/java/staffconnect/logic/parser/AddressBookParserTest.java deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/test/java/staffconnect/model/AddressBookTest.java b/src/test/java/staffconnect/model/AddressBookTest.java deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/test/java/staffconnect/storage/JsonAddressBookStorageTest.java b/src/test/java/staffconnect/storage/JsonAddressBookStorageTest.java deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/test/java/staffconnect/testutil/AddressBookBuilder.java b/src/test/java/staffconnect/testutil/AddressBookBuilder.java deleted file mode 100644 index e69de29bb2d..00000000000 From c428566a41e25e753d81bd5608c319219366aa15 Mon Sep 17 00:00:00 2001 From: tsulim Date: Mon, 11 Mar 2024 12:10:41 +0800 Subject: [PATCH 08/16] Refactor code to comply with the checkstyle rules --- src/main/java/staffconnect/MainApp.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/staffconnect/MainApp.java b/src/main/java/staffconnect/MainApp.java index 116e4bf231a..77b174f4899 100644 --- a/src/main/java/staffconnect/MainApp.java +++ b/src/main/java/staffconnect/MainApp.java @@ -23,8 +23,8 @@ import staffconnect.model.UserPrefs; import staffconnect.model.util.SampleDataUtil; import staffconnect.storage.JsonStaffConnectStorage; -import staffconnect.storage.StaffConnectStorage; import staffconnect.storage.JsonUserPrefsStorage; +import staffconnect.storage.StaffConnectStorage; import staffconnect.storage.Storage; import staffconnect.storage.StorageManager; import staffconnect.storage.UserPrefsStorage; From e81a82f8a8de98bb9035ef23a0e268c2dc118290 Mon Sep 17 00:00:00 2001 From: tsulim Date: Mon, 11 Mar 2024 12:19:08 +0800 Subject: [PATCH 09/16] Rename folder names for test data --- .../duplicatePersonAddressBook.json | 0 .../invalidPersonAddressBook.json | 0 .../typicalPersonsAddressBook.json | 0 .../invalidAndValidPersonAddressBook.json | 0 .../invalidPersonAddressBook.json | 0 .../notJsonFormatAddressBook.json | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename src/test/data/{JsonSerializableAddressBookTest => JsonSerializableStaffConnectTest}/duplicatePersonAddressBook.json (100%) rename src/test/data/{JsonSerializableAddressBookTest => JsonSerializableStaffConnectTest}/invalidPersonAddressBook.json (100%) rename src/test/data/{JsonSerializableAddressBookTest => JsonSerializableStaffConnectTest}/typicalPersonsAddressBook.json (100%) rename src/test/data/{JsonAddressBookStorageTest => JsonStaffConnectStorageTest}/invalidAndValidPersonAddressBook.json (100%) rename src/test/data/{JsonAddressBookStorageTest => JsonStaffConnectStorageTest}/invalidPersonAddressBook.json (100%) rename src/test/data/{JsonAddressBookStorageTest => JsonStaffConnectStorageTest}/notJsonFormatAddressBook.json (100%) diff --git a/src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json b/src/test/data/JsonSerializableStaffConnectTest/duplicatePersonAddressBook.json similarity index 100% rename from src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json rename to src/test/data/JsonSerializableStaffConnectTest/duplicatePersonAddressBook.json diff --git a/src/test/data/JsonSerializableAddressBookTest/invalidPersonAddressBook.json b/src/test/data/JsonSerializableStaffConnectTest/invalidPersonAddressBook.json similarity index 100% rename from src/test/data/JsonSerializableAddressBookTest/invalidPersonAddressBook.json rename to src/test/data/JsonSerializableStaffConnectTest/invalidPersonAddressBook.json diff --git a/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json b/src/test/data/JsonSerializableStaffConnectTest/typicalPersonsAddressBook.json similarity index 100% rename from src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json rename to src/test/data/JsonSerializableStaffConnectTest/typicalPersonsAddressBook.json diff --git a/src/test/data/JsonAddressBookStorageTest/invalidAndValidPersonAddressBook.json b/src/test/data/JsonStaffConnectStorageTest/invalidAndValidPersonAddressBook.json similarity index 100% rename from src/test/data/JsonAddressBookStorageTest/invalidAndValidPersonAddressBook.json rename to src/test/data/JsonStaffConnectStorageTest/invalidAndValidPersonAddressBook.json diff --git a/src/test/data/JsonAddressBookStorageTest/invalidPersonAddressBook.json b/src/test/data/JsonStaffConnectStorageTest/invalidPersonAddressBook.json similarity index 100% rename from src/test/data/JsonAddressBookStorageTest/invalidPersonAddressBook.json rename to src/test/data/JsonStaffConnectStorageTest/invalidPersonAddressBook.json diff --git a/src/test/data/JsonAddressBookStorageTest/notJsonFormatAddressBook.json b/src/test/data/JsonStaffConnectStorageTest/notJsonFormatAddressBook.json similarity index 100% rename from src/test/data/JsonAddressBookStorageTest/notJsonFormatAddressBook.json rename to src/test/data/JsonStaffConnectStorageTest/notJsonFormatAddressBook.json From 247997b1ff3b4696450e34efc82942855e2feab5 Mon Sep 17 00:00:00 2001 From: tsulim Date: Mon, 11 Mar 2024 22:44:10 +0800 Subject: [PATCH 10/16] Refactor `StaffConnect` class to `StaffBook` class --- .../diagrams/ArchitectureSequenceDiagram.puml | 2 +- src/main/java/staffconnect/MainApp.java | 14 +++---- src/main/java/staffconnect/logic/Logic.java | 4 +- .../logic/commands/ClearCommand.java | 9 ++-- src/main/java/staffconnect/model/Model.java | 20 ++++----- .../java/staffconnect/model/ModelManager.java | 36 ++++++++-------- .../{StaffConnect.java => StaffBook.java} | 30 ++++++------- .../model/util/SampleDataUtil.java | 6 +-- .../storage/JsonSerializableStaffConnect.java | 18 ++++---- .../storage/JsonStaffConnectStorage.java | 2 +- .../storage/StaffConnectStorage.java | 5 ++- .../staffconnect/storage/StorageManager.java | 4 +- .../logic/commands/AddCommandTest.java | 4 +- .../logic/commands/ClearCommandTest.java | 8 ++-- .../logic/commands/CommandTestUtil.java | 10 ++--- .../logic/commands/EditCommandTest.java | 16 +++---- .../staffconnect/model/ModelManagerTest.java | 20 ++++----- ...affConnectTest.java => StaffBookTest.java} | 42 +++++++++---------- .../JsonSerializableStaffConnectTest.java | 8 ++-- .../storage/JsonStaffConnectStorageTest.java | 12 +++--- .../storage/StorageManagerTest.java | 6 +-- .../testutil/StaffBookBuilder.java | 34 +++++++++++++++ .../testutil/StaffConnectBuilder.java | 34 --------------- .../staffconnect/testutil/TypicalPersons.java | 8 ++-- 24 files changed, 176 insertions(+), 176 deletions(-) rename src/main/java/staffconnect/model/{StaffConnect.java => StaffBook.java} (76%) rename src/test/java/staffconnect/model/{StaffConnectTest.java => StaffBookTest.java} (67%) create mode 100644 src/test/java/staffconnect/testutil/StaffBookBuilder.java delete mode 100644 src/test/java/staffconnect/testutil/StaffConnectBuilder.java diff --git a/docs/diagrams/ArchitectureSequenceDiagram.puml b/docs/diagrams/ArchitectureSequenceDiagram.puml index a8d42245707..e1b7a6012ff 100644 --- a/docs/diagrams/ArchitectureSequenceDiagram.puml +++ b/docs/diagrams/ArchitectureSequenceDiagram.puml @@ -20,7 +20,7 @@ activate model MODEL_COLOR model -[MODEL_COLOR]-> logic deactivate model -logic -[LOGIC_COLOR]> storage : saveAddressBook(staffConnect) +logic -[LOGIC_COLOR]> storage : saveAddressBook(staffBook) activate storage STORAGE_COLOR storage -[STORAGE_COLOR]> storage : Save to file diff --git a/src/main/java/staffconnect/MainApp.java b/src/main/java/staffconnect/MainApp.java index 77b174f4899..018d28bd835 100644 --- a/src/main/java/staffconnect/MainApp.java +++ b/src/main/java/staffconnect/MainApp.java @@ -19,7 +19,7 @@ import staffconnect.model.ModelManager; import staffconnect.model.ReadOnlyStaffConnect; import staffconnect.model.ReadOnlyUserPrefs; -import staffconnect.model.StaffConnect; +import staffconnect.model.StaffBook; import staffconnect.model.UserPrefs; import staffconnect.model.util.SampleDataUtil; import staffconnect.storage.JsonStaffConnectStorage; @@ -68,9 +68,9 @@ public void init() throws Exception { } /** - * Returns a {@code ModelManager} with the data from {@code storage}'s address book and {@code userPrefs}.
- * The data from the sample address book will be used instead if {@code storage}'s address book is not found, - * or an empty address book will be used instead if errors occur when reading {@code storage}'s address book. + * Returns a {@code ModelManager} with the data from {@code storage}'s staff book and {@code userPrefs}.
+ * The data from the sample staff book will be used instead if {@code storage}'s staff book is not found, + * or an empty staff book will be used instead if errors occur when reading {@code storage}'s staff book. */ private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) { logger.info("Using data file : " + storage.getAddressBookFilePath()); @@ -81,13 +81,13 @@ private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) { addressBookOptional = storage.readAddressBook(); if (!addressBookOptional.isPresent()) { logger.info("Creating a new data file " + storage.getAddressBookFilePath() - + " populated with a sample StaffConnect."); + + " populated with a sample StaffBook."); } initialData = addressBookOptional.orElseGet(SampleDataUtil::getSampleAddressBook); } catch (DataLoadingException e) { logger.warning("Data file at " + storage.getAddressBookFilePath() + " could not be loaded." - + " Will be starting with an empty StaffConnect."); - initialData = new StaffConnect(); + + " Will be starting with an empty StaffBook."); + initialData = new StaffBook(); } return new ModelManager(initialData, userPrefs); diff --git a/src/main/java/staffconnect/logic/Logic.java b/src/main/java/staffconnect/logic/Logic.java index a1a525b25ac..dbcaaa8186a 100644 --- a/src/main/java/staffconnect/logic/Logic.java +++ b/src/main/java/staffconnect/logic/Logic.java @@ -24,7 +24,7 @@ public interface Logic { CommandResult execute(String commandText) throws CommandException, ParseException; /** - * Returns the StaffConnect. + * Returns the StaffBook. * * @see staffconnect.model.Model#getAddressBook() */ @@ -34,7 +34,7 @@ public interface Logic { ObservableList getFilteredPersonList(); /** - * Returns the user prefs' address book file path. + * Returns the user prefs' staff book file path. */ Path getAddressBookFilePath(); diff --git a/src/main/java/staffconnect/logic/commands/ClearCommand.java b/src/main/java/staffconnect/logic/commands/ClearCommand.java index fb3552fe31f..9fc194f8ec0 100644 --- a/src/main/java/staffconnect/logic/commands/ClearCommand.java +++ b/src/main/java/staffconnect/logic/commands/ClearCommand.java @@ -3,21 +3,20 @@ import static java.util.Objects.requireNonNull; import staffconnect.model.Model; -import staffconnect.model.StaffConnect; +import staffconnect.model.StaffBook; /** - * Clears the address book. + * Clears the staff book. */ public class ClearCommand extends Command { public static final String COMMAND_WORD = "clear"; - public static final String MESSAGE_SUCCESS = "Address book has been cleared!"; - + public static final String MESSAGE_SUCCESS = "Staff book has been cleared!"; @Override public CommandResult execute(Model model) { requireNonNull(model); - model.setAddressBook(new StaffConnect()); + model.setAddressBook(new StaffBook()); return new CommandResult(MESSAGE_SUCCESS); } } diff --git a/src/main/java/staffconnect/model/Model.java b/src/main/java/staffconnect/model/Model.java index 689d65be437..802625deb86 100644 --- a/src/main/java/staffconnect/model/Model.java +++ b/src/main/java/staffconnect/model/Model.java @@ -35,44 +35,44 @@ public interface Model { void setGuiSettings(GuiSettings guiSettings); /** - * Returns the user prefs' address book file path. + * Returns the user prefs' staff book file path. */ Path getAddressBookFilePath(); /** - * Sets the user prefs' address book file path. + * Sets the user prefs' staff book file path. */ void setAddressBookFilePath(Path addressBookFilePath); /** - * Replaces address book data with the data in {@code addressBook}. + * Replaces staff book data with the data in {@code staffBook}. */ - void setAddressBook(ReadOnlyStaffConnect staffConnect); + void setAddressBook(ReadOnlyStaffConnect staffBook); - /** Returns the StaffConnect */ + /** Returns the StaffBook */ ReadOnlyStaffConnect getAddressBook(); /** - * Returns true if a person with the same identity as {@code person} exists in the address book. + * Returns true if a person with the same identity as {@code person} exists in the staff book. */ boolean hasPerson(Person person); /** * Deletes the given person. - * The person must exist in the address book. + * The person must exist in the staff book. */ void deletePerson(Person target); /** * Adds the given person. - * {@code person} must not already exist in the address book. + * {@code person} must not already exist in the staff book. */ void addPerson(Person person); /** * Replaces the given person {@code target} with {@code editedPerson}. - * {@code target} must exist in the address book. - * The person identity of {@code editedPerson} must not be the same as another existing person in the address book. + * {@code target} must exist in the staff book. + * The person identity of {@code editedPerson} must not be the same as another existing person in the staff book. */ void setPerson(Person target, Person editedPerson); diff --git a/src/main/java/staffconnect/model/ModelManager.java b/src/main/java/staffconnect/model/ModelManager.java index 67473e0ddea..2ca36ef2121 100644 --- a/src/main/java/staffconnect/model/ModelManager.java +++ b/src/main/java/staffconnect/model/ModelManager.java @@ -14,30 +14,30 @@ import staffconnect.model.person.Person; /** - * Represents the in-memory model of the address book data. + * Represents the in-memory model of the staff book data. */ public class ModelManager implements Model { private static final Logger logger = LogsCenter.getLogger(ModelManager.class); - private final StaffConnect staffConnect; + private final StaffBook staffBook; private final UserPrefs userPrefs; private final FilteredList filteredPersons; /** - * Initializes a ModelManager with the given staffConnect and userPrefs. + * Initializes a ModelManager with the given staffBook and userPrefs. */ - public ModelManager(ReadOnlyStaffConnect staffConnect, ReadOnlyUserPrefs userPrefs) { - requireAllNonNull(staffConnect, userPrefs); + public ModelManager(ReadOnlyStaffConnect staffBook, ReadOnlyUserPrefs userPrefs) { + requireAllNonNull(staffBook, userPrefs); - logger.fine("Initializing with address book: " + staffConnect + " and user prefs " + userPrefs); + logger.fine("Initializing with staff book: " + staffBook + " and user prefs " + userPrefs); - this.staffConnect = new StaffConnect(staffConnect); + this.staffBook = new StaffBook(staffBook); this.userPrefs = new UserPrefs(userPrefs); - filteredPersons = new FilteredList<>(this.staffConnect.getPersonList()); + filteredPersons = new FilteredList<>(this.staffBook.getPersonList()); } public ModelManager() { - this(new StaffConnect(), new UserPrefs()); + this(new StaffBook(), new UserPrefs()); } //=========== UserPrefs ================================================================================== @@ -75,32 +75,32 @@ public void setAddressBookFilePath(Path addressBookFilePath) { userPrefs.setAddressBookFilePath(addressBookFilePath); } - //=========== StaffConnect ================================================================================ + //=========== StaffBook ================================================================================ @Override - public void setAddressBook(ReadOnlyStaffConnect staffConnect) { - this.staffConnect.resetData(staffConnect); + public void setAddressBook(ReadOnlyStaffConnect staffBook) { + this.staffBook.resetData(staffBook); } @Override public ReadOnlyStaffConnect getAddressBook() { - return staffConnect; + return staffBook; } @Override public boolean hasPerson(Person person) { requireNonNull(person); - return staffConnect.hasPerson(person); + return staffBook.hasPerson(person); } @Override public void deletePerson(Person target) { - staffConnect.removePerson(target); + staffBook.removePerson(target); } @Override public void addPerson(Person person) { - staffConnect.addPerson(person); + staffBook.addPerson(person); updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); } @@ -108,7 +108,7 @@ public void addPerson(Person person) { public void setPerson(Person target, Person editedPerson) { requireAllNonNull(target, editedPerson); - staffConnect.setPerson(target, editedPerson); + staffBook.setPerson(target, editedPerson); } //=========== Filtered Person List Accessors ============================================================= @@ -140,7 +140,7 @@ public boolean equals(Object other) { } ModelManager otherModelManager = (ModelManager) other; - return staffConnect.equals(otherModelManager.staffConnect) + return staffBook.equals(otherModelManager.staffBook) && userPrefs.equals(otherModelManager.userPrefs) && filteredPersons.equals(otherModelManager.filteredPersons); } diff --git a/src/main/java/staffconnect/model/StaffConnect.java b/src/main/java/staffconnect/model/StaffBook.java similarity index 76% rename from src/main/java/staffconnect/model/StaffConnect.java rename to src/main/java/staffconnect/model/StaffBook.java index cc8e6902e43..9e4a784d424 100644 --- a/src/main/java/staffconnect/model/StaffConnect.java +++ b/src/main/java/staffconnect/model/StaffBook.java @@ -13,7 +13,7 @@ * Wraps all data at the fundamental level * Duplicates are not allowed (by .isSamePerson comparison) */ -public class StaffConnect implements ReadOnlyStaffConnect { +public class StaffBook implements ReadOnlyStaffConnect { private final UniquePersonList persons; @@ -28,12 +28,12 @@ public class StaffConnect implements ReadOnlyStaffConnect { persons = new UniquePersonList(); } - public StaffConnect() {} + public StaffBook() {} /** - * Creates an StaffConnect using the Persons in the {@code toBeCopied} + * Creates a StaffBook using the Persons in the {@code toBeCopied} */ - public StaffConnect(ReadOnlyStaffConnect toBeCopied) { + public StaffBook(ReadOnlyStaffConnect toBeCopied) { this(); resetData(toBeCopied); } @@ -49,7 +49,7 @@ public void setPersons(List persons) { } /** - * Resets the existing data of this {@code StaffConnect} with {@code newData}. + * Resets the existing data of this {@code StaffBook} with {@code newData}. */ public void resetData(ReadOnlyStaffConnect newData) { requireNonNull(newData); @@ -60,7 +60,7 @@ public void resetData(ReadOnlyStaffConnect newData) { //// person-level operations /** - * Returns true if a person with the same identity as {@code person} exists in the staffconnect. + * Returns true if a person with the same identity as {@code person} exists in the staff book. */ public boolean hasPerson(Person person) { requireNonNull(person); @@ -68,8 +68,8 @@ public boolean hasPerson(Person person) { } /** - * Adds a person to the staffconnect. - * The person must not already exist in the staffconnect. + * Adds a person to the staff book. + * The person must not already exist in the staff book. */ public void addPerson(Person p) { persons.add(p); @@ -77,8 +77,8 @@ public void addPerson(Person p) { /** * Replaces the given person {@code target} in the list with {@code editedPerson}. - * {@code target} must exist in the staffconnect. - * The person identity of {@code editedPerson} must not be the same as another existing person in the staffconnect. + * {@code target} must exist in the staff book. + * The person identity of {@code editedPerson} must not be the same as another existing person in the staff book. */ public void setPerson(Person target, Person editedPerson) { requireNonNull(editedPerson); @@ -87,8 +87,8 @@ public void setPerson(Person target, Person editedPerson) { } /** - * Removes {@code key} from this {@code StaffConnect}. - * {@code key} must exist in the staffconnect. + * Removes {@code key} from this {@code StaffBook}. + * {@code key} must exist in the staff book. */ public void removePerson(Person key) { persons.remove(key); @@ -115,12 +115,12 @@ public boolean equals(Object other) { } // instanceof handles nulls - if (!(other instanceof StaffConnect)) { + if (!(other instanceof StaffBook)) { return false; } - StaffConnect otherStaffConnect = (StaffConnect) other; - return persons.equals(otherStaffConnect.persons); + StaffBook otherStaffBook = (StaffBook) other; + return persons.equals(otherStaffBook.persons); } @Override diff --git a/src/main/java/staffconnect/model/util/SampleDataUtil.java b/src/main/java/staffconnect/model/util/SampleDataUtil.java index 291b8ec3a64..85e595d32fc 100644 --- a/src/main/java/staffconnect/model/util/SampleDataUtil.java +++ b/src/main/java/staffconnect/model/util/SampleDataUtil.java @@ -5,7 +5,7 @@ import java.util.stream.Collectors; import staffconnect.model.ReadOnlyStaffConnect; -import staffconnect.model.StaffConnect; +import staffconnect.model.StaffBook; import staffconnect.model.person.Address; import staffconnect.model.person.Email; import staffconnect.model.person.Name; @@ -14,7 +14,7 @@ import staffconnect.model.tag.Tag; /** - * Contains utility methods for populating {@code StaffConnect} with sample data. + * Contains utility methods for populating {@code StaffBook} with sample data. */ public class SampleDataUtil { public static Person[] getSamplePersons() { @@ -41,7 +41,7 @@ public static Person[] getSamplePersons() { } public static ReadOnlyStaffConnect getSampleAddressBook() { - StaffConnect sampleSc = new StaffConnect(); + StaffBook sampleSc = new StaffBook(); for (Person samplePerson : getSamplePersons()) { sampleSc.addPerson(samplePerson); } diff --git a/src/main/java/staffconnect/storage/JsonSerializableStaffConnect.java b/src/main/java/staffconnect/storage/JsonSerializableStaffConnect.java index 4e777d583c0..2504af901b6 100644 --- a/src/main/java/staffconnect/storage/JsonSerializableStaffConnect.java +++ b/src/main/java/staffconnect/storage/JsonSerializableStaffConnect.java @@ -10,13 +10,13 @@ import staffconnect.commons.exceptions.IllegalValueException; import staffconnect.model.ReadOnlyStaffConnect; -import staffconnect.model.StaffConnect; +import staffconnect.model.StaffBook; import staffconnect.model.person.Person; /** - * An Immutable StaffConnect that is serializable to JSON format. + * An Immutable StaffBook that is serializable to JSON format. */ -@JsonRootName(value = "staffconnect") +@JsonRootName(value = "staffbook") class JsonSerializableStaffConnect { public static final String MESSAGE_DUPLICATE_PERSON = "Persons list contains duplicate person(s)."; @@ -41,20 +41,20 @@ public JsonSerializableStaffConnect(ReadOnlyStaffConnect source) { } /** - * Converts this address book into the model's {@code StaffConnect} object. + * Converts this address book into the model's {@code StaffBook} object. * * @throws IllegalValueException if there were any data constraints violated. */ - public StaffConnect toModelType() throws IllegalValueException { - StaffConnect staffConnect = new StaffConnect(); + public StaffBook toModelType() throws IllegalValueException { + StaffBook staffBook = new StaffBook(); for (JsonAdaptedPerson jsonAdaptedPerson : persons) { Person person = jsonAdaptedPerson.toModelType(); - if (staffConnect.hasPerson(person)) { + if (staffBook.hasPerson(person)) { throw new IllegalValueException(MESSAGE_DUPLICATE_PERSON); } - staffConnect.addPerson(person); + staffBook.addPerson(person); } - return staffConnect; + return staffBook; } } diff --git a/src/main/java/staffconnect/storage/JsonStaffConnectStorage.java b/src/main/java/staffconnect/storage/JsonStaffConnectStorage.java index 3db547206aa..0ba12fb270d 100644 --- a/src/main/java/staffconnect/storage/JsonStaffConnectStorage.java +++ b/src/main/java/staffconnect/storage/JsonStaffConnectStorage.java @@ -15,7 +15,7 @@ import staffconnect.model.ReadOnlyStaffConnect; /** - * A class to access StaffConnect data stored as a json file on the hard disk. + * A class to access StaffBook data stored as a json file on the hard disk. */ public class JsonStaffConnectStorage implements StaffConnectStorage { diff --git a/src/main/java/staffconnect/storage/StaffConnectStorage.java b/src/main/java/staffconnect/storage/StaffConnectStorage.java index 54ca9b5dd36..4f102d11dbc 100644 --- a/src/main/java/staffconnect/storage/StaffConnectStorage.java +++ b/src/main/java/staffconnect/storage/StaffConnectStorage.java @@ -6,9 +6,10 @@ import staffconnect.commons.exceptions.DataLoadingException; import staffconnect.model.ReadOnlyStaffConnect; +import staffconnect.model.StaffBook; /** - * Represents a storage for {@link staffconnect.model.StaffConnect}. + * Represents a storage for {@link StaffBook}. */ public interface StaffConnectStorage { @@ -18,7 +19,7 @@ public interface StaffConnectStorage { Path getAddressBookFilePath(); /** - * Returns StaffConnect data as a {@link ReadOnlyStaffConnect}. + * Returns StaffBook data as a {@link ReadOnlyStaffConnect}. * Returns {@code Optional.empty()} if storage file is not found. * * @throws DataLoadingException if loading the data from storage failed. diff --git a/src/main/java/staffconnect/storage/StorageManager.java b/src/main/java/staffconnect/storage/StorageManager.java index 898cf36e3bb..955049d9d19 100644 --- a/src/main/java/staffconnect/storage/StorageManager.java +++ b/src/main/java/staffconnect/storage/StorageManager.java @@ -12,7 +12,7 @@ import staffconnect.model.UserPrefs; /** - * Manages storage of StaffConnect data in local storage. + * Manages storage of StaffBook data in local storage. */ public class StorageManager implements Storage { @@ -46,7 +46,7 @@ public void saveUserPrefs(ReadOnlyUserPrefs userPrefs) throws IOException { } - // ================ StaffConnect methods ============================== + // ================ StaffBook methods ============================== @Override public Path getAddressBookFilePath() { diff --git a/src/test/java/staffconnect/logic/commands/AddCommandTest.java b/src/test/java/staffconnect/logic/commands/AddCommandTest.java index cfe23144826..a6dda6eda3a 100644 --- a/src/test/java/staffconnect/logic/commands/AddCommandTest.java +++ b/src/test/java/staffconnect/logic/commands/AddCommandTest.java @@ -21,7 +21,7 @@ import staffconnect.model.Model; import staffconnect.model.ReadOnlyStaffConnect; import staffconnect.model.ReadOnlyUserPrefs; -import staffconnect.model.StaffConnect; +import staffconnect.model.StaffBook; import staffconnect.model.person.Person; import staffconnect.testutil.PersonBuilder; @@ -197,7 +197,7 @@ public void addPerson(Person person) { @Override public ReadOnlyStaffConnect getAddressBook() { - return new StaffConnect(); + return new StaffBook(); } } diff --git a/src/test/java/staffconnect/logic/commands/ClearCommandTest.java b/src/test/java/staffconnect/logic/commands/ClearCommandTest.java index 5a6f516faa2..9b0a75b6e67 100644 --- a/src/test/java/staffconnect/logic/commands/ClearCommandTest.java +++ b/src/test/java/staffconnect/logic/commands/ClearCommandTest.java @@ -7,13 +7,13 @@ import staffconnect.model.Model; import staffconnect.model.ModelManager; -import staffconnect.model.StaffConnect; +import staffconnect.model.StaffBook; import staffconnect.model.UserPrefs; public class ClearCommandTest { @Test - public void execute_emptyAddressBook_success() { + public void execute_emptyStaffBook_success() { Model model = new ModelManager(); Model expectedModel = new ModelManager(); @@ -21,10 +21,10 @@ public void execute_emptyAddressBook_success() { } @Test - public void execute_nonEmptyAddressBook_success() { + public void execute_nonEmptyStaffBook_success() { Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs()); - expectedModel.setAddressBook(new StaffConnect()); + expectedModel.setAddressBook(new StaffBook()); assertCommandSuccess(new ClearCommand(), model, ClearCommand.MESSAGE_SUCCESS, expectedModel); } diff --git a/src/test/java/staffconnect/logic/commands/CommandTestUtil.java b/src/test/java/staffconnect/logic/commands/CommandTestUtil.java index 78715a79034..a131ad81463 100644 --- a/src/test/java/staffconnect/logic/commands/CommandTestUtil.java +++ b/src/test/java/staffconnect/logic/commands/CommandTestUtil.java @@ -16,7 +16,7 @@ import staffconnect.commons.core.index.Index; import staffconnect.logic.commands.exceptions.CommandException; import staffconnect.model.Model; -import staffconnect.model.StaffConnect; +import staffconnect.model.StaffBook; import staffconnect.model.person.NameContainsKeywordsPredicate; import staffconnect.model.person.Person; import staffconnect.testutil.EditPersonDescriptorBuilder; @@ -99,21 +99,21 @@ public static void assertCommandSuccess(Command command, Model actualModel, Stri * Executes the given {@code command}, confirms that
* - a {@code CommandException} is thrown
* - the CommandException message matches {@code expectedMessage}
- * - the address book, filtered person list and selected person in {@code actualModel} remain unchanged + * - the staff book, filtered person list and selected person 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. - StaffConnect expectedStaffConnect = new StaffConnect(actualModel.getAddressBook()); + StaffBook expectedStaffBook = new StaffBook(actualModel.getAddressBook()); List expectedFilteredList = new ArrayList<>(actualModel.getFilteredPersonList()); assertThrows(CommandException.class, expectedMessage, () -> command.execute(actualModel)); - assertEquals(expectedStaffConnect, actualModel.getAddressBook()); + assertEquals(expectedStaffBook, actualModel.getAddressBook()); assertEquals(expectedFilteredList, actualModel.getFilteredPersonList()); } /** * Updates {@code model}'s filtered list to show only the person at the given {@code targetIndex} in the - * {@code model}'s address book. + * {@code model}'s staff book. */ public static void showPersonAtIndex(Model model, Index targetIndex) { assertTrue(targetIndex.getZeroBased() < model.getFilteredPersonList().size()); diff --git a/src/test/java/staffconnect/logic/commands/EditCommandTest.java b/src/test/java/staffconnect/logic/commands/EditCommandTest.java index 18325e8ba3f..02cf12e3855 100644 --- a/src/test/java/staffconnect/logic/commands/EditCommandTest.java +++ b/src/test/java/staffconnect/logic/commands/EditCommandTest.java @@ -22,7 +22,7 @@ import staffconnect.logic.commands.EditCommand.EditPersonDescriptor; import staffconnect.model.Model; import staffconnect.model.ModelManager; -import staffconnect.model.StaffConnect; +import staffconnect.model.StaffBook; import staffconnect.model.UserPrefs; import staffconnect.model.person.Person; import staffconnect.testutil.EditPersonDescriptorBuilder; @@ -43,7 +43,7 @@ public void execute_allFieldsSpecifiedUnfilteredList_success() { String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)); - Model expectedModel = new ModelManager(new StaffConnect(model.getAddressBook()), new UserPrefs()); + Model expectedModel = new ModelManager(new StaffBook(model.getAddressBook()), new UserPrefs()); expectedModel.setPerson(model.getFilteredPersonList().get(0), editedPerson); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); @@ -64,7 +64,7 @@ public void execute_someFieldsSpecifiedUnfilteredList_success() { String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)); - Model expectedModel = new ModelManager(new StaffConnect(model.getAddressBook()), new UserPrefs()); + Model expectedModel = new ModelManager(new StaffBook(model.getAddressBook()), new UserPrefs()); expectedModel.setPerson(lastPerson, editedPerson); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); @@ -77,7 +77,7 @@ public void execute_noFieldSpecifiedUnfilteredList_success() { String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)); - Model expectedModel = new ModelManager(new StaffConnect(model.getAddressBook()), new UserPrefs()); + Model expectedModel = new ModelManager(new StaffBook(model.getAddressBook()), new UserPrefs()); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); } @@ -93,7 +93,7 @@ public void execute_filteredList_success() { String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)); - Model expectedModel = new ModelManager(new StaffConnect(model.getAddressBook()), new UserPrefs()); + Model expectedModel = new ModelManager(new StaffBook(model.getAddressBook()), new UserPrefs()); expectedModel.setPerson(model.getFilteredPersonList().get(0), editedPerson); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); @@ -112,7 +112,7 @@ public void execute_duplicatePersonUnfilteredList_failure() { public void execute_duplicatePersonFilteredList_failure() { showPersonAtIndex(model, INDEX_FIRST_PERSON); - // edit person in filtered list into a duplicate in address book + // edit person in filtered list into a duplicate in staff book Person personInList = model.getAddressBook().getPersonList().get(INDEX_SECOND_PERSON.getZeroBased()); EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, new EditPersonDescriptorBuilder(personInList).build()); @@ -131,13 +131,13 @@ public void execute_invalidPersonIndexUnfilteredList_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 staff book */ @Test public void execute_invalidPersonIndexFilteredList_failure() { showPersonAtIndex(model, INDEX_FIRST_PERSON); Index outOfBoundIndex = INDEX_SECOND_PERSON; - // ensures that outOfBoundIndex is still in bounds of address book list + // ensures that outOfBoundIndex is still in bounds of staff book list assertTrue(outOfBoundIndex.getZeroBased() < model.getAddressBook().getPersonList().size()); EditCommand editCommand = new EditCommand(outOfBoundIndex, diff --git a/src/test/java/staffconnect/model/ModelManagerTest.java b/src/test/java/staffconnect/model/ModelManagerTest.java index 47b64f56e76..02b83e6ff8c 100644 --- a/src/test/java/staffconnect/model/ModelManagerTest.java +++ b/src/test/java/staffconnect/model/ModelManagerTest.java @@ -16,7 +16,7 @@ import staffconnect.commons.core.GuiSettings; import staffconnect.model.person.NameContainsKeywordsPredicate; -import staffconnect.testutil.StaffConnectBuilder; +import staffconnect.testutil.StaffBookBuilder; 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 StaffConnect(), new StaffConnect(modelManager.getAddressBook())); + assertEquals(new StaffBook(), new StaffBook(modelManager.getAddressBook())); } @Test @@ -95,13 +95,13 @@ public void getFilteredPersonList_modifyList_throwsUnsupportedOperationException @Test public void equals() { - StaffConnect staffConnect = new StaffConnectBuilder().withPerson(ALICE).withPerson(BENSON).build(); - StaffConnect differentStaffConnect = new StaffConnect(); + StaffBook staffBook = new StaffBookBuilder().withPerson(ALICE).withPerson(BENSON).build(); + StaffBook differentStaffBook = new StaffBook(); UserPrefs userPrefs = new UserPrefs(); // same values -> returns true - modelManager = new ModelManager(staffConnect, userPrefs); - ModelManager modelManagerCopy = new ModelManager(staffConnect, userPrefs); + modelManager = new ModelManager(staffBook, userPrefs); + ModelManager modelManagerCopy = new ModelManager(staffBook, userPrefs); assertTrue(modelManager.equals(modelManagerCopy)); // same object -> returns true @@ -113,13 +113,13 @@ public void equals() { // different types -> returns false assertFalse(modelManager.equals(5)); - // different staffConnect -> returns false - assertFalse(modelManager.equals(new ModelManager(differentStaffConnect, userPrefs))); + // different staffBook -> returns false + assertFalse(modelManager.equals(new ModelManager(differentStaffBook, userPrefs))); // different filteredList -> returns false String[] keywords = ALICE.getName().fullName.split("\\s+"); modelManager.updateFilteredPersonList(new NameContainsKeywordsPredicate(Arrays.asList(keywords))); - assertFalse(modelManager.equals(new ModelManager(staffConnect, userPrefs))); + assertFalse(modelManager.equals(new ModelManager(staffBook, userPrefs))); // resets modelManager to initial state for upcoming tests modelManager.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); @@ -127,6 +127,6 @@ public void equals() { // different userPrefs -> returns false UserPrefs differentUserPrefs = new UserPrefs(); differentUserPrefs.setAddressBookFilePath(Paths.get("differentFilePath")); - assertFalse(modelManager.equals(new ModelManager(staffConnect, differentUserPrefs))); + assertFalse(modelManager.equals(new ModelManager(staffBook, differentUserPrefs))); } } diff --git a/src/test/java/staffconnect/model/StaffConnectTest.java b/src/test/java/staffconnect/model/StaffBookTest.java similarity index 67% rename from src/test/java/staffconnect/model/StaffConnectTest.java rename to src/test/java/staffconnect/model/StaffBookTest.java index cbc1f89905d..9532db19330 100644 --- a/src/test/java/staffconnect/model/StaffConnectTest.java +++ b/src/test/java/staffconnect/model/StaffBookTest.java @@ -22,25 +22,25 @@ import staffconnect.model.person.exceptions.DuplicatePersonException; import staffconnect.testutil.PersonBuilder; -public class StaffConnectTest { +public class StaffBookTest { - private final StaffConnect staffConnect = new StaffConnect(); + private final StaffBook staffBook = new StaffBook(); @Test public void constructor() { - assertEquals(Collections.emptyList(), staffConnect.getPersonList()); + assertEquals(Collections.emptyList(), staffBook.getPersonList()); } @Test public void resetData_null_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> staffConnect.resetData(null)); + assertThrows(NullPointerException.class, () -> staffBook.resetData(null)); } @Test - public void resetData_withValidReadOnlyAddressBook_replacesData() { - StaffConnect newData = getTypicalAddressBook(); - staffConnect.resetData(newData); - assertEquals(newData, staffConnect); + public void resetData_withValidReadOnlyStaffBook_replacesData() { + StaffBook newData = getTypicalAddressBook(); + staffBook.resetData(newData); + assertEquals(newData, staffBook); } @Test @@ -51,42 +51,42 @@ public void resetData_withDuplicatePersons_throwsDuplicatePersonException() { List newPersons = Arrays.asList(ALICE, editedAlice); StaffConnectStub newData = new StaffConnectStub(newPersons); - assertThrows(DuplicatePersonException.class, () -> staffConnect.resetData(newData)); + assertThrows(DuplicatePersonException.class, () -> staffBook.resetData(newData)); } @Test public void hasPerson_nullPerson_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> staffConnect.hasPerson(null)); + assertThrows(NullPointerException.class, () -> staffBook.hasPerson(null)); } @Test - public void hasPerson_personNotInAddressBook_returnsFalse() { - assertFalse(staffConnect.hasPerson(ALICE)); + public void hasPerson_personNotInStaffBook_returnsFalse() { + assertFalse(staffBook.hasPerson(ALICE)); } @Test - public void hasPerson_personInAddressBook_returnsTrue() { - staffConnect.addPerson(ALICE); - assertTrue(staffConnect.hasPerson(ALICE)); + public void hasPerson_personInStaffBook_returnsTrue() { + staffBook.addPerson(ALICE); + assertTrue(staffBook.hasPerson(ALICE)); } @Test - public void hasPerson_personWithSameIdentityFieldsInAddressBook_returnsTrue() { - staffConnect.addPerson(ALICE); + public void hasPerson_personWithSameIdentityFieldsInStaffBook_returnsTrue() { + staffBook.addPerson(ALICE); Person editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) .build(); - assertTrue(staffConnect.hasPerson(editedAlice)); + assertTrue(staffBook.hasPerson(editedAlice)); } @Test public void getPersonList_modifyList_throwsUnsupportedOperationException() { - assertThrows(UnsupportedOperationException.class, () -> staffConnect.getPersonList().remove(0)); + assertThrows(UnsupportedOperationException.class, () -> staffBook.getPersonList().remove(0)); } @Test public void toStringMethod() { - String expected = StaffConnect.class.getCanonicalName() + "{persons=" + staffConnect.getPersonList() + "}"; - assertEquals(expected, staffConnect.toString()); + String expected = StaffBook.class.getCanonicalName() + "{persons=" + staffBook.getPersonList() + "}"; + assertEquals(expected, staffBook.toString()); } /** diff --git a/src/test/java/staffconnect/storage/JsonSerializableStaffConnectTest.java b/src/test/java/staffconnect/storage/JsonSerializableStaffConnectTest.java index d65bd77c381..a93eaca5cc5 100644 --- a/src/test/java/staffconnect/storage/JsonSerializableStaffConnectTest.java +++ b/src/test/java/staffconnect/storage/JsonSerializableStaffConnectTest.java @@ -10,7 +10,7 @@ import staffconnect.commons.exceptions.IllegalValueException; import staffconnect.commons.util.JsonUtil; -import staffconnect.model.StaffConnect; +import staffconnect.model.StaffBook; import staffconnect.testutil.TypicalPersons; public class JsonSerializableStaffConnectTest { @@ -24,9 +24,9 @@ public class JsonSerializableStaffConnectTest { public void toModelType_typicalPersonsFile_success() throws Exception { JsonSerializableStaffConnect dataFromFile = JsonUtil.readJsonFile(TYPICAL_PERSONS_FILE, JsonSerializableStaffConnect.class).get(); - StaffConnect staffConnectFromFile = dataFromFile.toModelType(); - StaffConnect typicalPersonsStaffConnect = TypicalPersons.getTypicalAddressBook(); - assertEquals(staffConnectFromFile, typicalPersonsStaffConnect); + StaffBook staffBookFromFile = dataFromFile.toModelType(); + StaffBook typicalPersonsStaffBook = TypicalPersons.getTypicalAddressBook(); + assertEquals(staffBookFromFile, typicalPersonsStaffBook); } @Test diff --git a/src/test/java/staffconnect/storage/JsonStaffConnectStorageTest.java b/src/test/java/staffconnect/storage/JsonStaffConnectStorageTest.java index 387801f11ed..8cca2b54386 100644 --- a/src/test/java/staffconnect/storage/JsonStaffConnectStorageTest.java +++ b/src/test/java/staffconnect/storage/JsonStaffConnectStorageTest.java @@ -17,7 +17,7 @@ import staffconnect.commons.exceptions.DataLoadingException; import staffconnect.model.ReadOnlyStaffConnect; -import staffconnect.model.StaffConnect; +import staffconnect.model.StaffBook; public class JsonStaffConnectStorageTest { private static final Path TEST_DATA_FOLDER = Paths.get("src", "test", "data", "JsonStaffConnectStorageTest"); @@ -63,26 +63,26 @@ public void readAddressBook_invalidAndValidPersonAddressBook_throwDataLoadingExc @Test public void readAndSaveAddressBook_allInOrder_success() throws Exception { Path filePath = testFolder.resolve("TempAddressBook.json"); - StaffConnect original = getTypicalAddressBook(); + StaffBook original = getTypicalAddressBook(); JsonStaffConnectStorage jsonAddressBookStorage = new JsonStaffConnectStorage(filePath); // Save in new file and read back jsonAddressBookStorage.saveAddressBook(original, filePath); ReadOnlyStaffConnect readBack = jsonAddressBookStorage.readAddressBook(filePath).get(); - assertEquals(original, new StaffConnect(readBack)); + assertEquals(original, new StaffBook(readBack)); // Modify data, overwrite exiting file, and read back original.addPerson(HOON); original.removePerson(ALICE); jsonAddressBookStorage.saveAddressBook(original, filePath); readBack = jsonAddressBookStorage.readAddressBook(filePath).get(); - assertEquals(original, new StaffConnect(readBack)); + assertEquals(original, new StaffBook(readBack)); // Save and read without specifying file path original.addPerson(IDA); jsonAddressBookStorage.saveAddressBook(original); // file path not specified readBack = jsonAddressBookStorage.readAddressBook().get(); // file path not specified - assertEquals(original, new StaffConnect(readBack)); + assertEquals(original, new StaffBook(readBack)); } @@ -105,6 +105,6 @@ private void saveAddressBook(ReadOnlyStaffConnect staffConnect, String filePath) @Test public void saveAddressBook_nullFilePath_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> saveAddressBook(new StaffConnect(), null)); + assertThrows(NullPointerException.class, () -> saveAddressBook(new StaffBook(), null)); } } diff --git a/src/test/java/staffconnect/storage/StorageManagerTest.java b/src/test/java/staffconnect/storage/StorageManagerTest.java index e51ebff0614..0ebd766bc60 100644 --- a/src/test/java/staffconnect/storage/StorageManagerTest.java +++ b/src/test/java/staffconnect/storage/StorageManagerTest.java @@ -12,7 +12,7 @@ import staffconnect.commons.core.GuiSettings; import staffconnect.model.ReadOnlyStaffConnect; -import staffconnect.model.StaffConnect; +import staffconnect.model.StaffBook; import staffconnect.model.UserPrefs; public class StorageManagerTest { @@ -54,10 +54,10 @@ public void addressBookReadSave() throws Exception { * {@link JsonStaffConnectStorage} class. * More extensive testing of UserPref saving/reading is done in {@link JsonStaffConnectStorageTest} class. */ - StaffConnect original = getTypicalAddressBook(); + StaffBook original = getTypicalAddressBook(); storageManager.saveAddressBook(original); ReadOnlyStaffConnect retrieved = storageManager.readAddressBook().get(); - assertEquals(original, new StaffConnect(retrieved)); + assertEquals(original, new StaffBook(retrieved)); } @Test diff --git a/src/test/java/staffconnect/testutil/StaffBookBuilder.java b/src/test/java/staffconnect/testutil/StaffBookBuilder.java new file mode 100644 index 00000000000..aabf40ef768 --- /dev/null +++ b/src/test/java/staffconnect/testutil/StaffBookBuilder.java @@ -0,0 +1,34 @@ +package staffconnect.testutil; + +import staffconnect.model.StaffBook; +import staffconnect.model.person.Person; + +/** + * A utility class to help with building StaffBook objects. + * Example usage:
+ * {@code StaffBook ab = new StaffBookBuilder().withPerson("John", "Doe").build();} + */ +public class StaffBookBuilder { + + private StaffBook staffBook; + + public StaffBookBuilder() { + staffBook = new StaffBook(); + } + + public StaffBookBuilder(StaffBook staffBook) { + this.staffBook = staffBook; + } + + /** + * Adds a new {@code Person} to the {@code StaffBook} that we are building. + */ + public StaffBookBuilder withPerson(Person person) { + staffBook.addPerson(person); + return this; + } + + public StaffBook build() { + return staffBook; + } +} diff --git a/src/test/java/staffconnect/testutil/StaffConnectBuilder.java b/src/test/java/staffconnect/testutil/StaffConnectBuilder.java deleted file mode 100644 index f15bc8e047b..00000000000 --- a/src/test/java/staffconnect/testutil/StaffConnectBuilder.java +++ /dev/null @@ -1,34 +0,0 @@ -package staffconnect.testutil; - -import staffconnect.model.StaffConnect; -import staffconnect.model.person.Person; - -/** - * A utility class to help with building StaffConnect objects. - * Example usage:
- * {@code StaffConnect ab = new StaffConnectBuilder().withPerson("John", "Doe").build();} - */ -public class StaffConnectBuilder { - - private StaffConnect staffConnect; - - public StaffConnectBuilder() { - staffConnect = new StaffConnect(); - } - - public StaffConnectBuilder(StaffConnect staffConnect) { - this.staffConnect = staffConnect; - } - - /** - * Adds a new {@code Person} to the {@code StaffConnect} that we are building. - */ - public StaffConnectBuilder withPerson(Person person) { - staffConnect.addPerson(person); - return this; - } - - public StaffConnect build() { - return staffConnect; - } -} diff --git a/src/test/java/staffconnect/testutil/TypicalPersons.java b/src/test/java/staffconnect/testutil/TypicalPersons.java index 24f32b79d56..e61089ba417 100644 --- a/src/test/java/staffconnect/testutil/TypicalPersons.java +++ b/src/test/java/staffconnect/testutil/TypicalPersons.java @@ -15,7 +15,7 @@ import java.util.Arrays; import java.util.List; -import staffconnect.model.StaffConnect; +import staffconnect.model.StaffBook; import staffconnect.model.person.Person; /** @@ -60,10 +60,10 @@ public class TypicalPersons { private TypicalPersons() {} // prevents instantiation /** - * Returns an {@code StaffConnect} with all the typical persons. + * Returns an {@code StaffBook} with all the typical persons. */ - public static StaffConnect getTypicalAddressBook() { - StaffConnect ab = new StaffConnect(); + public static StaffBook getTypicalAddressBook() { + StaffBook ab = new StaffBook(); for (Person person : getTypicalPersons()) { ab.addPerson(person); } From ecdeb95405b326d91802bb42b7d621d77136e850 Mon Sep 17 00:00:00 2001 From: tsulim Date: Mon, 11 Mar 2024 23:03:52 +0800 Subject: [PATCH 11/16] Refactor `ReadOnlyStaffConnect` class to `ReadOnlyStaffBook` class --- src/main/java/staffconnect/MainApp.java | 12 +++++----- src/main/java/staffconnect/logic/Logic.java | 4 ++-- .../java/staffconnect/logic/LogicManager.java | 4 ++-- src/main/java/staffconnect/model/Model.java | 4 ++-- .../java/staffconnect/model/ModelManager.java | 8 +++---- ...affConnect.java => ReadOnlyStaffBook.java} | 4 ++-- .../java/staffconnect/model/StaffBook.java | 6 ++--- .../model/util/SampleDataUtil.java | 10 ++++---- .../storage/JsonSerializableStaffConnect.java | 8 +++---- .../storage/JsonStaffConnectStorage.java | 24 +++++++++---------- .../storage/StaffConnectStorage.java | 18 +++++++------- .../java/staffconnect/storage/Storage.java | 6 ++--- .../staffconnect/storage/StorageManager.java | 14 +++++------ .../staffconnect/logic/LogicManagerTest.java | 4 ++-- .../logic/commands/AddCommandTest.java | 8 +++---- .../staffconnect/model/StaffBookTest.java | 8 +++---- .../storage/JsonStaffConnectStorageTest.java | 18 +++++++------- .../storage/StorageManagerTest.java | 4 ++-- 18 files changed, 82 insertions(+), 82 deletions(-) rename src/main/java/staffconnect/model/{ReadOnlyStaffConnect.java => ReadOnlyStaffBook.java} (78%) diff --git a/src/main/java/staffconnect/MainApp.java b/src/main/java/staffconnect/MainApp.java index 018d28bd835..370d1b58b7c 100644 --- a/src/main/java/staffconnect/MainApp.java +++ b/src/main/java/staffconnect/MainApp.java @@ -17,7 +17,7 @@ import staffconnect.logic.LogicManager; import staffconnect.model.Model; import staffconnect.model.ModelManager; -import staffconnect.model.ReadOnlyStaffConnect; +import staffconnect.model.ReadOnlyStaffBook; import staffconnect.model.ReadOnlyUserPrefs; import staffconnect.model.StaffBook; import staffconnect.model.UserPrefs; @@ -75,15 +75,15 @@ public void init() throws Exception { private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) { logger.info("Using data file : " + storage.getAddressBookFilePath()); - Optional addressBookOptional; - ReadOnlyStaffConnect initialData; + Optional staffBookOptional; + ReadOnlyStaffBook initialData; try { - addressBookOptional = storage.readAddressBook(); - if (!addressBookOptional.isPresent()) { + staffBookOptional = storage.readAddressBook(); + if (!staffBookOptional.isPresent()) { logger.info("Creating a new data file " + storage.getAddressBookFilePath() + " populated with a sample StaffBook."); } - initialData = addressBookOptional.orElseGet(SampleDataUtil::getSampleAddressBook); + initialData = staffBookOptional.orElseGet(SampleDataUtil::getSampleAddressBook); } catch (DataLoadingException e) { logger.warning("Data file at " + storage.getAddressBookFilePath() + " could not be loaded." + " Will be starting with an empty StaffBook."); diff --git a/src/main/java/staffconnect/logic/Logic.java b/src/main/java/staffconnect/logic/Logic.java index dbcaaa8186a..9ee2cf21abe 100644 --- a/src/main/java/staffconnect/logic/Logic.java +++ b/src/main/java/staffconnect/logic/Logic.java @@ -7,7 +7,7 @@ import staffconnect.logic.commands.CommandResult; import staffconnect.logic.commands.exceptions.CommandException; import staffconnect.logic.parser.exceptions.ParseException; -import staffconnect.model.ReadOnlyStaffConnect; +import staffconnect.model.ReadOnlyStaffBook; import staffconnect.model.person.Person; /** @@ -28,7 +28,7 @@ public interface Logic { * * @see staffconnect.model.Model#getAddressBook() */ - ReadOnlyStaffConnect getAddressBook(); + ReadOnlyStaffBook getAddressBook(); /** Returns an unmodifiable view of the filtered list of persons */ ObservableList getFilteredPersonList(); diff --git a/src/main/java/staffconnect/logic/LogicManager.java b/src/main/java/staffconnect/logic/LogicManager.java index 9e6dc4dc338..04e6d34f9db 100644 --- a/src/main/java/staffconnect/logic/LogicManager.java +++ b/src/main/java/staffconnect/logic/LogicManager.java @@ -14,7 +14,7 @@ import staffconnect.logic.parser.StaffConnectParser; import staffconnect.logic.parser.exceptions.ParseException; import staffconnect.model.Model; -import staffconnect.model.ReadOnlyStaffConnect; +import staffconnect.model.ReadOnlyStaffBook; import staffconnect.model.person.Person; import staffconnect.storage.Storage; @@ -62,7 +62,7 @@ public CommandResult execute(String commandText) throws CommandException, ParseE } @Override - public ReadOnlyStaffConnect getAddressBook() { + public ReadOnlyStaffBook getAddressBook() { return model.getAddressBook(); } diff --git a/src/main/java/staffconnect/model/Model.java b/src/main/java/staffconnect/model/Model.java index 802625deb86..fa3c4042400 100644 --- a/src/main/java/staffconnect/model/Model.java +++ b/src/main/java/staffconnect/model/Model.java @@ -47,10 +47,10 @@ public interface Model { /** * Replaces staff book data with the data in {@code staffBook}. */ - void setAddressBook(ReadOnlyStaffConnect staffBook); + void setAddressBook(ReadOnlyStaffBook staffBook); /** Returns the StaffBook */ - ReadOnlyStaffConnect getAddressBook(); + ReadOnlyStaffBook getAddressBook(); /** * Returns true if a person with the same identity as {@code person} exists in the staff book. diff --git a/src/main/java/staffconnect/model/ModelManager.java b/src/main/java/staffconnect/model/ModelManager.java index 2ca36ef2121..4b7c876e7bf 100644 --- a/src/main/java/staffconnect/model/ModelManager.java +++ b/src/main/java/staffconnect/model/ModelManager.java @@ -26,7 +26,7 @@ public class ModelManager implements Model { /** * Initializes a ModelManager with the given staffBook and userPrefs. */ - public ModelManager(ReadOnlyStaffConnect staffBook, ReadOnlyUserPrefs userPrefs) { + public ModelManager(ReadOnlyStaffBook staffBook, ReadOnlyUserPrefs userPrefs) { requireAllNonNull(staffBook, userPrefs); logger.fine("Initializing with staff book: " + staffBook + " and user prefs " + userPrefs); @@ -78,12 +78,12 @@ public void setAddressBookFilePath(Path addressBookFilePath) { //=========== StaffBook ================================================================================ @Override - public void setAddressBook(ReadOnlyStaffConnect staffBook) { + public void setAddressBook(ReadOnlyStaffBook staffBook) { this.staffBook.resetData(staffBook); } @Override - public ReadOnlyStaffConnect getAddressBook() { + public ReadOnlyStaffBook getAddressBook() { return staffBook; } @@ -115,7 +115,7 @@ public void setPerson(Person target, Person editedPerson) { /** * Returns an unmodifiable view of the list of {@code Person} backed by the internal list of - * {@code versionedAddressBook} + * {@code versionedStaffBook} */ @Override public ObservableList getFilteredPersonList() { diff --git a/src/main/java/staffconnect/model/ReadOnlyStaffConnect.java b/src/main/java/staffconnect/model/ReadOnlyStaffBook.java similarity index 78% rename from src/main/java/staffconnect/model/ReadOnlyStaffConnect.java rename to src/main/java/staffconnect/model/ReadOnlyStaffBook.java index 41d1bd89323..f63405e05ab 100644 --- a/src/main/java/staffconnect/model/ReadOnlyStaffConnect.java +++ b/src/main/java/staffconnect/model/ReadOnlyStaffBook.java @@ -4,9 +4,9 @@ import staffconnect.model.person.Person; /** - * Unmodifiable view of an address book + * Unmodifiable view of a staff book */ -public interface ReadOnlyStaffConnect { +public interface ReadOnlyStaffBook { /** * Returns an unmodifiable view of the persons list. diff --git a/src/main/java/staffconnect/model/StaffBook.java b/src/main/java/staffconnect/model/StaffBook.java index 9e4a784d424..649abbd6d1c 100644 --- a/src/main/java/staffconnect/model/StaffBook.java +++ b/src/main/java/staffconnect/model/StaffBook.java @@ -13,7 +13,7 @@ * Wraps all data at the fundamental level * Duplicates are not allowed (by .isSamePerson comparison) */ -public class StaffBook implements ReadOnlyStaffConnect { +public class StaffBook implements ReadOnlyStaffBook { private final UniquePersonList persons; @@ -33,7 +33,7 @@ public StaffBook() {} /** * Creates a StaffBook using the Persons in the {@code toBeCopied} */ - public StaffBook(ReadOnlyStaffConnect toBeCopied) { + public StaffBook(ReadOnlyStaffBook toBeCopied) { this(); resetData(toBeCopied); } @@ -51,7 +51,7 @@ public void setPersons(List persons) { /** * Resets the existing data of this {@code StaffBook} with {@code newData}. */ - public void resetData(ReadOnlyStaffConnect newData) { + public void resetData(ReadOnlyStaffBook newData) { requireNonNull(newData); setPersons(newData.getPersonList()); diff --git a/src/main/java/staffconnect/model/util/SampleDataUtil.java b/src/main/java/staffconnect/model/util/SampleDataUtil.java index 85e595d32fc..ed36b539ceb 100644 --- a/src/main/java/staffconnect/model/util/SampleDataUtil.java +++ b/src/main/java/staffconnect/model/util/SampleDataUtil.java @@ -4,7 +4,7 @@ import java.util.Set; import java.util.stream.Collectors; -import staffconnect.model.ReadOnlyStaffConnect; +import staffconnect.model.ReadOnlyStaffBook; import staffconnect.model.StaffBook; import staffconnect.model.person.Address; import staffconnect.model.person.Email; @@ -40,12 +40,12 @@ public static Person[] getSamplePersons() { }; } - public static ReadOnlyStaffConnect getSampleAddressBook() { - StaffBook sampleSc = new StaffBook(); + public static ReadOnlyStaffBook getSampleAddressBook() { + StaffBook sampleSb = new StaffBook(); for (Person samplePerson : getSamplePersons()) { - sampleSc.addPerson(samplePerson); + sampleSb.addPerson(samplePerson); } - return sampleSc; + return sampleSb; } /** diff --git a/src/main/java/staffconnect/storage/JsonSerializableStaffConnect.java b/src/main/java/staffconnect/storage/JsonSerializableStaffConnect.java index 2504af901b6..8757f16c167 100644 --- a/src/main/java/staffconnect/storage/JsonSerializableStaffConnect.java +++ b/src/main/java/staffconnect/storage/JsonSerializableStaffConnect.java @@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonRootName; import staffconnect.commons.exceptions.IllegalValueException; -import staffconnect.model.ReadOnlyStaffConnect; +import staffconnect.model.ReadOnlyStaffBook; import staffconnect.model.StaffBook; import staffconnect.model.person.Person; @@ -32,16 +32,16 @@ public JsonSerializableStaffConnect(@JsonProperty("persons") List readAddressBook() throws DataLoadingException { + public Optional readAddressBook() throws DataLoadingException { return readAddressBook(filePath); } @@ -42,17 +42,17 @@ public Optional readAddressBook() throws DataLoadingExcept * @param filePath location of the data. Cannot be null. * @throws DataLoadingException if loading the data from storage failed. */ - public Optional readAddressBook(Path filePath) throws DataLoadingException { + public Optional readAddressBook(Path filePath) throws DataLoadingException { requireNonNull(filePath); - Optional jsonAddressBook = JsonUtil.readJsonFile( + Optional jsonStaffBook = JsonUtil.readJsonFile( filePath, JsonSerializableStaffConnect.class); - if (!jsonAddressBook.isPresent()) { + if (!jsonStaffBook.isPresent()) { return Optional.empty(); } try { - return Optional.of(jsonAddressBook.get().toModelType()); + return Optional.of(jsonStaffBook.get().toModelType()); } catch (IllegalValueException ive) { logger.info("Illegal values found in " + filePath + ": " + ive.getMessage()); throw new DataLoadingException(ive); @@ -60,21 +60,21 @@ public Optional readAddressBook(Path filePath) throws Data } @Override - public void saveAddressBook(ReadOnlyStaffConnect addressBook) throws IOException { - saveAddressBook(addressBook, filePath); + public void saveAddressBook(ReadOnlyStaffBook staffBook) throws IOException { + saveAddressBook(staffBook, filePath); } /** - * Similar to {@link #saveAddressBook(ReadOnlyStaffConnect)}. + * Similar to {@link #saveAddressBook(ReadOnlyStaffBook)}. * * @param filePath location of the data. Cannot be null. */ - public void saveAddressBook(ReadOnlyStaffConnect addressBook, Path filePath) throws IOException { - requireNonNull(addressBook); + public void saveAddressBook(ReadOnlyStaffBook staffBook, Path filePath) throws IOException { + requireNonNull(staffBook); requireNonNull(filePath); FileUtil.createIfMissing(filePath); - JsonUtil.saveJsonFile(new JsonSerializableStaffConnect(addressBook), filePath); + JsonUtil.saveJsonFile(new JsonSerializableStaffConnect(staffBook), filePath); } } diff --git a/src/main/java/staffconnect/storage/StaffConnectStorage.java b/src/main/java/staffconnect/storage/StaffConnectStorage.java index 4f102d11dbc..008adedd3f5 100644 --- a/src/main/java/staffconnect/storage/StaffConnectStorage.java +++ b/src/main/java/staffconnect/storage/StaffConnectStorage.java @@ -5,7 +5,7 @@ import java.util.Optional; import staffconnect.commons.exceptions.DataLoadingException; -import staffconnect.model.ReadOnlyStaffConnect; +import staffconnect.model.ReadOnlyStaffBook; import staffconnect.model.StaffBook; /** @@ -19,28 +19,28 @@ public interface StaffConnectStorage { Path getAddressBookFilePath(); /** - * Returns StaffBook data as a {@link ReadOnlyStaffConnect}. + * Returns StaffBook data as a {@link ReadOnlyStaffBook}. * Returns {@code Optional.empty()} if storage file is not found. * * @throws DataLoadingException if loading the data from storage failed. */ - Optional readAddressBook() throws DataLoadingException; + Optional readAddressBook() throws DataLoadingException; /** * @see #getAddressBookFilePath() */ - Optional readAddressBook(Path filePath) throws DataLoadingException; + Optional readAddressBook(Path filePath) throws DataLoadingException; /** - * Saves the given {@link ReadOnlyStaffConnect} to the storage. - * @param addressBook cannot be null. + * Saves the given {@link ReadOnlyStaffBook} to the storage. + * @param staffBook cannot be null. * @throws IOException if there was any problem writing to the file. */ - void saveAddressBook(ReadOnlyStaffConnect addressBook) throws IOException; + void saveAddressBook(ReadOnlyStaffBook staffBook) throws IOException; /** - * @see #saveAddressBook(ReadOnlyStaffConnect) + * @see #saveAddressBook(ReadOnlyStaffBook) */ - void saveAddressBook(ReadOnlyStaffConnect addressBook, Path filePath) throws IOException; + void saveAddressBook(ReadOnlyStaffBook staffBook, Path filePath) throws IOException; } diff --git a/src/main/java/staffconnect/storage/Storage.java b/src/main/java/staffconnect/storage/Storage.java index b1f77cadccc..048dd105c21 100644 --- a/src/main/java/staffconnect/storage/Storage.java +++ b/src/main/java/staffconnect/storage/Storage.java @@ -5,7 +5,7 @@ import java.util.Optional; import staffconnect.commons.exceptions.DataLoadingException; -import staffconnect.model.ReadOnlyStaffConnect; +import staffconnect.model.ReadOnlyStaffBook; import staffconnect.model.ReadOnlyUserPrefs; import staffconnect.model.UserPrefs; @@ -24,9 +24,9 @@ public interface Storage extends StaffConnectStorage, UserPrefsStorage { Path getAddressBookFilePath(); @Override - Optional readAddressBook() throws DataLoadingException; + Optional readAddressBook() throws DataLoadingException; @Override - void saveAddressBook(ReadOnlyStaffConnect addressBook) throws IOException; + void saveAddressBook(ReadOnlyStaffBook staffBook) throws IOException; } diff --git a/src/main/java/staffconnect/storage/StorageManager.java b/src/main/java/staffconnect/storage/StorageManager.java index 955049d9d19..94f3cd2b4ca 100644 --- a/src/main/java/staffconnect/storage/StorageManager.java +++ b/src/main/java/staffconnect/storage/StorageManager.java @@ -7,7 +7,7 @@ import staffconnect.commons.core.LogsCenter; import staffconnect.commons.exceptions.DataLoadingException; -import staffconnect.model.ReadOnlyStaffConnect; +import staffconnect.model.ReadOnlyStaffBook; import staffconnect.model.ReadOnlyUserPrefs; import staffconnect.model.UserPrefs; @@ -54,25 +54,25 @@ public Path getAddressBookFilePath() { } @Override - public Optional readAddressBook() throws DataLoadingException { + public Optional readAddressBook() throws DataLoadingException { return readAddressBook(staffConnectStorage.getAddressBookFilePath()); } @Override - public Optional readAddressBook(Path filePath) throws DataLoadingException { + public Optional readAddressBook(Path filePath) throws DataLoadingException { logger.fine("Attempting to read data from file: " + filePath); return staffConnectStorage.readAddressBook(filePath); } @Override - public void saveAddressBook(ReadOnlyStaffConnect addressBook) throws IOException { - saveAddressBook(addressBook, staffConnectStorage.getAddressBookFilePath()); + public void saveAddressBook(ReadOnlyStaffBook staffBook) throws IOException { + saveAddressBook(staffBook, staffConnectStorage.getAddressBookFilePath()); } @Override - public void saveAddressBook(ReadOnlyStaffConnect addressBook, Path filePath) throws IOException { + public void saveAddressBook(ReadOnlyStaffBook staffBook, Path filePath) throws IOException { logger.fine("Attempting to write to data file: " + filePath); - staffConnectStorage.saveAddressBook(addressBook, filePath); + staffConnectStorage.saveAddressBook(staffBook, filePath); } } diff --git a/src/test/java/staffconnect/logic/LogicManagerTest.java b/src/test/java/staffconnect/logic/LogicManagerTest.java index dc6290e5400..e8313d18543 100644 --- a/src/test/java/staffconnect/logic/LogicManagerTest.java +++ b/src/test/java/staffconnect/logic/LogicManagerTest.java @@ -25,7 +25,7 @@ import staffconnect.logic.parser.exceptions.ParseException; import staffconnect.model.Model; import staffconnect.model.ModelManager; -import staffconnect.model.ReadOnlyStaffConnect; +import staffconnect.model.ReadOnlyStaffBook; import staffconnect.model.UserPrefs; import staffconnect.model.person.Person; import staffconnect.storage.JsonStaffConnectStorage; @@ -152,7 +152,7 @@ private void assertCommandFailureForExceptionFromStorage(IOException e, String e // Inject LogicManager with an StaffConnectStorage that throws the IOException e when saving JsonStaffConnectStorage addressBookStorage = new JsonStaffConnectStorage(prefPath) { @Override - public void saveAddressBook(ReadOnlyStaffConnect staffConnect, Path filePath) + public void saveAddressBook(ReadOnlyStaffBook staffBook, Path filePath) throws IOException { throw e; } diff --git a/src/test/java/staffconnect/logic/commands/AddCommandTest.java b/src/test/java/staffconnect/logic/commands/AddCommandTest.java index a6dda6eda3a..99d04fba1f3 100644 --- a/src/test/java/staffconnect/logic/commands/AddCommandTest.java +++ b/src/test/java/staffconnect/logic/commands/AddCommandTest.java @@ -19,7 +19,7 @@ import staffconnect.logic.Messages; import staffconnect.logic.commands.exceptions.CommandException; import staffconnect.model.Model; -import staffconnect.model.ReadOnlyStaffConnect; +import staffconnect.model.ReadOnlyStaffBook; import staffconnect.model.ReadOnlyUserPrefs; import staffconnect.model.StaffBook; import staffconnect.model.person.Person; @@ -124,12 +124,12 @@ public void addPerson(Person person) { } @Override - public void setAddressBook(ReadOnlyStaffConnect newData) { + public void setAddressBook(ReadOnlyStaffBook newData) { throw new AssertionError("This method should not be called."); } @Override - public ReadOnlyStaffConnect getAddressBook() { + public ReadOnlyStaffBook getAddressBook() { throw new AssertionError("This method should not be called."); } @@ -196,7 +196,7 @@ public void addPerson(Person person) { } @Override - public ReadOnlyStaffConnect getAddressBook() { + public ReadOnlyStaffBook getAddressBook() { return new StaffBook(); } } diff --git a/src/test/java/staffconnect/model/StaffBookTest.java b/src/test/java/staffconnect/model/StaffBookTest.java index 9532db19330..ddbb66883a1 100644 --- a/src/test/java/staffconnect/model/StaffBookTest.java +++ b/src/test/java/staffconnect/model/StaffBookTest.java @@ -49,7 +49,7 @@ public void resetData_withDuplicatePersons_throwsDuplicatePersonException() { Person editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) .build(); List newPersons = Arrays.asList(ALICE, editedAlice); - StaffConnectStub newData = new StaffConnectStub(newPersons); + StaffBookStub newData = new StaffBookStub(newPersons); assertThrows(DuplicatePersonException.class, () -> staffBook.resetData(newData)); } @@ -90,12 +90,12 @@ public void toStringMethod() { } /** - * A stub ReadOnlyStaffConnect whose persons list can violate interface constraints. + * A stub ReadOnlyStaffBook whose persons list can violate interface constraints. */ - private static class StaffConnectStub implements ReadOnlyStaffConnect { + private static class StaffBookStub implements ReadOnlyStaffBook { private final ObservableList persons = FXCollections.observableArrayList(); - StaffConnectStub(Collection persons) { + StaffBookStub(Collection persons) { this.persons.setAll(persons); } diff --git a/src/test/java/staffconnect/storage/JsonStaffConnectStorageTest.java b/src/test/java/staffconnect/storage/JsonStaffConnectStorageTest.java index 8cca2b54386..7995dd1dfc2 100644 --- a/src/test/java/staffconnect/storage/JsonStaffConnectStorageTest.java +++ b/src/test/java/staffconnect/storage/JsonStaffConnectStorageTest.java @@ -16,7 +16,7 @@ import org.junit.jupiter.api.io.TempDir; import staffconnect.commons.exceptions.DataLoadingException; -import staffconnect.model.ReadOnlyStaffConnect; +import staffconnect.model.ReadOnlyStaffBook; import staffconnect.model.StaffBook; public class JsonStaffConnectStorageTest { @@ -30,7 +30,7 @@ public void readAddressBook_nullFilePath_throwsNullPointerException() { assertThrows(NullPointerException.class, () -> readAddressBook(null)); } - private java.util.Optional readAddressBook(String filePath) throws Exception { + private java.util.Optional readAddressBook(String filePath) throws Exception { return new JsonStaffConnectStorage(Paths.get(filePath)).readAddressBook(addToTestDataPathIfNotNull(filePath)); } @@ -68,7 +68,7 @@ public void readAndSaveAddressBook_allInOrder_success() throws Exception { // Save in new file and read back jsonAddressBookStorage.saveAddressBook(original, filePath); - ReadOnlyStaffConnect readBack = jsonAddressBookStorage.readAddressBook(filePath).get(); + ReadOnlyStaffBook readBack = jsonAddressBookStorage.readAddressBook(filePath).get(); assertEquals(original, new StaffBook(readBack)); // Modify data, overwrite exiting file, and read back @@ -88,23 +88,23 @@ public void readAndSaveAddressBook_allInOrder_success() throws Exception { @Test public void saveAddressBook_nullAddressBook_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> saveAddressBook(null, "SomeFile.json")); + assertThrows(NullPointerException.class, () -> saveStaffBook(null, "SomeFile.json")); } /** - * Saves {@code addressBook} at the specified {@code filePath}. + * Saves {@code staffBook} at the specified {@code filePath}. */ - private void saveAddressBook(ReadOnlyStaffConnect staffConnect, String filePath) { + private void saveStaffBook(ReadOnlyStaffBook staffBook, String filePath) { try { new JsonStaffConnectStorage(Paths.get(filePath)) - .saveAddressBook(staffConnect, addToTestDataPathIfNotNull(filePath)); + .saveAddressBook(staffBook, 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 StaffBook(), null)); + public void saveStaffBook_nullFilePath_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> saveStaffBook(new StaffBook(), null)); } } diff --git a/src/test/java/staffconnect/storage/StorageManagerTest.java b/src/test/java/staffconnect/storage/StorageManagerTest.java index 0ebd766bc60..073c84f526e 100644 --- a/src/test/java/staffconnect/storage/StorageManagerTest.java +++ b/src/test/java/staffconnect/storage/StorageManagerTest.java @@ -11,7 +11,7 @@ import org.junit.jupiter.api.io.TempDir; import staffconnect.commons.core.GuiSettings; -import staffconnect.model.ReadOnlyStaffConnect; +import staffconnect.model.ReadOnlyStaffBook; import staffconnect.model.StaffBook; import staffconnect.model.UserPrefs; @@ -56,7 +56,7 @@ public void addressBookReadSave() throws Exception { */ StaffBook original = getTypicalAddressBook(); storageManager.saveAddressBook(original); - ReadOnlyStaffConnect retrieved = storageManager.readAddressBook().get(); + ReadOnlyStaffBook retrieved = storageManager.readAddressBook().get(); assertEquals(original, new StaffBook(retrieved)); } From 68305fd6887807ef8a20106e1101aed459979f32 Mon Sep 17 00:00:00 2001 From: tsulim Date: Mon, 11 Mar 2024 23:09:56 +0800 Subject: [PATCH 12/16] Refactor `StaffConnectStorage` class to `StaffBookStorage` class --- src/main/java/staffconnect/MainApp.java | 6 +++--- .../storage/JsonStaffConnectStorage.java | 2 +- ...nnectStorage.java => StaffBookStorage.java} | 2 +- .../java/staffconnect/storage/Storage.java | 2 +- .../staffconnect/storage/StorageManager.java | 18 +++++++++--------- .../staffconnect/logic/LogicManagerTest.java | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) rename src/main/java/staffconnect/storage/{StaffConnectStorage.java => StaffBookStorage.java} (97%) diff --git a/src/main/java/staffconnect/MainApp.java b/src/main/java/staffconnect/MainApp.java index 370d1b58b7c..f8170ca2059 100644 --- a/src/main/java/staffconnect/MainApp.java +++ b/src/main/java/staffconnect/MainApp.java @@ -24,7 +24,7 @@ import staffconnect.model.util.SampleDataUtil; import staffconnect.storage.JsonStaffConnectStorage; import staffconnect.storage.JsonUserPrefsStorage; -import staffconnect.storage.StaffConnectStorage; +import staffconnect.storage.StaffBookStorage; import staffconnect.storage.Storage; import staffconnect.storage.StorageManager; import staffconnect.storage.UserPrefsStorage; @@ -57,8 +57,8 @@ public void init() throws Exception { UserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(config.getUserPrefsFilePath()); UserPrefs userPrefs = initPrefs(userPrefsStorage); - StaffConnectStorage staffConnectStorage = new JsonStaffConnectStorage(userPrefs.getAddressBookFilePath()); - storage = new StorageManager(staffConnectStorage, userPrefsStorage); + StaffBookStorage staffBookStorage = new JsonStaffConnectStorage(userPrefs.getAddressBookFilePath()); + storage = new StorageManager(staffBookStorage, userPrefsStorage); model = initModelManager(storage, userPrefs); diff --git a/src/main/java/staffconnect/storage/JsonStaffConnectStorage.java b/src/main/java/staffconnect/storage/JsonStaffConnectStorage.java index 89f58bca295..19076013d8d 100644 --- a/src/main/java/staffconnect/storage/JsonStaffConnectStorage.java +++ b/src/main/java/staffconnect/storage/JsonStaffConnectStorage.java @@ -17,7 +17,7 @@ /** * A class to access StaffBook data stored as a json file on the hard disk. */ -public class JsonStaffConnectStorage implements StaffConnectStorage { +public class JsonStaffConnectStorage implements StaffBookStorage { private static final Logger logger = LogsCenter.getLogger(JsonStaffConnectStorage.class); diff --git a/src/main/java/staffconnect/storage/StaffConnectStorage.java b/src/main/java/staffconnect/storage/StaffBookStorage.java similarity index 97% rename from src/main/java/staffconnect/storage/StaffConnectStorage.java rename to src/main/java/staffconnect/storage/StaffBookStorage.java index 008adedd3f5..3f5accbebfa 100644 --- a/src/main/java/staffconnect/storage/StaffConnectStorage.java +++ b/src/main/java/staffconnect/storage/StaffBookStorage.java @@ -11,7 +11,7 @@ /** * Represents a storage for {@link StaffBook}. */ -public interface StaffConnectStorage { +public interface StaffBookStorage { /** * Returns the file path of the data file. diff --git a/src/main/java/staffconnect/storage/Storage.java b/src/main/java/staffconnect/storage/Storage.java index 048dd105c21..670ac6dbd28 100644 --- a/src/main/java/staffconnect/storage/Storage.java +++ b/src/main/java/staffconnect/storage/Storage.java @@ -12,7 +12,7 @@ /** * API of the Storage component */ -public interface Storage extends StaffConnectStorage, UserPrefsStorage { +public interface Storage extends StaffBookStorage, UserPrefsStorage { @Override Optional readUserPrefs() throws DataLoadingException; diff --git a/src/main/java/staffconnect/storage/StorageManager.java b/src/main/java/staffconnect/storage/StorageManager.java index 94f3cd2b4ca..3f5552860ca 100644 --- a/src/main/java/staffconnect/storage/StorageManager.java +++ b/src/main/java/staffconnect/storage/StorageManager.java @@ -17,14 +17,14 @@ public class StorageManager implements Storage { private static final Logger logger = LogsCenter.getLogger(StorageManager.class); - private StaffConnectStorage staffConnectStorage; + private StaffBookStorage staffBookStorage; private UserPrefsStorage userPrefsStorage; /** - * Creates a {@code StorageManager} with the given {@code StaffConnectStorage} and {@code UserPrefStorage}. + * Creates a {@code StorageManager} with the given {@code StaffBookStorage} and {@code UserPrefStorage}. */ - public StorageManager(StaffConnectStorage staffConnectStorage, UserPrefsStorage userPrefsStorage) { - this.staffConnectStorage = staffConnectStorage; + public StorageManager(StaffBookStorage staffBookStorage, UserPrefsStorage userPrefsStorage) { + this.staffBookStorage = staffBookStorage; this.userPrefsStorage = userPrefsStorage; } @@ -50,29 +50,29 @@ public void saveUserPrefs(ReadOnlyUserPrefs userPrefs) throws IOException { @Override public Path getAddressBookFilePath() { - return staffConnectStorage.getAddressBookFilePath(); + return staffBookStorage.getAddressBookFilePath(); } @Override public Optional readAddressBook() throws DataLoadingException { - return readAddressBook(staffConnectStorage.getAddressBookFilePath()); + return readAddressBook(staffBookStorage.getAddressBookFilePath()); } @Override public Optional readAddressBook(Path filePath) throws DataLoadingException { logger.fine("Attempting to read data from file: " + filePath); - return staffConnectStorage.readAddressBook(filePath); + return staffBookStorage.readAddressBook(filePath); } @Override public void saveAddressBook(ReadOnlyStaffBook staffBook) throws IOException { - saveAddressBook(staffBook, staffConnectStorage.getAddressBookFilePath()); + saveAddressBook(staffBook, staffBookStorage.getAddressBookFilePath()); } @Override public void saveAddressBook(ReadOnlyStaffBook staffBook, Path filePath) throws IOException { logger.fine("Attempting to write to data file: " + filePath); - staffConnectStorage.saveAddressBook(staffBook, filePath); + staffBookStorage.saveAddressBook(staffBook, filePath); } } diff --git a/src/test/java/staffconnect/logic/LogicManagerTest.java b/src/test/java/staffconnect/logic/LogicManagerTest.java index e8313d18543..e61441e3bca 100644 --- a/src/test/java/staffconnect/logic/LogicManagerTest.java +++ b/src/test/java/staffconnect/logic/LogicManagerTest.java @@ -149,7 +149,7 @@ private void assertCommandFailure(String inputCommand, Class Date: Mon, 11 Mar 2024 23:44:58 +0800 Subject: [PATCH 13/16] Refactor `JsonStaffConnectStorage` class to `JsonStaffBookStorage` class --- src/main/java/staffconnect/MainApp.java | 4 ++-- ...ffConnectStorage.java => JsonStaffBookStorage.java} | 6 +++--- src/test/java/staffconnect/logic/LogicManagerTest.java | 10 +++++----- ...tStorageTest.java => JsonStaffBookStorageTest.java} | 10 +++++----- .../java/staffconnect/storage/StorageManagerTest.java | 6 +++--- 5 files changed, 18 insertions(+), 18 deletions(-) rename src/main/java/staffconnect/storage/{JsonStaffConnectStorage.java => JsonStaffBookStorage.java} (94%) rename src/test/java/staffconnect/storage/{JsonStaffConnectStorageTest.java => JsonStaffBookStorageTest.java} (91%) diff --git a/src/main/java/staffconnect/MainApp.java b/src/main/java/staffconnect/MainApp.java index f8170ca2059..717c835f359 100644 --- a/src/main/java/staffconnect/MainApp.java +++ b/src/main/java/staffconnect/MainApp.java @@ -22,7 +22,7 @@ import staffconnect.model.StaffBook; import staffconnect.model.UserPrefs; import staffconnect.model.util.SampleDataUtil; -import staffconnect.storage.JsonStaffConnectStorage; +import staffconnect.storage.JsonStaffBookStorage; import staffconnect.storage.JsonUserPrefsStorage; import staffconnect.storage.StaffBookStorage; import staffconnect.storage.Storage; @@ -57,7 +57,7 @@ public void init() throws Exception { UserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(config.getUserPrefsFilePath()); UserPrefs userPrefs = initPrefs(userPrefsStorage); - StaffBookStorage staffBookStorage = new JsonStaffConnectStorage(userPrefs.getAddressBookFilePath()); + StaffBookStorage staffBookStorage = new JsonStaffBookStorage(userPrefs.getAddressBookFilePath()); storage = new StorageManager(staffBookStorage, userPrefsStorage); model = initModelManager(storage, userPrefs); diff --git a/src/main/java/staffconnect/storage/JsonStaffConnectStorage.java b/src/main/java/staffconnect/storage/JsonStaffBookStorage.java similarity index 94% rename from src/main/java/staffconnect/storage/JsonStaffConnectStorage.java rename to src/main/java/staffconnect/storage/JsonStaffBookStorage.java index 19076013d8d..ff29bac6637 100644 --- a/src/main/java/staffconnect/storage/JsonStaffConnectStorage.java +++ b/src/main/java/staffconnect/storage/JsonStaffBookStorage.java @@ -17,13 +17,13 @@ /** * A class to access StaffBook data stored as a json file on the hard disk. */ -public class JsonStaffConnectStorage implements StaffBookStorage { +public class JsonStaffBookStorage implements StaffBookStorage { - private static final Logger logger = LogsCenter.getLogger(JsonStaffConnectStorage.class); + private static final Logger logger = LogsCenter.getLogger(JsonStaffBookStorage.class); private Path filePath; - public JsonStaffConnectStorage(Path filePath) { + public JsonStaffBookStorage(Path filePath) { this.filePath = filePath; } diff --git a/src/test/java/staffconnect/logic/LogicManagerTest.java b/src/test/java/staffconnect/logic/LogicManagerTest.java index e61441e3bca..bc6c3e61f44 100644 --- a/src/test/java/staffconnect/logic/LogicManagerTest.java +++ b/src/test/java/staffconnect/logic/LogicManagerTest.java @@ -28,7 +28,7 @@ import staffconnect.model.ReadOnlyStaffBook; import staffconnect.model.UserPrefs; import staffconnect.model.person.Person; -import staffconnect.storage.JsonStaffConnectStorage; +import staffconnect.storage.JsonStaffBookStorage; import staffconnect.storage.JsonUserPrefsStorage; import staffconnect.storage.StorageManager; import staffconnect.testutil.PersonBuilder; @@ -45,8 +45,8 @@ public class LogicManagerTest { @BeforeEach public void setUp() { - JsonStaffConnectStorage addressBookStorage = - new JsonStaffConnectStorage(temporaryFolder.resolve("addressBook.json")); + JsonStaffBookStorage addressBookStorage = + new JsonStaffBookStorage(temporaryFolder.resolve("staffBook.json")); JsonUserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(temporaryFolder.resolve("userPrefs.json")); StorageManager storage = new StorageManager(addressBookStorage, userPrefsStorage); logic = new LogicManager(model, storage); @@ -150,7 +150,7 @@ private void assertCommandFailureForExceptionFromStorage(IOException e, String e Path prefPath = temporaryFolder.resolve("ExceptionUserPrefs.json"); // Inject LogicManager with a StaffBookStorage that throws the IOException e when saving - JsonStaffConnectStorage addressBookStorage = new JsonStaffConnectStorage(prefPath) { + JsonStaffBookStorage staffBookStorage = new JsonStaffBookStorage(prefPath) { @Override public void saveAddressBook(ReadOnlyStaffBook staffBook, Path filePath) throws IOException { @@ -160,7 +160,7 @@ public void saveAddressBook(ReadOnlyStaffBook staffBook, Path filePath) JsonUserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(temporaryFolder.resolve("ExceptionUserPrefs.json")); - StorageManager storage = new StorageManager(addressBookStorage, userPrefsStorage); + StorageManager storage = new StorageManager(staffBookStorage, userPrefsStorage); logic = new LogicManager(model, storage); diff --git a/src/test/java/staffconnect/storage/JsonStaffConnectStorageTest.java b/src/test/java/staffconnect/storage/JsonStaffBookStorageTest.java similarity index 91% rename from src/test/java/staffconnect/storage/JsonStaffConnectStorageTest.java rename to src/test/java/staffconnect/storage/JsonStaffBookStorageTest.java index 7995dd1dfc2..bd44a6d90e5 100644 --- a/src/test/java/staffconnect/storage/JsonStaffConnectStorageTest.java +++ b/src/test/java/staffconnect/storage/JsonStaffBookStorageTest.java @@ -19,8 +19,8 @@ import staffconnect.model.ReadOnlyStaffBook; import staffconnect.model.StaffBook; -public class JsonStaffConnectStorageTest { - private static final Path TEST_DATA_FOLDER = Paths.get("src", "test", "data", "JsonStaffConnectStorageTest"); +public class JsonStaffBookStorageTest { + private static final Path TEST_DATA_FOLDER = Paths.get("src", "test", "data", "JsonStaffBookStorageTest"); @TempDir public Path testFolder; @@ -31,7 +31,7 @@ public void readAddressBook_nullFilePath_throwsNullPointerException() { } private java.util.Optional readAddressBook(String filePath) throws Exception { - return new JsonStaffConnectStorage(Paths.get(filePath)).readAddressBook(addToTestDataPathIfNotNull(filePath)); + return new JsonStaffBookStorage(Paths.get(filePath)).readAddressBook(addToTestDataPathIfNotNull(filePath)); } private Path addToTestDataPathIfNotNull(String prefsFileInTestDataFolder) { @@ -64,7 +64,7 @@ public void readAddressBook_invalidAndValidPersonAddressBook_throwDataLoadingExc public void readAndSaveAddressBook_allInOrder_success() throws Exception { Path filePath = testFolder.resolve("TempAddressBook.json"); StaffBook original = getTypicalAddressBook(); - JsonStaffConnectStorage jsonAddressBookStorage = new JsonStaffConnectStorage(filePath); + JsonStaffBookStorage jsonAddressBookStorage = new JsonStaffBookStorage(filePath); // Save in new file and read back jsonAddressBookStorage.saveAddressBook(original, filePath); @@ -96,7 +96,7 @@ public void saveAddressBook_nullAddressBook_throwsNullPointerException() { */ private void saveStaffBook(ReadOnlyStaffBook staffBook, String filePath) { try { - new JsonStaffConnectStorage(Paths.get(filePath)) + new JsonStaffBookStorage(Paths.get(filePath)) .saveAddressBook(staffBook, addToTestDataPathIfNotNull(filePath)); } catch (IOException ioe) { throw new AssertionError("There should not be an error writing to the file.", ioe); diff --git a/src/test/java/staffconnect/storage/StorageManagerTest.java b/src/test/java/staffconnect/storage/StorageManagerTest.java index 073c84f526e..774bf6464e5 100644 --- a/src/test/java/staffconnect/storage/StorageManagerTest.java +++ b/src/test/java/staffconnect/storage/StorageManagerTest.java @@ -24,7 +24,7 @@ public class StorageManagerTest { @BeforeEach public void setUp() { - JsonStaffConnectStorage addressBookStorage = new JsonStaffConnectStorage(getTempFilePath("ab")); + JsonStaffBookStorage addressBookStorage = new JsonStaffBookStorage(getTempFilePath("ab")); JsonUserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(getTempFilePath("prefs")); storageManager = new StorageManager(addressBookStorage, userPrefsStorage); } @@ -51,8 +51,8 @@ public void prefsReadSave() throws Exception { public void addressBookReadSave() throws Exception { /* * Note: This is an integration test that verifies the StorageManager is properly wired to the - * {@link JsonStaffConnectStorage} class. - * More extensive testing of UserPref saving/reading is done in {@link JsonStaffConnectStorageTest} class. + * {@link JsonStaffBookStorage} class. + * More extensive testing of UserPref saving/reading is done in {@link JsonStaffBookStorageTest} class. */ StaffBook original = getTypicalAddressBook(); storageManager.saveAddressBook(original); From 803e4d918bacea845eda71d28e77ffaba21e36eb Mon Sep 17 00:00:00 2001 From: tsulim Date: Mon, 11 Mar 2024 23:54:59 +0800 Subject: [PATCH 14/16] Refactor `JsonSerializableStaffConnect` to `JsonSerializableStaffBook` --- ...ect.java => JsonSerializableStaffBook.java} | 10 +++++----- .../storage/JsonStaffBookStorage.java | 6 +++--- .../duplicatePersonAddressBook.json | 0 .../invalidPersonAddressBook.json | 0 .../typicalPersonsAddressBook.json | 0 .../invalidAndValidPersonAddressBook.json | 0 .../invalidPersonAddressBook.json | 0 .../notJsonFormatAddressBook.json | 0 ...java => JsonSerializableStaffBookTest.java} | 18 +++++++++--------- 9 files changed, 17 insertions(+), 17 deletions(-) rename src/main/java/staffconnect/storage/{JsonSerializableStaffConnect.java => JsonSerializableStaffBook.java} (84%) rename src/test/data/{JsonSerializableStaffConnectTest => JsonSerializableStaffBookTest}/duplicatePersonAddressBook.json (100%) rename src/test/data/{JsonSerializableStaffConnectTest => JsonSerializableStaffBookTest}/invalidPersonAddressBook.json (100%) rename src/test/data/{JsonSerializableStaffConnectTest => JsonSerializableStaffBookTest}/typicalPersonsAddressBook.json (100%) rename src/test/data/{JsonStaffConnectStorageTest => JsonStaffBookStorageTest}/invalidAndValidPersonAddressBook.json (100%) rename src/test/data/{JsonStaffConnectStorageTest => JsonStaffBookStorageTest}/invalidPersonAddressBook.json (100%) rename src/test/data/{JsonStaffConnectStorageTest => JsonStaffBookStorageTest}/notJsonFormatAddressBook.json (100%) rename src/test/java/staffconnect/storage/{JsonSerializableStaffConnectTest.java => JsonSerializableStaffBookTest.java} (71%) diff --git a/src/main/java/staffconnect/storage/JsonSerializableStaffConnect.java b/src/main/java/staffconnect/storage/JsonSerializableStaffBook.java similarity index 84% rename from src/main/java/staffconnect/storage/JsonSerializableStaffConnect.java rename to src/main/java/staffconnect/storage/JsonSerializableStaffBook.java index 8757f16c167..c35ff1253c2 100644 --- a/src/main/java/staffconnect/storage/JsonSerializableStaffConnect.java +++ b/src/main/java/staffconnect/storage/JsonSerializableStaffBook.java @@ -17,26 +17,26 @@ * An Immutable StaffBook that is serializable to JSON format. */ @JsonRootName(value = "staffbook") -class JsonSerializableStaffConnect { +class JsonSerializableStaffBook { public static final String MESSAGE_DUPLICATE_PERSON = "Persons list contains duplicate person(s)."; private final List persons = new ArrayList<>(); /** - * Constructs a {@code JsonSerializableStaffConnect} with the given persons. + * Constructs a {@code JsonSerializableStaffBook} with the given persons. */ @JsonCreator - public JsonSerializableStaffConnect(@JsonProperty("persons") List persons) { + public JsonSerializableStaffBook(@JsonProperty("persons") List persons) { this.persons.addAll(persons); } /** * Converts a given {@code ReadOnlyStaffBook} into this class for Jackson use. * - * @param source future changes to this will not affect the created {@code JsonSerializableStaffConnect}. + * @param source future changes to this will not affect the created {@code JsonSerializableStaffBook}. */ - public JsonSerializableStaffConnect(ReadOnlyStaffBook source) { + public JsonSerializableStaffBook(ReadOnlyStaffBook source) { persons.addAll(source.getPersonList().stream().map(JsonAdaptedPerson::new).collect(Collectors.toList())); } diff --git a/src/main/java/staffconnect/storage/JsonStaffBookStorage.java b/src/main/java/staffconnect/storage/JsonStaffBookStorage.java index ff29bac6637..7fb0599776d 100644 --- a/src/main/java/staffconnect/storage/JsonStaffBookStorage.java +++ b/src/main/java/staffconnect/storage/JsonStaffBookStorage.java @@ -45,8 +45,8 @@ public Optional readAddressBook() throws DataLoadingException public Optional readAddressBook(Path filePath) throws DataLoadingException { requireNonNull(filePath); - Optional jsonStaffBook = JsonUtil.readJsonFile( - filePath, JsonSerializableStaffConnect.class); + Optional jsonStaffBook = JsonUtil.readJsonFile( + filePath, JsonSerializableStaffBook.class); if (!jsonStaffBook.isPresent()) { return Optional.empty(); } @@ -74,7 +74,7 @@ public void saveAddressBook(ReadOnlyStaffBook staffBook, Path filePath) throws I requireNonNull(filePath); FileUtil.createIfMissing(filePath); - JsonUtil.saveJsonFile(new JsonSerializableStaffConnect(staffBook), filePath); + JsonUtil.saveJsonFile(new JsonSerializableStaffBook(staffBook), filePath); } } diff --git a/src/test/data/JsonSerializableStaffConnectTest/duplicatePersonAddressBook.json b/src/test/data/JsonSerializableStaffBookTest/duplicatePersonAddressBook.json similarity index 100% rename from src/test/data/JsonSerializableStaffConnectTest/duplicatePersonAddressBook.json rename to src/test/data/JsonSerializableStaffBookTest/duplicatePersonAddressBook.json diff --git a/src/test/data/JsonSerializableStaffConnectTest/invalidPersonAddressBook.json b/src/test/data/JsonSerializableStaffBookTest/invalidPersonAddressBook.json similarity index 100% rename from src/test/data/JsonSerializableStaffConnectTest/invalidPersonAddressBook.json rename to src/test/data/JsonSerializableStaffBookTest/invalidPersonAddressBook.json diff --git a/src/test/data/JsonSerializableStaffConnectTest/typicalPersonsAddressBook.json b/src/test/data/JsonSerializableStaffBookTest/typicalPersonsAddressBook.json similarity index 100% rename from src/test/data/JsonSerializableStaffConnectTest/typicalPersonsAddressBook.json rename to src/test/data/JsonSerializableStaffBookTest/typicalPersonsAddressBook.json diff --git a/src/test/data/JsonStaffConnectStorageTest/invalidAndValidPersonAddressBook.json b/src/test/data/JsonStaffBookStorageTest/invalidAndValidPersonAddressBook.json similarity index 100% rename from src/test/data/JsonStaffConnectStorageTest/invalidAndValidPersonAddressBook.json rename to src/test/data/JsonStaffBookStorageTest/invalidAndValidPersonAddressBook.json diff --git a/src/test/data/JsonStaffConnectStorageTest/invalidPersonAddressBook.json b/src/test/data/JsonStaffBookStorageTest/invalidPersonAddressBook.json similarity index 100% rename from src/test/data/JsonStaffConnectStorageTest/invalidPersonAddressBook.json rename to src/test/data/JsonStaffBookStorageTest/invalidPersonAddressBook.json diff --git a/src/test/data/JsonStaffConnectStorageTest/notJsonFormatAddressBook.json b/src/test/data/JsonStaffBookStorageTest/notJsonFormatAddressBook.json similarity index 100% rename from src/test/data/JsonStaffConnectStorageTest/notJsonFormatAddressBook.json rename to src/test/data/JsonStaffBookStorageTest/notJsonFormatAddressBook.json diff --git a/src/test/java/staffconnect/storage/JsonSerializableStaffConnectTest.java b/src/test/java/staffconnect/storage/JsonSerializableStaffBookTest.java similarity index 71% rename from src/test/java/staffconnect/storage/JsonSerializableStaffConnectTest.java rename to src/test/java/staffconnect/storage/JsonSerializableStaffBookTest.java index a93eaca5cc5..eba881bec15 100644 --- a/src/test/java/staffconnect/storage/JsonSerializableStaffConnectTest.java +++ b/src/test/java/staffconnect/storage/JsonSerializableStaffBookTest.java @@ -13,17 +13,17 @@ import staffconnect.model.StaffBook; import staffconnect.testutil.TypicalPersons; -public class JsonSerializableStaffConnectTest { +public class JsonSerializableStaffBookTest { - private static final Path TEST_DATA_FOLDER = Paths.get("src", "test", "data", "JsonSerializableStaffConnectTest"); + private static final Path TEST_DATA_FOLDER = Paths.get("src", "test", "data", "JsonSerializableStaffBookTest"); private static final Path TYPICAL_PERSONS_FILE = TEST_DATA_FOLDER.resolve("typicalPersonsAddressBook.json"); private static final Path INVALID_PERSON_FILE = TEST_DATA_FOLDER.resolve("invalidPersonAddressBook.json"); private static final Path DUPLICATE_PERSON_FILE = TEST_DATA_FOLDER.resolve("duplicatePersonAddressBook.json"); @Test public void toModelType_typicalPersonsFile_success() throws Exception { - JsonSerializableStaffConnect dataFromFile = JsonUtil.readJsonFile(TYPICAL_PERSONS_FILE, - JsonSerializableStaffConnect.class).get(); + JsonSerializableStaffBook dataFromFile = JsonUtil.readJsonFile(TYPICAL_PERSONS_FILE, + JsonSerializableStaffBook.class).get(); StaffBook staffBookFromFile = dataFromFile.toModelType(); StaffBook typicalPersonsStaffBook = TypicalPersons.getTypicalAddressBook(); assertEquals(staffBookFromFile, typicalPersonsStaffBook); @@ -31,16 +31,16 @@ public void toModelType_typicalPersonsFile_success() throws Exception { @Test public void toModelType_invalidPersonFile_throwsIllegalValueException() throws Exception { - JsonSerializableStaffConnect dataFromFile = JsonUtil.readJsonFile(INVALID_PERSON_FILE, - JsonSerializableStaffConnect.class).get(); + JsonSerializableStaffBook dataFromFile = JsonUtil.readJsonFile(INVALID_PERSON_FILE, + JsonSerializableStaffBook.class).get(); assertThrows(IllegalValueException.class, dataFromFile::toModelType); } @Test public void toModelType_duplicatePersons_throwsIllegalValueException() throws Exception { - JsonSerializableStaffConnect dataFromFile = JsonUtil.readJsonFile(DUPLICATE_PERSON_FILE, - JsonSerializableStaffConnect.class).get(); - assertThrows(IllegalValueException.class, JsonSerializableStaffConnect.MESSAGE_DUPLICATE_PERSON, + JsonSerializableStaffBook dataFromFile = JsonUtil.readJsonFile(DUPLICATE_PERSON_FILE, + JsonSerializableStaffBook.class).get(); + assertThrows(IllegalValueException.class, JsonSerializableStaffBook.MESSAGE_DUPLICATE_PERSON, dataFromFile::toModelType); } From 8b553763a0c19a44c3467d4d130b071a8463084f Mon Sep 17 00:00:00 2001 From: tsulim Date: Mon, 11 Mar 2024 23:59:23 +0800 Subject: [PATCH 15/16] Refactor respective data file names --- ...PersonAddressBook.json => duplicatePersonStaffBook.json} | 0 ...idPersonAddressBook.json => invalidPersonStaffBook.json} | 0 ...PersonsAddressBook.json => typicalPersonsStaffBook.json} | 0 ...AddressBook.json => invalidAndValidPersonStaffBook.json} | 0 ...idPersonAddressBook.json => invalidPersonStaffBook.json} | 0 ...onFormatAddressBook.json => notJsonFormatStaffBook.json} | 0 .../staffconnect/storage/JsonSerializableStaffBookTest.java | 6 +++--- .../java/staffconnect/storage/JsonStaffBookStorageTest.java | 6 +++--- 8 files changed, 6 insertions(+), 6 deletions(-) rename src/test/data/JsonSerializableStaffBookTest/{duplicatePersonAddressBook.json => duplicatePersonStaffBook.json} (100%) rename src/test/data/JsonSerializableStaffBookTest/{invalidPersonAddressBook.json => invalidPersonStaffBook.json} (100%) rename src/test/data/JsonSerializableStaffBookTest/{typicalPersonsAddressBook.json => typicalPersonsStaffBook.json} (100%) rename src/test/data/JsonStaffBookStorageTest/{invalidAndValidPersonAddressBook.json => invalidAndValidPersonStaffBook.json} (100%) rename src/test/data/JsonStaffBookStorageTest/{invalidPersonAddressBook.json => invalidPersonStaffBook.json} (100%) rename src/test/data/JsonStaffBookStorageTest/{notJsonFormatAddressBook.json => notJsonFormatStaffBook.json} (100%) diff --git a/src/test/data/JsonSerializableStaffBookTest/duplicatePersonAddressBook.json b/src/test/data/JsonSerializableStaffBookTest/duplicatePersonStaffBook.json similarity index 100% rename from src/test/data/JsonSerializableStaffBookTest/duplicatePersonAddressBook.json rename to src/test/data/JsonSerializableStaffBookTest/duplicatePersonStaffBook.json diff --git a/src/test/data/JsonSerializableStaffBookTest/invalidPersonAddressBook.json b/src/test/data/JsonSerializableStaffBookTest/invalidPersonStaffBook.json similarity index 100% rename from src/test/data/JsonSerializableStaffBookTest/invalidPersonAddressBook.json rename to src/test/data/JsonSerializableStaffBookTest/invalidPersonStaffBook.json diff --git a/src/test/data/JsonSerializableStaffBookTest/typicalPersonsAddressBook.json b/src/test/data/JsonSerializableStaffBookTest/typicalPersonsStaffBook.json similarity index 100% rename from src/test/data/JsonSerializableStaffBookTest/typicalPersonsAddressBook.json rename to src/test/data/JsonSerializableStaffBookTest/typicalPersonsStaffBook.json diff --git a/src/test/data/JsonStaffBookStorageTest/invalidAndValidPersonAddressBook.json b/src/test/data/JsonStaffBookStorageTest/invalidAndValidPersonStaffBook.json similarity index 100% rename from src/test/data/JsonStaffBookStorageTest/invalidAndValidPersonAddressBook.json rename to src/test/data/JsonStaffBookStorageTest/invalidAndValidPersonStaffBook.json diff --git a/src/test/data/JsonStaffBookStorageTest/invalidPersonAddressBook.json b/src/test/data/JsonStaffBookStorageTest/invalidPersonStaffBook.json similarity index 100% rename from src/test/data/JsonStaffBookStorageTest/invalidPersonAddressBook.json rename to src/test/data/JsonStaffBookStorageTest/invalidPersonStaffBook.json diff --git a/src/test/data/JsonStaffBookStorageTest/notJsonFormatAddressBook.json b/src/test/data/JsonStaffBookStorageTest/notJsonFormatStaffBook.json similarity index 100% rename from src/test/data/JsonStaffBookStorageTest/notJsonFormatAddressBook.json rename to src/test/data/JsonStaffBookStorageTest/notJsonFormatStaffBook.json diff --git a/src/test/java/staffconnect/storage/JsonSerializableStaffBookTest.java b/src/test/java/staffconnect/storage/JsonSerializableStaffBookTest.java index eba881bec15..28153f6361f 100644 --- a/src/test/java/staffconnect/storage/JsonSerializableStaffBookTest.java +++ b/src/test/java/staffconnect/storage/JsonSerializableStaffBookTest.java @@ -16,9 +16,9 @@ public class JsonSerializableStaffBookTest { private static final Path TEST_DATA_FOLDER = Paths.get("src", "test", "data", "JsonSerializableStaffBookTest"); - private static final Path TYPICAL_PERSONS_FILE = TEST_DATA_FOLDER.resolve("typicalPersonsAddressBook.json"); - private static final Path INVALID_PERSON_FILE = TEST_DATA_FOLDER.resolve("invalidPersonAddressBook.json"); - private static final Path DUPLICATE_PERSON_FILE = TEST_DATA_FOLDER.resolve("duplicatePersonAddressBook.json"); + private static final Path TYPICAL_PERSONS_FILE = TEST_DATA_FOLDER.resolve("typicalPersonsStaffBook.json"); + private static final Path INVALID_PERSON_FILE = TEST_DATA_FOLDER.resolve("invalidPersonStaffBook.json"); + private static final Path DUPLICATE_PERSON_FILE = TEST_DATA_FOLDER.resolve("duplicatePersonStaffBook.json"); @Test public void toModelType_typicalPersonsFile_success() throws Exception { diff --git a/src/test/java/staffconnect/storage/JsonStaffBookStorageTest.java b/src/test/java/staffconnect/storage/JsonStaffBookStorageTest.java index bd44a6d90e5..b2b4c2bef4c 100644 --- a/src/test/java/staffconnect/storage/JsonStaffBookStorageTest.java +++ b/src/test/java/staffconnect/storage/JsonStaffBookStorageTest.java @@ -47,17 +47,17 @@ public void read_missingFile_emptyResult() throws Exception { @Test public void read_notJsonFormat_exceptionThrown() { - assertThrows(DataLoadingException.class, () -> readAddressBook("notJsonFormatAddressBook.json")); + assertThrows(DataLoadingException.class, () -> readAddressBook("notJsonFormatStaffBook.json")); } @Test public void readAddressBook_invalidPersonAddressBook_throwDataLoadingException() { - assertThrows(DataLoadingException.class, () -> readAddressBook("invalidPersonAddressBook.json")); + assertThrows(DataLoadingException.class, () -> readAddressBook("invalidPersonStaffBook.json")); } @Test public void readAddressBook_invalidAndValidPersonAddressBook_throwDataLoadingException() { - assertThrows(DataLoadingException.class, () -> readAddressBook("invalidAndValidPersonAddressBook.json")); + assertThrows(DataLoadingException.class, () -> readAddressBook("invalidAndValidPersonStaffBook.json")); } @Test From 57772970c046c9efcbad9c2d137c1b03e22937c4 Mon Sep 17 00:00:00 2001 From: tsulim Date: Tue, 12 Mar 2024 02:32:39 +0800 Subject: [PATCH 16/16] Refactor class methods and variables --- build.gradle | 2 +- src/main/java/staffconnect/MainApp.java | 12 ++--- .../staffconnect/commons/core/LogsCenter.java | 6 +-- src/main/java/staffconnect/logic/Logic.java | 8 ++-- .../java/staffconnect/logic/LogicManager.java | 10 ++-- .../logic/commands/AddCommand.java | 6 +-- .../logic/commands/ClearCommand.java | 2 +- .../logic/commands/DeleteCommand.java | 2 +- .../logic/commands/EditCommand.java | 4 +- .../logic/commands/ExitCommand.java | 2 +- .../logic/commands/FindCommand.java | 2 +- .../logic/commands/ListCommand.java | 2 +- src/main/java/staffconnect/model/Model.java | 12 ++--- .../java/staffconnect/model/ModelManager.java | 14 +++--- .../staffconnect/model/ReadOnlyUserPrefs.java | 2 +- .../java/staffconnect/model/StaffBook.java | 2 +- .../java/staffconnect/model/UserPrefs.java | 20 ++++---- .../staffconnect/model/person/Address.java | 2 +- .../java/staffconnect/model/person/Email.java | 2 +- .../java/staffconnect/model/person/Name.java | 2 +- .../staffconnect/model/person/Person.java | 2 +- .../java/staffconnect/model/person/Phone.java | 2 +- src/main/java/staffconnect/model/tag/Tag.java | 2 +- .../model/util/SampleDataUtil.java | 2 +- .../storage/JsonStaffBookStorage.java | 18 ++++---- .../storage/StaffBookStorage.java | 14 +++--- .../java/staffconnect/storage/Storage.java | 6 +-- .../staffconnect/storage/StorageManager.java | 20 ++++---- src/main/java/staffconnect/ui/CommandBox.java | 2 +- src/main/java/staffconnect/ui/HelpWindow.java | 2 +- src/main/java/staffconnect/ui/MainWindow.java | 2 +- .../ExtraValuesUserPref.json | 2 +- .../TypicalUserPref.json | 2 +- .../staffconnect/logic/LogicManagerTest.java | 12 ++--- .../commands/AddCommandIntegrationTest.java | 8 ++-- .../logic/commands/AddCommandTest.java | 10 ++-- .../logic/commands/ClearCommandTest.java | 8 ++-- .../logic/commands/CommandTestUtil.java | 4 +- .../logic/commands/DeleteCommandTest.java | 10 ++-- .../logic/commands/EditCommandTest.java | 16 +++---- .../logic/commands/FindCommandTest.java | 6 +-- .../logic/commands/ListCommandTest.java | 6 +-- .../staffconnect/model/ModelManagerTest.java | 24 +++++----- .../staffconnect/model/StaffBookTest.java | 4 +- .../staffconnect/model/UserPrefsTest.java | 2 +- .../JsonSerializableStaffBookTest.java | 2 +- .../storage/JsonStaffBookStorageTest.java | 46 +++++++++---------- .../storage/JsonUserPrefsStorageTest.java | 2 +- .../storage/StorageManagerTest.java | 18 ++++---- .../staffconnect/testutil/TypicalPersons.java | 2 +- 50 files changed, 185 insertions(+), 185 deletions(-) diff --git a/build.gradle b/build.gradle index 503006abb7d..019e4a1e763 100644 --- a/build.gradle +++ b/build.gradle @@ -66,7 +66,7 @@ dependencies { } shadowJar { - archiveFileName = 'addressbook.jar' + archiveFileName = 'StaffConnect.jar' } defaultTasks 'clean', 'test' diff --git a/src/main/java/staffconnect/MainApp.java b/src/main/java/staffconnect/MainApp.java index 717c835f359..519d5fe92e0 100644 --- a/src/main/java/staffconnect/MainApp.java +++ b/src/main/java/staffconnect/MainApp.java @@ -57,7 +57,7 @@ public void init() throws Exception { UserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(config.getUserPrefsFilePath()); UserPrefs userPrefs = initPrefs(userPrefsStorage); - StaffBookStorage staffBookStorage = new JsonStaffBookStorage(userPrefs.getAddressBookFilePath()); + StaffBookStorage staffBookStorage = new JsonStaffBookStorage(userPrefs.getStaffConnectFilePath()); storage = new StorageManager(staffBookStorage, userPrefsStorage); model = initModelManager(storage, userPrefs); @@ -73,19 +73,19 @@ public void init() throws Exception { * or an empty staff book will be used instead if errors occur when reading {@code storage}'s staff book. */ private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) { - logger.info("Using data file : " + storage.getAddressBookFilePath()); + logger.info("Using data file : " + storage.getStaffBookFilePath()); Optional staffBookOptional; ReadOnlyStaffBook initialData; try { - staffBookOptional = storage.readAddressBook(); + staffBookOptional = storage.readStaffBook(); if (!staffBookOptional.isPresent()) { - logger.info("Creating a new data file " + storage.getAddressBookFilePath() + logger.info("Creating a new data file " + storage.getStaffBookFilePath() + " populated with a sample StaffBook."); } - initialData = staffBookOptional.orElseGet(SampleDataUtil::getSampleAddressBook); + initialData = staffBookOptional.orElseGet(SampleDataUtil::getSampleStaffBook); } catch (DataLoadingException e) { - logger.warning("Data file at " + storage.getAddressBookFilePath() + " could not be loaded." + logger.warning("Data file at " + storage.getStaffBookFilePath() + " could not be loaded." + " Will be starting with an empty StaffBook."); initialData = new StaffBook(); } diff --git a/src/main/java/staffconnect/commons/core/LogsCenter.java b/src/main/java/staffconnect/commons/core/LogsCenter.java index 25c034722c4..fee19bb06fd 100644 --- a/src/main/java/staffconnect/commons/core/LogsCenter.java +++ b/src/main/java/staffconnect/commons/core/LogsCenter.java @@ -20,7 +20,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 = "staffconnect.log"; private static final Logger logger; // logger for this class private static Logger baseLogger; // to be used as the parent of all other loggers created by this class. private static Level currentLogLevel = Level.INFO; @@ -75,11 +75,11 @@ private static void removeHandlers(Logger logger) { } /** - * Creates a logger named 'ab3', containing a {@code ConsoleHandler} and a {@code FileHandler}. + * Creates a logger named 'sc', containing a {@code ConsoleHandler} and a {@code FileHandler}. * Sets it as the {@code baseLogger}, to be used as the parent logger of all other loggers. */ private static void setBaseLogger() { - baseLogger = Logger.getLogger("ab3"); + baseLogger = Logger.getLogger("sc"); baseLogger.setUseParentHandlers(false); removeHandlers(baseLogger); diff --git a/src/main/java/staffconnect/logic/Logic.java b/src/main/java/staffconnect/logic/Logic.java index 9ee2cf21abe..86e0c5a8d8e 100644 --- a/src/main/java/staffconnect/logic/Logic.java +++ b/src/main/java/staffconnect/logic/Logic.java @@ -26,17 +26,17 @@ public interface Logic { /** * Returns the StaffBook. * - * @see staffconnect.model.Model#getAddressBook() + * @see staffconnect.model.Model#getStaffBook() */ - ReadOnlyStaffBook getAddressBook(); + ReadOnlyStaffBook getStaffBook(); /** Returns an unmodifiable view of the filtered list of persons */ ObservableList getFilteredPersonList(); /** - * Returns the user prefs' staff book file path. + * Returns the user prefs' StaffConnect file path. */ - Path getAddressBookFilePath(); + Path getStaffConnectFilePath(); /** * Returns the user prefs' GUI settings. diff --git a/src/main/java/staffconnect/logic/LogicManager.java b/src/main/java/staffconnect/logic/LogicManager.java index 04e6d34f9db..b020d300dc4 100644 --- a/src/main/java/staffconnect/logic/LogicManager.java +++ b/src/main/java/staffconnect/logic/LogicManager.java @@ -51,7 +51,7 @@ public CommandResult execute(String commandText) throws CommandException, ParseE commandResult = command.execute(model); try { - storage.saveAddressBook(model.getAddressBook()); + storage.saveStaffBook(model.getStaffBook()); } catch (AccessDeniedException e) { throw new CommandException(String.format(FILE_OPS_PERMISSION_ERROR_FORMAT, e.getMessage()), e); } catch (IOException ioe) { @@ -62,8 +62,8 @@ public CommandResult execute(String commandText) throws CommandException, ParseE } @Override - public ReadOnlyStaffBook getAddressBook() { - return model.getAddressBook(); + public ReadOnlyStaffBook getStaffBook() { + return model.getStaffBook(); } @Override @@ -72,8 +72,8 @@ public ObservableList getFilteredPersonList() { } @Override - public Path getAddressBookFilePath() { - return model.getAddressBookFilePath(); + public Path getStaffConnectFilePath() { + return model.getStaffConnectFilePath(); } @Override diff --git a/src/main/java/staffconnect/logic/commands/AddCommand.java b/src/main/java/staffconnect/logic/commands/AddCommand.java index bbcf5bdcde8..173b83d6d7d 100644 --- a/src/main/java/staffconnect/logic/commands/AddCommand.java +++ b/src/main/java/staffconnect/logic/commands/AddCommand.java @@ -14,13 +14,13 @@ import staffconnect.model.person.Person; /** - * Adds a person to the address book. + * Adds a person to the staff book. */ public class AddCommand extends Command { public static final String COMMAND_WORD = "add"; - public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to the address book. " + public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to the staff book. " + "Parameters: " + PREFIX_NAME + "NAME " + PREFIX_PHONE + "PHONE " @@ -36,7 +36,7 @@ public class AddCommand extends Command { + PREFIX_TAG + "owesMoney"; public static final String MESSAGE_SUCCESS = "New person added: %1$s"; - public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book"; + public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the staff book"; private final Person toAdd; diff --git a/src/main/java/staffconnect/logic/commands/ClearCommand.java b/src/main/java/staffconnect/logic/commands/ClearCommand.java index 9fc194f8ec0..6276388f704 100644 --- a/src/main/java/staffconnect/logic/commands/ClearCommand.java +++ b/src/main/java/staffconnect/logic/commands/ClearCommand.java @@ -16,7 +16,7 @@ public class ClearCommand extends Command { @Override public CommandResult execute(Model model) { requireNonNull(model); - model.setAddressBook(new StaffBook()); + model.setStaffBook(new StaffBook()); return new CommandResult(MESSAGE_SUCCESS); } } diff --git a/src/main/java/staffconnect/logic/commands/DeleteCommand.java b/src/main/java/staffconnect/logic/commands/DeleteCommand.java index 948132eade5..47e206341f3 100644 --- a/src/main/java/staffconnect/logic/commands/DeleteCommand.java +++ b/src/main/java/staffconnect/logic/commands/DeleteCommand.java @@ -12,7 +12,7 @@ import staffconnect.model.person.Person; /** - * Deletes a person identified using it's displayed index from the address book. + * Deletes a person identified using it's displayed index from the staff book. */ public class DeleteCommand extends Command { diff --git a/src/main/java/staffconnect/logic/commands/EditCommand.java b/src/main/java/staffconnect/logic/commands/EditCommand.java index 0221a7b3cd3..de8ece3efda 100644 --- a/src/main/java/staffconnect/logic/commands/EditCommand.java +++ b/src/main/java/staffconnect/logic/commands/EditCommand.java @@ -29,7 +29,7 @@ import staffconnect.model.tag.Tag; /** - * Edits the details of an existing person in the address book. + * Edits the details of an existing person in the staff book. */ public class EditCommand extends Command { @@ -50,7 +50,7 @@ public class EditCommand extends Command { public static final String MESSAGE_EDIT_PERSON_SUCCESS = "Edited Person: %1$s"; public static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided."; - public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book."; + public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the staff book."; private final Index index; private final EditPersonDescriptor editPersonDescriptor; diff --git a/src/main/java/staffconnect/logic/commands/ExitCommand.java b/src/main/java/staffconnect/logic/commands/ExitCommand.java index f68987a5ea9..07b1c3d8bd4 100644 --- a/src/main/java/staffconnect/logic/commands/ExitCommand.java +++ b/src/main/java/staffconnect/logic/commands/ExitCommand.java @@ -9,7 +9,7 @@ public class ExitCommand extends Command { public static final String COMMAND_WORD = "exit"; - public static final String MESSAGE_EXIT_ACKNOWLEDGEMENT = "Exiting Address Book as requested ..."; + public static final String MESSAGE_EXIT_ACKNOWLEDGEMENT = "Exiting StaffConnect as requested ..."; @Override public CommandResult execute(Model model) { diff --git a/src/main/java/staffconnect/logic/commands/FindCommand.java b/src/main/java/staffconnect/logic/commands/FindCommand.java index 3b8f6dd43ec..789e4cce2eb 100644 --- a/src/main/java/staffconnect/logic/commands/FindCommand.java +++ b/src/main/java/staffconnect/logic/commands/FindCommand.java @@ -8,7 +8,7 @@ import staffconnect.model.person.NameContainsKeywordsPredicate; /** - * Finds and lists all persons in address book whose name contains any of the argument keywords. + * Finds and lists all persons in staff book whose name contains any of the argument keywords. * Keyword matching is case insensitive. */ public class FindCommand extends Command { diff --git a/src/main/java/staffconnect/logic/commands/ListCommand.java b/src/main/java/staffconnect/logic/commands/ListCommand.java index 85fdcce2a7a..b1911f118d9 100644 --- a/src/main/java/staffconnect/logic/commands/ListCommand.java +++ b/src/main/java/staffconnect/logic/commands/ListCommand.java @@ -6,7 +6,7 @@ import staffconnect.model.Model; /** - * Lists all persons in the address book to the user. + * Lists all persons in the staff book to the user. */ public class ListCommand extends Command { diff --git a/src/main/java/staffconnect/model/Model.java b/src/main/java/staffconnect/model/Model.java index fa3c4042400..e52ec41313e 100644 --- a/src/main/java/staffconnect/model/Model.java +++ b/src/main/java/staffconnect/model/Model.java @@ -35,22 +35,22 @@ public interface Model { void setGuiSettings(GuiSettings guiSettings); /** - * Returns the user prefs' staff book file path. + * Returns the user prefs' StaffConnect file path. */ - Path getAddressBookFilePath(); + Path getStaffConnectFilePath(); /** - * Sets the user prefs' staff book file path. + * Sets the user prefs' StaffConnect file path. */ - void setAddressBookFilePath(Path addressBookFilePath); + void setStaffConnectFilePath(Path staffConnectFilePath); /** * Replaces staff book data with the data in {@code staffBook}. */ - void setAddressBook(ReadOnlyStaffBook staffBook); + void setStaffBook(ReadOnlyStaffBook staffBook); /** Returns the StaffBook */ - ReadOnlyStaffBook getAddressBook(); + ReadOnlyStaffBook getStaffBook(); /** * Returns true if a person with the same identity as {@code person} exists in the staff book. diff --git a/src/main/java/staffconnect/model/ModelManager.java b/src/main/java/staffconnect/model/ModelManager.java index 4b7c876e7bf..80b06ab8d38 100644 --- a/src/main/java/staffconnect/model/ModelManager.java +++ b/src/main/java/staffconnect/model/ModelManager.java @@ -65,25 +65,25 @@ public void setGuiSettings(GuiSettings guiSettings) { } @Override - public Path getAddressBookFilePath() { - return userPrefs.getAddressBookFilePath(); + public Path getStaffConnectFilePath() { + return userPrefs.getStaffConnectFilePath(); } @Override - public void setAddressBookFilePath(Path addressBookFilePath) { - requireNonNull(addressBookFilePath); - userPrefs.setAddressBookFilePath(addressBookFilePath); + public void setStaffConnectFilePath(Path staffConnectFilePath) { + requireNonNull(staffConnectFilePath); + userPrefs.setStaffConnectFilePath(staffConnectFilePath); } //=========== StaffBook ================================================================================ @Override - public void setAddressBook(ReadOnlyStaffBook staffBook) { + public void setStaffBook(ReadOnlyStaffBook staffBook) { this.staffBook.resetData(staffBook); } @Override - public ReadOnlyStaffBook getAddressBook() { + public ReadOnlyStaffBook getStaffBook() { return staffBook; } diff --git a/src/main/java/staffconnect/model/ReadOnlyUserPrefs.java b/src/main/java/staffconnect/model/ReadOnlyUserPrefs.java index 6272a8caa42..6e68706e74b 100644 --- a/src/main/java/staffconnect/model/ReadOnlyUserPrefs.java +++ b/src/main/java/staffconnect/model/ReadOnlyUserPrefs.java @@ -11,6 +11,6 @@ public interface ReadOnlyUserPrefs { GuiSettings getGuiSettings(); - Path getAddressBookFilePath(); + Path getStaffConnectFilePath(); } diff --git a/src/main/java/staffconnect/model/StaffBook.java b/src/main/java/staffconnect/model/StaffBook.java index 649abbd6d1c..22070ad7417 100644 --- a/src/main/java/staffconnect/model/StaffBook.java +++ b/src/main/java/staffconnect/model/StaffBook.java @@ -10,7 +10,7 @@ import staffconnect.model.person.UniquePersonList; /** - * Wraps all data at the fundamental level + * Wraps all data at the address-book level * Duplicates are not allowed (by .isSamePerson comparison) */ public class StaffBook implements ReadOnlyStaffBook { diff --git a/src/main/java/staffconnect/model/UserPrefs.java b/src/main/java/staffconnect/model/UserPrefs.java index ca4aef20b90..43cd9fd2c94 100644 --- a/src/main/java/staffconnect/model/UserPrefs.java +++ b/src/main/java/staffconnect/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 staffConnectFilePath = Paths.get("data" , "staffconnect.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()); + setStaffConnectFilePath(newUserPrefs.getStaffConnectFilePath()); } public GuiSettings getGuiSettings() { @@ -47,13 +47,13 @@ public void setGuiSettings(GuiSettings guiSettings) { this.guiSettings = guiSettings; } - public Path getAddressBookFilePath() { - return addressBookFilePath; + public Path getStaffConnectFilePath() { + return staffConnectFilePath; } - public void setAddressBookFilePath(Path addressBookFilePath) { - requireNonNull(addressBookFilePath); - this.addressBookFilePath = addressBookFilePath; + public void setStaffConnectFilePath(Path staffConnectFilePath) { + requireNonNull(staffConnectFilePath); + this.staffConnectFilePath = staffConnectFilePath; } @Override @@ -69,19 +69,19 @@ public boolean equals(Object other) { UserPrefs otherUserPrefs = (UserPrefs) other; return guiSettings.equals(otherUserPrefs.guiSettings) - && addressBookFilePath.equals(otherUserPrefs.addressBookFilePath); + && staffConnectFilePath.equals(otherUserPrefs.staffConnectFilePath); } @Override public int hashCode() { - return Objects.hash(guiSettings, addressBookFilePath); + return Objects.hash(guiSettings, staffConnectFilePath); } @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 : " + staffConnectFilePath); return sb.toString(); } diff --git a/src/main/java/staffconnect/model/person/Address.java b/src/main/java/staffconnect/model/person/Address.java index 19613c9b401..b4f9e0616b5 100644 --- a/src/main/java/staffconnect/model/person/Address.java +++ b/src/main/java/staffconnect/model/person/Address.java @@ -4,7 +4,7 @@ import static staffconnect.commons.util.AppUtil.checkArgument; /** - * Represents a Person's address in the address book. + * Represents a Person's address in the staff book. * Guarantees: immutable; is valid as declared in {@link #isValidAddress(String)} */ public class Address { diff --git a/src/main/java/staffconnect/model/person/Email.java b/src/main/java/staffconnect/model/person/Email.java index fcb90a15610..4b788e99cf0 100644 --- a/src/main/java/staffconnect/model/person/Email.java +++ b/src/main/java/staffconnect/model/person/Email.java @@ -4,7 +4,7 @@ import static staffconnect.commons.util.AppUtil.checkArgument; /** - * Represents a Person's email in the address book. + * Represents a Person's email in the staff book. * Guarantees: immutable; is valid as declared in {@link #isValidEmail(String)} */ public class Email { diff --git a/src/main/java/staffconnect/model/person/Name.java b/src/main/java/staffconnect/model/person/Name.java index b3e5840e256..e1d9e927aa3 100644 --- a/src/main/java/staffconnect/model/person/Name.java +++ b/src/main/java/staffconnect/model/person/Name.java @@ -4,7 +4,7 @@ import static staffconnect.commons.util.AppUtil.checkArgument; /** - * Represents a Person's name in the address book. + * Represents a Person's name in the staff book. * Guarantees: immutable; is valid as declared in {@link #isValidName(String)} */ public class Name { diff --git a/src/main/java/staffconnect/model/person/Person.java b/src/main/java/staffconnect/model/person/Person.java index eb9d8ad94cd..2256a57b1d8 100644 --- a/src/main/java/staffconnect/model/person/Person.java +++ b/src/main/java/staffconnect/model/person/Person.java @@ -11,7 +11,7 @@ import staffconnect.model.tag.Tag; /** - * Represents a Person in the address book. + * Represents a Person in the staff book. * Guarantees: details are present and not null, field values are validated, immutable. */ public class Person { diff --git a/src/main/java/staffconnect/model/person/Phone.java b/src/main/java/staffconnect/model/person/Phone.java index 5530782e90f..8269af72021 100644 --- a/src/main/java/staffconnect/model/person/Phone.java +++ b/src/main/java/staffconnect/model/person/Phone.java @@ -4,7 +4,7 @@ import static staffconnect.commons.util.AppUtil.checkArgument; /** - * Represents a Person's phone number in the address book. + * Represents a Person's phone number in the staff book. * Guarantees: immutable; is valid as declared in {@link #isValidPhone(String)} */ public class Phone { diff --git a/src/main/java/staffconnect/model/tag/Tag.java b/src/main/java/staffconnect/model/tag/Tag.java index 20c19790d6e..3ddc3784a01 100644 --- a/src/main/java/staffconnect/model/tag/Tag.java +++ b/src/main/java/staffconnect/model/tag/Tag.java @@ -4,7 +4,7 @@ import static staffconnect.commons.util.AppUtil.checkArgument; /** - * Represents a Tag in the address book. + * Represents a Tag in the staff book. * Guarantees: immutable; name is valid as declared in {@link #isValidTagName(String)} */ public class Tag { diff --git a/src/main/java/staffconnect/model/util/SampleDataUtil.java b/src/main/java/staffconnect/model/util/SampleDataUtil.java index ed36b539ceb..df8f3de5d9a 100644 --- a/src/main/java/staffconnect/model/util/SampleDataUtil.java +++ b/src/main/java/staffconnect/model/util/SampleDataUtil.java @@ -40,7 +40,7 @@ public static Person[] getSamplePersons() { }; } - public static ReadOnlyStaffBook getSampleAddressBook() { + public static ReadOnlyStaffBook getSampleStaffBook() { StaffBook sampleSb = new StaffBook(); for (Person samplePerson : getSamplePersons()) { sampleSb.addPerson(samplePerson); diff --git a/src/main/java/staffconnect/storage/JsonStaffBookStorage.java b/src/main/java/staffconnect/storage/JsonStaffBookStorage.java index 7fb0599776d..627d4ddff4b 100644 --- a/src/main/java/staffconnect/storage/JsonStaffBookStorage.java +++ b/src/main/java/staffconnect/storage/JsonStaffBookStorage.java @@ -27,22 +27,22 @@ public JsonStaffBookStorage(Path filePath) { this.filePath = filePath; } - public Path getAddressBookFilePath() { + public Path getStaffBookFilePath() { return filePath; } @Override - public Optional readAddressBook() throws DataLoadingException { - return readAddressBook(filePath); + public Optional readStaffBook() throws DataLoadingException { + return readStaffBook(filePath); } /** - * Similar to {@link #readAddressBook()}. + * Similar to {@link #readStaffBook()}. * * @param filePath location of the data. Cannot be null. * @throws DataLoadingException if loading the data from storage failed. */ - public Optional readAddressBook(Path filePath) throws DataLoadingException { + public Optional readStaffBook(Path filePath) throws DataLoadingException { requireNonNull(filePath); Optional jsonStaffBook = JsonUtil.readJsonFile( @@ -60,16 +60,16 @@ public Optional readAddressBook(Path filePath) throws DataLoa } @Override - public void saveAddressBook(ReadOnlyStaffBook staffBook) throws IOException { - saveAddressBook(staffBook, filePath); + public void saveStaffBook(ReadOnlyStaffBook staffBook) throws IOException { + saveStaffBook(staffBook, filePath); } /** - * Similar to {@link #saveAddressBook(ReadOnlyStaffBook)}. + * Similar to {@link #saveStaffBook(ReadOnlyStaffBook)}. * * @param filePath location of the data. Cannot be null. */ - public void saveAddressBook(ReadOnlyStaffBook staffBook, Path filePath) throws IOException { + public void saveStaffBook(ReadOnlyStaffBook staffBook, Path filePath) throws IOException { requireNonNull(staffBook); requireNonNull(filePath); diff --git a/src/main/java/staffconnect/storage/StaffBookStorage.java b/src/main/java/staffconnect/storage/StaffBookStorage.java index 3f5accbebfa..a89a9bc2f39 100644 --- a/src/main/java/staffconnect/storage/StaffBookStorage.java +++ b/src/main/java/staffconnect/storage/StaffBookStorage.java @@ -16,7 +16,7 @@ public interface StaffBookStorage { /** * Returns the file path of the data file. */ - Path getAddressBookFilePath(); + Path getStaffBookFilePath(); /** * Returns StaffBook data as a {@link ReadOnlyStaffBook}. @@ -24,23 +24,23 @@ public interface StaffBookStorage { * * @throws DataLoadingException if loading the data from storage failed. */ - Optional readAddressBook() throws DataLoadingException; + Optional readStaffBook() throws DataLoadingException; /** - * @see #getAddressBookFilePath() + * @see #getStaffBookFilePath() */ - Optional readAddressBook(Path filePath) throws DataLoadingException; + Optional readStaffBook(Path filePath) throws DataLoadingException; /** * Saves the given {@link ReadOnlyStaffBook} to the storage. * @param staffBook cannot be null. * @throws IOException if there was any problem writing to the file. */ - void saveAddressBook(ReadOnlyStaffBook staffBook) throws IOException; + void saveStaffBook(ReadOnlyStaffBook staffBook) throws IOException; /** - * @see #saveAddressBook(ReadOnlyStaffBook) + * @see #saveStaffBook(ReadOnlyStaffBook) */ - void saveAddressBook(ReadOnlyStaffBook staffBook, Path filePath) throws IOException; + void saveStaffBook(ReadOnlyStaffBook staffBook, Path filePath) throws IOException; } diff --git a/src/main/java/staffconnect/storage/Storage.java b/src/main/java/staffconnect/storage/Storage.java index 670ac6dbd28..3cdf66a4392 100644 --- a/src/main/java/staffconnect/storage/Storage.java +++ b/src/main/java/staffconnect/storage/Storage.java @@ -21,12 +21,12 @@ public interface Storage extends StaffBookStorage, UserPrefsStorage { void saveUserPrefs(ReadOnlyUserPrefs userPrefs) throws IOException; @Override - Path getAddressBookFilePath(); + Path getStaffBookFilePath(); @Override - Optional readAddressBook() throws DataLoadingException; + Optional readStaffBook() throws DataLoadingException; @Override - void saveAddressBook(ReadOnlyStaffBook staffBook) throws IOException; + void saveStaffBook(ReadOnlyStaffBook staffBook) throws IOException; } diff --git a/src/main/java/staffconnect/storage/StorageManager.java b/src/main/java/staffconnect/storage/StorageManager.java index 3f5552860ca..20b575d9884 100644 --- a/src/main/java/staffconnect/storage/StorageManager.java +++ b/src/main/java/staffconnect/storage/StorageManager.java @@ -49,30 +49,30 @@ public void saveUserPrefs(ReadOnlyUserPrefs userPrefs) throws IOException { // ================ StaffBook methods ============================== @Override - public Path getAddressBookFilePath() { - return staffBookStorage.getAddressBookFilePath(); + public Path getStaffBookFilePath() { + return staffBookStorage.getStaffBookFilePath(); } @Override - public Optional readAddressBook() throws DataLoadingException { - return readAddressBook(staffBookStorage.getAddressBookFilePath()); + public Optional readStaffBook() throws DataLoadingException { + return readStaffBook(staffBookStorage.getStaffBookFilePath()); } @Override - public Optional readAddressBook(Path filePath) throws DataLoadingException { + public Optional readStaffBook(Path filePath) throws DataLoadingException { logger.fine("Attempting to read data from file: " + filePath); - return staffBookStorage.readAddressBook(filePath); + return staffBookStorage.readStaffBook(filePath); } @Override - public void saveAddressBook(ReadOnlyStaffBook staffBook) throws IOException { - saveAddressBook(staffBook, staffBookStorage.getAddressBookFilePath()); + public void saveStaffBook(ReadOnlyStaffBook staffBook) throws IOException { + saveStaffBook(staffBook, staffBookStorage.getStaffBookFilePath()); } @Override - public void saveAddressBook(ReadOnlyStaffBook staffBook, Path filePath) throws IOException { + public void saveStaffBook(ReadOnlyStaffBook staffBook, Path filePath) throws IOException { logger.fine("Attempting to write to data file: " + filePath); - staffBookStorage.saveAddressBook(staffBook, filePath); + staffBookStorage.saveStaffBook(staffBook, filePath); } } diff --git a/src/main/java/staffconnect/ui/CommandBox.java b/src/main/java/staffconnect/ui/CommandBox.java index 2406fe6b847..3c0f0f31f44 100644 --- a/src/main/java/staffconnect/ui/CommandBox.java +++ b/src/main/java/staffconnect/ui/CommandBox.java @@ -77,7 +77,7 @@ public interface CommandExecutor { /** * Executes the command and returns the result. * - * @see Logic#execute(String) + * @see staffconnect.logic.Logic#execute(String) */ CommandResult execute(String commandText) throws CommandException, ParseException; } diff --git a/src/main/java/staffconnect/ui/HelpWindow.java b/src/main/java/staffconnect/ui/HelpWindow.java index dcf8cd7b2b7..dbefe489a8a 100644 --- a/src/main/java/staffconnect/ui/HelpWindow.java +++ b/src/main/java/staffconnect/ui/HelpWindow.java @@ -15,7 +15,7 @@ */ public class HelpWindow extends UiPart { - public static final String USERGUIDE_URL = "https://se-education.org/addressbook-level3/UserGuide.html"; + public static final String USERGUIDE_URL = "https://ay2324s2-cs2103-f08-3.github.io/tp/UserGuide.html"; public static final String HELP_MESSAGE = "Refer to the user guide: " + USERGUIDE_URL; private static final Logger logger = LogsCenter.getLogger(HelpWindow.class); diff --git a/src/main/java/staffconnect/ui/MainWindow.java b/src/main/java/staffconnect/ui/MainWindow.java index 85e4e2e09e5..24f15192d48 100644 --- a/src/main/java/staffconnect/ui/MainWindow.java +++ b/src/main/java/staffconnect/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.getStaffConnectFilePath()); statusbarPlaceholder.getChildren().add(statusBarFooter.getRoot()); CommandBox commandBox = new CommandBox(this::executeCommand); diff --git a/src/test/data/JsonUserPrefsStorageTest/ExtraValuesUserPref.json b/src/test/data/JsonUserPrefsStorageTest/ExtraValuesUserPref.json index 1037548a9cd..27958f70d7e 100644 --- a/src/test/data/JsonUserPrefsStorageTest/ExtraValuesUserPref.json +++ b/src/test/data/JsonUserPrefsStorageTest/ExtraValuesUserPref.json @@ -9,5 +9,5 @@ "z" : 99 } }, - "addressBookFilePath" : "addressbook.json" + "staffConnectFilePath" : "staffconnect.json" } diff --git a/src/test/data/JsonUserPrefsStorageTest/TypicalUserPref.json b/src/test/data/JsonUserPrefsStorageTest/TypicalUserPref.json index b819bed900a..bb00234e26c 100644 --- a/src/test/data/JsonUserPrefsStorageTest/TypicalUserPref.json +++ b/src/test/data/JsonUserPrefsStorageTest/TypicalUserPref.json @@ -7,5 +7,5 @@ "y" : 100 } }, - "addressBookFilePath" : "addressbook.json" + "staffConnectFilePath" : "staffconnect.json" } diff --git a/src/test/java/staffconnect/logic/LogicManagerTest.java b/src/test/java/staffconnect/logic/LogicManagerTest.java index bc6c3e61f44..35c0b0fb985 100644 --- a/src/test/java/staffconnect/logic/LogicManagerTest.java +++ b/src/test/java/staffconnect/logic/LogicManagerTest.java @@ -45,10 +45,10 @@ public class LogicManagerTest { @BeforeEach public void setUp() { - JsonStaffBookStorage addressBookStorage = - new JsonStaffBookStorage(temporaryFolder.resolve("staffBook.json")); + JsonStaffBookStorage staffBookStorage = + new JsonStaffBookStorage(temporaryFolder.resolve("staffConnect.json")); JsonUserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(temporaryFolder.resolve("userPrefs.json")); - StorageManager storage = new StorageManager(addressBookStorage, userPrefsStorage); + StorageManager storage = new StorageManager(staffBookStorage, userPrefsStorage); logic = new LogicManager(model, storage); } @@ -123,7 +123,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.getStaffBook(), new UserPrefs()); assertCommandFailure(inputCommand, expectedException, expectedMessage, expectedModel); } @@ -152,7 +152,7 @@ private void assertCommandFailureForExceptionFromStorage(IOException e, String e // Inject LogicManager with a StaffBookStorage that throws the IOException e when saving JsonStaffBookStorage staffBookStorage = new JsonStaffBookStorage(prefPath) { @Override - public void saveAddressBook(ReadOnlyStaffBook staffBook, Path filePath) + public void saveStaffBook(ReadOnlyStaffBook staffBook, Path filePath) throws IOException { throw e; } @@ -164,7 +164,7 @@ public void saveAddressBook(ReadOnlyStaffBook staffBook, Path filePath) logic = new LogicManager(model, storage); - // Triggers the saveAddressBook method by executing an add command + // Triggers the saveStaffBook method by executing an add command String addCommand = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY; Person expectedPerson = new PersonBuilder(AMY).withTags().build(); diff --git a/src/test/java/staffconnect/logic/commands/AddCommandIntegrationTest.java b/src/test/java/staffconnect/logic/commands/AddCommandIntegrationTest.java index 61cb5e69431..74ac30932c6 100644 --- a/src/test/java/staffconnect/logic/commands/AddCommandIntegrationTest.java +++ b/src/test/java/staffconnect/logic/commands/AddCommandIntegrationTest.java @@ -2,7 +2,7 @@ import static staffconnect.logic.commands.CommandTestUtil.assertCommandFailure; import static staffconnect.logic.commands.CommandTestUtil.assertCommandSuccess; -import static staffconnect.testutil.TypicalPersons.getTypicalAddressBook; +import static staffconnect.testutil.TypicalPersons.getTypicalStaffBook; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -23,14 +23,14 @@ public class AddCommandIntegrationTest { @BeforeEach public void setUp() { - model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + model = new ModelManager(getTypicalStaffBook(), new UserPrefs()); } @Test public void execute_newPerson_success() { Person validPerson = new PersonBuilder().build(); - Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); + Model expectedModel = new ModelManager(model.getStaffBook(), new UserPrefs()); expectedModel.addPerson(validPerson); assertCommandSuccess(new AddCommand(validPerson), model, @@ -40,7 +40,7 @@ public void execute_newPerson_success() { @Test public void execute_duplicatePerson_throwsCommandException() { - Person personInList = model.getAddressBook().getPersonList().get(0); + Person personInList = model.getStaffBook().getPersonList().get(0); assertCommandFailure(new AddCommand(personInList), model, AddCommand.MESSAGE_DUPLICATE_PERSON); } diff --git a/src/test/java/staffconnect/logic/commands/AddCommandTest.java b/src/test/java/staffconnect/logic/commands/AddCommandTest.java index 99d04fba1f3..db79059a20a 100644 --- a/src/test/java/staffconnect/logic/commands/AddCommandTest.java +++ b/src/test/java/staffconnect/logic/commands/AddCommandTest.java @@ -109,12 +109,12 @@ public void setGuiSettings(GuiSettings guiSettings) { } @Override - public Path getAddressBookFilePath() { + public Path getStaffConnectFilePath() { throw new AssertionError("This method should not be called."); } @Override - public void setAddressBookFilePath(Path addressBookFilePath) { + public void setStaffConnectFilePath(Path staffConnectFilePath) { throw new AssertionError("This method should not be called."); } @@ -124,12 +124,12 @@ public void addPerson(Person person) { } @Override - public void setAddressBook(ReadOnlyStaffBook newData) { + public void setStaffBook(ReadOnlyStaffBook newData) { throw new AssertionError("This method should not be called."); } @Override - public ReadOnlyStaffBook getAddressBook() { + public ReadOnlyStaffBook getStaffBook() { throw new AssertionError("This method should not be called."); } @@ -196,7 +196,7 @@ public void addPerson(Person person) { } @Override - public ReadOnlyStaffBook getAddressBook() { + public ReadOnlyStaffBook getStaffBook() { return new StaffBook(); } } diff --git a/src/test/java/staffconnect/logic/commands/ClearCommandTest.java b/src/test/java/staffconnect/logic/commands/ClearCommandTest.java index 9b0a75b6e67..617641c3f29 100644 --- a/src/test/java/staffconnect/logic/commands/ClearCommandTest.java +++ b/src/test/java/staffconnect/logic/commands/ClearCommandTest.java @@ -1,7 +1,7 @@ package staffconnect.logic.commands; import static staffconnect.logic.commands.CommandTestUtil.assertCommandSuccess; -import static staffconnect.testutil.TypicalPersons.getTypicalAddressBook; +import static staffconnect.testutil.TypicalPersons.getTypicalStaffBook; import org.junit.jupiter.api.Test; @@ -22,9 +22,9 @@ public void execute_emptyStaffBook_success() { @Test public void execute_nonEmptyStaffBook_success() { - Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); - Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs()); - expectedModel.setAddressBook(new StaffBook()); + Model model = new ModelManager(getTypicalStaffBook(), new UserPrefs()); + Model expectedModel = new ModelManager(getTypicalStaffBook(), new UserPrefs()); + expectedModel.setStaffBook(new StaffBook()); assertCommandSuccess(new ClearCommand(), model, ClearCommand.MESSAGE_SUCCESS, expectedModel); } diff --git a/src/test/java/staffconnect/logic/commands/CommandTestUtil.java b/src/test/java/staffconnect/logic/commands/CommandTestUtil.java index a131ad81463..ec44f77e0c0 100644 --- a/src/test/java/staffconnect/logic/commands/CommandTestUtil.java +++ b/src/test/java/staffconnect/logic/commands/CommandTestUtil.java @@ -104,11 +104,11 @@ public static void assertCommandSuccess(Command command, Model actualModel, Stri 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. - StaffBook expectedStaffBook = new StaffBook(actualModel.getAddressBook()); + StaffBook expectedStaffBook = new StaffBook(actualModel.getStaffBook()); List expectedFilteredList = new ArrayList<>(actualModel.getFilteredPersonList()); assertThrows(CommandException.class, expectedMessage, () -> command.execute(actualModel)); - assertEquals(expectedStaffBook, actualModel.getAddressBook()); + assertEquals(expectedStaffBook, actualModel.getStaffBook()); assertEquals(expectedFilteredList, actualModel.getFilteredPersonList()); } /** diff --git a/src/test/java/staffconnect/logic/commands/DeleteCommandTest.java b/src/test/java/staffconnect/logic/commands/DeleteCommandTest.java index 7cbc4f9e8db..b53dd325fe6 100644 --- a/src/test/java/staffconnect/logic/commands/DeleteCommandTest.java +++ b/src/test/java/staffconnect/logic/commands/DeleteCommandTest.java @@ -8,7 +8,7 @@ import static staffconnect.logic.commands.CommandTestUtil.showPersonAtIndex; import static staffconnect.testutil.TypicalIndexes.INDEX_FIRST_PERSON; import static staffconnect.testutil.TypicalIndexes.INDEX_SECOND_PERSON; -import static staffconnect.testutil.TypicalPersons.getTypicalAddressBook; +import static staffconnect.testutil.TypicalPersons.getTypicalStaffBook; import org.junit.jupiter.api.Test; @@ -25,7 +25,7 @@ */ public class DeleteCommandTest { - private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + private Model model = new ModelManager(getTypicalStaffBook(), new UserPrefs()); @Test public void execute_validIndexUnfilteredList_success() { @@ -35,7 +35,7 @@ public void execute_validIndexUnfilteredList_success() { String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(personToDelete)); - ModelManager expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); + ModelManager expectedModel = new ModelManager(model.getStaffBook(), new UserPrefs()); expectedModel.deletePerson(personToDelete); assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); @@ -59,7 +59,7 @@ public void execute_validIndexFilteredList_success() { String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(personToDelete)); - Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); + Model expectedModel = new ModelManager(model.getStaffBook(), new UserPrefs()); expectedModel.deletePerson(personToDelete); showNoPerson(expectedModel); @@ -72,7 +72,7 @@ public void execute_invalidIndexFilteredList_throwsCommandException() { Index outOfBoundIndex = INDEX_SECOND_PERSON; // ensures that outOfBoundIndex is still in bounds of address book list - assertTrue(outOfBoundIndex.getZeroBased() < model.getAddressBook().getPersonList().size()); + assertTrue(outOfBoundIndex.getZeroBased() < model.getStaffBook().getPersonList().size()); DeleteCommand deleteCommand = new DeleteCommand(outOfBoundIndex); diff --git a/src/test/java/staffconnect/logic/commands/EditCommandTest.java b/src/test/java/staffconnect/logic/commands/EditCommandTest.java index 02cf12e3855..3f22b9d16d1 100644 --- a/src/test/java/staffconnect/logic/commands/EditCommandTest.java +++ b/src/test/java/staffconnect/logic/commands/EditCommandTest.java @@ -13,7 +13,7 @@ import static staffconnect.logic.commands.CommandTestUtil.showPersonAtIndex; import static staffconnect.testutil.TypicalIndexes.INDEX_FIRST_PERSON; import static staffconnect.testutil.TypicalIndexes.INDEX_SECOND_PERSON; -import static staffconnect.testutil.TypicalPersons.getTypicalAddressBook; +import static staffconnect.testutil.TypicalPersons.getTypicalStaffBook; import org.junit.jupiter.api.Test; @@ -33,7 +33,7 @@ */ public class EditCommandTest { - private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + private Model model = new ModelManager(getTypicalStaffBook(), new UserPrefs()); @Test public void execute_allFieldsSpecifiedUnfilteredList_success() { @@ -43,7 +43,7 @@ public void execute_allFieldsSpecifiedUnfilteredList_success() { String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)); - Model expectedModel = new ModelManager(new StaffBook(model.getAddressBook()), new UserPrefs()); + Model expectedModel = new ModelManager(new StaffBook(model.getStaffBook()), new UserPrefs()); expectedModel.setPerson(model.getFilteredPersonList().get(0), editedPerson); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); @@ -64,7 +64,7 @@ public void execute_someFieldsSpecifiedUnfilteredList_success() { String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)); - Model expectedModel = new ModelManager(new StaffBook(model.getAddressBook()), new UserPrefs()); + Model expectedModel = new ModelManager(new StaffBook(model.getStaffBook()), new UserPrefs()); expectedModel.setPerson(lastPerson, editedPerson); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); @@ -77,7 +77,7 @@ public void execute_noFieldSpecifiedUnfilteredList_success() { String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)); - Model expectedModel = new ModelManager(new StaffBook(model.getAddressBook()), new UserPrefs()); + Model expectedModel = new ModelManager(new StaffBook(model.getStaffBook()), new UserPrefs()); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); } @@ -93,7 +93,7 @@ public void execute_filteredList_success() { String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)); - Model expectedModel = new ModelManager(new StaffBook(model.getAddressBook()), new UserPrefs()); + Model expectedModel = new ModelManager(new StaffBook(model.getStaffBook()), new UserPrefs()); expectedModel.setPerson(model.getFilteredPersonList().get(0), editedPerson); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); @@ -113,7 +113,7 @@ public void execute_duplicatePersonFilteredList_failure() { showPersonAtIndex(model, INDEX_FIRST_PERSON); // edit person in filtered list into a duplicate in staff book - Person personInList = model.getAddressBook().getPersonList().get(INDEX_SECOND_PERSON.getZeroBased()); + Person personInList = model.getStaffBook().getPersonList().get(INDEX_SECOND_PERSON.getZeroBased()); EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, new EditPersonDescriptorBuilder(personInList).build()); @@ -138,7 +138,7 @@ public void execute_invalidPersonIndexFilteredList_failure() { showPersonAtIndex(model, INDEX_FIRST_PERSON); Index outOfBoundIndex = INDEX_SECOND_PERSON; // ensures that outOfBoundIndex is still in bounds of staff book list - assertTrue(outOfBoundIndex.getZeroBased() < model.getAddressBook().getPersonList().size()); + assertTrue(outOfBoundIndex.getZeroBased() < model.getStaffBook().getPersonList().size()); EditCommand editCommand = new EditCommand(outOfBoundIndex, new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB).build()); diff --git a/src/test/java/staffconnect/logic/commands/FindCommandTest.java b/src/test/java/staffconnect/logic/commands/FindCommandTest.java index 6bc9f997a38..5232033022e 100644 --- a/src/test/java/staffconnect/logic/commands/FindCommandTest.java +++ b/src/test/java/staffconnect/logic/commands/FindCommandTest.java @@ -8,7 +8,7 @@ import static staffconnect.testutil.TypicalPersons.CARL; import static staffconnect.testutil.TypicalPersons.ELLE; import static staffconnect.testutil.TypicalPersons.FIONA; -import static staffconnect.testutil.TypicalPersons.getTypicalAddressBook; +import static staffconnect.testutil.TypicalPersons.getTypicalStaffBook; 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(getTypicalStaffBook(), new UserPrefs()); + private Model expectedModel = new ModelManager(getTypicalStaffBook(), new UserPrefs()); @Test public void equals() { diff --git a/src/test/java/staffconnect/logic/commands/ListCommandTest.java b/src/test/java/staffconnect/logic/commands/ListCommandTest.java index 48a213af69c..2af87503b8f 100644 --- a/src/test/java/staffconnect/logic/commands/ListCommandTest.java +++ b/src/test/java/staffconnect/logic/commands/ListCommandTest.java @@ -3,7 +3,7 @@ import static staffconnect.logic.commands.CommandTestUtil.assertCommandSuccess; import static staffconnect.logic.commands.CommandTestUtil.showPersonAtIndex; import static staffconnect.testutil.TypicalIndexes.INDEX_FIRST_PERSON; -import static staffconnect.testutil.TypicalPersons.getTypicalAddressBook; +import static staffconnect.testutil.TypicalPersons.getTypicalStaffBook; 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(getTypicalStaffBook(), new UserPrefs()); + expectedModel = new ModelManager(model.getStaffBook(), new UserPrefs()); } @Test diff --git a/src/test/java/staffconnect/model/ModelManagerTest.java b/src/test/java/staffconnect/model/ModelManagerTest.java index 02b83e6ff8c..08951abce4b 100644 --- a/src/test/java/staffconnect/model/ModelManagerTest.java +++ b/src/test/java/staffconnect/model/ModelManagerTest.java @@ -26,7 +26,7 @@ public class ModelManagerTest { public void constructor() { assertEquals(new UserPrefs(), modelManager.getUserPrefs()); assertEquals(new GuiSettings(), modelManager.getGuiSettings()); - assertEquals(new StaffBook(), new StaffBook(modelManager.getAddressBook())); + assertEquals(new StaffBook(), new StaffBook(modelManager.getStaffBook())); } @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.setStaffConnectFilePath(Paths.get("staff/connect/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.setStaffConnectFilePath(Paths.get("new/staff/connect/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 setStaffConnectFilePath_nullPath_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> modelManager.setStaffConnectFilePath(null)); } @Test - public void setAddressBookFilePath_validPath_setsAddressBookFilePath() { - Path path = Paths.get("address/book/file/path"); - modelManager.setAddressBookFilePath(path); - assertEquals(path, modelManager.getAddressBookFilePath()); + public void setStaffConnectFilePath_validPath_setsStaffConnectFilePath() { + Path path = Paths.get("staff/connect/file/path"); + modelManager.setStaffConnectFilePath(path); + assertEquals(path, modelManager.getStaffConnectFilePath()); } @Test @@ -78,12 +78,12 @@ public void hasPerson_nullPerson_throwsNullPointerException() { } @Test - public void hasPerson_personNotInAddressBook_returnsFalse() { + public void hasPerson_personNotInStaffBook_returnsFalse() { assertFalse(modelManager.hasPerson(ALICE)); } @Test - public void hasPerson_personInAddressBook_returnsTrue() { + public void hasPerson_personInStaffBook_returnsTrue() { modelManager.addPerson(ALICE); assertTrue(modelManager.hasPerson(ALICE)); } @@ -126,7 +126,7 @@ public void equals() { // different userPrefs -> returns false UserPrefs differentUserPrefs = new UserPrefs(); - differentUserPrefs.setAddressBookFilePath(Paths.get("differentFilePath")); + differentUserPrefs.setStaffConnectFilePath(Paths.get("differentFilePath")); assertFalse(modelManager.equals(new ModelManager(staffBook, differentUserPrefs))); } } diff --git a/src/test/java/staffconnect/model/StaffBookTest.java b/src/test/java/staffconnect/model/StaffBookTest.java index ddbb66883a1..7f622b4e5f6 100644 --- a/src/test/java/staffconnect/model/StaffBookTest.java +++ b/src/test/java/staffconnect/model/StaffBookTest.java @@ -7,7 +7,7 @@ import static staffconnect.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; import static staffconnect.testutil.Assert.assertThrows; import static staffconnect.testutil.TypicalPersons.ALICE; -import static staffconnect.testutil.TypicalPersons.getTypicalAddressBook; +import static staffconnect.testutil.TypicalPersons.getTypicalStaffBook; import java.util.Arrays; import java.util.Collection; @@ -38,7 +38,7 @@ public void resetData_null_throwsNullPointerException() { @Test public void resetData_withValidReadOnlyStaffBook_replacesData() { - StaffBook newData = getTypicalAddressBook(); + StaffBook newData = getTypicalStaffBook(); staffBook.resetData(newData); assertEquals(newData, staffBook); } diff --git a/src/test/java/staffconnect/model/UserPrefsTest.java b/src/test/java/staffconnect/model/UserPrefsTest.java index 5d53dd6798e..3ddd1798433 100644 --- a/src/test/java/staffconnect/model/UserPrefsTest.java +++ b/src/test/java/staffconnect/model/UserPrefsTest.java @@ -15,7 +15,7 @@ public void setGuiSettings_nullGuiSettings_throwsNullPointerException() { @Test public void setAddressBookFilePath_nullPath_throwsNullPointerException() { UserPrefs userPrefs = new UserPrefs(); - assertThrows(NullPointerException.class, () -> userPrefs.setAddressBookFilePath(null)); + assertThrows(NullPointerException.class, () -> userPrefs.setStaffConnectFilePath(null)); } } diff --git a/src/test/java/staffconnect/storage/JsonSerializableStaffBookTest.java b/src/test/java/staffconnect/storage/JsonSerializableStaffBookTest.java index 28153f6361f..11fabb40f75 100644 --- a/src/test/java/staffconnect/storage/JsonSerializableStaffBookTest.java +++ b/src/test/java/staffconnect/storage/JsonSerializableStaffBookTest.java @@ -25,7 +25,7 @@ public void toModelType_typicalPersonsFile_success() throws Exception { JsonSerializableStaffBook dataFromFile = JsonUtil.readJsonFile(TYPICAL_PERSONS_FILE, JsonSerializableStaffBook.class).get(); StaffBook staffBookFromFile = dataFromFile.toModelType(); - StaffBook typicalPersonsStaffBook = TypicalPersons.getTypicalAddressBook(); + StaffBook typicalPersonsStaffBook = TypicalPersons.getTypicalStaffBook(); assertEquals(staffBookFromFile, typicalPersonsStaffBook); } diff --git a/src/test/java/staffconnect/storage/JsonStaffBookStorageTest.java b/src/test/java/staffconnect/storage/JsonStaffBookStorageTest.java index b2b4c2bef4c..fefb9aa323a 100644 --- a/src/test/java/staffconnect/storage/JsonStaffBookStorageTest.java +++ b/src/test/java/staffconnect/storage/JsonStaffBookStorageTest.java @@ -6,7 +6,7 @@ import static staffconnect.testutil.TypicalPersons.ALICE; import static staffconnect.testutil.TypicalPersons.HOON; import static staffconnect.testutil.TypicalPersons.IDA; -import static staffconnect.testutil.TypicalPersons.getTypicalAddressBook; +import static staffconnect.testutil.TypicalPersons.getTypicalStaffBook; import java.io.IOException; import java.nio.file.Path; @@ -26,12 +26,12 @@ public class JsonStaffBookStorageTest { public Path testFolder; @Test - public void readAddressBook_nullFilePath_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> readAddressBook(null)); + public void readStaffBook_nullFilePath_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> readStaffBook(null)); } - private java.util.Optional readAddressBook(String filePath) throws Exception { - return new JsonStaffBookStorage(Paths.get(filePath)).readAddressBook(addToTestDataPathIfNotNull(filePath)); + private java.util.Optional readStaffBook(String filePath) throws Exception { + return new JsonStaffBookStorage(Paths.get(filePath)).readStaffBook(addToTestDataPathIfNotNull(filePath)); } private Path addToTestDataPathIfNotNull(String prefsFileInTestDataFolder) { @@ -42,52 +42,52 @@ private Path addToTestDataPathIfNotNull(String prefsFileInTestDataFolder) { @Test public void read_missingFile_emptyResult() throws Exception { - assertFalse(readAddressBook("NonExistentFile.json").isPresent()); + assertFalse(readStaffBook("NonExistentFile.json").isPresent()); } @Test public void read_notJsonFormat_exceptionThrown() { - assertThrows(DataLoadingException.class, () -> readAddressBook("notJsonFormatStaffBook.json")); + assertThrows(DataLoadingException.class, () -> readStaffBook("notJsonFormatStaffBook.json")); } @Test - public void readAddressBook_invalidPersonAddressBook_throwDataLoadingException() { - assertThrows(DataLoadingException.class, () -> readAddressBook("invalidPersonStaffBook.json")); + public void readStaffBook_invalidPersonStaffBook_throwDataLoadingException() { + assertThrows(DataLoadingException.class, () -> readStaffBook("invalidPersonStaffBook.json")); } @Test - public void readAddressBook_invalidAndValidPersonAddressBook_throwDataLoadingException() { - assertThrows(DataLoadingException.class, () -> readAddressBook("invalidAndValidPersonStaffBook.json")); + public void readStaffBook_invalidAndValidPersonStaffBook_throwDataLoadingException() { + assertThrows(DataLoadingException.class, () -> readStaffBook("invalidAndValidPersonStaffBook.json")); } @Test - public void readAndSaveAddressBook_allInOrder_success() throws Exception { - Path filePath = testFolder.resolve("TempAddressBook.json"); - StaffBook original = getTypicalAddressBook(); - JsonStaffBookStorage jsonAddressBookStorage = new JsonStaffBookStorage(filePath); + public void readAndSaveStaffBook_allInOrder_success() throws Exception { + Path filePath = testFolder.resolve("TempStaffConnect.json"); + StaffBook original = getTypicalStaffBook(); + JsonStaffBookStorage jsonStaffBookStorage = new JsonStaffBookStorage(filePath); // Save in new file and read back - jsonAddressBookStorage.saveAddressBook(original, filePath); - ReadOnlyStaffBook readBack = jsonAddressBookStorage.readAddressBook(filePath).get(); + jsonStaffBookStorage.saveStaffBook(original, filePath); + ReadOnlyStaffBook readBack = jsonStaffBookStorage.readStaffBook(filePath).get(); assertEquals(original, new StaffBook(readBack)); // Modify data, overwrite exiting file, and read back original.addPerson(HOON); original.removePerson(ALICE); - jsonAddressBookStorage.saveAddressBook(original, filePath); - readBack = jsonAddressBookStorage.readAddressBook(filePath).get(); + jsonStaffBookStorage.saveStaffBook(original, filePath); + readBack = jsonStaffBookStorage.readStaffBook(filePath).get(); assertEquals(original, new StaffBook(readBack)); // Save and read without specifying file path original.addPerson(IDA); - jsonAddressBookStorage.saveAddressBook(original); // file path not specified - readBack = jsonAddressBookStorage.readAddressBook().get(); // file path not specified + jsonStaffBookStorage.saveStaffBook(original); // file path not specified + readBack = jsonStaffBookStorage.readStaffBook().get(); // file path not specified assertEquals(original, new StaffBook(readBack)); } @Test - public void saveAddressBook_nullAddressBook_throwsNullPointerException() { + public void saveStaffBook_nullStaffBook_throwsNullPointerException() { assertThrows(NullPointerException.class, () -> saveStaffBook(null, "SomeFile.json")); } @@ -97,7 +97,7 @@ public void saveAddressBook_nullAddressBook_throwsNullPointerException() { private void saveStaffBook(ReadOnlyStaffBook staffBook, String filePath) { try { new JsonStaffBookStorage(Paths.get(filePath)) - .saveAddressBook(staffBook, addToTestDataPathIfNotNull(filePath)); + .saveStaffBook(staffBook, addToTestDataPathIfNotNull(filePath)); } catch (IOException ioe) { throw new AssertionError("There should not be an error writing to the file.", ioe); } diff --git a/src/test/java/staffconnect/storage/JsonUserPrefsStorageTest.java b/src/test/java/staffconnect/storage/JsonUserPrefsStorageTest.java index 715bc238811..080cc5eb376 100644 --- a/src/test/java/staffconnect/storage/JsonUserPrefsStorageTest.java +++ b/src/test/java/staffconnect/storage/JsonUserPrefsStorageTest.java @@ -73,7 +73,7 @@ public void readUserPrefs_extraValuesInFile_extraValuesIgnored() throws DataLoad private UserPrefs getTypicalUserPrefs() { UserPrefs userPrefs = new UserPrefs(); userPrefs.setGuiSettings(new GuiSettings(1000, 500, 300, 100)); - userPrefs.setAddressBookFilePath(Paths.get("addressbook.json")); + userPrefs.setStaffConnectFilePath(Paths.get("staffconnect.json")); return userPrefs; } diff --git a/src/test/java/staffconnect/storage/StorageManagerTest.java b/src/test/java/staffconnect/storage/StorageManagerTest.java index 774bf6464e5..c846c364db6 100644 --- a/src/test/java/staffconnect/storage/StorageManagerTest.java +++ b/src/test/java/staffconnect/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 staffconnect.testutil.TypicalPersons.getTypicalAddressBook; +import static staffconnect.testutil.TypicalPersons.getTypicalStaffBook; import java.nio.file.Path; @@ -24,9 +24,9 @@ public class StorageManagerTest { @BeforeEach public void setUp() { - JsonStaffBookStorage addressBookStorage = new JsonStaffBookStorage(getTempFilePath("ab")); + JsonStaffBookStorage staffBookStorage = new JsonStaffBookStorage(getTempFilePath("ab")); JsonUserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(getTempFilePath("prefs")); - storageManager = new StorageManager(addressBookStorage, userPrefsStorage); + storageManager = new StorageManager(staffBookStorage, userPrefsStorage); } private Path getTempFilePath(String fileName) { @@ -48,21 +48,21 @@ public void prefsReadSave() throws Exception { } @Test - public void addressBookReadSave() throws Exception { + public void staffBookReadSave() throws Exception { /* * Note: This is an integration test that verifies the StorageManager is properly wired to the * {@link JsonStaffBookStorage} class. * More extensive testing of UserPref saving/reading is done in {@link JsonStaffBookStorageTest} class. */ - StaffBook original = getTypicalAddressBook(); - storageManager.saveAddressBook(original); - ReadOnlyStaffBook retrieved = storageManager.readAddressBook().get(); + StaffBook original = getTypicalStaffBook(); + storageManager.saveStaffBook(original); + ReadOnlyStaffBook retrieved = storageManager.readStaffBook().get(); assertEquals(original, new StaffBook(retrieved)); } @Test - public void getAddressBookFilePath() { - assertNotNull(storageManager.getAddressBookFilePath()); + public void getStaffBookFilePath() { + assertNotNull(storageManager.getStaffBookFilePath()); } } diff --git a/src/test/java/staffconnect/testutil/TypicalPersons.java b/src/test/java/staffconnect/testutil/TypicalPersons.java index e61089ba417..f6497f7c60b 100644 --- a/src/test/java/staffconnect/testutil/TypicalPersons.java +++ b/src/test/java/staffconnect/testutil/TypicalPersons.java @@ -62,7 +62,7 @@ private TypicalPersons() {} // prevents instantiation /** * Returns an {@code StaffBook} with all the typical persons. */ - public static StaffBook getTypicalAddressBook() { + public static StaffBook getTypicalStaffBook() { StaffBook ab = new StaffBook(); for (Person person : getTypicalPersons()) { ab.addPerson(person);