forked from nus-cs2103-AY2324S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
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
12 changed files
with
195 additions
and
26 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
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
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
115 changes: 115 additions & 0 deletions
115
src/test/java/seedu/address/logic/parser/ModulePlanParserTest.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,115 @@ | ||
package seedu.address.logic.parser; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; | ||
import static seedu.address.logic.Messages.MESSAGE_UNKNOWN_COMMAND; | ||
import static seedu.address.logic.commands.CommandTestUtil.VALID_CODE_CS2040S; | ||
import static seedu.address.testutil.Assert.assertThrows; | ||
import static seedu.address.testutil.TypicalModules.CS2030S; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.logic.commands.AddCommand; | ||
import seedu.address.logic.commands.CalculateCapCommand; | ||
import seedu.address.logic.commands.CalculateMcCommand; | ||
import seedu.address.logic.commands.ClearCommand; | ||
import seedu.address.logic.commands.DeleteCommand; | ||
import seedu.address.logic.commands.EditCommand; | ||
import seedu.address.logic.commands.EditCommand.EditModuleDescriptor; | ||
import seedu.address.logic.commands.ExitCommand; | ||
import seedu.address.logic.commands.FindCommand; | ||
import seedu.address.logic.commands.HelpCommand; | ||
import seedu.address.logic.commands.ListCommand; | ||
import seedu.address.logic.parser.exceptions.ParseException; | ||
import seedu.address.model.module.Module; | ||
import seedu.address.model.module.ModuleCode; | ||
import seedu.address.model.module.NameContainsKeywordsPredicate; | ||
import seedu.address.testutil.EditModuleDescriptorBuilder; | ||
import seedu.address.testutil.ModuleBuilder; | ||
import seedu.address.testutil.ModuleUtil; | ||
|
||
public class ModulePlanParserTest { | ||
|
||
private final ModulePlanParser parser = new ModulePlanParser(); | ||
|
||
@Test | ||
public void parseCommand_add() throws Exception { | ||
Module module = new ModuleBuilder().build(); | ||
AddCommand command = (AddCommand) parser.parseCommand(ModuleUtil.getAddCommand(module)); | ||
assertEquals(new AddCommand(module), command); | ||
} | ||
|
||
@Test | ||
public void parseCommand_clear() throws Exception { | ||
assertTrue(parser.parseCommand(ClearCommand.COMMAND_WORD) instanceof ClearCommand); | ||
assertTrue(parser.parseCommand(ClearCommand.COMMAND_WORD + " 3") instanceof ClearCommand); | ||
} | ||
|
||
@Test | ||
public void parseCommand_delete() throws Exception { | ||
DeleteCommand command = (DeleteCommand) parser.parseCommand( | ||
DeleteCommand.COMMAND_WORD + " " + CS2030S.getModuleCode()); | ||
assertEquals(new DeleteCommand(CS2030S.getModuleCode()), command); | ||
} | ||
|
||
@Test | ||
public void parseCommand_edit() throws Exception { | ||
Module module = new ModuleBuilder().build(); | ||
EditModuleDescriptor descriptor = new EditModuleDescriptorBuilder(module).build(); | ||
EditCommand command = (EditCommand) parser.parseCommand(EditCommand.COMMAND_WORD + " " | ||
+ CS2030S.getModuleCode() + " " + ModuleUtil.getEditModuleDescriptorDetails(descriptor)); | ||
assertEquals(new EditCommand(CS2030S.getModuleCode(), descriptor), command); | ||
} | ||
|
||
@Test | ||
public void parseCommand_exit() throws Exception { | ||
assertTrue(parser.parseCommand(ExitCommand.COMMAND_WORD) instanceof ExitCommand); | ||
assertTrue(parser.parseCommand(ExitCommand.COMMAND_WORD + " 3") instanceof ExitCommand); | ||
} | ||
|
||
@Test | ||
public void parseCommand_find() throws Exception { | ||
List<String> keywords = Arrays.asList("foo", "bar", "baz"); | ||
FindCommand command = (FindCommand) parser.parseCommand( | ||
FindCommand.COMMAND_WORD + " " + keywords.stream().collect(Collectors.joining(" "))); | ||
assertEquals(new FindCommand(new NameContainsKeywordsPredicate(keywords)), command); | ||
} | ||
|
||
@Test | ||
public void parseCommand_help() throws Exception { | ||
assertTrue(parser.parseCommand(HelpCommand.COMMAND_WORD) instanceof HelpCommand); | ||
assertTrue(parser.parseCommand(HelpCommand.COMMAND_WORD + " 3") instanceof HelpCommand); | ||
} | ||
|
||
@Test | ||
public void parseCommand_list() throws Exception { | ||
assertTrue(parser.parseCommand(ListCommand.COMMAND_WORD) instanceof ListCommand); | ||
assertTrue(parser.parseCommand(ListCommand.COMMAND_WORD + " 3") instanceof ListCommand); | ||
} | ||
|
||
@Test | ||
public void parseCommand_calculateCap() throws Exception { | ||
assertTrue(parser.parseCommand(CalculateCapCommand.COMMAND_WORD) instanceof CalculateCapCommand); | ||
} | ||
|
||
@Test | ||
public void parseCommand_calculateMc() throws Exception { | ||
assertTrue(parser.parseCommand(CalculateMcCommand.COMMAND_WORD) instanceof CalculateMcCommand); | ||
} | ||
|
||
@Test | ||
public void parseCommand_unrecognisedInput_throwsParseException() { | ||
assertThrows(ParseException.class, String.format(MESSAGE_INVALID_COMMAND_FORMAT, HelpCommand.MESSAGE_USAGE), () | ||
-> parser.parseCommand("")); | ||
} | ||
|
||
@Test | ||
public void parseCommand_unknownCommand_throwsParseException() { | ||
assertThrows(ParseException.class, MESSAGE_UNKNOWN_COMMAND, () -> parser.parseCommand("unknownCommand")); | ||
} | ||
} |
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
Oops, something went wrong.