Skip to content

Commit

Permalink
Move utility method to helper class
Browse files Browse the repository at this point in the history
  • Loading branch information
damithc committed Sep 8, 2016
1 parent c57de5e commit b71c347
Showing 1 changed file with 29 additions and 25 deletions.
54 changes: 29 additions & 25 deletions test/java/seedu/addressbook/logic/LogicTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ public void execute_delete_removesCorrectPerson() throws Exception {
threePersons);
}


@Test
public void execute_delete_missingInAddressBook() throws Exception {

Expand All @@ -419,18 +418,7 @@ public void execute_delete_missingInAddressBook() throws Exception {
threePersons);
}

/**
* Generates a Person object with given name. Other fields will have some dummy values.
*/
private Person generatePersonWithName(String name) throws Exception {
return new Person(
new Name(name),
new Phone("1", false),
new Email("1@email", false),
new Address("House of 1", false),
new UniqueTagList(new Tag("tag"))
);
}


@Test
public void execute_find_invalidArgsFormat() throws Exception {
Expand All @@ -440,10 +428,11 @@ public void execute_find_invalidArgsFormat() throws Exception {

@Test
public void execute_find_onlyMatchesFullWordsInNames() throws Exception {
Person pTarget1 = generatePersonWithName("bla bla KEY bla");
Person pTarget2 = generatePersonWithName("bla KEY bla bceofeia");
Person p1 = generatePersonWithName("KE Y");
Person p2 = generatePersonWithName("KEYKEYKEY sduauo");
TestDataHelper helper = new TestDataHelper();
Person pTarget1 = helper.generatePersonWithName("bla bla KEY bla");
Person pTarget2 = helper.generatePersonWithName("bla KEY bla bceofeia");
Person p1 = helper.generatePersonWithName("KE Y");
Person p2 = helper.generatePersonWithName("KEYKEYKEY sduauo");

AddressBook expectedAB = new AddressBook();
expectedAB.addPerson(p1);
Expand All @@ -468,10 +457,11 @@ public void execute_find_onlyMatchesFullWordsInNames() throws Exception {

@Test
public void execute_find_isCaseSensitive() throws Exception {
Person pTarget1 = generatePersonWithName("bla bla KEY bla");
Person pTarget2 = generatePersonWithName("bla KEY bla bceofeia");
Person p1 = generatePersonWithName("key key");
Person p2 = generatePersonWithName("KEy sduauo");
TestDataHelper helper = new TestDataHelper();
Person pTarget1 = helper.generatePersonWithName("bla bla KEY bla");
Person pTarget2 = helper.generatePersonWithName("bla KEY bla bceofeia");
Person p1 = helper.generatePersonWithName("key key");
Person p2 = helper.generatePersonWithName("KEy sduauo");

AddressBook expectedAB = new AddressBook();
expectedAB.addPerson(p1);
Expand All @@ -496,10 +486,11 @@ public void execute_find_isCaseSensitive() throws Exception {

@Test
public void execute_find_matchesIfAnyKeywordPresent() throws Exception {
Person pTarget1 = generatePersonWithName("bla bla KEY bla");
Person pTarget2 = generatePersonWithName("bla rAnDoM bla bceofeia");
Person p1 = generatePersonWithName("key key");
Person p2 = generatePersonWithName("KEy sduauo");
TestDataHelper helper = new TestDataHelper();
Person pTarget1 = helper.generatePersonWithName("bla bla KEY bla");
Person pTarget2 = helper.generatePersonWithName("bla rAnDoM bla bceofeia");
Person p1 = helper.generatePersonWithName("key key");
Person p2 = helper.generatePersonWithName("KEy sduauo");

AddressBook expectedAB = new AddressBook();
expectedAB.addPerson(p1);
Expand Down Expand Up @@ -612,6 +603,19 @@ List<Person> generatePersonList(Boolean... isPrivateStatuses) throws Exception{
}
return persons;
}

/**
* Generates a Person object with given name. Other fields will have some dummy values.
*/
Person generatePersonWithName(String name) throws Exception {
return new Person(
new Name(name),
new Phone("1", false),
new Email("1@email", false),
new Address("House of 1", false),
new UniqueTagList(new Tag("tag"))
);
}
}

}

0 comments on commit b71c347

Please sign in to comment.