Skip to content

Commit

Permalink
Refine execute_find_onlyMatchesFullWordsInNames()
Browse files Browse the repository at this point in the history
  • Loading branch information
damithc committed Sep 8, 2016
1 parent b71c347 commit f2edf7f
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions test/java/seedu/addressbook/logic/LogicTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ private void assertNonMutatingCommandBehavior(String inputCommand,
CommandResult r = logic.execute(inputCommand);
assertEquals(expectedMessage, r.feedbackToUser);
assertEquals(r.getRelevantPersons().isPresent(), isRelevantPersonsExpected);
if(isRelevantPersonsExpected){
assertEquals(lastShownList, r.getRelevantPersons().get());
}
// no side effects to logic object
assertLogicObjectStateEquals(expectedAddressBook, lastShownList);
}
Expand Down Expand Up @@ -433,26 +436,17 @@ public void execute_find_onlyMatchesFullWordsInNames() throws Exception {
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);
expectedAB.addPerson(pTarget1);
expectedAB.addPerson(p2);
expectedAB.addPerson(pTarget2);

List<Person> expectedList = new ArrayList<>();
expectedList.addAll(Arrays.asList(pTarget1, pTarget2));

addressBook.addPerson(p1);
addressBook.addPerson(pTarget1);
addressBook.addPerson(p2);
addressBook.addPerson(pTarget2);
CommandResult r = logic.execute("find KEY");

assertEquals(Command.getMessageForPersonListShownSummary(expectedList), r.feedbackToUser);
assertTrue(r.getRelevantPersons().isPresent());
assertEquals(expectedList, r.getRelevantPersons().get());
assertLogicObjectStateEquals(expectedAB, expectedList);
List<Person> fourPersons = helper.generatePersonList(p1, pTarget1, p2, pTarget2);
AddressBook expectedAB = helper.generateAddressBook(fourPersons);
List<Person> expectedList = helper.generatePersonList(pTarget1, pTarget2);
helper.addToAddressBook(addressBook, fourPersons);

assertNonMutatingCommandBehavior("find KEY",
Command.getMessageForPersonListShownSummary(expectedList),
expectedAB,
true,
expectedList);
}

@Test
Expand Down

0 comments on commit f2edf7f

Please sign in to comment.