forked from nusCS2113-AY1819S1/addressbook-level4
-
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.
Merge pull request #168 from tristyxxnana/GradebookDeleteCommand
Updated Gradebook Delete Command
- Loading branch information
Showing
8 changed files
with
115 additions
and
36 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
52 changes: 52 additions & 0 deletions
52
src/test/java/seedu/address/logic/commands/GradebookDeleteCommandTest.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,52 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import org.junit.AfterClass; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.ExpectedException; | ||
import seedu.address.logic.CommandHistory; | ||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.ModelManager; | ||
import seedu.address.model.gradebook.GradebookManager; | ||
import seedu.address.testutil.GradebookBuilder; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static seedu.address.logic.commands.GradebookDeleteCommand.MESSAGE_DELETE_SUCCESS; | ||
|
||
|
||
public class GradebookDeleteCommandTest { | ||
private static GradebookManager gradebookManager = new GradebookManager(); | ||
|
||
private static GradebookBuilder dummyGradebookComponent = new GradebookBuilder(); | ||
|
||
@Rule | ||
public ExpectedException thrown = ExpectedException.none(); | ||
|
||
@Before | ||
public void setUp() { | ||
gradebookManager.clearGradebook(); | ||
gradebookManager.saveGradebookList(); | ||
} | ||
|
||
@Test | ||
public void execute_gradebookDelete_success() throws CommandException { | ||
String moduleCode = "CS2113"; | ||
String gradebookComponentName = "Finals"; | ||
String expectedMessage = String.format(MESSAGE_DELETE_SUCCESS, moduleCode, gradebookComponentName); | ||
|
||
gradebookManager.addGradebookComponent(dummyGradebookComponent.build()); | ||
gradebookManager.saveGradebookList(); | ||
|
||
GradebookDeleteCommand gradebookDeleteCommand = new GradebookDeleteCommand(moduleCode, gradebookComponentName); | ||
CommandResult result = gradebookDeleteCommand.execute(new ModelManager(), new CommandHistory()); | ||
|
||
assertEquals(expectedMessage, result.feedbackToUser); | ||
} | ||
|
||
@AfterClass | ||
public static void tearDown() { | ||
gradebookManager.clearGradebook(); | ||
gradebookManager.saveGradebookList(); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
src/test/java/seedu/address/logic/parser/GradebookDeleteCommandParserTest.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 |
---|---|---|
@@ -1,4 +1,59 @@ | ||
package seedu.address.logic.parser; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.ExpectedException; | ||
import seedu.address.logic.commands.GradebookDeleteCommand; | ||
import seedu.address.logic.parser.exceptions.ParseException; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertNotNull; | ||
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; | ||
import static seedu.address.logic.parser.GradebookDeleteCommandParser.MESSAGE_EMPTY_INPUTS; | ||
|
||
public class GradebookDeleteCommandParserTest { | ||
private GradebookDeleteCommandParser parser = new GradebookDeleteCommandParser(); | ||
|
||
@Rule | ||
public ExpectedException thrown = ExpectedException.none(); | ||
|
||
@Test | ||
public void parse_invalidFormat_throwsParseException() throws ParseException { | ||
String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, GradebookDeleteCommand.MESSAGE_USAGE); | ||
|
||
//invalid arguments found | ||
String arg = "this is an invalid format"; | ||
|
||
thrown.expect(ParseException.class); | ||
thrown.expectMessage(expectedMessage); | ||
parser.parse(arg); | ||
} | ||
|
||
@Test | ||
public void parse_validArgs_success() throws ParseException { | ||
//valid arguments without optional arguments | ||
String args = " mc/CS2113 i/Finals"; | ||
GradebookDeleteCommand gradebookDeleteCommand = parser.parse(args); | ||
assertNotNull(gradebookDeleteCommand); | ||
} | ||
|
||
@Test | ||
public void parse_emptyModuleCodeArgs_throwsParseException() throws ParseException { | ||
String expectedMessage = String.format(MESSAGE_EMPTY_INPUTS); | ||
//module code empty | ||
String args = " mc/ i/Finals"; | ||
thrown.expect(ParseException.class); | ||
thrown.expectMessage(expectedMessage); | ||
parser.parse(args); | ||
} | ||
|
||
@Test | ||
public void parse_emptyComponentNameArgs_throwsParseException() throws ParseException { | ||
String expectedMessage = String.format(MESSAGE_EMPTY_INPUTS); | ||
//component name empty | ||
String arg = " mc/CS2113 i/"; | ||
thrown.expect(ParseException.class); | ||
thrown.expectMessage(expectedMessage); | ||
parser.parse(arg); | ||
} | ||
} |