diff --git a/src/main/java/seedu/lovebook/MainApp.java b/src/main/java/seedu/lovebook/MainApp.java index ffc1b70a82e..14e427e74f4 100644 --- a/src/main/java/seedu/lovebook/MainApp.java +++ b/src/main/java/seedu/lovebook/MainApp.java @@ -201,6 +201,7 @@ public void stop() { logger.info("============================ [ Stopping Height Book ] ============================="); try { storage.saveUserPrefs(model.getUserPrefs()); + storage.saveDatePrefs(model.getDatePrefs()); } catch (IOException e) { logger.severe("Failed to save preferences " + StringUtil.getDetails(e)); } diff --git a/src/main/java/seedu/lovebook/model/DatePrefs.java b/src/main/java/seedu/lovebook/model/DatePrefs.java index 886c4f50b01..97dbad46efb 100644 --- a/src/main/java/seedu/lovebook/model/DatePrefs.java +++ b/src/main/java/seedu/lovebook/model/DatePrefs.java @@ -2,10 +2,7 @@ import static java.util.Objects.requireNonNull; -import java.util.Date; -import java.util.List; import java.util.Objects; -import java.util.prefs.Preferences; import seedu.lovebook.commons.util.ToStringBuilder; import seedu.lovebook.model.person.Age; @@ -13,12 +10,18 @@ import seedu.lovebook.model.person.Height; import seedu.lovebook.model.person.Income; +/** + * Represents the preferences of the user for a date. + */ public class DatePrefs implements ReadOnlyDatePrefs { private Age age; private Gender gender; private Height height; private Income income; + /** + * Creates a {@code DatePrefs} with default values. + */ public DatePrefs() { this.age = new Age("21"); this.gender = new Gender("F"); @@ -26,6 +29,9 @@ public DatePrefs() { this.income = new Income("10000"); } + /** + * Creates a {@code DatePrefs} with the given values. + */ public DatePrefs(Age age, Gender gender, Height height, Income income) { this.age = age; this.gender = gender; @@ -33,6 +39,9 @@ public DatePrefs(Age age, Gender gender, Height height, Income income) { this.income = income; } + /** + * Creates a {@code DatePrefs} with the given values. + */ public DatePrefs(ReadOnlyDatePrefs toBeCopied) { this(); resetData(toBeCopied); diff --git a/src/main/java/seedu/lovebook/model/LoveBook.java b/src/main/java/seedu/lovebook/model/LoveBook.java index ff7bcec335e..1926e49358e 100644 --- a/src/main/java/seedu/lovebook/model/LoveBook.java +++ b/src/main/java/seedu/lovebook/model/LoveBook.java @@ -53,7 +53,6 @@ public void setPersons(List dates) { */ public void resetData(ReadOnlyLoveBook newData) { requireNonNull(newData); - setPersons(newData.getPersonList()); } @@ -82,7 +81,6 @@ public void addPerson(Date p) { */ public void setPerson(Date target, Date editedDate) { requireNonNull(editedDate); - dates.setPerson(target, editedDate); } diff --git a/src/main/java/seedu/lovebook/model/ReadOnlyDatePrefs.java b/src/main/java/seedu/lovebook/model/ReadOnlyDatePrefs.java index e1d532a658f..d4c45aac07c 100644 --- a/src/main/java/seedu/lovebook/model/ReadOnlyDatePrefs.java +++ b/src/main/java/seedu/lovebook/model/ReadOnlyDatePrefs.java @@ -1,5 +1,8 @@ package seedu.lovebook.model; +/** + * Unmodifiable view of date preferences. + */ public interface ReadOnlyDatePrefs { DatePrefs getPreferences(); } diff --git a/src/main/java/seedu/lovebook/model/util/SampleDatePrefUtil.java b/src/main/java/seedu/lovebook/model/util/SampleDatePrefUtil.java index 810ebc085cd..367fc4a728c 100644 --- a/src/main/java/seedu/lovebook/model/util/SampleDatePrefUtil.java +++ b/src/main/java/seedu/lovebook/model/util/SampleDatePrefUtil.java @@ -6,6 +6,9 @@ import seedu.lovebook.model.person.Height; import seedu.lovebook.model.person.Income; +/** + * A utility class containing a sample {@code DatePrefs} to be used in tests. + */ public class SampleDatePrefUtil { public static DatePrefs getSamplePreferences() { Age age = new Age("20"); diff --git a/src/main/java/seedu/lovebook/storage/DatePrefsStorage.java b/src/main/java/seedu/lovebook/storage/DatePrefsStorage.java index 65d935fec45..45876d48e3e 100644 --- a/src/main/java/seedu/lovebook/storage/DatePrefsStorage.java +++ b/src/main/java/seedu/lovebook/storage/DatePrefsStorage.java @@ -7,6 +7,9 @@ import seedu.lovebook.commons.exceptions.DataLoadingException; import seedu.lovebook.model.ReadOnlyDatePrefs; +/** + * Represents a storage for {@link seedu.lovebook.model.DatePrefs}. + */ public interface DatePrefsStorage { /** * Returns the file path of the data file. diff --git a/src/main/java/seedu/lovebook/storage/JsonAdaptedDatePrefs.java b/src/main/java/seedu/lovebook/storage/JsonAdaptedDatePrefs.java index 69f1b1b702f..4b766bcdd6b 100644 --- a/src/main/java/seedu/lovebook/storage/JsonAdaptedDatePrefs.java +++ b/src/main/java/seedu/lovebook/storage/JsonAdaptedDatePrefs.java @@ -4,13 +4,16 @@ import com.fasterxml.jackson.annotation.JsonProperty; import seedu.lovebook.commons.exceptions.IllegalValueException; +import seedu.lovebook.model.DatePrefs; import seedu.lovebook.model.person.Age; import seedu.lovebook.model.person.Date; import seedu.lovebook.model.person.Gender; import seedu.lovebook.model.person.Height; import seedu.lovebook.model.person.Income; -import seedu.lovebook.model.DatePrefs; +/** + * Jackson-friendly version of {@link DatePrefs}. + */ public class JsonAdaptedDatePrefs { public static final String MISSING_FIELD_MESSAGE_FORMAT = "Date's %s field is missing!"; private String age; diff --git a/src/main/java/seedu/lovebook/storage/JsonLoveBookDatePrefs.java b/src/main/java/seedu/lovebook/storage/JsonLoveBookDatePrefs.java index cd60f5271de..c08b2b0dd5b 100644 --- a/src/main/java/seedu/lovebook/storage/JsonLoveBookDatePrefs.java +++ b/src/main/java/seedu/lovebook/storage/JsonLoveBookDatePrefs.java @@ -14,6 +14,9 @@ import seedu.lovebook.commons.util.JsonUtil; import seedu.lovebook.model.ReadOnlyDatePrefs; +/** + * A class to access DatePrefs data stored as a json file on the hard disk. + */ public class JsonLoveBookDatePrefs implements DatePrefsStorage { private static final Logger logger = LogsCenter.getLogger(JsonLoveBookDatePrefs.class); diff --git a/src/main/java/seedu/lovebook/storage/JsonSerializableDatePrefs.java b/src/main/java/seedu/lovebook/storage/JsonSerializableDatePrefs.java index 84e8493338d..ab2009618a8 100644 --- a/src/main/java/seedu/lovebook/storage/JsonSerializableDatePrefs.java +++ b/src/main/java/seedu/lovebook/storage/JsonSerializableDatePrefs.java @@ -1,22 +1,23 @@ package seedu.lovebook.storage; -import java.util.List; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonRootName; -import seedu.lovebook.commons.exceptions.IllegalValueException; -import seedu.lovebook.model.ReadOnlyDatePrefs; +import seedu.lovebook.commons.exceptions.IllegalValueException; import seedu.lovebook.model.DatePrefs; +import seedu.lovebook.model.ReadOnlyDatePrefs; +/** + * An Immutable DatePrefs that is serializable to JSON format. + */ @JsonRootName(value = "DatePrefs") public class JsonSerializableDatePrefs { private JsonAdaptedDatePrefs jsonDatePrefs; private DatePrefs datePrefs; /** - * Constructs a {@code JsonSerializableLoveBook} with the given dates. + * Constructs a {@code JsonSerializableDatePrefs} with the given preferences. */ @JsonCreator public JsonSerializableDatePrefs(@JsonProperty("prefs") JsonAdaptedDatePrefs prefs) { @@ -24,16 +25,16 @@ public JsonSerializableDatePrefs(@JsonProperty("prefs") JsonAdaptedDatePrefs pre } /** - * Converts a given {@code ReadOnlyLoveBook} into this class for Jackson use. + * Converts a given {@code ReadyOnlyDatePrefs} into this class for Jackson use. * - * @param source future changes to this will not affect the created {@code JsonSerializableLoveBook}. + * @param source future changes to this will not affect the created {@code JsonSerializableDatePrefs}. */ public JsonSerializableDatePrefs(ReadOnlyDatePrefs source) { datePrefs = source.getPreferences(); } /** - * Converts this lovebook book into the model's {@code LoveBook} object. + * Converts these preferences into the model's {@code Preferences} object. * * @throws IllegalValueException if there were any data constraints violated. */ diff --git a/src/main/java/seedu/lovebook/storage/StorageManager.java b/src/main/java/seedu/lovebook/storage/StorageManager.java index ca740334ee9..db3d5cbb721 100644 --- a/src/main/java/seedu/lovebook/storage/StorageManager.java +++ b/src/main/java/seedu/lovebook/storage/StorageManager.java @@ -23,14 +23,19 @@ public class StorageManager implements Storage { private DatePrefsStorage datePrefsStorage; /** - * Creates a {@code StorageManager} with the given {@code LoveBookStorage} and {@code UserPrefStorage}. + * Creates a {@code StorageManager} with the given {@code LoveBookStorage} and {@code UserPrefStorage} + * and {@code DatePrefsStorage}. */ - public StorageManager(LoveBookStorage loveBookStorage, UserPrefsStorage userPrefsStorage, DatePrefsStorage datePrefsStorage) { + public StorageManager(LoveBookStorage loveBookStorage, UserPrefsStorage userPrefsStorage, + DatePrefsStorage datePrefsStorage) { this.loveBookStorage = loveBookStorage; this.userPrefsStorage = userPrefsStorage; this.datePrefsStorage = datePrefsStorage; } + /** + * Creates a {@code StorageManager} with the given {@code LoveBookStorage} and {@code UserPrefStorage}. + */ public StorageManager(LoveBookStorage loveBookStorage, UserPrefsStorage userPrefsStorage) { this.loveBookStorage = loveBookStorage; this.userPrefsStorage = userPrefsStorage; @@ -86,7 +91,7 @@ public void saveLoveBook(ReadOnlyLoveBook loveBook, Path filePath) throws IOExce // ================ DatePrefs Methods ============================== @Override public Path getDatePrefsFilePath() { - return loveBookStorage.getLoveBookFilePath(); + return datePrefsStorage.getDatePrefsFilePath(); } @Override @@ -102,7 +107,7 @@ public Optional readDatePrefs(Path filePath) throws DataLoadi @Override public void saveDatePrefs(ReadOnlyDatePrefs loveBook) throws IOException { - saveDatePrefs(loveBook, loveBookStorage.getLoveBookFilePath()); + saveDatePrefs(loveBook, getDatePrefsFilePath()); } @Override diff --git a/src/test/java/seedu/lovebook/logic/LogicManagerTest.java b/src/test/java/seedu/lovebook/logic/LogicManagerTest.java index fbdd6028d1b..92fb081dfe3 100644 --- a/src/test/java/seedu/lovebook/logic/LogicManagerTest.java +++ b/src/test/java/seedu/lovebook/logic/LogicManagerTest.java @@ -131,7 +131,7 @@ private void assertCommandException(String inputCommand, String expectedMessage) */ private void assertCommandFailure(String inputCommand, Class expectedException, String expectedMessage) { - Model expectedModel = new ModelManager(model.getLoveBook(), new UserPrefs()); + Model expectedModel = new ModelManager(model.getLoveBook(), new UserPrefs(), model.getDatePrefs()); assertCommandFailure(inputCommand, expectedException, expectedMessage, expectedModel); } diff --git a/src/test/java/seedu/lovebook/logic/commands/AddCommandIntegrationTest.java b/src/test/java/seedu/lovebook/logic/commands/AddCommandIntegrationTest.java index 7f832f690e9..f559b924b98 100644 --- a/src/test/java/seedu/lovebook/logic/commands/AddCommandIntegrationTest.java +++ b/src/test/java/seedu/lovebook/logic/commands/AddCommandIntegrationTest.java @@ -2,6 +2,7 @@ import static seedu.lovebook.logic.commands.CommandTestUtil.assertCommandFailure; import static seedu.lovebook.logic.commands.CommandTestUtil.assertCommandSuccess; +import static seedu.lovebook.testutil.TypicalDatePrefs.getTypicalDatePrefs; import static seedu.lovebook.testutil.TypicalPersons.getTypicalLoveBook; import org.junit.jupiter.api.BeforeEach; @@ -23,14 +24,14 @@ public class AddCommandIntegrationTest { @BeforeEach public void setUp() { - model = new ModelManager(getTypicalLoveBook(), new UserPrefs()); + model = new ModelManager(getTypicalLoveBook(), new UserPrefs(), getTypicalDatePrefs()); } @Test public void execute_newPerson_success() { Date validDate = new PersonBuilder().build(); - Model expectedModel = new ModelManager(model.getLoveBook(), new UserPrefs()); + Model expectedModel = new ModelManager(model.getLoveBook(), new UserPrefs(), model.getDatePrefs()); expectedModel.addPerson(validDate); assertCommandSuccess(new AddCommand(validDate), model, diff --git a/src/test/java/seedu/lovebook/logic/commands/AddCommandTest.java b/src/test/java/seedu/lovebook/logic/commands/AddCommandTest.java index 95c92ca3630..81a2ea17275 100644 --- a/src/test/java/seedu/lovebook/logic/commands/AddCommandTest.java +++ b/src/test/java/seedu/lovebook/logic/commands/AddCommandTest.java @@ -18,8 +18,10 @@ import seedu.lovebook.commons.core.GuiSettings; import seedu.lovebook.logic.Messages; import seedu.lovebook.logic.commands.exceptions.CommandException; +import seedu.lovebook.model.DatePrefs; import seedu.lovebook.model.LoveBook; import seedu.lovebook.model.Model; +import seedu.lovebook.model.ReadOnlyDatePrefs; import seedu.lovebook.model.ReadOnlyLoveBook; import seedu.lovebook.model.ReadOnlyUserPrefs; import seedu.lovebook.model.person.Date; @@ -162,6 +164,26 @@ public void updateFilteredPersonList(Predicate predicate) { public String getWelcomeMessage() { throw new AssertionError("This method should not be called."); } + + @Override + public DatePrefs getDatePrefs() { + throw new AssertionError("This method should not be called."); + } + + @Override + public void setDatePrefs(ReadOnlyDatePrefs datePrefs) { + throw new AssertionError("This method should not be called."); + } + + @Override + public Path getDatePrefsFilePath() { + throw new AssertionError("This method should not be called."); + } + + @Override + public void setDatePrefsFilePath(Path datePrefsFilePath) { + throw new AssertionError("This method should not be called."); + } } /** diff --git a/src/test/java/seedu/lovebook/logic/commands/ClearCommandTest.java b/src/test/java/seedu/lovebook/logic/commands/ClearCommandTest.java index 73903cdad4d..2c4e106aae1 100644 --- a/src/test/java/seedu/lovebook/logic/commands/ClearCommandTest.java +++ b/src/test/java/seedu/lovebook/logic/commands/ClearCommandTest.java @@ -1,6 +1,7 @@ package seedu.lovebook.logic.commands; import static seedu.lovebook.logic.commands.CommandTestUtil.assertCommandSuccess; +import static seedu.lovebook.testutil.TypicalDatePrefs.getTypicalDatePrefs; import static seedu.lovebook.testutil.TypicalPersons.getTypicalLoveBook; import org.junit.jupiter.api.Test; @@ -22,8 +23,8 @@ public void execute_emptyLoveBook_success() { @Test public void execute_nonEmptyLoveBook_success() { - Model model = new ModelManager(getTypicalLoveBook(), new UserPrefs()); - Model expectedModel = new ModelManager(getTypicalLoveBook(), new UserPrefs()); + Model model = new ModelManager(getTypicalLoveBook(), new UserPrefs(), getTypicalDatePrefs()); + Model expectedModel = new ModelManager(getTypicalLoveBook(), new UserPrefs(), getTypicalDatePrefs()); expectedModel.setLoveBook(new LoveBook()); assertCommandSuccess(new ClearCommand(), model, ClearCommand.MESSAGE_SUCCESS, expectedModel); diff --git a/src/test/java/seedu/lovebook/logic/commands/DeleteCommandTest.java b/src/test/java/seedu/lovebook/logic/commands/DeleteCommandTest.java index e2dbbcf2c2b..a39257e50e9 100644 --- a/src/test/java/seedu/lovebook/logic/commands/DeleteCommandTest.java +++ b/src/test/java/seedu/lovebook/logic/commands/DeleteCommandTest.java @@ -6,6 +6,7 @@ import static seedu.lovebook.logic.commands.CommandTestUtil.assertCommandFailure; import static seedu.lovebook.logic.commands.CommandTestUtil.assertCommandSuccess; import static seedu.lovebook.logic.commands.CommandTestUtil.showPersonAtIndex; +import static seedu.lovebook.testutil.TypicalDatePrefs.getTypicalDatePrefs; import static seedu.lovebook.testutil.TypicalIndexes.INDEX_FIRST_PERSON; import static seedu.lovebook.testutil.TypicalIndexes.INDEX_SECOND_PERSON; import static seedu.lovebook.testutil.TypicalPersons.getTypicalLoveBook; @@ -25,7 +26,7 @@ */ public class DeleteCommandTest { - private Model model = new ModelManager(getTypicalLoveBook(), new UserPrefs()); + private Model model = new ModelManager(getTypicalLoveBook(), new UserPrefs(), getTypicalDatePrefs()); @Test public void execute_validIndexUnfilteredList_success() { @@ -35,7 +36,7 @@ public void execute_validIndexUnfilteredList_success() { String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(dateToDelete)); - ModelManager expectedModel = new ModelManager(model.getLoveBook(), new UserPrefs()); + ModelManager expectedModel = new ModelManager(model.getLoveBook(), new UserPrefs(), model.getDatePrefs()); expectedModel.deletePerson(dateToDelete); assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); @@ -59,7 +60,7 @@ public void execute_validIndexFilteredList_success() { String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(dateToDelete)); - Model expectedModel = new ModelManager(model.getLoveBook(), new UserPrefs()); + Model expectedModel = new ModelManager(model.getLoveBook(), new UserPrefs(), model.getDatePrefs()); expectedModel.deletePerson(dateToDelete); showNoPerson(expectedModel); diff --git a/src/test/java/seedu/lovebook/logic/commands/EditCommandTest.java b/src/test/java/seedu/lovebook/logic/commands/EditCommandTest.java index f81e859bf82..944e683aade 100644 --- a/src/test/java/seedu/lovebook/logic/commands/EditCommandTest.java +++ b/src/test/java/seedu/lovebook/logic/commands/EditCommandTest.java @@ -11,6 +11,7 @@ import static seedu.lovebook.logic.commands.CommandTestUtil.assertCommandFailure; import static seedu.lovebook.logic.commands.CommandTestUtil.assertCommandSuccess; import static seedu.lovebook.logic.commands.CommandTestUtil.showPersonAtIndex; +import static seedu.lovebook.testutil.TypicalDatePrefs.getTypicalDatePrefs; import static seedu.lovebook.testutil.TypicalIndexes.INDEX_FIRST_PERSON; import static seedu.lovebook.testutil.TypicalIndexes.INDEX_SECOND_PERSON; import static seedu.lovebook.testutil.TypicalPersons.getTypicalLoveBook; @@ -33,7 +34,7 @@ */ public class EditCommandTest { - private Model model = new ModelManager(getTypicalLoveBook(), new UserPrefs()); + private Model model = new ModelManager(getTypicalLoveBook(), new UserPrefs(), getTypicalDatePrefs()); @Test public void execute_allFieldsSpecifiedUnfilteredList_success() { @@ -43,7 +44,8 @@ public void execute_allFieldsSpecifiedUnfilteredList_success() { String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedDate)); - Model expectedModel = new ModelManager(new LoveBook(model.getLoveBook()), new UserPrefs()); + Model expectedModel = new ModelManager(new LoveBook(model.getLoveBook()), new UserPrefs(), + model.getDatePrefs()); expectedModel.setPerson(model.getFilteredPersonList().get(0), editedDate); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); @@ -64,7 +66,8 @@ public void execute_someFieldsSpecifiedUnfilteredList_success() { String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedDate)); - Model expectedModel = new ModelManager(new LoveBook(model.getLoveBook()), new UserPrefs()); + Model expectedModel = new ModelManager(new LoveBook(model.getLoveBook()), new UserPrefs(), + model.getDatePrefs()); expectedModel.setPerson(lastDate, editedDate); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); @@ -77,7 +80,8 @@ public void execute_noFieldSpecifiedUnfilteredList_success() { String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedDate)); - Model expectedModel = new ModelManager(new LoveBook(model.getLoveBook()), new UserPrefs()); + Model expectedModel = new ModelManager(new LoveBook(model.getLoveBook()), new UserPrefs(), + model.getDatePrefs()); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); } @@ -93,7 +97,8 @@ public void execute_filteredList_success() { String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedDate)); - Model expectedModel = new ModelManager(new LoveBook(model.getLoveBook()), new UserPrefs()); + Model expectedModel = new ModelManager(new LoveBook(model.getLoveBook()), new UserPrefs(), + model.getDatePrefs()); expectedModel.setPerson(model.getFilteredPersonList().get(0), editedDate); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); diff --git a/src/test/java/seedu/lovebook/logic/commands/FindCommandTest.java b/src/test/java/seedu/lovebook/logic/commands/FindCommandTest.java index bca942bab51..5b0aceb8be8 100644 --- a/src/test/java/seedu/lovebook/logic/commands/FindCommandTest.java +++ b/src/test/java/seedu/lovebook/logic/commands/FindCommandTest.java @@ -5,6 +5,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.lovebook.logic.Messages.MESSAGE_PERSONS_LISTED_OVERVIEW; import static seedu.lovebook.logic.commands.CommandTestUtil.assertCommandSuccess; +import static seedu.lovebook.testutil.TypicalDatePrefs.getTypicalDatePrefs; import static seedu.lovebook.testutil.TypicalPersons.CARL; import static seedu.lovebook.testutil.TypicalPersons.ELLE; import static seedu.lovebook.testutil.TypicalPersons.FIONA; @@ -24,8 +25,8 @@ * Contains integration tests (interaction with the Model) for {@code FindCommand}. */ public class FindCommandTest { - private Model model = new ModelManager(getTypicalLoveBook(), new UserPrefs()); - private Model expectedModel = new ModelManager(getTypicalLoveBook(), new UserPrefs()); + private Model model = new ModelManager(getTypicalLoveBook(), new UserPrefs(), getTypicalDatePrefs()); + private Model expectedModel = new ModelManager(getTypicalLoveBook(), new UserPrefs(), getTypicalDatePrefs()); @Test public void equals() { diff --git a/src/test/java/seedu/lovebook/logic/commands/ListCommandTest.java b/src/test/java/seedu/lovebook/logic/commands/ListCommandTest.java index d5ec105bee8..5712a8357be 100644 --- a/src/test/java/seedu/lovebook/logic/commands/ListCommandTest.java +++ b/src/test/java/seedu/lovebook/logic/commands/ListCommandTest.java @@ -2,6 +2,7 @@ import static seedu.lovebook.logic.commands.CommandTestUtil.assertCommandSuccess; import static seedu.lovebook.logic.commands.CommandTestUtil.showPersonAtIndex; +import static seedu.lovebook.testutil.TypicalDatePrefs.getTypicalDatePrefs; import static seedu.lovebook.testutil.TypicalIndexes.INDEX_FIRST_PERSON; import static seedu.lovebook.testutil.TypicalPersons.getTypicalLoveBook; @@ -22,8 +23,8 @@ public class ListCommandTest { @BeforeEach public void setUp() { - model = new ModelManager(getTypicalLoveBook(), new UserPrefs()); - expectedModel = new ModelManager(model.getLoveBook(), new UserPrefs()); + model = new ModelManager(getTypicalLoveBook(), new UserPrefs(), getTypicalDatePrefs()); + expectedModel = new ModelManager(model.getLoveBook(), new UserPrefs(), getTypicalDatePrefs()); } @Test diff --git a/src/test/java/seedu/lovebook/model/ModelManagerTest.java b/src/test/java/seedu/lovebook/model/ModelManagerTest.java index eafecc971a7..3fef006686f 100644 --- a/src/test/java/seedu/lovebook/model/ModelManagerTest.java +++ b/src/test/java/seedu/lovebook/model/ModelManagerTest.java @@ -107,8 +107,8 @@ public void equals() { UserPrefs userPrefs = new UserPrefs(); // same values -> returns true - modelManager = new ModelManager(loveBook, userPrefs); - ModelManager modelManagerCopy = new ModelManager(loveBook, userPrefs); + modelManager = new ModelManager(loveBook, userPrefs, new DatePrefs()); + ModelManager modelManagerCopy = new ModelManager(loveBook, userPrefs, new DatePrefs()); assertTrue(modelManager.equals(modelManagerCopy)); // same object -> returns true @@ -121,12 +121,12 @@ public void equals() { assertFalse(modelManager.equals(5)); // different LoveBook -> returns false - assertFalse(modelManager.equals(new ModelManager(differentLoveBook, userPrefs))); + assertFalse(modelManager.equals(new ModelManager(differentLoveBook, userPrefs, new DatePrefs()))); // different filteredList -> returns false String[] keywords = ALICE.getName().fullName.split("\\s+"); modelManager.updateFilteredPersonList(new NameContainsKeywordsPredicate(Arrays.asList(keywords))); - assertFalse(modelManager.equals(new ModelManager(loveBook, userPrefs))); + assertFalse(modelManager.equals(new ModelManager(loveBook, userPrefs, new DatePrefs()))); // resets modelManager to initial state for upcoming tests modelManager.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); @@ -134,6 +134,6 @@ public void equals() { // different userPrefs -> returns false UserPrefs differentUserPrefs = new UserPrefs(); differentUserPrefs.setLoveBookFilePath(Paths.get("differentFilePath")); - assertFalse(modelManager.equals(new ModelManager(loveBook, differentUserPrefs))); + assertFalse(modelManager.equals(new ModelManager(loveBook, differentUserPrefs, new DatePrefs()))); } } diff --git a/src/test/java/seedu/lovebook/storage/StorageManagerTest.java b/src/test/java/seedu/lovebook/storage/StorageManagerTest.java index f22885a712c..9d087706898 100644 --- a/src/test/java/seedu/lovebook/storage/StorageManagerTest.java +++ b/src/test/java/seedu/lovebook/storage/StorageManagerTest.java @@ -26,7 +26,6 @@ public class StorageManagerTest { public void setUp() { JsonLoveBookStorage loveBookStorage = new JsonLoveBookStorage(getTempFilePath("ab")); JsonUserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(getTempFilePath("prefs")); -// JsonDatePrefsStorageTest datePrefsStorage = new JsonDatePrefsStorageTest(); storageManager = new StorageManager(loveBookStorage, userPrefsStorage); } diff --git a/src/test/java/seedu/lovebook/testutil/TypicalDatePrefs.java b/src/test/java/seedu/lovebook/testutil/TypicalDatePrefs.java new file mode 100644 index 00000000000..0067787d400 --- /dev/null +++ b/src/test/java/seedu/lovebook/testutil/TypicalDatePrefs.java @@ -0,0 +1,14 @@ +package seedu.lovebook.testutil; + +import seedu.lovebook.model.DatePrefs; + +/** + * A utility class containing the default date preferences. + */ +public class TypicalDatePrefs { + private static DatePrefs datePrefs = new DatePrefs(); + + public static DatePrefs getTypicalDatePrefs() { + return datePrefs; + } +}