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.
Merge pull request #201 from wamps-jp/branch-test-cases
Add test cases for `List`, `Sort`, and `Reminder`
- Loading branch information
Showing
5 changed files
with
186 additions
and
1 deletion.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
src/test/java/seedu/address/logic/commands/ReminderCommandTest.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,53 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotEquals; | ||
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; | ||
import static seedu.address.testutil.TypicalContacts.getTypicalAddressBook; | ||
|
||
import java.util.ArrayList; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.model.Model; | ||
import seedu.address.model.ModelManager; | ||
import seedu.address.model.UserPrefs; | ||
import seedu.address.model.jobapplication.JobApplication; | ||
|
||
class ReminderCommandTest { | ||
private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); | ||
private Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs()); | ||
|
||
@Test | ||
public void equals() { | ||
ReminderCommand r = new ReminderCommand(true); | ||
ReminderCommand r2 = new ReminderCommand(true); | ||
ReminderCommand r3 = new ReminderCommand(false); | ||
|
||
assertEquals(r, r); | ||
assertEquals(r, r2); | ||
assertNotEquals(r, r3); | ||
} | ||
|
||
@Test | ||
public void execute_remindEarliest_applicationsSorted() { | ||
String expectedMessage = ReminderCommand.MESSAGE_REMINDED_EARLIEST; | ||
ReminderCommand command = new ReminderCommand(true); | ||
expectedModel.updateSortedApplicationList(JobApplication.DEADLINE_COMPARATOR); | ||
assertCommandSuccess(command, model, expectedMessage, expectedModel); | ||
ArrayList<JobApplication> arrayList1 = new ArrayList<>(model.getDisplayedApplicationList()); | ||
ArrayList<JobApplication> arrayList2 = new ArrayList<>(expectedModel.getDisplayedApplicationList()); | ||
assertEquals(arrayList1, arrayList2); | ||
} | ||
|
||
@Test | ||
public void execute_sortTitle_applicationsSorted() { | ||
String expectedMessage = ReminderCommand.MESSAGE_REMINDED_LATEST; | ||
ReminderCommand command = new ReminderCommand(false); | ||
expectedModel.updateSortedApplicationList(JobApplication.DEADLINE_COMPARATOR.reversed()); | ||
assertCommandSuccess(command, model, expectedMessage, expectedModel); | ||
ArrayList<JobApplication> arrayList1 = new ArrayList<>(model.getDisplayedApplicationList()); | ||
ArrayList<JobApplication> arrayList2 = new ArrayList<>(expectedModel.getDisplayedApplicationList()); | ||
assertEquals(arrayList1, arrayList2); | ||
} | ||
} |
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
39 changes: 39 additions & 0 deletions
39
src/test/java/seedu/address/logic/parser/ReminderCommandParserTest.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,39 @@ | ||
package seedu.address.logic.parser; | ||
|
||
import static seedu.address.logic.Messages.MESSAGE_EXTRA_FIELDS; | ||
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 org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.logic.commands.ReminderCommand; | ||
|
||
public class ReminderCommandParserTest { | ||
|
||
private ReminderCommandParser parser = new ReminderCommandParser(); | ||
|
||
@Test | ||
public void parse_emptyArg_throwsParseException() { | ||
assertParseFailure(parser, " ", | ||
String.format(MESSAGE_INVALID_COMMAND_FORMAT, ReminderCommand.MESSAGE_USAGE)); | ||
} | ||
|
||
@Test | ||
public void parse_invalidArg_throwsParseException() { | ||
assertParseFailure(parser, "--org", | ||
MESSAGE_EXTRA_FIELDS + "--org"); | ||
assertParseFailure(parser, "--by", | ||
MESSAGE_EXTRA_FIELDS + "--by"); | ||
} | ||
|
||
@Test | ||
public void parse_validArgs_returnsReminderCommand() { | ||
ReminderCommand expectedReminderCommand = | ||
new ReminderCommand(true); | ||
assertParseSuccess(parser, "--earliest", expectedReminderCommand); | ||
ReminderCommand expectedReminderCommand2 = | ||
new ReminderCommand(false); | ||
assertParseSuccess(parser, "--latest", expectedReminderCommand2); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/test/java/seedu/address/logic/parser/SortCommandParserTest.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,43 @@ | ||
package seedu.address.logic.parser; | ||
|
||
import static seedu.address.logic.Messages.MESSAGE_EXTRA_FIELDS; | ||
import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; | ||
import static seedu.address.logic.Messages.MESSAGE_SIMULTANEOUS_USE_DISALLOWED_FIELDS; | ||
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; | ||
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.logic.commands.SortCommand; | ||
import seedu.address.model.Model; | ||
|
||
public class SortCommandParserTest { | ||
|
||
private SortCommandParser parser = new SortCommandParser(); | ||
|
||
@Test | ||
public void parse_emptyArg_throwsParseException() { | ||
assertParseFailure(parser, " ", | ||
String.format(MESSAGE_INVALID_COMMAND_FORMAT, SortCommand.MESSAGE_USAGE)); | ||
} | ||
|
||
@Test | ||
public void parse_invalidArg_throwsParseException() { | ||
assertParseFailure(parser, "--title --name", | ||
MESSAGE_SIMULTANEOUS_USE_DISALLOWED_FIELDS + "--name, --title"); | ||
assertParseFailure(parser, "--none --descending", | ||
MESSAGE_SIMULTANEOUS_USE_DISALLOWED_FIELDS + "--descending, --none"); | ||
assertParseFailure(parser, "--org", | ||
MESSAGE_EXTRA_FIELDS + "--org"); | ||
} | ||
|
||
@Test | ||
public void parse_validArgs_returnsSortCommand() { | ||
SortCommand expectedSortCommand = | ||
new SortCommand(Model.COMPARATOR_ADDRESS, null, false); | ||
assertParseSuccess(parser, "--address", expectedSortCommand); | ||
SortCommand expectedSortCommand2 = | ||
new SortCommand(Model.COMPARATOR_ADDRESS, null, true); | ||
assertParseSuccess(parser, "--none", expectedSortCommand2); | ||
} | ||
} |