Skip to content

Commit

Permalink
Refine execute_viewAll_alsoShowsPrivate()
Browse files Browse the repository at this point in the history
  • Loading branch information
damithc committed Sep 8, 2016
1 parent 4bad62b commit b5349ac
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions test/java/seedu/addressbook/logic/LogicTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ private void assertInvalidIndexBehaviorForCommand(String commandWord) throws Exc
public void execute_view_onlyShowsNonPrivate() throws Exception {

TestDataHelper helper = new TestDataHelper();
Person p1 = helper.generatePerson(1, false);
Person p1 = helper.generatePerson(1, true);
Person p2 = helper.generatePerson(2, false);
List<Person> lastShownList = helper.generatePersonList(p1, p2);
AddressBook expectedAB = helper.generateAddressBook(lastShownList);
Expand Down Expand Up @@ -313,32 +313,27 @@ public void execute_viewAll_invalidIndex() throws Exception {
}

@Test
public void execute_view_alsoShowsPrivate() throws Exception {
//TODO: what's the purpose of this test?
List<Person> lastShownList = new ArrayList<>();
public void execute_viewAll_alsoShowsPrivate() throws Exception {
TestDataHelper helper = new TestDataHelper();
Person p1 = helper.generatePerson(1, false);
Person p1 = helper.generatePerson(1, true);
Person p2 = helper.generatePerson(2, false);
lastShownList.add(p1);
lastShownList.add(p2);
AddressBook expectedAB = new AddressBook();
expectedAB.addPerson(p1);
expectedAB.addPerson(p2);
List<Person> lastShownList = helper.generatePersonList(p1, p2);
AddressBook expectedAB = helper.generateAddressBook(lastShownList);
helper.addToAddressBook(addressBook, lastShownList);

addressBook.addPerson(p1);
addressBook.addPerson(p2);
logic.setLastShownList(lastShownList);
CommandResult r;

r = logic.execute("view 1");
assertEquals(String.format(ViewAllCommand.MESSAGE_VIEW_PERSON_DETAILS, p1.getAsTextShowAll()), r.feedbackToUser);
assertFalse(r.getRelevantPersons().isPresent());
assertLogicObjectStateEquals(expectedAB, lastShownList);
assertNonMutatingCommandBehavior("viewall 1",
String.format(ViewCommand.MESSAGE_VIEW_PERSON_DETAILS, p1.getAsTextShowAll()),
expectedAB,
false,
lastShownList);

r = logic.execute("view 2");
assertEquals(String.format(ViewAllCommand.MESSAGE_VIEW_PERSON_DETAILS, p2.getAsTextShowAll()), r.feedbackToUser);
assertFalse(r.getRelevantPersons().isPresent());
assertLogicObjectStateEquals(expectedAB, lastShownList);
assertNonMutatingCommandBehavior("viewall 2",
String.format(ViewCommand.MESSAGE_VIEW_PERSON_DETAILS, p2.getAsTextShowAll()),
expectedAB,
false,
lastShownList);
}

@Test
Expand All @@ -359,7 +354,6 @@ public void execute_tryToViewAllPersonMissingInAddressBook_errorMessage() throws
expectedAB,
false,
lastShownList);

}

@Test
Expand Down Expand Up @@ -421,8 +415,6 @@ public void execute_delete_missingInAddressBook() throws Exception {
threePersons);
}



@Test
public void execute_find_invalidArgsFormat() throws Exception {
String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindCommand.MESSAGE_USAGE);
Expand Down

0 comments on commit b5349ac

Please sign in to comment.