forked from nus-cs2103-AY1617S2/addressbook-level4
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #42 from CS2103JAN2017-W15-B4/pass-junit
Modify JUnit tests for the refactored Task
- Loading branch information
Showing
15 changed files
with
144 additions
and
161 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,11 +25,15 @@ public class EditCommandTest extends AddressBookGuiTest { | |
|
||
@Test | ||
public void edit_allFieldsSpecified_success() throws Exception { | ||
String detailsToEdit = "Bobby p/91234567 e/[email protected] a/Block 123, Bobby Street 3 t/husband"; | ||
String detailsToEdit | ||
= "Bobby s/2017-04-01T10:16:30 e/2017-04-01T10:16:30 l/Block 123, Bobby Street 3 t/husband"; | ||
int addressBookIndex = 1; | ||
|
||
TestPerson editedPerson = new PersonBuilder().withName("Bobby").withPhone("91234567") | ||
.withEmail("[email protected]").withAddress("Block 123, Bobby Street 3").withTags("husband").build(); | ||
TestPerson editedPerson = new PersonBuilder().withName("Bobby") | ||
.withEndDateTime("2017-04-01T10:16:30") | ||
.withStartDateTime("2017-04-01T10:16:30") | ||
.withLocation("Block 123, Bobby Street 3") | ||
.withTags("husband").build(); | ||
|
||
assertEditSuccess(addressBookIndex, addressBookIndex, detailsToEdit, editedPerson); | ||
} | ||
|
@@ -93,13 +97,13 @@ public void edit_invalidValues_failure() { | |
commandBox.runCommand("edit 1 *&"); | ||
assertResultMessage(Title.MESSAGE_TITLE_CONSTRAINTS); | ||
|
||
commandBox.runCommand("edit 1 p/abcd"); | ||
commandBox.runCommand("edit 1 e/abcd"); | ||
assertResultMessage(EndDateTime.MESSAGE_DATETIME_CONSTRAINTS); | ||
|
||
commandBox.runCommand("edit 1 e/yahoo!!!"); | ||
commandBox.runCommand("edit 1 s/yahoo!!!"); | ||
assertResultMessage(StartDateTime.MESSAGE_DATETIME_CONSTRAINTS); | ||
|
||
commandBox.runCommand("edit 1 a/"); | ||
commandBox.runCommand("edit 1 l/"); | ||
assertResultMessage(Location.MESSAGE_LOCATION_CONSTRAINTS); | ||
|
||
commandBox.runCommand("edit 1 t/*&"); | ||
|
@@ -108,8 +112,8 @@ public void edit_invalidValues_failure() { | |
|
||
@Test | ||
public void edit_duplicatePerson_failure() { | ||
commandBox.runCommand("edit 3 Alice Pauline p/85355255 e/[email protected] " | ||
+ "a/123, Jurong West Ave 6, #08-111 t/friends"); | ||
commandBox.runCommand("edit 3 Alice Pauline s/2017-04-01T10:16:30 e/2017-04-01T10:16:30 " | ||
+ "l/123, Jurong West Ave 6, #08-111 t/friends"); | ||
assertResultMessage(EditCommand.MESSAGE_DUPLICATE_PERSON); | ||
} | ||
|
||
|
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 |
---|---|---|
|
@@ -188,21 +188,26 @@ public void execute_clear() throws Exception { | |
@Test | ||
public void execute_add_invalidArgsFormat() { | ||
String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE); | ||
assertCommandFailure("add wrong args wrong args", expectedMessage); | ||
assertCommandFailure("add Valid Name 12345 e/[email protected] a/valid,address", expectedMessage); | ||
assertCommandFailure("add Valid Name p/12345 [email protected] a/valid, address", expectedMessage); | ||
assertCommandFailure("add Valid Name p/12345 e/[email protected] valid, address", expectedMessage); | ||
assertCommandFailure("add wrong args wrong args", | ||
expectedMessage); | ||
assertCommandFailure("add Valid Name 2017-04-01T10:16:30 e/2017-04-01T10:16:30 l/valid,address", | ||
expectedMessage); | ||
assertCommandFailure("add Valid Name s/2017-04-01T10:16:30 2017-04-01T10:16:30 l/valid, address", | ||
expectedMessage); | ||
assertCommandFailure("add Valid Name s/2017-04-01T10:16:30 e/2017-04-01T10:16:30 valid, address", | ||
expectedMessage); | ||
} | ||
|
||
@Test | ||
public void execute_add_invalidPersonData() { | ||
assertCommandFailure("add []\\[;] p/12345 e/[email protected] a/valid, address", | ||
assertCommandFailure("add []\\[;] s/2017-04-01T10:16:30 e/2017-04-01T10:16:30 l/valid, address", | ||
Title.MESSAGE_TITLE_CONSTRAINTS); | ||
assertCommandFailure("add Valid Name p/not_numbers e/[email protected] a/valid, address", | ||
assertCommandFailure("add Valid Name s/not_numbers e/2017-04-01T10:16:30 l/valid, address", | ||
EndDateTime.MESSAGE_DATETIME_CONSTRAINTS); | ||
assertCommandFailure("add Valid Name p/12345 e/notAnEmail a/valid, address", | ||
assertCommandFailure("add Valid Name s/2017-04-01T10:16:30 e/notAnEmail l/valid, address", | ||
StartDateTime.MESSAGE_DATETIME_CONSTRAINTS); | ||
assertCommandFailure("add Valid Name p/12345 e/[email protected] a/valid, address t/invalid_-[.tag", | ||
assertCommandFailure( | ||
"add Valid Name s/2017-04-01T10:16:30 e/2017-04-01T10:16:30 l/valid, address t/invalid_-[.tag", | ||
Tag.MESSAGE_TAG_CONSTRAINTS); | ||
|
||
} | ||
|
@@ -416,8 +421,8 @@ class TestDataHelper { | |
|
||
Task adam() throws Exception { | ||
Title title = new Title("Adam Brown"); | ||
EndDateTime privateEndDateTime = new EndDateTime("111111"); | ||
StartDateTime startDateTime = new StartDateTime("[email protected]"); | ||
EndDateTime privateEndDateTime = new EndDateTime("2017-04-01T10:16:30"); | ||
StartDateTime startDateTime = new StartDateTime("2017-04-01T10:16:30"); | ||
Location privateLocation = new Location("111, alpha street"); | ||
Tag tag1 = new Tag("tag1"); | ||
Tag tag2 = new Tag("longertag2"); | ||
|
@@ -435,8 +440,8 @@ Task adam() throws Exception { | |
Task generateTask(int seed) throws Exception { | ||
return new Task( | ||
new Title("Person " + seed), | ||
new StartDateTime(seed + "@email"), | ||
new EndDateTime("" + Math.abs(seed)), | ||
new StartDateTime("2017-04-01T10:16:30"), | ||
new EndDateTime("2017-04-01T10:16:30"), | ||
new Location("House of " + seed), | ||
new UniqueTagList(new Tag("tag" + Math.abs(seed)), new Tag("tag" + Math.abs(seed + 1))) | ||
); | ||
|
@@ -449,9 +454,9 @@ String generateAddCommand(Task p) { | |
cmd.append("add "); | ||
|
||
cmd.append(p.getTitle().toString()); | ||
cmd.append(" e/").append(p.getStartDateTime()); | ||
cmd.append(" p/").append(p.getEndDateTime()); | ||
cmd.append(" a/").append(p.getLocation()); | ||
cmd.append(" s/").append(p.getStartDateTime()); | ||
cmd.append(" e/").append(p.getEndDateTime()); | ||
cmd.append(" l/").append(p.getLocation()); | ||
|
||
UniqueTagList tags = p.getTags(); | ||
for (Tag t: tags) { | ||
|
@@ -534,8 +539,8 @@ List<Task> generateTaskList(Task... persons) { | |
Task generateTaskWithName(String name) throws Exception { | ||
return new Task( | ||
new Title(name), | ||
new StartDateTime("1@email"), | ||
new EndDateTime("1"), | ||
new StartDateTime("2017-04-01T10:16:30"), | ||
new EndDateTime("2017-04-01T10:16:30"), | ||
new Location("House of 1"), | ||
new UniqueTagList(new Tag("tag")) | ||
); | ||
|
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
src/test/java/seedu/geekeep/model/person/EndDateTimeTest.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,21 @@ | ||
package seedu.geekeep.model.person; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.junit.Test; | ||
|
||
import seedu.geekeep.model.task.EndDateTime; | ||
|
||
public class EndDateTimeTest { | ||
|
||
@Test | ||
public void isValidEndDateTime() { | ||
// invalid end date time | ||
assertFalse(EndDateTime.isValidDateTime("")); // empty string | ||
assertFalse(EndDateTime.isValidDateTime(" ")); // spaces only | ||
|
||
// valid end date time | ||
assertTrue(EndDateTime.isValidDateTime("2017-04-01T10:16:30")); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
src/test/java/seedu/geekeep/model/person/StartDateTimeTest.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,21 @@ | ||
package seedu.geekeep.model.person; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.junit.Test; | ||
|
||
import seedu.geekeep.model.task.StartDateTime; | ||
|
||
public class StartDateTimeTest { | ||
|
||
@Test | ||
public void isValidStartDateTime() { | ||
// invalid start date time | ||
assertFalse(StartDateTime.isValidDateTime("")); // empty string | ||
assertFalse(StartDateTime.isValidDateTime(" ")); // spaces only | ||
|
||
// valid start date time | ||
assertTrue(StartDateTime.isValidDateTime("2017-04-01T10:16:30")); | ||
} | ||
} |
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
Oops, something went wrong.