-
Notifications
You must be signed in to change notification settings - Fork 548
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
202 additions
and
30 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
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
7 changes: 0 additions & 7 deletions
7
src/main/java/seedu/address/model/tutorialgroup/exceptions/DuplicateGroupException.java
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -19,20 +19,26 @@ | |
import seedu.address.model.student.Name; | ||
import seedu.address.model.student.Phone; | ||
import seedu.address.model.tag.Tag; | ||
import seedu.address.model.tutorialgroup.GroupNumber; | ||
import seedu.address.model.tutorialgroup.GroupType; | ||
|
||
public class ParserUtilTest { | ||
private static final String INVALID_NAME = "R@chel"; | ||
private static final String INVALID_PHONE = "+651234"; | ||
private static final String INVALID_ADDRESS = " "; | ||
private static final String INVALID_EMAIL = "example.com"; | ||
private static final String INVALID_TAG = "#friend"; | ||
private static final String INVALID_GROUP_NUMBER = "a"; | ||
private static final String INVALID_GROUP_TYPE = "OP3"; | ||
|
||
private static final String VALID_NAME = "Rachel Walker"; | ||
private static final String VALID_PHONE = "123456"; | ||
private static final String VALID_ADDRESS = "123 Main Street #0505"; | ||
private static final String VALID_EMAIL = "[email protected]"; | ||
private static final String VALID_TAG_1 = "friend"; | ||
private static final String VALID_TAG_2 = "neighbour"; | ||
private static final String VALID_GROUP_NUMBER = "1"; | ||
private static final String VALID_GROUP_TYPE = "OP1"; | ||
|
||
private static final String WHITESPACE = " \t\r\n"; | ||
|
||
|
@@ -193,4 +199,50 @@ public void parseTags_collectionWithValidTags_returnsTagSet() throws Exception { | |
|
||
assertEquals(expectedTagSet, actualTagSet); | ||
} | ||
|
||
@Test | ||
public void parseGroupNumber_null_throwsNullPointerException() { | ||
assertThrows(NullPointerException.class, () -> ParserUtil.parseGroupNumber((String) null)); | ||
} | ||
|
||
@Test | ||
public void parseGroupNumber_invalidValue_throwsParseException() { | ||
assertThrows(ParseException.class, () -> ParserUtil.parseGroupNumber(INVALID_GROUP_NUMBER)); | ||
} | ||
|
||
@Test | ||
public void parseGroupNumber_validValueWithoutWhitespace_returnsGroupNumber() throws Exception { | ||
GroupNumber expectedGroupNumber = new GroupNumber(VALID_GROUP_NUMBER); | ||
assertEquals(expectedGroupNumber, ParserUtil.parseGroupNumber(VALID_GROUP_NUMBER)); | ||
} | ||
|
||
@Test | ||
public void parseGroupNumber_validValueWithWhitespace_returnsTrimmedGroupNumber() throws Exception { | ||
String groupNumberWithWhitespace = WHITESPACE + VALID_GROUP_NUMBER + WHITESPACE; | ||
GroupNumber expectedGroupNumber = new GroupNumber(VALID_GROUP_NUMBER); | ||
assertEquals(expectedGroupNumber, ParserUtil.parseGroupNumber(groupNumberWithWhitespace)); | ||
} | ||
|
||
@Test | ||
public void parseGroupType_null_throwsNullPointerException() { | ||
assertThrows(NullPointerException.class, () -> ParserUtil.parseGroupType((String) null)); | ||
} | ||
|
||
@Test | ||
public void parseGroupType_invalidValue_throwsParseException() { | ||
assertThrows(ParseException.class, () -> ParserUtil.parseGroupType(INVALID_GROUP_TYPE)); | ||
} | ||
|
||
@Test | ||
public void parseGroupType_validValueWithoutWhitespace_returnsGroupType() throws Exception { | ||
GroupType expectedGroupType = new GroupType(VALID_GROUP_TYPE); | ||
assertEquals(expectedGroupType, ParserUtil.parseGroupType(VALID_GROUP_TYPE)); | ||
} | ||
|
||
@Test | ||
public void parseGroupType_validValueWithWhitespace_returnsTrimmedGroupType() throws Exception { | ||
String groupTypeWithWhitespace = WHITESPACE + VALID_GROUP_TYPE + WHITESPACE; | ||
GroupType expectedGroupType = new GroupType(VALID_GROUP_TYPE); | ||
assertEquals(expectedGroupType, ParserUtil.parseGroupType(groupTypeWithWhitespace)); | ||
} | ||
} |
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
90 changes: 90 additions & 0 deletions
90
src/test/java/seedu/address/model/tutorialgroup/UniqueTutorialGroupListTest.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,90 @@ | ||
package seedu.address.model.tutorialgroup; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB; | ||
import static seedu.address.logic.commands.CommandTestUtil.VALID_CLASSCODE_G02; | ||
import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; | ||
import static seedu.address.testutil.Assert.assertThrows; | ||
import static seedu.address.testutil.TypicalStudents.ALICE; | ||
import static seedu.address.testutil.TypicalStudents.BOB; | ||
import static seedu.address.testutil.TypicalTutorialGroups.TUT_01; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.model.student.Student; | ||
import seedu.address.model.student.UniqueStudentList; | ||
import seedu.address.model.student.exceptions.DuplicateStudentException; | ||
import seedu.address.model.student.exceptions.StudentNotFoundException; | ||
import seedu.address.model.tutorialgroup.exceptions.DuplicateTutorialGroupException; | ||
import seedu.address.model.tutorialgroup.exceptions.TutorialGroupNotFoundException; | ||
import seedu.address.testutil.StudentBuilder; | ||
import seedu.address.testutil.TutorialGroupBuilder; | ||
|
||
public class UniqueTutorialGroupListTest { | ||
|
||
private final UniqueTutorialGroupList uniqueTutorialGroupList = new UniqueTutorialGroupList(); | ||
|
||
@Test | ||
public void contains_nullTutorialGroup_throwsNullPointerException() { | ||
assertThrows(NullPointerException.class, () -> uniqueTutorialGroupList.contains(null)); | ||
} | ||
|
||
@Test | ||
public void contains_tutorialGroupNotInList_returnsFalse() { | ||
assertFalse(uniqueTutorialGroupList.contains(TUT_01)); | ||
} | ||
|
||
@Test | ||
public void contains_tutorialGroupInList_returnsTrue() { | ||
uniqueTutorialGroupList.add(TUT_01); | ||
assertTrue(uniqueTutorialGroupList.contains(TUT_01)); | ||
} | ||
|
||
@Test | ||
public void contains_tutorialGroupWithDifferentClassCode_returnsFalse() { | ||
uniqueTutorialGroupList.add(TUT_01); | ||
TutorialGroup editedTUT_01 = new TutorialGroupBuilder(TUT_01).withClassCode(VALID_CLASSCODE_G02) | ||
.build(); | ||
assertFalse(uniqueTutorialGroupList.contains(editedTUT_01)); | ||
} | ||
|
||
@Test | ||
public void add_nullTutorialGroup_throwsNullPointerException() { | ||
assertThrows(NullPointerException.class, () -> uniqueTutorialGroupList.add(null)); | ||
} | ||
|
||
@Test | ||
public void add_duplicateTutorialGroup_throwsDuplicateTutorialGroupException() { | ||
uniqueTutorialGroupList.add(TUT_01); | ||
assertThrows(DuplicateTutorialGroupException.class, () -> uniqueTutorialGroupList.add(TUT_01)); | ||
} | ||
|
||
@Test | ||
public void remove_nullTutorialGroup_throwsNullPointerException() { | ||
assertThrows(NullPointerException.class, () -> uniqueTutorialGroupList.remove(null)); | ||
} | ||
|
||
@Test | ||
public void remove_tutorialGroupDoesNotExist_throwsTutorialGroupNotFoundException() { | ||
assertThrows(TutorialGroupNotFoundException.class, () -> uniqueTutorialGroupList.remove(TUT_01)); | ||
} | ||
|
||
@Test | ||
public void remove_existingTutorialGroup_removesTutorialGroup() { | ||
uniqueTutorialGroupList.add(TUT_01); | ||
uniqueTutorialGroupList.remove(TUT_01); | ||
UniqueTutorialGroupList expectedUniqueTutorialGroupList = new UniqueTutorialGroupList(); | ||
assertEquals(expectedUniqueTutorialGroupList, uniqueTutorialGroupList); | ||
} | ||
|
||
@Test | ||
public void asUnmodifiableObservableList_modifyList_throwsUnsupportedOperationException() { | ||
assertThrows(UnsupportedOperationException.class, () | ||
-> uniqueTutorialGroupList.asUnmodifiableObservableList().remove(0)); | ||
} | ||
|
||
} |