forked from nus-cs2103-AY1920S1/addressbook-level3
-
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 #327 from ngswbryan/update-tests
Updated more tests
- Loading branch information
Showing
9 changed files
with
370 additions
and
7 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
12 changes: 12 additions & 0 deletions
12
src/main/java/seedu/address/model/commands/commandsexceptions/DuplicateCommandException.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.model.commands.commandsexceptions; | ||
|
||
/** | ||
* Signals that the operation will result in duplicate Earnings | ||
* (Earnings are considered duplicates if they have the same | ||
* classId, date, amount and type). | ||
*/ | ||
public class DuplicateCommandException extends RuntimeException { | ||
public DuplicateCommandException() { | ||
super("Operation would result in duplicate command"); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/test/java/seedu/address/logic/commands/CancelCommandTest.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,23 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static seedu.address.logic.commands.CancelCommand.SHOWING_CANCEL_MESSAGE; | ||
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.model.Model; | ||
import seedu.address.model.ModelManager; | ||
|
||
public class CancelCommandTest { | ||
private Model model = new ModelManager(); | ||
private Model expectedModel = new ModelManager(); | ||
|
||
@Test | ||
public void execute_help_success() { | ||
CommandResult expectedCommandResult = new CommandResult(SHOWING_CANCEL_MESSAGE, | ||
false, false, false, false, | ||
false, false, false, false); | ||
|
||
assertCommandSuccess(new CancelCommand(), model, expectedCommandResult, expectedModel); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/test/java/seedu/address/model/classid/ClassIdTest.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,37 @@ | ||
package seedu.address.model.classid; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static seedu.address.testutil.Assert.assertThrows; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class ClassIdTest { | ||
|
||
@Test | ||
public void constructor_null_throwsNullPointerException() { | ||
assertThrows(NullPointerException.class, () -> new ClassId(null)); | ||
} | ||
|
||
@Test | ||
public void constructor_invalidClassId_throwsIllegalArgumentException() { | ||
String invalidClassId = ""; | ||
assertThrows(IllegalArgumentException.class, () -> new ClassId(invalidClassId)); | ||
} | ||
|
||
@Test | ||
public void isValidClassId() { | ||
// null classId | ||
assertThrows(NullPointerException.class, () -> ClassId.isValidClassId(null)); | ||
|
||
// invalid classId | ||
assertFalse(ClassId.isValidClassId("")); // empty string | ||
assertFalse(ClassId.isValidClassId(" ")); // spaces only | ||
|
||
assertTrue(ClassId.isValidClassId("CS2030")); | ||
assertTrue(ClassId.isValidClassId("CS1231")); | ||
assertTrue(ClassId.isValidClassId("CS2030 Tut 7")); | ||
assertTrue(ClassId.isValidClassId("CS40000000")); | ||
assertTrue(ClassId.isValidClassId("random class")); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/test/java/seedu/address/model/commands/CommandActionTest.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,38 @@ | ||
package seedu.address.model.classid; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static seedu.address.testutil.Assert.assertThrows; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.model.commands.CommandAction; | ||
|
||
public class CommandActionTest { | ||
|
||
@Test | ||
public void constructor_null_throwsNullPointerException() { | ||
assertThrows(NullPointerException.class, () -> new CommandAction(null)); | ||
} | ||
|
||
@Test | ||
public void constructor_invalidCommandAction_throwsIllegalArgumentException() { | ||
String invalidCommandAction = ""; | ||
assertThrows(IllegalArgumentException.class, () -> new CommandAction(invalidCommandAction)); | ||
} | ||
|
||
@Test | ||
public void isValidCommandAction() { | ||
|
||
assertThrows(NullPointerException.class, () -> CommandAction.isValidAction(null)); | ||
|
||
assertFalse(CommandAction.isValidAction("")); // empty string | ||
assertFalse(CommandAction.isValidAction(" ")); // spaces only | ||
|
||
assertTrue(CommandAction.isValidAction("add")); | ||
assertTrue(CommandAction.isValidAction("delete")); | ||
assertTrue(CommandAction.isValidAction("plus multiply")); | ||
assertTrue(CommandAction.isValidAction("randomize")); | ||
assertTrue(CommandAction.isValidAction("random")); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
src/test/java/seedu/address/model/commands/CommandObjectTest.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,55 @@ | ||
package seedu.address.model.person; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static seedu.address.testutil.TypicalTutorAid.ADDER; | ||
import static seedu.address.testutil.TypicalTutorAid.DELETER; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.model.commands.CommandObject; | ||
import seedu.address.testutil.CommandObjectBuilder; | ||
|
||
public class CommandObjectTest { | ||
|
||
public static final String VALID_COMMAND_ACTION_MUL = "multiply"; | ||
public static final String VALID_WORD_MUL = "mul"; | ||
|
||
@Test | ||
public void isSameCommandObject() { | ||
// same object -> returns true | ||
assertTrue(ADDER.isSameCommand(ADDER)); | ||
|
||
// null -> returns false | ||
assertFalse(ADDER.isSameCommand(null)); | ||
} | ||
|
||
@Test | ||
public void equals() { | ||
// same values -> returns true | ||
CommandObject adderCopy = new CommandObjectBuilder(ADDER).build(); | ||
assertTrue(ADDER.equals(adderCopy)); | ||
|
||
// same object -> returns true | ||
assertTrue(ADDER.equals(ADDER)); | ||
|
||
// null -> returns false | ||
assertFalse(ADDER.equals(null)); | ||
|
||
// different type -> returns false | ||
assertFalse(ADDER.equals(5)); | ||
|
||
// different command -> returns false | ||
assertFalse(ADDER.equals(DELETER)); | ||
|
||
// different action -> returns false | ||
CommandObject editedAdder = new CommandObjectBuilder(ADDER) | ||
.withCommandAction(VALID_COMMAND_ACTION_MUL).build(); | ||
assertFalse(ADDER.equals(editedAdder)); | ||
|
||
// different commandword -> returns false | ||
editedAdder = new CommandObjectBuilder(ADDER).withCommandWord(VALID_WORD_MUL).build(); | ||
assertFalse(ADDER.equals(editedAdder)); | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
src/test/java/seedu/address/model/commands/CommandWordTest.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,38 @@ | ||
package seedu.address.model.classid; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static seedu.address.testutil.Assert.assertThrows; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.model.commands.CommandWord; | ||
|
||
public class CommandWordTest { | ||
|
||
@Test | ||
public void constructor_null_throwsNullPointerException() { | ||
assertThrows(NullPointerException.class, () -> new CommandWord(null)); | ||
} | ||
|
||
@Test | ||
public void constructor_invalidCommandWord_throwsIllegalArgumentException() { | ||
String invalidCommandWord = ""; | ||
assertThrows(IllegalArgumentException.class, () -> new CommandWord(invalidCommandWord)); | ||
} | ||
|
||
@Test | ||
public void isValidCommandWord() { | ||
|
||
assertThrows(NullPointerException.class, () -> CommandWord.isValidWord(null)); | ||
|
||
assertFalse(CommandWord.isValidWord("")); // empty string | ||
assertFalse(CommandWord.isValidWord(" ")); // spaces only | ||
|
||
assertTrue(CommandWord.isValidWord("test")); | ||
assertTrue(CommandWord.isValidWord("test test")); | ||
assertTrue(CommandWord.isValidWord("accepted!")); | ||
assertTrue(CommandWord.isValidWord("okay123")); | ||
assertTrue(CommandWord.isValidWord("random")); | ||
} | ||
} |
Oops, something went wrong.