Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kngys committed Nov 7, 2024
1 parent 886f26c commit a68917e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/test/java/seedu/address/logic/LogicManagerTest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package seedu.address.logic;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static seedu.address.logic.Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX;
import static seedu.address.logic.Messages.MESSAGE_EMPTY_PERSON_LIST;
import static seedu.address.logic.Messages.MESSAGE_UNKNOWN_COMMAND;
import static seedu.address.logic.commands.CommandTestUtil.ADDRESS_DESC_AMY;
import static seedu.address.logic.commands.CommandTestUtil.COMPANY_DESC_AMY;
Expand Down Expand Up @@ -62,7 +62,8 @@ public void execute_invalidCommandFormat_throwsParseException() {
@Test
public void execute_commandExecutionError_throwsCommandException() {
String deleteCommand = "delete 9";
assertCommandException(deleteCommand, MESSAGE_INVALID_PERSON_DISPLAYED_INDEX);
String expectedString = String.format(MESSAGE_EMPTY_PERSON_LIST, "delete");
assertCommandException(deleteCommand, expectedString);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure;
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.address.logic.commands.CommandTestUtil.showEmptyPersonList;
import static seedu.address.logic.commands.CommandTestUtil.showPersonAtIndex;
import static seedu.address.testutil.Assert.assertThrows;
import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON;
Expand Down Expand Up @@ -88,6 +89,23 @@ public void execute_unfilteredList_success() {
assertCommandSuccess(addTransactionCommand, model, expectedMessage, expectedModel);
}

@Test
public void execute_emptyList_throwCommandException() {
showEmptyPersonList(model);

Transaction transactionToAdd = new Transaction("buy raw materials", -100,
"Company ABC", LocalDate.parse("2024-10-15", DateTimeUtil.DEFAULT_DATE_PARSER));

Index outOfBoundIndex = INDEX_FIRST_PERSON;

AddTransactionCommand addTransactionCommand = new AddTransactionCommand(outOfBoundIndex, transactionToAdd);

String expectedMessage = String.format(Messages.MESSAGE_EMPTY_PERSON_LIST, "addt");

assertCommandFailure(addTransactionCommand, model, expectedMessage);

}

@Test
public void execute_invalidIndexFilteredList_throwsCommandException() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,13 @@ public static void showPersonAtIndex(Model model, Index targetIndex) {
assertEquals(1, model.getFilteredPersonList().size());
}

/**
* Updates {@code model}'s filtered list to empty person list in the {@code model}'s address book.
*/
public static void showEmptyPersonList(Model model) {
model.updateFilteredPersonList(new PersonContainsKeywordsPredicate(Arrays.asList("PREDICATE_ALWAYS_FALSE")));
assertEquals(0, model.getFilteredPersonList().size());
}


}

0 comments on commit a68917e

Please sign in to comment.