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 a68917e commit 487882b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/test/java/seedu/address/logic/commands/DeleteCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,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.TypicalIndexes.INDEX_FIRST_PERSON;
import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PERSON;
Expand Down Expand Up @@ -41,6 +42,21 @@ public void execute_validIndexUnfilteredList_success() {
assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel);
}

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


Index outOfBoundIndex = INDEX_FIRST_PERSON;

DeleteCommand deleteCommand = new DeleteCommand(outOfBoundIndex);

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

assertCommandFailure(deleteCommand, model, expectedMessage);

}

@Test
public void execute_invalidIndexUnfilteredList_throwsCommandException() {
Index outOfBoundIndex = Index.fromOneBased(model.getFilteredPersonList().size() + 1);
Expand Down
17 changes: 17 additions & 0 deletions src/test/java/seedu/address/logic/commands/EditCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND;
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.TypicalIndexes.INDEX_FIRST_PERSON;
import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PERSON;
Expand Down Expand Up @@ -108,6 +109,22 @@ public void execute_duplicatePersonUnfilteredList_failure() {
assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_PERSON);
}

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

Index outOfBoundIndex = INDEX_FIRST_PERSON;

Person personInList = model.getAddressBook().getPersonList().get(INDEX_FIRST_PERSON.getZeroBased());
EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON,
new EditPersonDescriptorBuilder(personInList).build());

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

assertCommandFailure(editCommand, model, expectedMessage);

}

@Test
public void execute_duplicatePersonFilteredList_failure() {
showPersonAtIndex(model, INDEX_FIRST_PERSON);
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.TypicalIndexes.INDEX_FIRST_PERSON;
import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PERSON;
Expand Down Expand Up @@ -33,6 +34,20 @@ public void execute_listAllTransactions_success() {
expectedModel);
}

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

Index outOfBoundIndex = INDEX_FIRST_PERSON;

ListTransactionCommand listTransactionCommand = new ListTransactionCommand(outOfBoundIndex);

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

assertCommandFailure(listTransactionCommand, model, expectedMessage);

}

@Test
public void execute_listTransactionsInvalidIndex_throwsCommandException() {
Index outOfBoundIndex = Index.fromOneBased(model.getFilteredPersonList().size() + 1);
Expand Down

0 comments on commit 487882b

Please sign in to comment.