Skip to content

Commit

Permalink
Merge pull request #259 from minpyaemoe/branch-update-UG-for-adding-t…
Browse files Browse the repository at this point in the history
…ag-removing-tag

Updating UG for add/remove tag, reminder deadline constraint and amended isSameSpending method
  • Loading branch information
Nanosync committed Nov 10, 2019
2 parents 31c4206 + e324bf9 commit 1611156
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 52 deletions.
7 changes: 5 additions & 2 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ Edits a spending at a specified index in the list. +
* If you are using a different currency, the cost entered may have precision errors as it will be converted to SGD.
****

[NOTE]
In v1.4, this command does not support adding or removing a particular tag from a specific spending. Removing and adding of tags will be available from v2.0 onwards.

*Examples:*

* `edit 1 c/100` +
Expand Down Expand Up @@ -515,12 +518,12 @@ A graph is shown.

=== Adding a reminder: `reminder add`

Adds a reminder to the reminder list. Key information such as deadline and message are recorded.
Adds a reminder to the reminder list when the user enters a new reminder. Key information such as deadline and message are recorded.

*Format:* `reminder add d/DATE m/MESSAGE`

[NOTE]
The date of a deadline must be within 1 year from the current date. MoneyGoWhere will check if the given reminder message and deadline are valid. If it encounters invalid information such as an empty message, the application will display an error.
The date of the deadline in a reminder must be in the future before the end of next year. In other words, MoneyGoWhere will accept dates starting from today until the end of next year as deadlines.

*Examples:*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ public AddReminderCommand parse(String args) throws ParseException {
throw new ParseException(DEADLINE_INVALID_TOO_FAR);
}

if (date.dateValue.isBefore(LocalDate.now())
&& LocalDate.now().getYear() - date.dateValue.getYear() > ParserUtil.DATE_FAR_BEHIND_RANGE) {
if (date.dateValue.isBefore(LocalDate.now())) {
throw new ParseException(DEADLINE_INVALID_FAR_BEHIND);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/moneygowhere/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public class ParserUtil {

public static final String MESSAGE_INVALID_INDEX = "Index is not a non-zero unsigned integer.";
public static final String DATE_INVALID_TOO_FAR = "Date can only be until end of this month.";
public static final String DEADLINE_INVALID_FAR_BEHIND = "Deadline is 1 year behind from now";
public static final String DEADLINE_INVALID_TOO_FAR = "Deadline must be within 1 years from now.";
public static final String DEADLINE_INVALID_FAR_BEHIND = "Deadline must be in the future.";
public static final String DEADLINE_INVALID_TOO_FAR = "Deadline must be before the end of next year.";
public static final int DATE_FAR_FORWARD_RANGE = 1;
public static final int DATE_FAR_BEHIND_RANGE = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public boolean isSameSpending(Spending otherSpending) {

return otherSpending != null
&& otherSpending.getName().equals(getName())
&& (otherSpending.getDate().equals(getDate()) || otherSpending.getRemark().equals(getRemark()));
&& otherSpending.getCost().equals(getCost())
&& otherSpending.getDate().equals(getDate());
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/seedu/moneygowhere/logic/LogicManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ public class LogicManagerTest {

@BeforeEach
public void setUp() {
JsonSpendingBookStorage addressBookStorage =
JsonSpendingBookStorage spendingBookStorage =
new JsonSpendingBookStorage(temporaryFolder.resolve("moneygowhere.json"));
JsonUserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(temporaryFolder.resolve("userPrefs.json"));
StorageManager storage = new StorageManager(addressBookStorage, userPrefsStorage);
StorageManager storage = new StorageManager(spendingBookStorage, userPrefsStorage);
logic = new LogicManager(model, storage);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public class ExportCommandTest {

@BeforeEach
public void setUp() {
JsonSpendingBookStorage addressBookStorage =
JsonSpendingBookStorage spendingBookStorage =
new JsonSpendingBookStorage(temporaryFolder.resolve("moneygowhere.json"));
JsonUserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(temporaryFolder.resolve("userPrefs.json"));
StorageManager storage = new StorageManager(addressBookStorage, userPrefsStorage);
StorageManager storage = new StorageManager(spendingBookStorage, userPrefsStorage);
Model model = new ModelManager(getTypicalSpendingBook(), new UserPrefs());
model.setSpendingBookFilePath(temporaryFolder.resolve("moneygowhere.json"));
logic = new LogicManager(model, storage);
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/seedu/moneygowhere/model/ModelManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ public void setUserPrefs_nullUserPrefs_throwsNullPointerException() {
@Test
public void setUserPrefs_validUserPrefs_copiesUserPrefs() {
UserPrefs userPrefs = new UserPrefs();
userPrefs.setSpendingBookFilePath(Paths.get("address/book/file/path"));
userPrefs.setSpendingBookFilePath(Paths.get("spending/book/file/path"));
userPrefs.setGuiSettings(new GuiSettings(1, 2, 3, 4));
modelManager.setUserPrefs(userPrefs);
assertEquals(userPrefs, modelManager.getUserPrefs());

// Modifying userPrefs should not modify modelManager's userPrefs
UserPrefs oldUserPrefs = new UserPrefs(userPrefs);
userPrefs.setSpendingBookFilePath(Paths.get("new/address/book/file/path"));
userPrefs.setSpendingBookFilePath(Paths.get("new/spending/book/file/path"));
assertEquals(oldUserPrefs, modelManager.getUserPrefs());
}

Expand All @@ -72,7 +72,7 @@ public void setAddressBookFilePath_nullPath_throwsNullPointerException() {

@Test
public void setAddressBookFilePath_validPath_setsAddressBookFilePath() {
Path path = Paths.get("address/book/file/path");
Path path = Paths.get("spending/book/file/path");
modelManager.setSpendingBookFilePath(path);
assertEquals(path, modelManager.getSpendingBookFilePath());
}
Expand Down Expand Up @@ -143,7 +143,7 @@ public void equals() {
// different types -> returns false
assertFalse(modelManager.equals(5));

// different addressBook -> returns false
// different spendingBook -> returns false
assertFalse(modelManager.equals(new ModelManager(differentSpendingBook, userPrefs)));

// different filteredList -> returns false
Expand Down
52 changes: 26 additions & 26 deletions src/test/java/seedu/moneygowhere/model/SpendingBookTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.moneygowhere.logic.commands.CommandTestUtil.VALID_COST_BOB;
import static seedu.moneygowhere.logic.commands.CommandTestUtil.VALID_REMARK_BOB;
import static seedu.moneygowhere.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND;
import static seedu.moneygowhere.testutil.Assert.assertThrows;
import static seedu.moneygowhere.testutil.TypicalSpendings.APPLE;
Expand Down Expand Up @@ -34,85 +34,85 @@

public class SpendingBookTest {

private final SpendingBook addressBook = new SpendingBook();
private final SpendingBook spendingBook = new SpendingBook();

@Test
public void constructor() {
assertEquals(Collections.emptyList(), addressBook.getSpendingList());
assertEquals(Collections.emptyList(), addressBook.getReminderList());
assertEquals(new Budget(1000), addressBook.getBudget());
assertEquals(Collections.emptyList(), spendingBook.getSpendingList());
assertEquals(Collections.emptyList(), spendingBook.getReminderList());
assertEquals(new Budget(1000), spendingBook.getBudget());
}

@Test
public void resetData_null_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> addressBook.resetData(null));
assertThrows(NullPointerException.class, () -> spendingBook.resetData(null));
}

@Test
public void resetData_withValidReadOnlyAddressBook_replacesData() {
SpendingBook newData = getTypicalSpendingBook();
addressBook.resetData(newData);
assertEquals(newData, addressBook);
spendingBook.resetData(newData);
assertEquals(newData, spendingBook);
}

@Test
public void hasSpending_nullSpending_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> addressBook.hasSpending(null));
assertThrows(NullPointerException.class, () -> spendingBook.hasSpending(null));
}

@Test
public void hasReminder_nullReminder_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> addressBook.hasReminder(null));
assertThrows(NullPointerException.class, () -> spendingBook.hasReminder(null));
}

@Test
public void hasSpending_spendingNotInAddressBook_returnsFalse() {
assertFalse(addressBook.hasSpending(APPLE));
assertFalse(spendingBook.hasSpending(APPLE));
}

@Test
public void hasReminder_reminderNotInAddressBook_returnsFalse() {
assertFalse(addressBook.hasReminder(BILL_REMINDER));
assertFalse(spendingBook.hasReminder(BILL_REMINDER));
}

@Test
public void hasSpending_spendingInAddressBook_returnsTrue() {
addressBook.addSpending(APPLE);
assertTrue(addressBook.hasSpending(APPLE));
spendingBook.addSpending(APPLE);
assertTrue(spendingBook.hasSpending(APPLE));

List<Spending> spendings = new ArrayList<>(Arrays.asList(BANANA, CATFOOD, DESSERT));
addressBook.addSpending(spendings);
spendingBook.addSpending(spendings);

assertTrue(addressBook.hasSpending(BANANA));
assertTrue(addressBook.hasSpending(CATFOOD));
assertTrue(addressBook.hasSpending(DESSERT));
assertTrue(spendingBook.hasSpending(BANANA));
assertTrue(spendingBook.hasSpending(CATFOOD));
assertTrue(spendingBook.hasSpending(DESSERT));

}

@Test
public void hasReminder_reminderInAddressBook_returnsTrue() {
addressBook.addReminder(BILL_REMINDER);
assertTrue(addressBook.hasReminder(BILL_REMINDER));
spendingBook.addReminder(BILL_REMINDER);
assertTrue(spendingBook.hasReminder(BILL_REMINDER));
}

@Test
public void hasSpending_spendingWithSameIdentityFieldsInAddressBook_returnsTrue() {
addressBook.addSpending(APPLE);
Spending editedAlice = new SpendingBuilder(APPLE).withCost(VALID_COST_BOB).withTags(VALID_TAG_HUSBAND)
spendingBook.addSpending(APPLE);
Spending editedAlice = new SpendingBuilder(APPLE).withRemark(VALID_REMARK_BOB).withTags(VALID_TAG_HUSBAND)
.build();
assertTrue(addressBook.hasSpending(editedAlice));
assertTrue(spendingBook.hasSpending(editedAlice));
}

@Test
public void getSpendingList_modifyList_throwsUnsupportedOperationException() {
assertThrows(UnsupportedOperationException.class, () -> addressBook.getSpendingList().remove(0));
assertThrows(UnsupportedOperationException.class, () -> spendingBook.getSpendingList().remove(0));
}

@Test
public void setBudget_validInput_success() {
Budget budget = new Budget(1000);
addressBook.setBudget(budget);
assertTrue(addressBook.getBudget().equals(budget));
spendingBook.setBudget(budget);
assertTrue(spendingBook.getBudget().equals(budget));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ public void isSameSpending() {
.withTags(VALID_TAG_HUSBAND).build();
assertTrue(APPLE.isSameSpending(editedAlice));

// same name, same remark, different attributes -> returns true
editedAlice = new SpendingBuilder(APPLE).withDate(VALID_DATE_BOB)
.withTags(VALID_TAG_HUSBAND).build();
assertTrue(APPLE.isSameSpending(editedAlice));

// same name, same date, same remark, different attributes -> returns true
editedAlice = new SpendingBuilder(APPLE).withTags(VALID_TAG_HUSBAND).build();
assertTrue(APPLE.isSameSpending(editedAlice));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,23 @@ public void readAndSaveAddressBook_allInOrder_success() throws Exception {

@Test
public void saveAddressBook_nullAddressBook_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> saveAddressBook(null, "SomeFile.json"));
assertThrows(NullPointerException.class, () -> saveSpendingBook(null, "SomeFile.json"));
}

/**
* Saves {@code addressBook} at the specified {@code filePath}.
*/
private void saveAddressBook(ReadOnlySpendingBook addressBook, String filePath) {
private void saveSpendingBook(ReadOnlySpendingBook spendingBook, String filePath) {
try {
new JsonSpendingBookStorage(Paths.get(filePath))
.saveSpendingBook(addressBook, addToTestDataPathIfNotNull(filePath));
.saveSpendingBook(spendingBook, 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 SpendingBook(), null));
assertThrows(NullPointerException.class, () -> saveSpendingBook(new SpendingBook(), null));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public EditSpendingDescriptorBuilder withRemark(String remark) {
/**
* Sets the {@code Cost} of the {@code EditPersonDescriptor} that we are building.
*/
public EditSpendingDescriptorBuilder withCost(String address) {
descriptor.setCost(new Cost(address));
public EditSpendingDescriptorBuilder withCost(String cost) {
descriptor.setCost(new Cost(cost));
return this;
}

Expand Down

0 comments on commit 1611156

Please sign in to comment.