-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for AddReminderCommand, DeleteReminderCommand, ListReminder…
…Command, CompleteDeliveryJobCommand, DeleteDeliveryJobCommand. Tests coverage is quite low, at 48%. Increasing test coverage helps to enhance product quality. Let's add more tests to increase test coverage.
- Loading branch information
Showing
13 changed files
with
172 additions
and
0 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
18 changes: 18 additions & 0 deletions
18
src/test/java/seedu/address/logic/commands/jobs/CompleteDeliveryJobCommandTest.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,18 @@ | ||
package seedu.address.logic.commands.jobs; | ||
|
||
import static seedu.address.testutil.Assert.assertThrows; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class CompleteDeliveryJobCommandTest { | ||
@Test | ||
public void constructor_nullJobID_throwsNullPointerException() { | ||
assertThrows(NullPointerException.class, () -> new CompleteDeliveryJobCommand(null, true)); | ||
} | ||
|
||
@Test | ||
public void constructor_nullDeliveredStatus_throwsNullPointerException() { | ||
assertThrows(NullPointerException.class, () -> new CompleteDeliveryJobCommand("ABCDEFGH", (Boolean) null)); | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
src/test/java/seedu/address/logic/commands/jobs/DeleteDeliveryJobCommandTest.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,12 @@ | ||
package seedu.address.logic.commands.jobs; | ||
|
||
import static seedu.address.testutil.Assert.assertThrows; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class DeleteDeliveryJobCommandTest { | ||
@Test | ||
public void constructor_nullPerson_throwsNullPointerException() { | ||
assertThrows(NullPointerException.class, () -> new DeleteDeliveryJobCommand(null)); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/test/java/seedu/address/logic/commands/jobs/EditDeliveryJobCommandTest.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,4 @@ | ||
package seedu.address.logic.commands.jobs; | ||
|
||
public class EditDeliveryJobCommandTest { | ||
} |
4 changes: 4 additions & 0 deletions
4
src/test/java/seedu/address/logic/commands/jobs/FindDeliveryJobCommandTest.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,4 @@ | ||
package seedu.address.logic.commands.jobs; | ||
|
||
public class FindDeliveryJobCommandTest { | ||
} |
4 changes: 4 additions & 0 deletions
4
src/test/java/seedu/address/logic/commands/jobs/ImportDeliveryJobCommandTest.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,4 @@ | ||
package seedu.address.logic.commands.jobs; | ||
|
||
public class ImportDeliveryJobCommandTest { | ||
} |
4 changes: 4 additions & 0 deletions
4
src/test/java/seedu/address/logic/commands/jobs/ListDeliveryJobCommandTest.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,4 @@ | ||
package seedu.address.logic.commands.jobs; | ||
|
||
public class ListDeliveryJobCommandTest { | ||
} |
16 changes: 16 additions & 0 deletions
16
src/test/java/seedu/address/logic/commands/reminder/AddReminderCommandTest.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,16 @@ | ||
package seedu.address.logic.commands.reminder; | ||
|
||
import static seedu.address.testutil.Assert.assertThrows; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.model.reminder.Reminder; | ||
|
||
|
||
public class AddReminderCommandTest { | ||
@Test | ||
public void constructor_nullReminder_throwsNullPointerException() { | ||
assertThrows(NullPointerException.class, () -> new AddReminderCommand((Reminder) null)); | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
src/test/java/seedu/address/logic/commands/reminder/DeleteReminderCommandTest.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.reminder; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; | ||
import static seedu.address.testutil.TypicalDeliveryJobs.getTypicalDeliveryJobSystem; | ||
import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; | ||
import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PERSON; | ||
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.commons.core.Messages; | ||
import seedu.address.commons.core.index.Index; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.ModelManager; | ||
import seedu.address.model.UserPrefs; | ||
|
||
|
||
public class DeleteReminderCommandTest { | ||
private Model model = new ModelManager(getTypicalAddressBook(), getTypicalDeliveryJobSystem(), new UserPrefs()); | ||
|
||
@Test | ||
public void execute_invalidIndexReminderList_throwsCommandException() { | ||
Index outOfBoundIndex = Index.fromOneBased(model.getReminderList().size() + 1); | ||
DeleteReminderCommand deleteCommand = new DeleteReminderCommand(outOfBoundIndex.getZeroBased()); | ||
|
||
assertCommandFailure(deleteCommand, model, Messages.MESSAGE_INVALID_REMINDER_DISPLAYED_INDEX); | ||
} | ||
|
||
@Test | ||
public void equals() { | ||
DeleteReminderCommand deleteFirstCommand = new DeleteReminderCommand(INDEX_FIRST_PERSON.getZeroBased()); | ||
DeleteReminderCommand deleteSecondCommand = new DeleteReminderCommand(INDEX_SECOND_PERSON.getZeroBased()); | ||
|
||
// same object -> returns true | ||
assertTrue(deleteFirstCommand.equals(deleteFirstCommand)); | ||
|
||
// same values -> returns true | ||
DeleteReminderCommand deleteFirstCommandCopy = new DeleteReminderCommand(INDEX_FIRST_PERSON.getZeroBased()); | ||
assertTrue(deleteFirstCommand.equals(deleteFirstCommandCopy)); | ||
|
||
// different types -> returns false | ||
assertFalse(deleteFirstCommand.equals(1)); | ||
|
||
// null -> returns false | ||
assertFalse(deleteFirstCommand.equals(null)); | ||
|
||
// different index -> returns false | ||
assertFalse(deleteFirstCommand.equals(deleteSecondCommand)); | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
src/test/java/seedu/address/logic/commands/reminder/ListReminderCommandTest.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,33 @@ | ||
package seedu.address.logic.commands.reminder; | ||
|
||
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; | ||
import static seedu.address.testutil.TypicalDeliveryJobs.getTypicalDeliveryJobSystem; | ||
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.logic.commands.CommandResult; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.ModelManager; | ||
import seedu.address.model.UserPrefs; | ||
|
||
|
||
public class ListReminderCommandTest { | ||
private Model model; | ||
private Model expectedModel; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
model = new ModelManager(getTypicalAddressBook(), getTypicalDeliveryJobSystem(), new UserPrefs()); | ||
expectedModel = new ModelManager(model.getAddressBook(), getTypicalDeliveryJobSystem(), new UserPrefs()); | ||
} | ||
|
||
@Test | ||
public void execute_reminderList_showsReminderList() { | ||
CommandResult listReminderCommandResult = new CommandResult(ListReminderCommand.SHOWING_REMINDER_LIST_MESSAGE, | ||
false, false, true, false, false); | ||
assertCommandSuccess(new ListReminderCommand(), model, listReminderCommandResult, expectedModel); | ||
} | ||
|
||
} |