From 309d1338f4769d1672a4553380966d967e2b8319 Mon Sep 17 00:00:00 2001 From: pjanthony2001 <104015990+pjanthony2001@users.noreply.github.com> Date: Mon, 15 Apr 2024 20:29:49 +0800 Subject: [PATCH 1/4] Update JavaDocs --- src/main/java/seedu/address/MainApp.java | 2 +- .../history/BufferedHistoryManager.java | 4 +-- .../java/seedu/address/history/History.java | 2 +- .../seedu/address/history/HistoryManager.java | 4 +-- .../seedu/address/history/ModelState.java | 23 +++++++++------- .../seedu/address/logic/LogicManager.java | 4 +++ .../java/seedu/address/logic/Messages.java | 2 +- .../seedu/address/logic/commands/Command.java | 26 ++++++++++++++++--- .../address/logic/commands/CommandResult.java | 2 +- .../address/logic/commands/RedoCommand.java | 3 +-- .../address/logic/commands/StartCommand.java | 6 +---- .../address/logic/commands/UndoCommand.java | 3 +-- .../java/seedu/address/model/AddressBook.java | 1 + .../java/seedu/address/model/Calendar.java | 4 +-- .../address/model/ReadOnlyAddressBook.java | 4 +++ .../seedu/address/model/ReadOnlyCalendar.java | 6 ++++- .../seedu/address/model/event/Heading.java | 4 +-- .../exceptions/DuplicateEventException.java | 2 +- .../address/storage/CalendarStorage.java | 14 +++++----- .../address/storage/JsonAdaptedEvent.java | 8 +++--- .../address/storage/JsonCalendarStorage.java | 2 +- 21 files changed, 78 insertions(+), 48 deletions(-) diff --git a/src/main/java/seedu/address/MainApp.java b/src/main/java/seedu/address/MainApp.java index 26194d8c4c4..45bc12191f7 100644 --- a/src/main/java/seedu/address/MainApp.java +++ b/src/main/java/seedu/address/MainApp.java @@ -99,7 +99,7 @@ private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) { ReadOnlyCalendar initialCalendarData; try { calendarOptional = storage.readCalendar(); - if (!calendarOptional.isPresent()) { + if (calendarOptional.isEmpty()) { logger.info("Creating a new data file " + storage.getCalendarFilePath() + " populated with a sample Calendar."); } diff --git a/src/main/java/seedu/address/history/BufferedHistoryManager.java b/src/main/java/seedu/address/history/BufferedHistoryManager.java index 67abd7b3b47..850841ff708 100644 --- a/src/main/java/seedu/address/history/BufferedHistoryManager.java +++ b/src/main/java/seedu/address/history/BufferedHistoryManager.java @@ -3,12 +3,12 @@ import seedu.address.history.exceptions.HistoryException; /** - * @param The type of state that the abstract class keeps track of + * @param The type of state that the BufferedHistoryManager class keeps track of */ public class BufferedHistoryManager extends HistoryManager implements BufferedHistory { /** - * Constructs a new HistoryManager with a starting state. + * Constructs a new BufferedHistoryManager with a starting state. This state acts as the buffer. * * @param startState The initial state of the history. */ diff --git a/src/main/java/seedu/address/history/History.java b/src/main/java/seedu/address/history/History.java index 26a4e80ac7a..7e40d0b382f 100644 --- a/src/main/java/seedu/address/history/History.java +++ b/src/main/java/seedu/address/history/History.java @@ -16,7 +16,7 @@ public interface History { /** * Rolls forward to the next state in the history. * - * @throws Exception If there are no more future states to roll forward to. + * @throws HistoryException If there are no more future states to roll forward to. */ void rollForwardState() throws HistoryException; diff --git a/src/main/java/seedu/address/history/HistoryManager.java b/src/main/java/seedu/address/history/HistoryManager.java index 76d88eb3b86..1aacd8aa278 100644 --- a/src/main/java/seedu/address/history/HistoryManager.java +++ b/src/main/java/seedu/address/history/HistoryManager.java @@ -5,7 +5,7 @@ import seedu.address.history.exceptions.HistoryException; /** - * @param The type of state that the abstract class keeps track of + * @param The type of state that the HistoryManager class keeps track of */ public class HistoryManager implements History { protected int currStateIdx; @@ -23,7 +23,7 @@ public HistoryManager(T startState) { } /** - * Removes modelStates after the current state, effectively truncating the history. + * Removes states after the current state, effectively truncating the history. */ private void truncate() { assert (currStateIdx >= 0 && currStateIdx < states.size()); diff --git a/src/main/java/seedu/address/history/ModelState.java b/src/main/java/seedu/address/history/ModelState.java index f4f6dd2d783..cda290f1945 100644 --- a/src/main/java/seedu/address/history/ModelState.java +++ b/src/main/java/seedu/address/history/ModelState.java @@ -12,22 +12,21 @@ /** * The `ModelState` class represents a snapshot of the ConnectCare application's state at a specific point in time. - * It contains information about the executed command and the list of tasks at that time. + * It contains information about the executed command, the AddressBook and the Calendar at that time. */ public class ModelState { private final Command command; private final ReadOnlyAddressBook addressBook; private final Predicate filteredPersonsListPredicate; - private final ReadOnlyCalendar calendar; /** * Constructs a new ModelState object with the given command and task list. * * @param command The command executed to reach this state. - * @param addressBook The list of tasks at this state. + * @param addressBook The address book at this state. * @param filteredPersonsListPredicate The predicate of the filtered list - * @param calendar + * @param calendar The calendar at this state */ public ModelState(Command command, ReadOnlyAddressBook addressBook, Predicate filteredPersonsListPredicate, ReadOnlyCalendar calendar) { @@ -38,9 +37,9 @@ public ModelState(Command command, ReadOnlyAddressBook addressBook, } /** - * Gets the list of tasks at this state. + * Gets the AddressBook at this state. * - * @return The list of tasks. + * @return The AddressBook. */ public ReadOnlyAddressBook getAddressBook() { return addressBook; @@ -56,14 +55,19 @@ public Command getCommand() { } /** - * Gets the command executed to reach this state. + * Gets the predicate that was used at this state to display the filtered list of persons. * - * @return The command. + * @return The predicate. */ public Predicate getFilteredPersonsListPredicate() { return filteredPersonsListPredicate; } + /** + * Gets the calendar at this state. + * + * @return The calendar. + */ public ReadOnlyCalendar getCalendar() { return calendar; } @@ -89,7 +93,8 @@ public boolean equals(Object other) { return addressBook.equals(otherModelState.addressBook) && command.equals(otherModelState.command) - && filteredList.equals(filteredListOther); + && filteredList.equals(filteredListOther) + && calendar.equals(otherModelState.calendar); } } diff --git a/src/main/java/seedu/address/logic/LogicManager.java b/src/main/java/seedu/address/logic/LogicManager.java index fb6d4929a2b..73467a23ef4 100644 --- a/src/main/java/seedu/address/logic/LogicManager.java +++ b/src/main/java/seedu/address/logic/LogicManager.java @@ -99,13 +99,17 @@ public GuiSettings getGuiSettings() { public void setGuiSettings(GuiSettings guiSettings) { model.setGuiSettings(guiSettings); } + + @Override public ObservableList getEventList() { return model.getEventList(); } + @Override public String retrievePreviousCommand() throws HistoryException { return model.retrievePreviousCommand(); } + @Override public String retrieveNextCommand() throws HistoryException { return model.retrieveNextCommand(); diff --git a/src/main/java/seedu/address/logic/Messages.java b/src/main/java/seedu/address/logic/Messages.java index 5a27ba9f6f3..49784535688 100644 --- a/src/main/java/seedu/address/logic/Messages.java +++ b/src/main/java/seedu/address/logic/Messages.java @@ -59,7 +59,7 @@ public static String format(Person person) { return builder.toString(); } /** - * Formats the {@code person} for display to the user. + * Formats the {@code event} for display to the user. */ public static String format(Event event) { final StringBuilder builder = new StringBuilder(); diff --git a/src/main/java/seedu/address/logic/commands/Command.java b/src/main/java/seedu/address/logic/commands/Command.java index dfdb87f5662..bf1d525270b 100644 --- a/src/main/java/seedu/address/logic/commands/Command.java +++ b/src/main/java/seedu/address/logic/commands/Command.java @@ -7,21 +7,39 @@ * Represents a command with hidden internal logic and the ability to be executed. */ public abstract class Command { - private boolean isReversible; + private boolean isReversible = false; /** * Executes the command and returns the result message. * * @param model {@code Model} which the command should operate on. - * @return feedback message of the operation result for display + * @return feedback message of the operation result for display. * @throws CommandException If an error occurs during command execution. */ public abstract CommandResult execute(Model model) throws CommandException; + + /** + * Returns the string representation of the command for History saving purposes. + * + * @return The string representation of command. + */ public abstract String getCommandString(); + + /** + * Returns if the command is reversible or not. By default, it is not reversible. + * + * @return true if the command is reversible and false otherwise. + */ public boolean isReversible() { return isReversible; } - public void setReversible(boolean setValue) { - isReversible = setValue; + + /** + * Sets if the command is reversible or not. By default, it is not reversible. + * + * @param isReversible The boolean representing if the command is reversible or not. + */ + public void setReversible(boolean isReversible) { + this.isReversible = isReversible; } } diff --git a/src/main/java/seedu/address/logic/commands/CommandResult.java b/src/main/java/seedu/address/logic/commands/CommandResult.java index 33d9aab8942..46be05debb4 100644 --- a/src/main/java/seedu/address/logic/commands/CommandResult.java +++ b/src/main/java/seedu/address/logic/commands/CommandResult.java @@ -14,7 +14,7 @@ public class CommandResult { private final String feedbackToUser; private final boolean isDisplayCommand; - private Person firstMatchedPerson; + private final Person firstMatchedPerson; /** Help information should be shown to the user. */ private final boolean isShowHelp; diff --git a/src/main/java/seedu/address/logic/commands/RedoCommand.java b/src/main/java/seedu/address/logic/commands/RedoCommand.java index 1355fba9f71..ff0b86a7aee 100644 --- a/src/main/java/seedu/address/logic/commands/RedoCommand.java +++ b/src/main/java/seedu/address/logic/commands/RedoCommand.java @@ -8,12 +8,11 @@ import seedu.address.model.Model; /** - * Undoes a command + * Redoes a command, reverting the model to that state */ public class RedoCommand extends Command { public static final String COMMAND_WORD = "redo"; - public static final String MESSAGE_USAGE = COMMAND_WORD + ": Redoes the most recent command."; public static final String MESSAGE_SUCCESS = "Command redone: %1$s"; public static final String MESSAGE_NO_ROLLFORWARD = "There is no more history to roll forward!"; diff --git a/src/main/java/seedu/address/logic/commands/StartCommand.java b/src/main/java/seedu/address/logic/commands/StartCommand.java index a4720e88689..86cedb2de0b 100644 --- a/src/main/java/seedu/address/logic/commands/StartCommand.java +++ b/src/main/java/seedu/address/logic/commands/StartCommand.java @@ -4,7 +4,7 @@ import seedu.address.model.Model; /** - * Start command for the start state + * A dummy start command for the start state */ public class StartCommand extends Command { @@ -24,10 +24,6 @@ private StartCommand() { public CommandResult execute(Model model) throws CommandException { throw new CommandException(MESSAGE_SHOULD_NOT_EXECUTE); } - - /** - * @return String representation of command - */ @Override public String getCommandString() { return COMMAND_WORD; diff --git a/src/main/java/seedu/address/logic/commands/UndoCommand.java b/src/main/java/seedu/address/logic/commands/UndoCommand.java index 6ef00832866..96cd513d014 100644 --- a/src/main/java/seedu/address/logic/commands/UndoCommand.java +++ b/src/main/java/seedu/address/logic/commands/UndoCommand.java @@ -8,12 +8,11 @@ import seedu.address.model.Model; /** - * Undoes a command + * Undoes any command that is reversible, reverting the model to its previous state */ public class UndoCommand extends Command { public static final String COMMAND_WORD = "undo"; - public static final String MESSAGE_USAGE = COMMAND_WORD + ": Undoes the most recent command."; public static final String MESSAGE_SUCCESS = "Command undone: %1$s"; public static final String MESSAGE_NO_ROLLBACK = "There is no more history to roll back!"; diff --git a/src/main/java/seedu/address/model/AddressBook.java b/src/main/java/seedu/address/model/AddressBook.java index d021ba637f1..903fd371eba 100644 --- a/src/main/java/seedu/address/model/AddressBook.java +++ b/src/main/java/seedu/address/model/AddressBook.java @@ -130,6 +130,7 @@ public int hashCode() { return persons.hashCode(); } + @Override public ReadOnlyAddressBook deepCopy() throws IllegalValueException { return new JsonSerializableAddressBook(this).toModelType(); } diff --git a/src/main/java/seedu/address/model/Calendar.java b/src/main/java/seedu/address/model/Calendar.java index 74eefcdb62d..916fa7fe339 100644 --- a/src/main/java/seedu/address/model/Calendar.java +++ b/src/main/java/seedu/address/model/Calendar.java @@ -68,10 +68,10 @@ public void resetData(ReadOnlyCalendar newData) { setEvents(newData.getEventList()); } - //// person-level operations + //// event-level operations /** - * Returns true if an event with the same identity as {@code even} exists in the calendar. + * Returns true if an event with the same "identity" (heading) as {@code event} exists in the calendar. */ public boolean hasEvent(Event event) { requireNonNull(event); diff --git a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java b/src/main/java/seedu/address/model/ReadOnlyAddressBook.java index 58981ca775d..3d0bb09b0ab 100644 --- a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java +++ b/src/main/java/seedu/address/model/ReadOnlyAddressBook.java @@ -14,5 +14,9 @@ public interface ReadOnlyAddressBook { * This list will not contain any duplicate persons. */ ObservableList getPersonList(); + + /** + * Returns an unmodifiable deep copy of the ReadOnlyAddressBook + */ ReadOnlyAddressBook deepCopy() throws IllegalValueException; } diff --git a/src/main/java/seedu/address/model/ReadOnlyCalendar.java b/src/main/java/seedu/address/model/ReadOnlyCalendar.java index 92626344971..3ed05efaa68 100644 --- a/src/main/java/seedu/address/model/ReadOnlyCalendar.java +++ b/src/main/java/seedu/address/model/ReadOnlyCalendar.java @@ -10,8 +10,12 @@ public interface ReadOnlyCalendar { /** * Returns an unmodifiable view of the event list. - * This list will not contain any duplicate events?. + * This list will not contain any duplicate events. */ ObservableList getEventList(); + + /** + * Returns an unmodifiable deep copy of the ReadOnlyCalendar. + */ ReadOnlyCalendar deepCopy() throws IllegalValueException; } diff --git a/src/main/java/seedu/address/model/event/Heading.java b/src/main/java/seedu/address/model/event/Heading.java index 739c9aab8c1..f93b76f2766 100644 --- a/src/main/java/seedu/address/model/event/Heading.java +++ b/src/main/java/seedu/address/model/event/Heading.java @@ -23,7 +23,7 @@ public class Heading { /** * Constructs a {@code Heading}. * - * @param heading A valid name. + * @param heading A valid heading for the event. */ public Heading(String heading) { requireNonNull(heading); @@ -32,7 +32,7 @@ public Heading(String heading) { } /** - * Returns true if a given string is a valid name. + * Returns true if a given string is a valid heading. */ public static boolean isValidHeading(String test) { return (test.length() <= 70) && (test.matches(VALIDATION_REGEX)); diff --git a/src/main/java/seedu/address/model/event/exceptions/DuplicateEventException.java b/src/main/java/seedu/address/model/event/exceptions/DuplicateEventException.java index d3303224916..7705530bae7 100644 --- a/src/main/java/seedu/address/model/event/exceptions/DuplicateEventException.java +++ b/src/main/java/seedu/address/model/event/exceptions/DuplicateEventException.java @@ -5,6 +5,6 @@ */ public class DuplicateEventException extends RuntimeException { public DuplicateEventException() { - super("Operation would result in duplicate persons"); + super("Operation would result in duplicate events"); } } diff --git a/src/main/java/seedu/address/storage/CalendarStorage.java b/src/main/java/seedu/address/storage/CalendarStorage.java index 86d14083f1f..b7f174281cd 100644 --- a/src/main/java/seedu/address/storage/CalendarStorage.java +++ b/src/main/java/seedu/address/storage/CalendarStorage.java @@ -5,12 +5,12 @@ import java.util.Optional; import seedu.address.commons.exceptions.DataLoadingException; -import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.ReadOnlyCalendar; import seedu.address.model.ReadOnlyCalendar; /** - * Calendar Storage + * Represents a storage for the Calendar */ public interface CalendarStorage { /** @@ -19,7 +19,7 @@ public interface CalendarStorage { Path getCalendarFilePath(); /** - * Returns AddressBook data as a {@link ReadOnlyAddressBook}. + * Returns Calander data as a {@link ReadOnlyCalendar}. * Returns {@code Optional.empty()} if storage file is not found. * * @throws DataLoadingException if loading the data from storage failed. @@ -32,15 +32,15 @@ public interface CalendarStorage { Optional readCalendar(Path filePath) throws DataLoadingException; /** - * Saves the given {@link ReadOnlyAddressBook} to the storage. - * @param addressBook cannot be null. + * Saves the given {@link ReadOnlyCalendar} to the storage. + * @param calendar cannot be null. * @throws IOException if there was any problem writing to the file. */ - void saveCalendar(ReadOnlyCalendar addressBook) throws IOException; + void saveCalendar(ReadOnlyCalendar calendar) throws IOException; /** * @see #saveCalendar(ReadOnlyCalendar) */ - void saveCalendar(ReadOnlyCalendar addressBook, Path filePath) throws IOException; + void saveCalendar(ReadOnlyCalendar calendar, Path filePath) throws IOException; } diff --git a/src/main/java/seedu/address/storage/JsonAdaptedEvent.java b/src/main/java/seedu/address/storage/JsonAdaptedEvent.java index 7860bdc387d..0b19010c3c2 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedEvent.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedEvent.java @@ -16,7 +16,7 @@ */ class JsonAdaptedEvent { - public static final String MISSING_FIELD_MESSAGE_FORMAT = "Person's %s field is missing!"; + public static final String MISSING_FIELD_MESSAGE_FORMAT = "Event's %s field is missing!"; private final String time; private final String heading; @@ -24,7 +24,7 @@ class JsonAdaptedEvent { private final String clientName; /** - * Constructs a {@code JsonAdaptedPerson} with the given person details. + * Constructs a {@code JsonAdaptedEvent} with the given person details. */ @JsonCreator public JsonAdaptedEvent(@JsonProperty("heading") String heading, @JsonProperty("time") String time, @@ -37,7 +37,7 @@ public JsonAdaptedEvent(@JsonProperty("heading") String heading, @JsonProperty(" } /** - * Converts a given {@code Person} into this class for Jackson use. + * Converts a given {@code Event} into this class for Jackson use. */ public JsonAdaptedEvent(Event source) { heading = source.getHeadingString(); @@ -47,7 +47,7 @@ public JsonAdaptedEvent(Event source) { } /** - * Converts this Jackson-friendly adapted person object into the model's {@code Person} object. + * Converts this Jackson-friendly adapted person object into the model's {@code Event} object. * * @throws IllegalValueException if there were any data constraints violated in the adapted person. */ diff --git a/src/main/java/seedu/address/storage/JsonCalendarStorage.java b/src/main/java/seedu/address/storage/JsonCalendarStorage.java index f09b7a096cd..5ed55e06d45 100644 --- a/src/main/java/seedu/address/storage/JsonCalendarStorage.java +++ b/src/main/java/seedu/address/storage/JsonCalendarStorage.java @@ -47,7 +47,7 @@ public Optional readCalendar(Path filePath) throws DataLoading Optional jsonCalendar = JsonUtil.readJsonFile( filePath, JsonSerializableCalendar.class); - if (!jsonCalendar.isPresent()) { + if (jsonCalendar.isEmpty()) { return Optional.empty(); } From b2ff4e2baacc314357e26cf736f30c7605e7c404 Mon Sep 17 00:00:00 2001 From: pjanthony2001 <104015990+pjanthony2001@users.noreply.github.com> Date: Mon, 15 Apr 2024 20:32:42 +0800 Subject: [PATCH 2/4] Fix checkstyle error --- src/main/java/seedu/address/storage/CalendarStorage.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/seedu/address/storage/CalendarStorage.java b/src/main/java/seedu/address/storage/CalendarStorage.java index b7f174281cd..47d32bbb7bb 100644 --- a/src/main/java/seedu/address/storage/CalendarStorage.java +++ b/src/main/java/seedu/address/storage/CalendarStorage.java @@ -6,7 +6,6 @@ import seedu.address.commons.exceptions.DataLoadingException; import seedu.address.model.ReadOnlyCalendar; -import seedu.address.model.ReadOnlyCalendar; /** From c28b5c9c6c7fd591480a5bdc88df351af907b240 Mon Sep 17 00:00:00 2001 From: pjanthony2001 <104015990+pjanthony2001@users.noreply.github.com> Date: Mon, 15 Apr 2024 20:47:49 +0800 Subject: [PATCH 3/4] Update tests --- .../java/seedu/address/history/CommandStateTest.java | 2 +- ...HistoryManagerTest.java => HistoryManagerTest.java} | 0 .../java/seedu/address/history/ModelStateTest.java | 3 ++- .../seedu/address/logic/commands/AddCommandTest.java | 4 ++-- .../seedu/address/logic/commands/ClearCommandTest.java | 2 +- .../address/logic/commands/DeleteCommandTest.java | 2 +- .../address/logic/commands/DisplayCommandTest.java | 2 +- .../seedu/address/logic/commands/ExitCommandTest.java | 2 +- .../seedu/address/logic/commands/FindCommandTest.java | 2 +- .../seedu/address/logic/commands/HelpCommandTest.java | 2 +- .../seedu/address/logic/commands/ListCommandTest.java | 2 +- .../logic/commands/RedoCommandIntegrationTest.java | 8 ++++---- .../seedu/address/logic/commands/RedoCommandTest.java | 2 +- .../logic/commands/ScheduleDeleteCommandTest.java | 2 +- .../seedu/address/logic/commands/StartCommandTest.java | 6 +----- .../logic/commands/UndoCommandIntegrationTest.java | 10 +++++----- .../seedu/address/logic/commands/UndoCommandTest.java | 2 +- .../address/logic/commands/UpdateCommandTest.java | 2 +- 18 files changed, 26 insertions(+), 29 deletions(-) rename src/test/java/seedu/address/history/{ModelHistoryManagerTest.java => HistoryManagerTest.java} (100%) diff --git a/src/test/java/seedu/address/history/CommandStateTest.java b/src/test/java/seedu/address/history/CommandStateTest.java index 90dcf272713..a64ce32f409 100644 --- a/src/test/java/seedu/address/history/CommandStateTest.java +++ b/src/test/java/seedu/address/history/CommandStateTest.java @@ -5,7 +5,7 @@ import org.junit.jupiter.api.Test; public class CommandStateTest { - private CommandState commandState = new CommandState("update u/Alex Yeoh p/92647812"); + private final CommandState commandState = new CommandState("update u/Alex Yeoh p/92647812"); @Test void getCommandText_validCommand_success() { diff --git a/src/test/java/seedu/address/history/ModelHistoryManagerTest.java b/src/test/java/seedu/address/history/HistoryManagerTest.java similarity index 100% rename from src/test/java/seedu/address/history/ModelHistoryManagerTest.java rename to src/test/java/seedu/address/history/HistoryManagerTest.java diff --git a/src/test/java/seedu/address/history/ModelStateTest.java b/src/test/java/seedu/address/history/ModelStateTest.java index 89f43dfe59e..62fe59308f4 100644 --- a/src/test/java/seedu/address/history/ModelStateTest.java +++ b/src/test/java/seedu/address/history/ModelStateTest.java @@ -30,6 +30,7 @@ class ModelStateTest { private Calendar calendar; private FilteredList filteredPersons; private Command command; + @BeforeEach void setup() { addressBook = getTypicalAddressBook(); @@ -46,7 +47,7 @@ void getAddressBook_typicalAddressBook_successfullyReturnsTypicalAddressBook() { } @Test - void getCommand_commandStubTracked_successfullyReturnsCommandStub() { + void getCommand_commandStubReversible_successfullyReturnsCommandStub() { Command original = getCommandStub(); Command retrieved = modelState.getCommand(); assertEquals(original, retrieved); diff --git a/src/test/java/seedu/address/logic/commands/AddCommandTest.java b/src/test/java/seedu/address/logic/commands/AddCommandTest.java index d8990f4c525..78d2eda5d64 100644 --- a/src/test/java/seedu/address/logic/commands/AddCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/AddCommandTest.java @@ -91,14 +91,14 @@ public void toStringMethod() { } @Test - public void getCommandStringTest() { + public void getCommandString_returnsCommandString() { AddCommand addCommand = new AddCommand(ALICE); String expected = AddCommand.COMMAND_WORD; assertEquals(expected, addCommand.getCommandString()); } /** - * A default model stub that have all of the methods failing. + * A default model stub that have all the methods failing. */ private class ModelStub implements Model { @Override diff --git a/src/test/java/seedu/address/logic/commands/ClearCommandTest.java b/src/test/java/seedu/address/logic/commands/ClearCommandTest.java index d56780d0403..02aeb7ed6c9 100644 --- a/src/test/java/seedu/address/logic/commands/ClearCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/ClearCommandTest.java @@ -32,7 +32,7 @@ public void execute_nonEmptyAddressBook_success() { } @Test - public void getCommandStringTest() { + public void getCommandString_returnsCommandString() { ClearCommand clearCommand = new ClearCommand(); String expected = ClearCommand.COMMAND_WORD; assertEquals(expected, clearCommand.getCommandString()); diff --git a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java b/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java index 9930c15c124..533d0190092 100644 --- a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java @@ -111,7 +111,7 @@ public void toStringMethod() { } @Test - public void getCommandStringTest() { + public void getCommandString_returnsCommandString() { DeleteCommand deleteCommand = new DeleteCommand(INDEX_FIRST_PERSON); String expected = DeleteCommand.COMMAND_WORD; assertEquals(expected, deleteCommand.getCommandString()); diff --git a/src/test/java/seedu/address/logic/commands/DisplayCommandTest.java b/src/test/java/seedu/address/logic/commands/DisplayCommandTest.java index b6fb9014ca6..43c0ad289b9 100644 --- a/src/test/java/seedu/address/logic/commands/DisplayCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/DisplayCommandTest.java @@ -94,7 +94,7 @@ public void getPerson_success() { } @Test - public void getCommandStringTest() { + public void getCommandString_returnsCommandString() { NameContainsKeywordsPredicate predicate = preparePredicate("Kurz Elle Kunz"); DisplayCommand displayCommand = new DisplayCommand(predicate); String expected = DisplayCommand.COMMAND_WORD; diff --git a/src/test/java/seedu/address/logic/commands/ExitCommandTest.java b/src/test/java/seedu/address/logic/commands/ExitCommandTest.java index a905d06424e..047bc5eb4fe 100644 --- a/src/test/java/seedu/address/logic/commands/ExitCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/ExitCommandTest.java @@ -20,7 +20,7 @@ public void execute_exit_success() { } @Test - public void getCommandStringTest() { + public void getCommandString_returnsCommandString() { ExitCommand exitCommand = new ExitCommand(); String expected = ExitCommand.COMMAND_WORD; assertEquals(expected, exitCommand.getCommandString()); diff --git a/src/test/java/seedu/address/logic/commands/FindCommandTest.java b/src/test/java/seedu/address/logic/commands/FindCommandTest.java index 79ad69b29ee..3557b41e6d3 100644 --- a/src/test/java/seedu/address/logic/commands/FindCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/FindCommandTest.java @@ -89,7 +89,7 @@ public void execute_multipleParameters() throws ParseException { } @Test - public void getCommandStringTest() throws ParseException { + public void getCommandString_returnsCommandString() throws ParseException { FindCommand findCommand = parser.parse("find n/Kurz"); String expected = FindCommand.COMMAND_WORD; assertEquals(expected, findCommand.getCommandString()); diff --git a/src/test/java/seedu/address/logic/commands/HelpCommandTest.java b/src/test/java/seedu/address/logic/commands/HelpCommandTest.java index 024fc892365..b4ba150c96d 100644 --- a/src/test/java/seedu/address/logic/commands/HelpCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/HelpCommandTest.java @@ -20,7 +20,7 @@ public void execute_help_success() { } @Test - public void getCommandStringTest() { + public void getCommandString_returnsCommandString() { HelpCommand helpCommand = new HelpCommand(); String expected = HelpCommand.COMMAND_WORD; assertEquals(expected, helpCommand.getCommandString()); diff --git a/src/test/java/seedu/address/logic/commands/ListCommandTest.java b/src/test/java/seedu/address/logic/commands/ListCommandTest.java index 5e337a92c8a..e55fa11f304 100644 --- a/src/test/java/seedu/address/logic/commands/ListCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/ListCommandTest.java @@ -40,7 +40,7 @@ public void execute_listIsFiltered_showsEverything() { } @Test - public void getCommandStringTest() { + public void getCommandString_returnsCommandString() { ListCommand listCommand = new ListCommand(); String expected = ListCommand.COMMAND_WORD; assertEquals(expected, listCommand.getCommandString()); diff --git a/src/test/java/seedu/address/logic/commands/RedoCommandIntegrationTest.java b/src/test/java/seedu/address/logic/commands/RedoCommandIntegrationTest.java index c3f8869b1bc..9da03f7bc05 100644 --- a/src/test/java/seedu/address/logic/commands/RedoCommandIntegrationTest.java +++ b/src/test/java/seedu/address/logic/commands/RedoCommandIntegrationTest.java @@ -34,12 +34,12 @@ void setUp() { } @Test - void executeFailure() { + void execute_redoStartState_commandFailure() { assertCommandFailure(new RedoCommand(), model, RedoCommand.MESSAGE_NO_ROLLFORWARD); } @Test - void executeAddCommandSuccess() { + void execute_redoAddCommand_commandSuccess() { try { Person validPerson = new PersonBuilder().build(); AddCommand addCommand = new AddCommand(validPerson); @@ -64,7 +64,7 @@ void executeAddCommandSuccess() { } @Test - void executeClearCommandSuccess() { + void execute_redoClearCommand_commandSuccess() { try { model = new ModelManager(getTypicalAddressBook(), new UserPrefs(), getTypicalCalendar()); ClearCommand clearCommand = new ClearCommand(); @@ -87,7 +87,7 @@ void executeClearCommandSuccess() { } @Test - void executeFailureRedoTwice() { + void execute_redoTwice_commandFailure() { try { Person validPerson = new PersonBuilder().build(); AddCommand addCommand = new AddCommand(validPerson); diff --git a/src/test/java/seedu/address/logic/commands/RedoCommandTest.java b/src/test/java/seedu/address/logic/commands/RedoCommandTest.java index 999c3514fa6..4a9816af6a3 100644 --- a/src/test/java/seedu/address/logic/commands/RedoCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/RedoCommandTest.java @@ -7,7 +7,7 @@ public class RedoCommandTest { @Test - public void getCommandStringTest() { + public void getCommandString_returnsCommandString() { RedoCommand redoCommand = new RedoCommand(); String expected = RedoCommand.COMMAND_WORD; assertEquals(expected, redoCommand.getCommandString()); diff --git a/src/test/java/seedu/address/logic/commands/ScheduleDeleteCommandTest.java b/src/test/java/seedu/address/logic/commands/ScheduleDeleteCommandTest.java index e99d7ab50cf..f68095e7e0d 100644 --- a/src/test/java/seedu/address/logic/commands/ScheduleDeleteCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/ScheduleDeleteCommandTest.java @@ -73,7 +73,7 @@ public void equals() { } @Test - public void getCommandStringTest() { + public void getCommandString_returnsCommandString() { ScheduleDeleteCommand deleteCommand = new ScheduleDeleteCommand(new Heading(VALID_HEADING_MEETING_WITH_ALICE)); String expected = "schedule " + ScheduleDeleteCommand.COMMAND_WORD; assertEquals(expected, deleteCommand.getCommandString()); diff --git a/src/test/java/seedu/address/logic/commands/StartCommandTest.java b/src/test/java/seedu/address/logic/commands/StartCommandTest.java index 5112f3d6a4a..bd24cd9e686 100644 --- a/src/test/java/seedu/address/logic/commands/StartCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/StartCommandTest.java @@ -17,13 +17,9 @@ public void execute_throwsCommandException() { } @Test - public void getCommandStringTest() { + public void getCommandString_returnsCommandString() { StartCommand startCommand = StartCommand.getStartCommand(); String expected = StartCommand.COMMAND_WORD; assertEquals(expected, startCommand.getCommandString()); } - - public static boolean assertionsDisabled() { - return !StartCommand.class.desiredAssertionStatus(); - } } diff --git a/src/test/java/seedu/address/logic/commands/UndoCommandIntegrationTest.java b/src/test/java/seedu/address/logic/commands/UndoCommandIntegrationTest.java index 538dc733064..b954663c371 100644 --- a/src/test/java/seedu/address/logic/commands/UndoCommandIntegrationTest.java +++ b/src/test/java/seedu/address/logic/commands/UndoCommandIntegrationTest.java @@ -35,12 +35,12 @@ void setUp() { } @Test - void executeFailure() { + void execute_startStateRollback_failure() { assertCommandFailure(new UndoCommand(), model, UndoCommand.MESSAGE_NO_ROLLBACK); } @Test - void executeAddCommandSuccess() { + void execute_undoAddCommand_success() { try { Person validPerson = new PersonBuilder().build(); AddCommand addCommand = new AddCommand(validPerson); @@ -63,7 +63,7 @@ void executeAddCommandSuccess() { } @Test - void executeClearCommandSuccess() { + void execute_undoClearCommand_commandSuccess() { try { model = new ModelManager(getTypicalAddressBook(), new UserPrefs(), getTypicalCalendar()); ClearCommand clearCommand = new ClearCommand(); @@ -84,7 +84,7 @@ void executeClearCommandSuccess() { } @Test - void executeHelpCommandFailure() { + void execute_undoHelpCommand_commandFailure() { try { model = new ModelManager(getTypicalAddressBook(), new UserPrefs(), getTypicalCalendar()); HelpCommand helpCommand = new HelpCommand(); @@ -103,7 +103,7 @@ void executeHelpCommandFailure() { @Test - void executeFailureUndoTwice() { + void execute_undoTwice_throwsCommandException() { try { Person validPerson = new PersonBuilder().build(); AddCommand addCommand = new AddCommand(validPerson); diff --git a/src/test/java/seedu/address/logic/commands/UndoCommandTest.java b/src/test/java/seedu/address/logic/commands/UndoCommandTest.java index 753861561f9..2852dae67b6 100644 --- a/src/test/java/seedu/address/logic/commands/UndoCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/UndoCommandTest.java @@ -7,7 +7,7 @@ public class UndoCommandTest { @Test - public void getCommandStringTest() { + public void getCommandString_returnsCommandString() { UndoCommand undoCommand = new UndoCommand(); String expected = UndoCommand.COMMAND_WORD; assertEquals(expected, undoCommand.getCommandString()); diff --git a/src/test/java/seedu/address/logic/commands/UpdateCommandTest.java b/src/test/java/seedu/address/logic/commands/UpdateCommandTest.java index a7525255143..6c2793d3b70 100644 --- a/src/test/java/seedu/address/logic/commands/UpdateCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/UpdateCommandTest.java @@ -174,7 +174,7 @@ public void toStringMethod() { } @Test - public void getCommandStringTest() { + public void getCommandString_returnsCommandString() { UpdateCommand updateCommand = new UpdateCommand(ALICE.getName(), new UpdateCommand.UpdatePersonDescriptor()); String expected = UpdateCommand.COMMAND_WORD; assertEquals(expected, updateCommand.getCommandString()); From 34555f2556e9a35a2ba5a3aa835f2215ecc271ff Mon Sep 17 00:00:00 2001 From: pjanthony2001 <104015990+pjanthony2001@users.noreply.github.com> Date: Mon, 15 Apr 2024 20:49:25 +0800 Subject: [PATCH 4/4] Remove redundant constant --- src/main/java/seedu/address/logic/Messages.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/seedu/address/logic/Messages.java b/src/main/java/seedu/address/logic/Messages.java index 49784535688..66071e4662b 100644 --- a/src/main/java/seedu/address/logic/Messages.java +++ b/src/main/java/seedu/address/logic/Messages.java @@ -22,7 +22,6 @@ public class Messages { "Multiple values specified for the following single-valued field(s): "; public static final String MESSAGE_DUPLICATE_NAMES = "There are people with the same names in the list"; public static final String MESSAGE_INVALID_EVENT_DISPLAYED_HEADING = "The event heading provided is invalid"; - public static final String MESSAGE_DUPLICATE_HEADINGS = "There are events with the same headings in the list";