forked from nus-cs2103-AY2324S2/tp
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
53 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/test/java/scm/address/logic/parser/FindScheduleCommandParserTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package scm.address.logic.parser; | ||
|
||
import static scm.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; | ||
import static scm.address.logic.parser.CommandParserTestUtil.assertParseFailure; | ||
import static scm.address.logic.parser.CommandParserTestUtil.assertParseSuccess; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.Optional; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import scm.address.logic.commands.FindScheduleCommand; | ||
import scm.address.model.schedule.AfterDateTimePredicate; | ||
import scm.address.model.schedule.BeforeDateTimePredicate; | ||
import scm.address.model.schedule.DescriptionContainsKeywordsPredicate; | ||
import scm.address.model.schedule.DuringDateTimePredicate; | ||
import scm.address.model.schedule.TitleContainsKeywordsPredicate; | ||
|
||
|
||
|
||
public class FindScheduleCommandParserTest { | ||
private final FindScheduleCommandParser parser = new FindScheduleCommandParser(); | ||
|
||
@Test | ||
public void parse_emptyArg_throwsParseException() { | ||
assertParseFailure(parser, " ", | ||
String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindScheduleCommand.MESSAGE_USAGE)); | ||
} | ||
|
||
@Test | ||
public void parse_validArgs_returnsFindScheduleCommand() { | ||
// no leading and trailing whitespaces | ||
FindScheduleCommand expectedFindScheduleCommand = | ||
new FindScheduleCommand(new TitleContainsKeywordsPredicate(Arrays.asList("meeting", "lesson")), | ||
new DescriptionContainsKeywordsPredicate(Collections.emptyList()), | ||
new BeforeDateTimePredicate(Optional.of(LocalDateTime.of(2024, 5, 7, 0, 0))), | ||
new AfterDateTimePredicate(Optional.of(LocalDateTime.of(2024, 4, 30, 12, 0))), | ||
new DuringDateTimePredicate(Optional.empty())); | ||
assertParseSuccess(parser, " title/meeting lesson before/2024-05-07 00:00 after/2024-04-30 12:00", | ||
expectedFindScheduleCommand); | ||
|
||
// multiple whitespaces between keywords | ||
assertParseSuccess(parser, | ||
" \n title/meeting \t lesson \n before/2024-05-07 \n 00:00 \t after/2024-04-30 \t 12:00", | ||
expectedFindScheduleCommand); | ||
} | ||
} |