From b81b6c811b4355b1ee5270509bd9afe427936d92 Mon Sep 17 00:00:00 2001 From: PierceAndy Date: Thu, 9 Feb 2017 20:30:18 +0800 Subject: [PATCH] AddressBook: remove unused containsTag() 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. --- src/seedu/addressbook/data/AddressBook.java | 7 ----- .../addressbook/data/AddressBookTest.java | 29 ++++--------------- 2 files changed, 5 insertions(+), 31 deletions(-) diff --git a/src/seedu/addressbook/data/AddressBook.java b/src/seedu/addressbook/data/AddressBook.java index e64f7351e..a99a92f9f 100644 --- a/src/seedu/addressbook/data/AddressBook.java +++ b/src/seedu/addressbook/data/AddressBook.java @@ -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. * diff --git a/test/java/seedu/addressbook/data/AddressBookTest.java b/test/java/seedu/addressbook/data/AddressBookTest.java index 0634f6b82..16bf58554 100644 --- a/test/java/seedu/addressbook/data/AddressBookTest.java +++ b/test/java/seedu/addressbook/data/AddressBookTest.java @@ -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)); @@ -117,7 +117,7 @@ public void addPerson_personAlreadyInListButHasTagNotInList_tagNotAdded() throws // ignore expected exception } - assertFalse(defaultAddressBook.containsTag(tagPrizeWinner)); + assertFalse(defaultAddressBook.getAllTags().contains(tagPrizeWinner)); } @Test @@ -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());