Skip to content

Commit

Permalink
fix test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Kailash201 committed Nov 11, 2023
1 parent 140b757 commit b01f23f
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 64 deletions.
1 change: 0 additions & 1 deletion src/main/java/seedu/address/model/TimeIntervalList.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.person.Person;

/**
* Class representing the list of time intervals
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
{
"persons": [ {
"name": "Alice Pauline",
"phone": "94351253",
"email": "[email protected]",
"address": "123, Jurong West Ave 6, #08-111",
"tags": [ "friends" ]
"persons" : [ {
"name" : "Alice Pauline",
"phone" : "94351253",
"email" : "[email protected]",
"groupList" : [ {
"groupRemark" : "CS2105 remark",
"meetingTimeList" : [],
"groupName" : "CS2105"
}],
"freeTimeList" : [ ]
}, {
"name": "Alice Pauline",
"phone": "94351253",
"email": "[email protected]",
"address": "4th street"
} ]
"name" : "Alice Pauline",
"phone" : "94351253",
"email" : "[email protected]",
"groupList" : [ {
"groupRemark" : "CS2105 remark",
"meetingTimeList" : [],
"groupName" : "CS2105"
}],
"freeTimeList" : [ ]
} ],
"groups" : [ {
"groupRemark" : "CS2105 remark",
"meetingTimeList" : [ {
"start" : "MON 1200",
"end" : "MON 1400"
}, {
"start" : "WED 1600",
"end" : "THU 1800"
}],
"groupName" : "CS2105"
}]
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
{
"persons": [ {
"name": "Hans Muster",
"phone": "9482424",
"email": "invalid@email!3e",
"address": "4th street"
} ]
"persons" : [ {
"name" : "Alice Pauline",
"phone" : "94351253",
"email" : "[email protected]",
"groupList" : [ {
"groupRemark" : "CS2105 remark",
"meetingTimeList" : [],
"groupName" : "CS2105"
}],
"freeTimeList" : [ ]
}],
"groups" : [ {
"groupRemark" : "CS2105 remark",
"meetingTimeList" : [ {
"start" : "MONddd 1200",
"end" : "MON 1400"
}, {
"start" : "WED 1600",
"end" : "THU 1800"
}],
"groupName" : "CS2105"
}]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,82 @@
"name" : "Alice Pauline",
"phone" : "94351253",
"email" : "[email protected]",
"groupList" : [ "CS2103T"]
"groupList" : [ {
"groupRemark" : "CS2105 remark",
"meetingTimeList" : [],
"groupName" : "CS2105"
}],
"freeTimeList" : [ ]
}, {
"name" : "Benson Meier",
"phone" : "98765432",
"email" : "[email protected]",
"groupList" : [ "CS2103T"]
"groupList" : [ {
"groupRemark" : "CS2105 remark",
"meetingTimeList" : [],
"groupName" : "CS2105"
}],
"freeTimeList" : [ ]
}, {
"name" : "Carl Kurz",
"phone" : "95352563",
"email" : "[email protected]",
"groupList" : [ "CS2103T"]
"groupList" : [ {
"groupRemark" : "CS2105 remark",
"meetingTimeList" : [],
"groupName" : "CS2105"
}],
"freeTimeList" : [ ]
}, {
"name" : "Daniel Meier",
"phone" : "87652533",
"email" : "[email protected]",
"groupList" : [ "CS2103T"]
"groupList" : [ {
"groupRemark" : "CS2105 remark",
"meetingTimeList" : [],
"groupName" : "CS2105"
}],
"freeTimeList" : [ ]
}, {
"name" : "Elle Meyer",
"phone" : "9482224",
"email" : "[email protected]",
"groupList" : [ "CS2103T"]
"groupList" : [ {
"groupRemark" : "CS2105 remark",
"meetingTimeList" : [],
"groupName" : "CS2105"
}],
"freeTimeList" : [ ]
}, {
"name" : "Fiona Kunz",
"phone" : "9482427",
"email" : "[email protected]",
"groupList" : [ "CS2103T"]
"groupList" : [ {
"groupRemark" : "CS2105 remark",
"meetingTimeList" : [],
"groupName" : "CS2105"
}],
"freeTimeList" : [ ]
}, {
"name" : "George Best",
"phone" : "9482442",
"email" : "[email protected]",
"groupList" : [ "CS2103T"]
} ]
"groupList" : [ {
"groupRemark" : "CS2105 remark",
"meetingTimeList" : [],
"groupName" : "CS2105"
}],
"freeTimeList" : [ ]
} ],
"groups" : [ {
"groupRemark" : "CS2105 remark",
"meetingTimeList" : [ {
"start" : "MON 1200",
"end" : "MON 1400"
}, {
"start" : "WED 1600",
"end" : "THU 1800"
}],
"groupName" : "CS2105"
}]
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void execute_multipleKeywords_multiplePersonsFound() {
public void toStringMethod() {
NameContainsKeywordsPredicate predicate = new NameContainsKeywordsPredicate(Arrays.asList("keyword"));
FindCommand findCommand = new FindPersonCommand(predicate);
String expected = FindCommand.class.getCanonicalName() + "{predicate=" + predicate + "}";
String expected = FindPersonCommand.class.getCanonicalName() + "{predicate=" + predicate + "}";
assertEquals(expected, findCommand.toString());
}

Expand Down
27 changes: 16 additions & 11 deletions src/test/java/seedu/address/logic/parser/AddCommandParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,13 @@ public void parse_allFieldsPresent_success() {
}

@Test
public void parse_repeatedNonTagValue_failure() {
String validExpectedPersonString = NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB;
public void parse_repeated_failure() {
String validExpectedPersonString = NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + GROUP_DESC_BOB;

// multiple names
assertParseFailure(parser, NAME_DESC_AMY + validExpectedPersonString,
Messages.getErrorMessageForDuplicatePrefixes(PREFIX_NAME));


// multiple phones
assertParseFailure(parser, PHONE_DESC_AMY + validExpectedPersonString,
Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PHONE));
Expand All @@ -75,28 +74,36 @@ public void parse_repeatedNonTagValue_failure() {
assertParseFailure(parser, EMAIL_DESC_AMY + validExpectedPersonString,
Messages.getErrorMessageForDuplicatePrefixes(PREFIX_EMAIL));

// multiple groups
assertParseFailure(parser, GROUP_DESC_BOB + validExpectedPersonString,
Messages.getErrorMessageForDuplicatePrefixes(PREFIX_GROUPTAG));

// multiple fields repeated
assertParseFailure(parser,
validExpectedPersonString + PHONE_DESC_AMY + EMAIL_DESC_AMY + NAME_DESC_AMY + validExpectedPersonString,
Messages.getErrorMessageForDuplicatePrefixes(PREFIX_NAME, PREFIX_EMAIL, PREFIX_PHONE));
Messages.getErrorMessageForDuplicatePrefixes(PREFIX_NAME, PREFIX_EMAIL, PREFIX_PHONE, PREFIX_GROUPTAG));

// invalid name
assertParseFailure(parser, INVALID_NAME_DESC + PHONE_DESC_BOB + EMAIL_DESC_BOB,
assertParseFailure(parser, INVALID_NAME_DESC + PHONE_DESC_BOB + EMAIL_DESC_BOB + GROUP_DESC_BOB,
Name.MESSAGE_CONSTRAINTS);

// invalid email
assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + INVALID_EMAIL_DESC,
assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + INVALID_EMAIL_DESC + GROUP_DESC_BOB,
Email.MESSAGE_CONSTRAINTS);

// invalid phone
assertParseFailure(parser, NAME_DESC_BOB + INVALID_PHONE_DESC + EMAIL_DESC_BOB,
assertParseFailure(parser, NAME_DESC_BOB + INVALID_PHONE_DESC + EMAIL_DESC_BOB + GROUP_DESC_BOB,
Phone.MESSAGE_CONSTRAINTS);

// invalid group
assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_GROUP_DESC,
Group.MESSAGE_CONSTRAINTS);


}

@Test
public void parse_optionalFieldsMissing_success() {
// zero tags
Person expectedPerson = new PersonBuilder(AMYWITHOUTGROUP).build();
assertParseSuccess(parser, NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY,
new AddCommand(expectedPerson));
Expand Down Expand Up @@ -138,8 +145,6 @@ public void parse_invalidValue_failure() {
assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + INVALID_EMAIL_DESC + GROUP_DESC_BOB,
Email.MESSAGE_CONSTRAINTS);

// invalid address

// invalid group
assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_GROUP_DESC,
Group.MESSAGE_CONSTRAINTS);
Expand All @@ -153,6 +158,6 @@ public void parse_invalidValue_failure() {
String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE));

assertParseFailure(parser, PREAMBLE_NON_EMPTY + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB
+ " " + PREFIX_GROUPTAG, String.format(MESSAGE_INVALID_COMMAND_FORMAT, Group.MESSAGE_CONSTRAINTS));
+ GROUP_DESC_BOB, String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public void parse_validArgs_returnsFindCommand() {
// no leading and trailing whitespaces
FindCommand expectedFindCommand =
new FindPersonCommand(new NameContainsKeywordsPredicate(Arrays.asList("Alice", "Bob")));
assertParseSuccess(parser, "Alice Bob", expectedFindCommand);
assertParseSuccess(parser, " n/Alice Bob", expectedFindCommand);

// multiple whitespaces between keywords
assertParseSuccess(parser, " \n Alice \n \t Bob \t", expectedFindCommand);
assertParseSuccess(parser, " n/ Alice Bob ", expectedFindCommand);
}

}
4 changes: 3 additions & 1 deletion src/test/java/seedu/address/model/AddressBookTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public void toStringMethod() {
*/
private static class AddressBookStub implements ReadOnlyAddressBook {
private final ObservableList<Person> persons = FXCollections.observableArrayList();
private final ObservableList<Group> groups = FXCollections.observableArrayList();


AddressBookStub(Collection<Person> persons) {
this.persons.setAll(persons);
Expand All @@ -106,7 +108,7 @@ public ObservableList<Person> getPersonList() {
//need to be edited
@Override
public ObservableList<Group> getGroupList() {
return getGroupList();
return groups;
}
}

Expand Down
20 changes: 6 additions & 14 deletions src/test/java/seedu/address/testutil/TypicalGroups.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import static seedu.address.logic.commands.CommandTestUtil.VALID_GROUP_CS;
import static seedu.address.logic.commands.CommandTestUtil.VALID_GROUP_CS2103T;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import seedu.address.model.group.Group;
import seedu.address.model.group.GroupList;
import seedu.address.model.group.GroupRemark;

/**
Expand All @@ -26,20 +27,11 @@ public class TypicalGroups {
.withTimeIntervalList("mon 1200 - mon 1400", "wed 1600 - thu 1800").build();

public static final Group CS2105 = new GroupBuilder().withName("CS2105")
.withGroupRemark("CS2105 remark").withListOfGroupMates("Avner", "Bernie", "Coin", "Dawson")
.withTimeIntervalList("mon 1200 - mon 1400", "wed 1600 - thu 1800").build();


public static GroupList getTypicalPGroup() {

GroupList groupList = new GroupList();
Group[] groupArray = {CS2100, CS2102, CS2103, CS2105};

Arrays.stream(groupArray).forEach(groupList::add);

return groupList;

.withGroupRemark("CS2105 remark").withTimeIntervalList("mon 1200 - mon 1400", "wed 1600 - thu 1800")
.build();

public static List<Group> getTypicalGroup() {
return new ArrayList<>(Arrays.asList(CS2105));
}

}
21 changes: 12 additions & 9 deletions src/test/java/seedu/address/testutil/TypicalPersons.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.List;

import seedu.address.model.AddressBook;
import seedu.address.model.group.Group;
import seedu.address.model.person.Person;

/**
Expand All @@ -24,26 +25,26 @@ public class TypicalPersons {
public static final Person ALICE = new PersonBuilder().withName("Alice Pauline")
.withEmail("[email protected]")
.withPhone("94351253")
.withGroupList("CS2103T").build();
.withGroupList("CS2105").build();
public static final Person BENSON = new PersonBuilder().withName("Benson Meier")
.withEmail("[email protected]").withPhone("98765432")
.withGroupList("CS2103T").build();
.withGroupList("CS2105").build();
public static final Person CARL = new PersonBuilder().withName("Carl Kurz").withPhone("95352563")
.withEmail("[email protected]").withGroupList("CS2103T").build();
.withEmail("[email protected]").withGroupList("CS2105").build();
public static final Person DANIEL = new PersonBuilder().withName("Daniel Meier").withPhone("87652533")
.withEmail("[email protected]").withGroupList("CS2103T").build();
.withEmail("[email protected]").withGroupList("CS2105").build();
public static final Person ELLE = new PersonBuilder().withName("Elle Meyer").withPhone("9482224")
.withEmail("[email protected]").withGroupList("CS2103T").build();
.withEmail("[email protected]").withGroupList("CS2105").build();
public static final Person FIONA = new PersonBuilder().withName("Fiona Kunz").withPhone("9482427")
.withEmail("[email protected]").withGroupList("CS2103T").build();
.withEmail("[email protected]").withGroupList("CS2105").build();
public static final Person GEORGE = new PersonBuilder().withName("George Best").withPhone("9482442")
.withEmail("[email protected]").withGroupList("CS2103T").build();
.withEmail("[email protected]").withGroupList("CS2105").build();

// Manually added
public static final Person HOON = new PersonBuilder().withName("Hoon Meier").withPhone("8482424")
.withEmail("[email protected]").withGroupList("CS2103T").build();
.withEmail("[email protected]").withGroupList("CS2105").build();
public static final Person IDA = new PersonBuilder().withName("Ida Mueller").withPhone("8482131")
.withEmail("[email protected]").withGroupList("CS2103T").build();
.withEmail("[email protected]").withGroupList("CS2105").build();

// Manually added - Person's details found in {@code CommandTestUtil}
public static final Person AMY = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY)
Expand All @@ -64,6 +65,8 @@ private TypicalPersons() {} // prevents instantiation
*/
public static AddressBook getTypicalAddressBook() {
AddressBook ab = new AddressBook();
Group group = TypicalGroups.getTypicalGroup().get(0);
ab.addGroup(group);
for (Person person : getTypicalPersons()) {
ab.addPerson(person);
}
Expand Down

0 comments on commit b01f23f

Please sign in to comment.