Skip to content

Commit

Permalink
AddressBook: remove unused containsTag()
Browse files Browse the repository at this point in the history
AddressBook#containsTag() checks if a given Tag is in the master list of
Tags. However this method is not used anywhere as there are no commands
that support it, and is not part of any learning objectives. While it is
used in two tests for AddressBook#addPerson(),
AddressBook#containsTag(Tag):boolean is used infrequently enough to
justify superseding it with AddressBook#getAllTags():UniqueTagList and
UniqueTagList#contains(Tag).

Let's remove AddressBook#containsTag() as unused code contributes to
maintenance and comprehension overheads.
  • Loading branch information
PierceAndy committed Feb 10, 2017
1 parent 4beca9c commit b81b6c8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 31 deletions.
7 changes: 0 additions & 7 deletions src/seedu/addressbook/data/AddressBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,6 @@ public boolean containsPerson(ReadOnlyPerson key) {
return allPersons.contains(key);
}

/**
* Returns true if an equivalent person exists in the address book.
*/
public boolean containsTag(Tag key) {
return allTags.contains(key);
}

/**
* Removes the equivalent person from the address book.
*
Expand Down
29 changes: 5 additions & 24 deletions test/java/seedu/addressbook/data/AddressBookTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ public void addPerson_emptyAddressBook() throws Exception {

@Test
public void addPerson_someTagsNotInTagList() throws Exception {
assertFalse(defaultAddressBook.containsTag(tagEconomist));
assertFalse(defaultAddressBook.containsTag(tagPrizeWinner));
assertFalse(defaultAddressBook.getAllTags().contains(tagEconomist));
assertFalse(defaultAddressBook.getAllTags().contains(tagPrizeWinner));
defaultAddressBook.addPerson(davidElliot);
assertTrue(defaultAddressBook.containsTag(tagEconomist));
assertTrue(defaultAddressBook.containsTag(tagPrizeWinner));
assertTrue(defaultAddressBook.getAllTags().contains(tagEconomist));
assertTrue(defaultAddressBook.getAllTags().contains(tagPrizeWinner));

assertTrue(isTagObjectInAddressBookList(tagEconomist, defaultAddressBook));
assertTrue(isTagObjectInAddressBookList(tagPrizeWinner, defaultAddressBook));
Expand All @@ -117,7 +117,7 @@ public void addPerson_personAlreadyInListButHasTagNotInList_tagNotAdded() throws
// ignore expected exception
}

assertFalse(defaultAddressBook.containsTag(tagPrizeWinner));
assertFalse(defaultAddressBook.getAllTags().contains(tagPrizeWinner));
}

@Test
Expand All @@ -139,25 +139,6 @@ public void containsPerson() throws Exception {
}
}

@Test
public void containsTag() throws Exception {
UniqueTagList tagsWhichShouldBeIn = new UniqueTagList(tagMathematician, tagScientist);
UniqueTagList tagsWHichShouldNotBeIn = new UniqueTagList(tagEconomist, tagPrizeWinner);

for (Tag tagWhichShouldBeIn : tagsWhichShouldBeIn) {
assertTrue(defaultAddressBook.containsTag(tagWhichShouldBeIn));
}
for (Tag tagWhichShouldNotBeIn : tagsWHichShouldNotBeIn) {
assertFalse(defaultAddressBook.containsTag(tagWhichShouldNotBeIn));
}

UniqueTagList allTags = new UniqueTagList(tagPrizeWinner, tagScientist, tagMathematician, tagEconomist);

for (Tag tag : allTags) {
assertFalse(emptyAddressBook.containsTag(tag));
}
}

@Test
public void removePerson_personExists_removesNormally() throws Exception {
int numberOfPersonsBeforeRemoval = getSize(defaultAddressBook.getAllPersons());
Expand Down

0 comments on commit b81b6c8

Please sign in to comment.