Skip to content

Commit

Permalink
Merge pull request AY2425S1-CS2103T-F13-4#170 from AY2425S1-CS2103T-F…
Browse files Browse the repository at this point in the history
…13-4/empty-list-message

Update message for attempting `deletet` on empty list
  • Loading branch information
darkmoongreatsword authored Nov 7, 2024
2 parents eaf8df6 + a624ba0 commit 967f524
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/main/java/seedu/address/logic/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class Messages {
public static final String MESSAGE_EMPTY_OTHER_PARTY = "Other party should not be blank!";
public static final String MESSAGE_EMPTY_DATE = "Date should not be blank!";

public static final String MESSAGE_EMPTY_TRANSACTION_LIST =
"Invalid command: The current transaction list is empty.";
/**
* Returns an error message indicating the duplicate prefixes.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public CommandResult execute(Model model) throws CommandException {
Person selected = lastShownList.get(CURRENT_PERSON.getZeroBased());
List<Transaction> transactions = new ArrayList<>(model.getFilteredTransactionList());

if (transactions.isEmpty()) {
throw new CommandException(Messages.MESSAGE_EMPTY_TRANSACTION_LIST);
}
if (index.getZeroBased() >= transactions.size()) {
throw new CommandException(Messages.MESSAGE_INVALID_TRANSACTION_DISPLAYED_INDEX);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void execute_emptyFilteredTransactionList_throwsCommandException() {
List<Transaction> transactions = new ArrayList<>();
model.updateTransactionList(transactions);

String expectedMessage = Messages.MESSAGE_INVALID_TRANSACTION_DISPLAYED_INDEX;
String expectedMessage = Messages.MESSAGE_EMPTY_TRANSACTION_LIST;

DeleteTransactionCommand deleteTransactionCommand = new DeleteTransactionCommand(INDEX_FIRST_TRANSACTION);
assertCommandFailure(deleteTransactionCommand, model, expectedMessage);
Expand All @@ -68,7 +68,7 @@ public void execute_unfilteredListFailure_throwsCommandException() {
showPersonAtIndex(expectedModel, INDEX_FIRST_PERSON);
model.setIsViewTransactions(true);

String expectedMessage = Messages.MESSAGE_INVALID_TRANSACTION_DISPLAYED_INDEX;
String expectedMessage = Messages.MESSAGE_EMPTY_TRANSACTION_LIST;

DeleteTransactionCommand deleteTransactionCommand = new DeleteTransactionCommand(INDEX_FIRST_TRANSACTION);
assertCommandFailure(deleteTransactionCommand, model, expectedMessage);
Expand Down

0 comments on commit 967f524

Please sign in to comment.