Skip to content

Commit

Permalink
FindCommandParserTest.java: Add test for thrown exception
Browse files Browse the repository at this point in the history
  • Loading branch information
yyihaoc committed Oct 17, 2024
1 parent 357b7fa commit 52be150
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure;
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess;
import static seedu.address.testutil.Assert.assertThrows;

import java.util.List;

import org.junit.jupiter.api.Test;

import seedu.address.logic.commands.FindCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.person.NameContainsKeywordsPredicate;
import seedu.address.model.person.RoleContainsKeywordsPredicate;

Expand Down Expand Up @@ -44,6 +46,27 @@ public void parse_emptyArgumentAfterPrefix_throwsParseException() {
String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindCommand.MESSAGE_USAGE));
}

@Test
public void parse_emptyNameKeyword_throwsParseException() {
// Test where the name field is empty
String userInput = " n/ r/Developer"; // n/ contains only whitespace
assertThrows(ParseException.class, () -> parser.parse(userInput));
}

@Test
public void parse_emptyRoleKeyword_throwsParseException() {
// Test where the role field is empty
String userInput = " n/John Doe r/ "; // r/ contains only whitespace
assertThrows(ParseException.class, () -> parser.parse(userInput));
}

@Test
public void parse_emptyNameAndRoleKeywords_throwsParseException() {
// Test where both name and role fields are empty
String userInput = " n/ r/ "; // both contain only whitespace
assertThrows(ParseException.class, () -> parser.parse(userInput));
}

@Test
public void parse_validArgs_returnsFindCommand() {
// no leading and trailing whitespaces
Expand Down

0 comments on commit 52be150

Please sign in to comment.