diff --git a/src/main/java/seedu/savvytasker/MainApp.java b/src/main/java/seedu/savvytasker/MainApp.java index 849b796ee519..7273d2cdea21 100644 --- a/src/main/java/seedu/savvytasker/MainApp.java +++ b/src/main/java/seedu/savvytasker/MainApp.java @@ -31,7 +31,7 @@ public class MainApp extends Application { private static final Logger logger = LogsCenter.getLogger(MainApp.class); - public static final Version VERSION = new Version(1, 0, 0, true); + public static final Version VERSION = new Version(0, 4, 0, true); protected Ui ui; protected Logic logic; @@ -44,7 +44,7 @@ public MainApp() {} @Override public void init() throws Exception { - logger.info("=============================[ Initializing AddressBook ]==========================="); + logger.info("=============================[ Initializing Savvy Tasker ]==========================="); super.init(); config = initConfig(getApplicationParameter("config")); @@ -74,14 +74,14 @@ private Model initModelManager(Storage storage, UserPrefs userPrefs) { try { savvyTaskerOptional = storage.readSavvyTasker(); if(!savvyTaskerOptional.isPresent()){ - logger.info("Data file not found. Will be starting with an empty AddressBook"); + logger.info("Data file not found. Will be starting with an empty Savvy Tasker"); } initialData = savvyTaskerOptional.orElse(new SavvyTasker()); } catch (DataConversionException e) { - logger.warning("Data file not in the correct format. Will be starting with an empty AddressBook"); + logger.warning("Data file not in the correct format. Will be starting with an empty Savvy Tasker"); initialData = new SavvyTasker(); } catch (IOException e) { - logger.warning("Problem while reading from the file. . Will be starting with an empty AddressBook"); + logger.warning("Problem while reading from the file. . Will be starting with an empty Savvy Tasker"); initialData = new SavvyTasker(); } @@ -138,7 +138,7 @@ protected UserPrefs initPrefs(Config config) { "Using default user prefs"); initializedPrefs = new UserPrefs(); } catch (IOException e) { - logger.warning("Problem while reading from the file. . Will be starting with an empty AddressBook"); + logger.warning("Problem while reading from the file. . Will be starting with an empty Savvy Tasker"); initializedPrefs = new UserPrefs(); } @@ -158,13 +158,13 @@ private void initEventsCenter() { @Override public void start(Stage primaryStage) { - logger.info("Starting AddressBook " + MainApp.VERSION); + logger.info("Starting Savvy Tasker " + MainApp.VERSION); ui.start(primaryStage); } @Override public void stop() { - logger.info("============================ [ Stopping Address Book ] ============================="); + logger.info("============================ [ Stopping Savvy Tasker ] ============================="); ui.stop(); try { storage.saveUserPrefs(userPrefs); diff --git a/src/main/java/seedu/savvytasker/commons/core/GuiSettings.java b/src/main/java/seedu/savvytasker/commons/core/GuiSettings.java index fca203251759..c7bb07be54a2 100644 --- a/src/main/java/seedu/savvytasker/commons/core/GuiSettings.java +++ b/src/main/java/seedu/savvytasker/commons/core/GuiSettings.java @@ -9,6 +9,10 @@ */ public class GuiSettings implements Serializable { + /** + * Generated serial + */ + private static final long serialVersionUID = -7442507632162266083L; private static final double DEFAULT_HEIGHT = 600; private static final double DEFAULT_WIDTH = 740; diff --git a/src/main/java/seedu/savvytasker/commons/core/UnmodifiableObservableList.java b/src/main/java/seedu/savvytasker/commons/core/UnmodifiableObservableList.java index ee38fc63d6d3..703ec628cc12 100644 --- a/src/main/java/seedu/savvytasker/commons/core/UnmodifiableObservableList.java +++ b/src/main/java/seedu/savvytasker/commons/core/UnmodifiableObservableList.java @@ -95,7 +95,7 @@ public final SortedList sorted(Comparator comparator) { public final SortedList sorted() { return sorted(Comparator.nullsFirst((o1, o2) -> { if (o1 instanceof Comparable) { - return ((Comparable) o1).compareTo(o2); + return ((Comparable) o1).compareTo(o2); } return Collator.getInstance().compare(o1.toString(), o2.toString()); })); diff --git a/src/main/java/seedu/savvytasker/commons/events/model/AddressBookChangedEvent.java b/src/main/java/seedu/savvytasker/commons/events/model/AddressBookChangedEvent.java deleted file mode 100644 index 02f07cdb169e..000000000000 --- a/src/main/java/seedu/savvytasker/commons/events/model/AddressBookChangedEvent.java +++ /dev/null @@ -1,19 +0,0 @@ -package seedu.savvytasker.commons.events.model; - -import seedu.savvytasker.commons.events.BaseEvent; -import seedu.savvytasker.model.ReadOnlyAddressBook; - -/** Indicates the AddressBook in the model has changed*/ -public class AddressBookChangedEvent extends BaseEvent { - - public final ReadOnlyAddressBook data; - - public AddressBookChangedEvent(ReadOnlyAddressBook data){ - this.data = data; - } - - @Override - public String toString() { - return "number of persons " + data.getPersonList().size() + ", number of tags " + data.getTagList().size(); - } -} diff --git a/src/main/java/seedu/savvytasker/commons/events/ui/JumpToListRequestEvent.java b/src/main/java/seedu/savvytasker/commons/events/ui/JumpToListRequestEvent.java index 3fef46270461..104ee70b0659 100644 --- a/src/main/java/seedu/savvytasker/commons/events/ui/JumpToListRequestEvent.java +++ b/src/main/java/seedu/savvytasker/commons/events/ui/JumpToListRequestEvent.java @@ -3,7 +3,7 @@ import seedu.savvytasker.commons.events.BaseEvent; /** - * Indicates a request to jump to the list of persons + * Indicates a request to jump to the list of tasks */ public class JumpToListRequestEvent extends BaseEvent { diff --git a/src/main/java/seedu/savvytasker/commons/events/ui/TaskPanelSelectionChangedEvent.java b/src/main/java/seedu/savvytasker/commons/events/ui/TaskPanelSelectionChangedEvent.java index dca09770ea5b..89caab54a44f 100644 --- a/src/main/java/seedu/savvytasker/commons/events/ui/TaskPanelSelectionChangedEvent.java +++ b/src/main/java/seedu/savvytasker/commons/events/ui/TaskPanelSelectionChangedEvent.java @@ -1,7 +1,7 @@ package seedu.savvytasker.commons.events.ui; import seedu.savvytasker.commons.events.BaseEvent; -import seedu.savvytasker.model.person.ReadOnlyTask; +import seedu.savvytasker.model.task.ReadOnlyTask; /** * Represents a selection change in the Person List Panel diff --git a/src/main/java/seedu/savvytasker/commons/exceptions/DataConversionException.java b/src/main/java/seedu/savvytasker/commons/exceptions/DataConversionException.java index f64199deff22..087f61d9b771 100644 --- a/src/main/java/seedu/savvytasker/commons/exceptions/DataConversionException.java +++ b/src/main/java/seedu/savvytasker/commons/exceptions/DataConversionException.java @@ -4,6 +4,11 @@ * Represents an error during conversion of data from one format to another */ public class DataConversionException extends Exception { + /** + * Generated serial + */ + private static final long serialVersionUID = -5908631495910190437L; + public DataConversionException(Exception cause) { super(cause); } diff --git a/src/main/java/seedu/savvytasker/commons/exceptions/DuplicateDataException.java b/src/main/java/seedu/savvytasker/commons/exceptions/DuplicateDataException.java index f3fc02d5ae4f..e096adf6b272 100644 --- a/src/main/java/seedu/savvytasker/commons/exceptions/DuplicateDataException.java +++ b/src/main/java/seedu/savvytasker/commons/exceptions/DuplicateDataException.java @@ -4,6 +4,11 @@ * Signals an error caused by duplicate data where there should be none. */ public abstract class DuplicateDataException extends IllegalValueException { + /** + * Generated serial + */ + private static final long serialVersionUID = 5045611929659070003L; + public DuplicateDataException(String message) { super(message); } diff --git a/src/main/java/seedu/savvytasker/commons/exceptions/IllegalValueException.java b/src/main/java/seedu/savvytasker/commons/exceptions/IllegalValueException.java index a33075c24e85..fd5295f907a3 100644 --- a/src/main/java/seedu/savvytasker/commons/exceptions/IllegalValueException.java +++ b/src/main/java/seedu/savvytasker/commons/exceptions/IllegalValueException.java @@ -4,6 +4,11 @@ * Signals that some given data does not fulfill some constraints. */ public class IllegalValueException extends Exception { + /** + * Generated serial + */ + private static final long serialVersionUID = 193885632897265498L; + /** * @param message should contain relevant information on the failed constraint(s) */ diff --git a/src/main/java/seedu/savvytasker/commons/util/CollectionUtil.java b/src/main/java/seedu/savvytasker/commons/util/CollectionUtil.java deleted file mode 100644 index 617290a80c46..000000000000 --- a/src/main/java/seedu/savvytasker/commons/util/CollectionUtil.java +++ /dev/null @@ -1,47 +0,0 @@ -package seedu.savvytasker.commons.util; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -/** - * Utility methods related to Collections - */ -public class CollectionUtil { - - /** - * Returns true if any of the given items are null. - */ - public static boolean isAnyNull(Object... items) { - for (Object item : items) { - if (item == null) { - return true; - } - } - return false; - } - - - - /** - * Throws an assertion error if the collection or any item in it is null. - */ - public static void assertNoNullElements(Collection items) { - assert items != null; - assert !isAnyNull(items); - } - - /** - * Returns true if every element in a collection are unique by {@link Object#equals(Object)}. - */ - public static boolean elementsAreUnique(Collection items) { - final Set testSet = new HashSet<>(); - for (Object item : items) { - final boolean itemAlreadyExists = !testSet.add(item); // see Set documentation - if (itemAlreadyExists) { - return false; - } - } - return true; - } -} diff --git a/src/main/java/seedu/savvytasker/commons/util/JsonUtil.java b/src/main/java/seedu/savvytasker/commons/util/JsonUtil.java index 99bdac17ec82..b5c8d453273d 100644 --- a/src/main/java/seedu/savvytasker/commons/util/JsonUtil.java +++ b/src/main/java/seedu/savvytasker/commons/util/JsonUtil.java @@ -20,6 +20,11 @@ public class JsonUtil { private static class LevelDeserializer extends FromStringDeserializer { + /** + * Generated serial + */ + private static final long serialVersionUID = 7901046138205615293L; + protected LevelDeserializer(Class vc) { super(vc); } diff --git a/src/main/java/seedu/savvytasker/logic/Logic.java b/src/main/java/seedu/savvytasker/logic/Logic.java index bcea4afa8902..80316d645807 100644 --- a/src/main/java/seedu/savvytasker/logic/Logic.java +++ b/src/main/java/seedu/savvytasker/logic/Logic.java @@ -2,7 +2,7 @@ import javafx.collections.ObservableList; import seedu.savvytasker.logic.commands.CommandResult; -import seedu.savvytasker.model.person.ReadOnlyTask; +import seedu.savvytasker.model.task.ReadOnlyTask; /** * API of the Logic component diff --git a/src/main/java/seedu/savvytasker/logic/LogicManager.java b/src/main/java/seedu/savvytasker/logic/LogicManager.java index 05c2e91286ea..89e11e58dfd9 100644 --- a/src/main/java/seedu/savvytasker/logic/LogicManager.java +++ b/src/main/java/seedu/savvytasker/logic/LogicManager.java @@ -7,7 +7,7 @@ import seedu.savvytasker.logic.commands.CommandResult; import seedu.savvytasker.logic.parser.*; import seedu.savvytasker.model.Model; -import seedu.savvytasker.model.person.ReadOnlyTask; +import seedu.savvytasker.model.task.ReadOnlyTask; import seedu.savvytasker.storage.Storage; import java.util.Stack; diff --git a/src/main/java/seedu/savvytasker/logic/commands/AddCommand.java b/src/main/java/seedu/savvytasker/logic/commands/AddCommand.java index d4346c90bd5a..768d421f5859 100644 --- a/src/main/java/seedu/savvytasker/logic/commands/AddCommand.java +++ b/src/main/java/seedu/savvytasker/logic/commands/AddCommand.java @@ -1,8 +1,8 @@ package seedu.savvytasker.logic.commands; import seedu.savvytasker.logic.commands.models.AddCommandModel; -import seedu.savvytasker.model.person.*; -import seedu.savvytasker.model.person.TaskList.DuplicateTaskException; +import seedu.savvytasker.model.task.Task; +import seedu.savvytasker.model.task.TaskList.DuplicateTaskException; /** * Adds a person to the address book. @@ -42,7 +42,6 @@ public CommandResult execute() { model.addTask(toAdd); return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd)); } catch (DuplicateTaskException e) { - assert false; // ModelManager will ensure no duplicated tasks return new CommandResult(MESSAGE_DUPLICATE_TASK); } diff --git a/src/main/java/seedu/savvytasker/logic/commands/AliasCommand.java b/src/main/java/seedu/savvytasker/logic/commands/AliasCommand.java index 559bae3ece66..0205fa9ec82f 100644 --- a/src/main/java/seedu/savvytasker/logic/commands/AliasCommand.java +++ b/src/main/java/seedu/savvytasker/logic/commands/AliasCommand.java @@ -1,8 +1,8 @@ package seedu.savvytasker.logic.commands; import seedu.savvytasker.logic.commands.models.AliasCommandModel; -import seedu.savvytasker.model.person.*; -import seedu.savvytasker.model.person.TaskList.DuplicateTaskException; +import seedu.savvytasker.model.task.Task; +import seedu.savvytasker.model.task.TaskList.DuplicateTaskException; /** * Command to create aliases diff --git a/src/main/java/seedu/savvytasker/logic/commands/DeleteCommand.java b/src/main/java/seedu/savvytasker/logic/commands/DeleteCommand.java index a111be90caf7..42b9bec4a5f1 100644 --- a/src/main/java/seedu/savvytasker/logic/commands/DeleteCommand.java +++ b/src/main/java/seedu/savvytasker/logic/commands/DeleteCommand.java @@ -5,8 +5,8 @@ import seedu.savvytasker.commons.core.Messages; import seedu.savvytasker.commons.core.UnmodifiableObservableList; import seedu.savvytasker.logic.commands.models.DeleteCommandModel; -import seedu.savvytasker.model.person.ReadOnlyTask; -import seedu.savvytasker.model.person.TaskList.TaskNotFoundException; +import seedu.savvytasker.model.task.ReadOnlyTask; +import seedu.savvytasker.model.task.TaskList.TaskNotFoundException; /** * Deletes a person identified using it's last displayed index from the address book. diff --git a/src/main/java/seedu/savvytasker/logic/commands/ModifyCommand.java b/src/main/java/seedu/savvytasker/logic/commands/ModifyCommand.java index 9b0d8ecde5bb..c04bfea6cfdd 100644 --- a/src/main/java/seedu/savvytasker/logic/commands/ModifyCommand.java +++ b/src/main/java/seedu/savvytasker/logic/commands/ModifyCommand.java @@ -3,8 +3,9 @@ import seedu.savvytasker.commons.core.Messages; import seedu.savvytasker.commons.core.UnmodifiableObservableList; import seedu.savvytasker.logic.commands.models.ModifyCommandModel; -import seedu.savvytasker.model.person.*; -import seedu.savvytasker.model.person.TaskList.TaskNotFoundException; +import seedu.savvytasker.model.task.ReadOnlyTask; +import seedu.savvytasker.model.task.Task; +import seedu.savvytasker.model.task.TaskList.TaskNotFoundException; /** * Adds a person to the address book. diff --git a/src/main/java/seedu/savvytasker/logic/commands/SelectCommand.java b/src/main/java/seedu/savvytasker/logic/commands/SelectCommand.java index 81cd134d84c6..f905fb1deb79 100644 --- a/src/main/java/seedu/savvytasker/logic/commands/SelectCommand.java +++ b/src/main/java/seedu/savvytasker/logic/commands/SelectCommand.java @@ -4,7 +4,7 @@ import seedu.savvytasker.commons.core.Messages; import seedu.savvytasker.commons.core.UnmodifiableObservableList; import seedu.savvytasker.commons.events.ui.JumpToListRequestEvent; -import seedu.savvytasker.model.person.ReadOnlyTask; +import seedu.savvytasker.model.task.ReadOnlyTask; /** * Selects a person identified using it's last displayed index from the address book. diff --git a/src/main/java/seedu/savvytasker/logic/commands/UnaliasCommand.java b/src/main/java/seedu/savvytasker/logic/commands/UnaliasCommand.java index 51b95c3d5e19..4d8250324257 100644 --- a/src/main/java/seedu/savvytasker/logic/commands/UnaliasCommand.java +++ b/src/main/java/seedu/savvytasker/logic/commands/UnaliasCommand.java @@ -2,8 +2,8 @@ import seedu.savvytasker.commons.exceptions.IllegalValueException; import seedu.savvytasker.logic.commands.models.AliasCommandModel; -import seedu.savvytasker.model.person.*; -import seedu.savvytasker.model.person.TaskList.DuplicateTaskException; +import seedu.savvytasker.model.task.Task; +import seedu.savvytasker.model.task.TaskList.DuplicateTaskException; /** * Command to remove aliases diff --git a/src/main/java/seedu/savvytasker/logic/parser/MarkCommandParser.java b/src/main/java/seedu/savvytasker/logic/parser/MarkCommandParser.java index ac8c53d9b02a..322d71bf3ba4 100644 --- a/src/main/java/seedu/savvytasker/logic/parser/MarkCommandParser.java +++ b/src/main/java/seedu/savvytasker/logic/parser/MarkCommandParser.java @@ -4,9 +4,7 @@ import java.util.regex.Pattern; import seedu.savvytasker.commons.core.Messages; -import seedu.savvytasker.logic.commands.DeleteCommand; import seedu.savvytasker.logic.commands.MarkCommand; -import seedu.savvytasker.logic.commands.models.DeleteCommandModel; public class MarkCommandParser implements CommandParser { private static final String HEADER = "mark"; @@ -33,7 +31,7 @@ public String getRequiredFormat() { public MarkCommand parse(String commandText) throws ParseException { Matcher matcher = REGEX_PATTERN.matcher(commandText); if (matcher.matches()) { - int[] indices = parseIndices(matcher.group(REGEX_REF_INDICES)); + parseIndices(matcher.group(REGEX_REF_INDICES)); // TODO: Integrate with MarkCommand properly return new MarkCommand(); diff --git a/src/main/java/seedu/savvytasker/logic/parser/RedoCommandParser.java b/src/main/java/seedu/savvytasker/logic/parser/RedoCommandParser.java index 629e420bab80..7bc1d512878d 100644 --- a/src/main/java/seedu/savvytasker/logic/parser/RedoCommandParser.java +++ b/src/main/java/seedu/savvytasker/logic/parser/RedoCommandParser.java @@ -1,9 +1,7 @@ package seedu.savvytasker.logic.parser; import seedu.savvytasker.commons.core.Messages; -import seedu.savvytasker.logic.commands.ExitCommand; import seedu.savvytasker.logic.commands.RedoCommand; -import seedu.savvytasker.logic.commands.UndoCommand; public class RedoCommandParser implements CommandParser { private static final String HEADER = "redo"; diff --git a/src/main/java/seedu/savvytasker/logic/parser/UndoCommandParser.java b/src/main/java/seedu/savvytasker/logic/parser/UndoCommandParser.java index d83e08312102..f620ba4ab208 100644 --- a/src/main/java/seedu/savvytasker/logic/parser/UndoCommandParser.java +++ b/src/main/java/seedu/savvytasker/logic/parser/UndoCommandParser.java @@ -1,7 +1,6 @@ package seedu.savvytasker.logic.parser; import seedu.savvytasker.commons.core.Messages; -import seedu.savvytasker.logic.commands.ExitCommand; import seedu.savvytasker.logic.commands.UndoCommand; public class UndoCommandParser implements CommandParser { diff --git a/src/main/java/seedu/savvytasker/logic/parser/UnmarkCommandParser.java b/src/main/java/seedu/savvytasker/logic/parser/UnmarkCommandParser.java index 7968fa247ab1..442231edc13b 100644 --- a/src/main/java/seedu/savvytasker/logic/parser/UnmarkCommandParser.java +++ b/src/main/java/seedu/savvytasker/logic/parser/UnmarkCommandParser.java @@ -4,9 +4,7 @@ import java.util.regex.Pattern; import seedu.savvytasker.commons.core.Messages; -import seedu.savvytasker.logic.commands.DeleteCommand; import seedu.savvytasker.logic.commands.UnmarkCommand; -import seedu.savvytasker.logic.commands.models.DeleteCommandModel; public class UnmarkCommandParser implements CommandParser { private static final String HEADER = "unmark"; @@ -33,7 +31,7 @@ public String getRequiredFormat() { public UnmarkCommand parse(String commandText) throws ParseException { Matcher matcher = REGEX_PATTERN.matcher(commandText); if (matcher.matches()) { - int[] indices = parseIndices(matcher.group(REGEX_REF_INDICES)); + parseIndices(matcher.group(REGEX_REF_INDICES)); // TODO: Integrate UnmarkCommand properly! return new UnmarkCommand(); diff --git a/src/main/java/seedu/savvytasker/model/AddressBook.java b/src/main/java/seedu/savvytasker/model/AddressBook.java deleted file mode 100644 index 8604359fbd9a..000000000000 --- a/src/main/java/seedu/savvytasker/model/AddressBook.java +++ /dev/null @@ -1,165 +0,0 @@ -package seedu.savvytasker.model; - -import javafx.collections.ObservableList; -import seedu.savvytasker.model.person.Person; -import seedu.savvytasker.model.person.ReadOnlyPerson; -import seedu.savvytasker.model.person.UniquePersonList; -import seedu.savvytasker.model.person.UniquePersonList.DuplicatePersonException; -import seedu.savvytasker.model.person.UniquePersonList.PersonNotFoundException; -import seedu.savvytasker.model.tag.Tag; -import seedu.savvytasker.model.tag.UniqueTagList; - -import java.util.*; -import java.util.stream.Collectors; - -/** - * Wraps all data at the address-book level - * Duplicates are not allowed (by .equals comparison) - */ -public class AddressBook implements ReadOnlyAddressBook { - - private final UniquePersonList persons; - private final UniqueTagList tags; - - { - persons = new UniquePersonList(); - tags = new UniqueTagList(); - } - - public AddressBook() {} - - /** - * Persons and Tags are copied into this addressbook - */ - public AddressBook(ReadOnlyAddressBook toBeCopied) { - this(toBeCopied.getUniquePersonList(), toBeCopied.getUniqueTagList()); - } - - /** - * Persons and Tags are copied into this addressbook - */ - public AddressBook(UniquePersonList persons, UniqueTagList tags) { - resetData(persons.getInternalList(), tags.getInternalList()); - } - - public static ReadOnlyAddressBook getEmptyAddressBook() { - return new AddressBook(); - } - -//// list overwrite operations - - public ObservableList getPersons() { - return persons.getInternalList(); - } - - public void setPersons(List persons) { - this.persons.getInternalList().setAll(persons); - } - - public void setTags(Collection tags) { - this.tags.getInternalList().setAll(tags); - } - - public void resetData(Collection newPersons, Collection newTags) { - setPersons(newPersons.stream().map(Person::new).collect(Collectors.toList())); - setTags(newTags); - } - - public void resetData(ReadOnlyAddressBook newData) { - resetData(newData.getPersonList(), newData.getTagList()); - } - -//// person-level operations - - /** - * Adds a person to the address book. - * Also checks the new person's tags and updates {@link #tags} with any new tags found, - * and updates the Tag objects in the person to point to those in {@link #tags}. - * - * @throws UniquePersonList.DuplicatePersonException if an equivalent person already exists. - */ - public void addPerson(Person p) throws DuplicatePersonException { - syncTagsWithMasterList(p); - persons.add(p); - } - - /** - * Ensures that every tag in this person: - * - exists in the master list {@link #tags} - * - points to a Tag object in the master list - */ - private void syncTagsWithMasterList(Person person) { - final UniqueTagList personTags = person.getTags(); - tags.mergeFrom(personTags); - - // Create map with values = tag object references in the master list - final Map masterTagObjects = new HashMap<>(); - for (Tag tag : tags) { - masterTagObjects.put(tag, tag); - } - - // Rebuild the list of person tags using references from the master list - final Set commonTagReferences = new HashSet<>(); - for (Tag tag : personTags) { - commonTagReferences.add(masterTagObjects.get(tag)); - } - person.setTags(new UniqueTagList(commonTagReferences)); - } - - public boolean removePerson(ReadOnlyPerson key) throws PersonNotFoundException { - if (persons.remove(key)) { - return true; - } else { - throw new UniquePersonList.PersonNotFoundException(); - } - } - -//// tag-level operations - - public void addTag(Tag t) throws UniqueTagList.DuplicateTagException { - tags.add(t); - } - -//// util methods - - @Override - public String toString() { - return persons.getInternalList().size() + " persons, " + tags.getInternalList().size() + " tags"; - // TODO: refine later - } - - @Override - public List getPersonList() { - return Collections.unmodifiableList(persons.getInternalList()); - } - - @Override - public List getTagList() { - return Collections.unmodifiableList(tags.getInternalList()); - } - - @Override - public UniquePersonList getUniquePersonList() { - return this.persons; - } - - @Override - public UniqueTagList getUniqueTagList() { - return this.tags; - } - - - @Override - public boolean equals(Object other) { - return other == this // short circuit if same object - || (other instanceof AddressBook // instanceof handles nulls - && this.persons.equals(((AddressBook) other).persons) - && this.tags.equals(((AddressBook) other).tags)); - } - - @Override - public int hashCode() { - // use this method for custom fields hashing instead of implementing your own - return Objects.hash(persons, tags); - } -} diff --git a/src/main/java/seedu/savvytasker/model/Model.java b/src/main/java/seedu/savvytasker/model/Model.java index fdd6f4057d2c..2108571315a5 100644 --- a/src/main/java/seedu/savvytasker/model/Model.java +++ b/src/main/java/seedu/savvytasker/model/Model.java @@ -1,11 +1,11 @@ package seedu.savvytasker.model; import seedu.savvytasker.commons.core.UnmodifiableObservableList; -import seedu.savvytasker.model.person.ReadOnlyTask; -import seedu.savvytasker.model.person.Task; -import seedu.savvytasker.model.person.TaskList.DuplicateTaskException; -import seedu.savvytasker.model.person.TaskList.TaskNotFoundException; import seedu.savvytasker.model.task.FindType; +import seedu.savvytasker.model.task.ReadOnlyTask; +import seedu.savvytasker.model.task.Task; +import seedu.savvytasker.model.task.TaskList.DuplicateTaskException; +import seedu.savvytasker.model.task.TaskList.TaskNotFoundException; /** * The API of the Model component. diff --git a/src/main/java/seedu/savvytasker/model/ModelManager.java b/src/main/java/seedu/savvytasker/model/ModelManager.java index c9699f4b7860..e72480a0acc4 100644 --- a/src/main/java/seedu/savvytasker/model/ModelManager.java +++ b/src/main/java/seedu/savvytasker/model/ModelManager.java @@ -7,11 +7,11 @@ import seedu.savvytasker.commons.core.UnmodifiableObservableList; import seedu.savvytasker.commons.events.model.SavvyTaskerChangedEvent; import seedu.savvytasker.commons.util.StringUtil; -import seedu.savvytasker.model.person.ReadOnlyTask; -import seedu.savvytasker.model.person.Task; -import seedu.savvytasker.model.person.TaskList.DuplicateTaskException; -import seedu.savvytasker.model.person.TaskList.TaskNotFoundException; import seedu.savvytasker.model.task.FindType; +import seedu.savvytasker.model.task.ReadOnlyTask; +import seedu.savvytasker.model.task.Task; +import seedu.savvytasker.model.task.TaskList.DuplicateTaskException; +import seedu.savvytasker.model.task.TaskList.TaskNotFoundException; import java.util.Arrays; import java.util.Comparator; diff --git a/src/main/java/seedu/savvytasker/model/ReadOnlyAddressBook.java b/src/main/java/seedu/savvytasker/model/ReadOnlyAddressBook.java deleted file mode 100644 index 31a5e25fa4d2..000000000000 --- a/src/main/java/seedu/savvytasker/model/ReadOnlyAddressBook.java +++ /dev/null @@ -1,30 +0,0 @@ -package seedu.savvytasker.model; - - -import java.util.List; - -import seedu.savvytasker.model.person.ReadOnlyPerson; -import seedu.savvytasker.model.person.UniquePersonList; -import seedu.savvytasker.model.tag.Tag; -import seedu.savvytasker.model.tag.UniqueTagList; - -/** - * Unmodifiable view of an address book - */ -public interface ReadOnlyAddressBook { - - UniqueTagList getUniqueTagList(); - - UniquePersonList getUniquePersonList(); - - /** - * Returns an unmodifiable view of persons list - */ - List getPersonList(); - - /** - * Returns an unmodifiable view of tags list - */ - List getTagList(); - -} diff --git a/src/main/java/seedu/savvytasker/model/ReadOnlySavvyTasker.java b/src/main/java/seedu/savvytasker/model/ReadOnlySavvyTasker.java index 0d47888e8e21..c2a43ec3c167 100644 --- a/src/main/java/seedu/savvytasker/model/ReadOnlySavvyTasker.java +++ b/src/main/java/seedu/savvytasker/model/ReadOnlySavvyTasker.java @@ -2,8 +2,8 @@ import java.util.List; -import seedu.savvytasker.model.person.ReadOnlyTask; -import seedu.savvytasker.model.person.TaskList; +import seedu.savvytasker.model.task.ReadOnlyTask; +import seedu.savvytasker.model.task.TaskList; /** * Unmodifiable view of a task list diff --git a/src/main/java/seedu/savvytasker/model/SavvyTasker.java b/src/main/java/seedu/savvytasker/model/SavvyTasker.java index 673162e66b96..c3c53fe848b3 100644 --- a/src/main/java/seedu/savvytasker/model/SavvyTasker.java +++ b/src/main/java/seedu/savvytasker/model/SavvyTasker.java @@ -1,11 +1,11 @@ package seedu.savvytasker.model; import javafx.collections.ObservableList; -import seedu.savvytasker.model.person.ReadOnlyTask; -import seedu.savvytasker.model.person.Task; -import seedu.savvytasker.model.person.TaskList; -import seedu.savvytasker.model.person.TaskList.DuplicateTaskException; -import seedu.savvytasker.model.person.TaskList.TaskNotFoundException; +import seedu.savvytasker.model.task.ReadOnlyTask; +import seedu.savvytasker.model.task.Task; +import seedu.savvytasker.model.task.TaskList; +import seedu.savvytasker.model.task.TaskList.DuplicateTaskException; +import seedu.savvytasker.model.task.TaskList.TaskNotFoundException; import java.util.*; import java.util.stream.Collectors; diff --git a/src/main/java/seedu/savvytasker/model/person/Address.java b/src/main/java/seedu/savvytasker/model/person/Address.java deleted file mode 100644 index 37fcc64bdd41..000000000000 --- a/src/main/java/seedu/savvytasker/model/person/Address.java +++ /dev/null @@ -1,54 +0,0 @@ -package seedu.savvytasker.model.person; - - -import seedu.savvytasker.commons.exceptions.IllegalValueException; - -/** - * Represents a Person's address in the address book. - * Guarantees: immutable; is valid as declared in {@link #isValidAddress(String)} - */ -public class Address { - - public static final String MESSAGE_ADDRESS_CONSTRAINTS = "Person addresses can be in any format"; - public static final String ADDRESS_VALIDATION_REGEX = ".+"; - - public final String value; - - /** - * Validates given address. - * - * @throws IllegalValueException if given address string is invalid. - */ - public Address(String address) throws IllegalValueException { - assert address != null; - if (!isValidAddress(address)) { - throw new IllegalValueException(MESSAGE_ADDRESS_CONSTRAINTS); - } - this.value = address; - } - - /** - * Returns true if a given string is a valid person email. - */ - public static boolean isValidAddress(String test) { - return test.matches(ADDRESS_VALIDATION_REGEX); - } - - @Override - public String toString() { - return value; - } - - @Override - public boolean equals(Object other) { - return other == this // short circuit if same object - || (other instanceof Address // instanceof handles nulls - && this.value.equals(((Address) other).value)); // state check - } - - @Override - public int hashCode() { - return value.hashCode(); - } - -} \ No newline at end of file diff --git a/src/main/java/seedu/savvytasker/model/person/Email.java b/src/main/java/seedu/savvytasker/model/person/Email.java deleted file mode 100644 index 5ebea8e509da..000000000000 --- a/src/main/java/seedu/savvytasker/model/person/Email.java +++ /dev/null @@ -1,56 +0,0 @@ -package seedu.savvytasker.model.person; - - -import seedu.savvytasker.commons.exceptions.IllegalValueException; - -/** - * Represents a Person's phone number in the address book. - * Guarantees: immutable; is valid as declared in {@link #isValidEmail(String)} - */ -public class Email { - - public static final String MESSAGE_EMAIL_CONSTRAINTS = - "Person emails should be 2 alphanumeric/period strings separated by '@'"; - public static final String EMAIL_VALIDATION_REGEX = "[\\w\\.]+@[\\w\\.]+"; - - public final String value; - - /** - * Validates given email. - * - * @throws IllegalValueException if given email address string is invalid. - */ - public Email(String email) throws IllegalValueException { - assert email != null; - email = email.trim(); - if (!isValidEmail(email)) { - throw new IllegalValueException(MESSAGE_EMAIL_CONSTRAINTS); - } - this.value = email; - } - - /** - * Returns if a given string is a valid person email. - */ - public static boolean isValidEmail(String test) { - return test.matches(EMAIL_VALIDATION_REGEX); - } - - @Override - public String toString() { - return value; - } - - @Override - public boolean equals(Object other) { - return other == this // short circuit if same object - || (other instanceof Email // instanceof handles nulls - && this.value.equals(((Email) other).value)); // state check - } - - @Override - public int hashCode() { - return value.hashCode(); - } - -} diff --git a/src/main/java/seedu/savvytasker/model/person/Name.java b/src/main/java/seedu/savvytasker/model/person/Name.java deleted file mode 100644 index db5efca92b33..000000000000 --- a/src/main/java/seedu/savvytasker/model/person/Name.java +++ /dev/null @@ -1,55 +0,0 @@ -package seedu.savvytasker.model.person; - -import seedu.savvytasker.commons.exceptions.IllegalValueException; - -/** - * Represents a Person's name in the address book. - * Guarantees: immutable; is valid as declared in {@link #isValidName(String)} - */ -public class Name { - - public static final String MESSAGE_NAME_CONSTRAINTS = "Person names should be spaces or alphanumeric characters"; - public static final String NAME_VALIDATION_REGEX = "[\\p{Alnum} ]+"; - - public final String fullName; - - /** - * Validates given name. - * - * @throws IllegalValueException if given name string is invalid. - */ - public Name(String name) throws IllegalValueException { - assert name != null; - name = name.trim(); - if (!isValidName(name)) { - throw new IllegalValueException(MESSAGE_NAME_CONSTRAINTS); - } - this.fullName = name; - } - - /** - * Returns true if a given string is a valid person name. - */ - public static boolean isValidName(String test) { - return test.matches(NAME_VALIDATION_REGEX); - } - - - @Override - public String toString() { - return fullName; - } - - @Override - public boolean equals(Object other) { - return other == this // short circuit if same object - || (other instanceof Name // instanceof handles nulls - && this.fullName.equals(((Name) other).fullName)); // state check - } - - @Override - public int hashCode() { - return fullName.hashCode(); - } - -} diff --git a/src/main/java/seedu/savvytasker/model/person/Person.java b/src/main/java/seedu/savvytasker/model/person/Person.java deleted file mode 100644 index 5c399b048c6e..000000000000 --- a/src/main/java/seedu/savvytasker/model/person/Person.java +++ /dev/null @@ -1,90 +0,0 @@ -package seedu.savvytasker.model.person; - -import java.util.Objects; - -import seedu.savvytasker.commons.util.CollectionUtil; -import seedu.savvytasker.model.tag.UniqueTagList; - -/** - * Represents a Person in the address book. - * Guarantees: details are present and not null, field values are validated. - */ -public class Person implements ReadOnlyPerson { - - private Name name; - private Phone phone; - private Email email; - private Address address; - - private UniqueTagList tags; - - /** - * Every field must be present and not null. - */ - public Person(Name name, Phone phone, Email email, Address address, UniqueTagList tags) { - assert !CollectionUtil.isAnyNull(name, phone, email, address, tags); - this.name = name; - this.phone = phone; - this.email = email; - this.address = address; - this.tags = new UniqueTagList(tags); // protect internal tags from changes in the arg list - } - - /** - * Copy constructor. - */ - public Person(ReadOnlyPerson source) { - this(source.getName(), source.getPhone(), source.getEmail(), source.getAddress(), source.getTags()); - } - - @Override - public Name getName() { - return name; - } - - @Override - public Phone getPhone() { - return phone; - } - - @Override - public Email getEmail() { - return email; - } - - @Override - public Address getAddress() { - return address; - } - - @Override - public UniqueTagList getTags() { - return new UniqueTagList(tags); - } - - /** - * Replaces this person's tags with the tags in the argument tag list. - */ - public void setTags(UniqueTagList replacement) { - tags.setTags(replacement); - } - - @Override - public boolean equals(Object other) { - return other == this // short circuit if same object - || (other instanceof ReadOnlyPerson // instanceof handles nulls - && this.isSameStateAs((ReadOnlyPerson) other)); - } - - @Override - public int hashCode() { - // use this method for custom fields hashing instead of implementing your own - return Objects.hash(name, phone, email, address, tags); - } - - @Override - public String toString() { - return getAsText(); - } - -} diff --git a/src/main/java/seedu/savvytasker/model/person/Phone.java b/src/main/java/seedu/savvytasker/model/person/Phone.java deleted file mode 100644 index fa414a54ea81..000000000000 --- a/src/main/java/seedu/savvytasker/model/person/Phone.java +++ /dev/null @@ -1,54 +0,0 @@ -package seedu.savvytasker.model.person; - -import seedu.savvytasker.commons.exceptions.IllegalValueException; - -/** - * Represents a Person's phone number in the address book. - * Guarantees: immutable; is valid as declared in {@link #isValidPhone(String)} - */ -public class Phone { - - public static final String MESSAGE_PHONE_CONSTRAINTS = "Person phone numbers should only contain numbers"; - public static final String PHONE_VALIDATION_REGEX = "\\d+"; - - public final String value; - - /** - * Validates given phone number. - * - * @throws IllegalValueException if given phone string is invalid. - */ - public Phone(String phone) throws IllegalValueException { - assert phone != null; - phone = phone.trim(); - if (!isValidPhone(phone)) { - throw new IllegalValueException(MESSAGE_PHONE_CONSTRAINTS); - } - this.value = phone; - } - - /** - * Returns true if a given string is a valid person phone number. - */ - public static boolean isValidPhone(String test) { - return test.matches(PHONE_VALIDATION_REGEX); - } - - @Override - public String toString() { - return value; - } - - @Override - public boolean equals(Object other) { - return other == this // short circuit if same object - || (other instanceof Phone // instanceof handles nulls - && this.value.equals(((Phone) other).value)); // state check - } - - @Override - public int hashCode() { - return value.hashCode(); - } - -} diff --git a/src/main/java/seedu/savvytasker/model/person/ReadOnlyPerson.java b/src/main/java/seedu/savvytasker/model/person/ReadOnlyPerson.java deleted file mode 100644 index d0c6ef0fbe50..000000000000 --- a/src/main/java/seedu/savvytasker/model/person/ReadOnlyPerson.java +++ /dev/null @@ -1,65 +0,0 @@ -package seedu.savvytasker.model.person; - -import seedu.savvytasker.model.tag.UniqueTagList; - -/** - * A read-only immutable interface for a Person in the addressbook. - * Implementations should guarantee: details are present and not null, field values are validated. - */ -public interface ReadOnlyPerson { - - Name getName(); - Phone getPhone(); - Email getEmail(); - Address getAddress(); - - /** - * The returned TagList is a deep copy of the internal TagList, - * changes on the returned list will not affect the person's internal tags. - */ - UniqueTagList getTags(); - - /** - * Returns true if both have the same state. (interfaces cannot override .equals) - */ - default boolean isSameStateAs(ReadOnlyPerson other) { - return other == this // short circuit if same object - || (other != null // this is first to avoid NPE below - && other.getName().equals(this.getName()) // state checks here onwards - && other.getPhone().equals(this.getPhone()) - && other.getEmail().equals(this.getEmail()) - && other.getAddress().equals(this.getAddress())); - } - - /** - * Formats the person as text, showing all contact details. - */ - default String getAsText() { - final StringBuilder builder = new StringBuilder(); - builder.append(getName()) - .append(" Phone: ") - .append(getPhone()) - .append(" Email: ") - .append(getEmail()) - .append(" Address: ") - .append(getAddress()) - .append(" Tags: "); - getTags().forEach(builder::append); - return builder.toString(); - } - - /** - * Returns a string representation of this Person's tags - */ - default String tagsString() { - final StringBuffer buffer = new StringBuffer(); - final String separator = ", "; - getTags().forEach(tag -> buffer.append(tag).append(separator)); - if (buffer.length() == 0) { - return ""; - } else { - return buffer.substring(0, buffer.length() - separator.length()); - } - } - -} diff --git a/src/main/java/seedu/savvytasker/model/person/UniquePersonList.java b/src/main/java/seedu/savvytasker/model/person/UniquePersonList.java deleted file mode 100644 index 9d309e5c00ce..000000000000 --- a/src/main/java/seedu/savvytasker/model/person/UniquePersonList.java +++ /dev/null @@ -1,109 +0,0 @@ -package seedu.savvytasker.model.person; - -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -import seedu.savvytasker.commons.exceptions.DuplicateDataException; -import seedu.savvytasker.commons.util.CollectionUtil; - -import java.util.*; - -/** - * A list of persons that enforces uniqueness between its elements and does not allow nulls. - * - * Supports a minimal set of list operations. - * - * @see Person#equals(Object) - * @see CollectionUtil#elementsAreUnique(Collection) - */ -public class UniquePersonList implements Iterable { - - /** - * Signals that an operation would have violated the 'no duplicates' property of the list. - */ - public static class DuplicatePersonException extends DuplicateDataException { - - /** - * Generated serial ID - */ - private static final long serialVersionUID = 8933810750762846403L; - - protected DuplicatePersonException() { - super("Operation would result in duplicate persons"); - } - } - - /** - * Signals that an operation targeting a specified person in the list would fail because - * there is no such matching person in the list. - */ - public static class PersonNotFoundException extends Exception { - - /** - * Generated serial ID - */ - private static final long serialVersionUID = -7591982407764643511L;} - - private final ObservableList internalList = FXCollections.observableArrayList(); - - /** - * Constructs empty PersonList. - */ - public UniquePersonList() {} - - /** - * Returns true if the list contains an equivalent person as the given argument. - */ - public boolean contains(ReadOnlyPerson toCheck) { - assert toCheck != null; - return internalList.contains(toCheck); - } - - /** - * Adds a person to the list. - * - * @throws DuplicatePersonException if the person to add is a duplicate of an existing person in the list. - */ - public void add(Person toAdd) throws DuplicatePersonException { - assert toAdd != null; - if (contains(toAdd)) { - throw new DuplicatePersonException(); - } - internalList.add(toAdd); - } - - /** - * Removes the equivalent person from the list. - * - * @throws PersonNotFoundException if no such person could be found in the list. - */ - public boolean remove(ReadOnlyPerson toRemove) throws PersonNotFoundException { - assert toRemove != null; - final boolean personFoundAndDeleted = internalList.remove(toRemove); - if (!personFoundAndDeleted) { - throw new PersonNotFoundException(); - } - return personFoundAndDeleted; - } - - public ObservableList getInternalList() { - return internalList; - } - - @Override - public Iterator iterator() { - return internalList.iterator(); - } - - @Override - public boolean equals(Object other) { - return other == this // short circuit if same object - || (other instanceof UniquePersonList // instanceof handles nulls - && this.internalList.equals( - ((UniquePersonList) other).internalList)); - } - - @Override - public int hashCode() { - return internalList.hashCode(); - } -} diff --git a/src/main/java/seedu/savvytasker/model/tag/Tag.java b/src/main/java/seedu/savvytasker/model/tag/Tag.java deleted file mode 100644 index 0c791b549401..000000000000 --- a/src/main/java/seedu/savvytasker/model/tag/Tag.java +++ /dev/null @@ -1,60 +0,0 @@ -package seedu.savvytasker.model.tag; - - -import seedu.savvytasker.commons.exceptions.IllegalValueException; - -/** - * Represents a Tag in the address book. - * Guarantees: immutable; name is valid as declared in {@link #isValidTagName(String)} - */ -public class Tag { - - public static final String MESSAGE_TAG_CONSTRAINTS = "Tags names should be alphanumeric"; - public static final String TAG_VALIDATION_REGEX = "\\p{Alnum}+"; - - public String tagName; - - public Tag() { - } - - /** - * Validates given tag name. - * - * @throws IllegalValueException if the given tag name string is invalid. - */ - public Tag(String name) throws IllegalValueException { - assert name != null; - name = name.trim(); - if (!isValidTagName(name)) { - throw new IllegalValueException(MESSAGE_TAG_CONSTRAINTS); - } - this.tagName = name; - } - - /** - * Returns true if a given string is a valid tag name. - */ - public static boolean isValidTagName(String test) { - return test.matches(TAG_VALIDATION_REGEX); - } - - @Override - public boolean equals(Object other) { - return other == this // short circuit if same object - || (other instanceof Tag // instanceof handles nulls - && this.tagName.equals(((Tag) other).tagName)); // state check - } - - @Override - public int hashCode() { - return tagName.hashCode(); - } - - /** - * Format state as text for viewing. - */ - public String toString() { - return '[' + tagName + ']'; - } - -} diff --git a/src/main/java/seedu/savvytasker/model/tag/UniqueTagList.java b/src/main/java/seedu/savvytasker/model/tag/UniqueTagList.java deleted file mode 100644 index 9066ce8cf006..000000000000 --- a/src/main/java/seedu/savvytasker/model/tag/UniqueTagList.java +++ /dev/null @@ -1,143 +0,0 @@ -package seedu.savvytasker.model.tag; - -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -import seedu.savvytasker.commons.exceptions.DuplicateDataException; -import seedu.savvytasker.commons.util.CollectionUtil; - -import java.util.*; - -/** - * A list of tags that enforces no nulls and uniqueness between its elements. - * - * Supports minimal set of list operations for the app's features. - * - * @see Tag#equals(Object) - * @see CollectionUtil#elementsAreUnique(Collection) - */ -public class UniqueTagList implements Iterable { - - /** - * Signals that an operation would have violated the 'no duplicates' property of the list. - */ - public static class DuplicateTagException extends DuplicateDataException { - protected DuplicateTagException() { - super("Operation would result in duplicate tags"); - } - } - - private final ObservableList internalList = FXCollections.observableArrayList(); - - /** - * Constructs empty TagList. - */ - public UniqueTagList() {} - - /** - * Varargs/array constructor, enforces no nulls or duplicates. - */ - public UniqueTagList(Tag... tags) throws DuplicateTagException { - assert !CollectionUtil.isAnyNull((Object[]) tags); - final List initialTags = Arrays.asList(tags); - if (!CollectionUtil.elementsAreUnique(initialTags)) { - throw new DuplicateTagException(); - } - internalList.addAll(initialTags); - } - - /** - * java collections constructor, enforces no null or duplicate elements. - */ - public UniqueTagList(Collection tags) throws DuplicateTagException { - CollectionUtil.assertNoNullElements(tags); - if (!CollectionUtil.elementsAreUnique(tags)) { - throw new DuplicateTagException(); - } - internalList.addAll(tags); - } - - /** - * java set constructor, enforces no nulls. - */ - public UniqueTagList(Set tags) { - CollectionUtil.assertNoNullElements(tags); - internalList.addAll(tags); - } - - /** - * Copy constructor, insulates from changes in source. - */ - public UniqueTagList(UniqueTagList source) { - internalList.addAll(source.internalList); // insulate internal list from changes in argument - } - - /** - * All tags in this list as a Set. This set is mutable and change-insulated against the internal list. - */ - public Set toSet() { - return new HashSet<>(internalList); - } - - /** - * Replaces the Tags in this list with those in the argument tag list. - */ - public void setTags(UniqueTagList replacement) { - this.internalList.clear(); - this.internalList.addAll(replacement.internalList); - } - - /** - * Adds every tag from the argument list that does not yet exist in this list. - */ - public void mergeFrom(UniqueTagList tags) { - final Set alreadyInside = this.toSet(); - for (Tag tag : tags) { - if (!alreadyInside.contains(tag)) { - internalList.add(tag); - } - } - } - - /** - * Returns true if the list contains an equivalent Tag as the given argument. - */ - public boolean contains(Tag toCheck) { - assert toCheck != null; - return internalList.contains(toCheck); - } - - /** - * Adds a Tag to the list. - * - * @throws DuplicateTagException if the Tag to add is a duplicate of an existing Tag in the list. - */ - public void add(Tag toAdd) throws DuplicateTagException { - assert toAdd != null; - if (contains(toAdd)) { - throw new DuplicateTagException(); - } - internalList.add(toAdd); - } - - @Override - public Iterator iterator() { - return internalList.iterator(); - } - - public ObservableList getInternalList() { - return internalList; - } - - @Override - public boolean equals(Object other) { - return other == this // short circuit if same object - || (other instanceof UniqueTagList // instanceof handles nulls - && this.internalList.equals( - ((UniqueTagList) other).internalList)); - } - - @Override - public int hashCode() { - return internalList.hashCode(); - } -} diff --git a/src/main/java/seedu/savvytasker/model/person/ReadOnlyTask.java b/src/main/java/seedu/savvytasker/model/task/ReadOnlyTask.java similarity index 92% rename from src/main/java/seedu/savvytasker/model/person/ReadOnlyTask.java rename to src/main/java/seedu/savvytasker/model/task/ReadOnlyTask.java index f435521d6a62..c69fb332fae8 100644 --- a/src/main/java/seedu/savvytasker/model/person/ReadOnlyTask.java +++ b/src/main/java/seedu/savvytasker/model/task/ReadOnlyTask.java @@ -1,10 +1,7 @@ -package seedu.savvytasker.model.person; +package seedu.savvytasker.model.task; import java.util.Date; -import seedu.savvytasker.model.task.PriorityLevel; -import seedu.savvytasker.model.task.RecurrenceType; - /** * A read-only immutable interface for a Task in the TaskList. * Implementations should guarantee: details are present and not null, field values are validated. diff --git a/src/main/java/seedu/savvytasker/model/person/Task.java b/src/main/java/seedu/savvytasker/model/task/Task.java similarity index 97% rename from src/main/java/seedu/savvytasker/model/person/Task.java rename to src/main/java/seedu/savvytasker/model/task/Task.java index 444057e377de..2d1ca88fcd0b 100644 --- a/src/main/java/seedu/savvytasker/model/person/Task.java +++ b/src/main/java/seedu/savvytasker/model/task/Task.java @@ -1,11 +1,9 @@ -package seedu.savvytasker.model.person; +package seedu.savvytasker.model.task; import java.util.Date; import java.util.Objects; import seedu.savvytasker.logic.commands.models.ModifyCommandModel; -import seedu.savvytasker.model.task.PriorityLevel; -import seedu.savvytasker.model.task.RecurrenceType; /** * Represents a Task in the task list. diff --git a/src/main/java/seedu/savvytasker/model/person/TaskList.java b/src/main/java/seedu/savvytasker/model/task/TaskList.java similarity index 94% rename from src/main/java/seedu/savvytasker/model/person/TaskList.java rename to src/main/java/seedu/savvytasker/model/task/TaskList.java index 3ec686a3200e..2676e21c8539 100644 --- a/src/main/java/seedu/savvytasker/model/person/TaskList.java +++ b/src/main/java/seedu/savvytasker/model/task/TaskList.java @@ -1,19 +1,17 @@ -package seedu.savvytasker.model.person; +package seedu.savvytasker.model.task; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import seedu.savvytasker.commons.exceptions.DuplicateDataException; -import seedu.savvytasker.commons.util.CollectionUtil; import java.util.*; /** - * A list of persons that enforces uniqueness between its elements and does not allow nulls. + * A list of tasks that enforces uniqueness between its elements and does not allow nulls. * * Supports a minimal set of list operations. * - * @see Person#equals(Object) - * @see CollectionUtil#elementsAreUnique(Collection) + * @see Task#equals(Object) */ public class TaskList implements Iterable { @@ -82,6 +80,7 @@ public int getNextId() { * Returns true if the list contains an equivalent task as the given argument. */ public boolean contains(ReadOnlyTask toCheck) { + assert toCheck != null; return internalList.contains(toCheck); } diff --git a/src/main/java/seedu/savvytasker/storage/AddressBookStorage.java b/src/main/java/seedu/savvytasker/storage/AddressBookStorage.java deleted file mode 100644 index c88249e480ff..000000000000 --- a/src/main/java/seedu/savvytasker/storage/AddressBookStorage.java +++ /dev/null @@ -1,44 +0,0 @@ -package seedu.savvytasker.storage; - -import java.io.IOException; -import java.util.Optional; - -import seedu.savvytasker.commons.exceptions.DataConversionException; -import seedu.savvytasker.model.ReadOnlyAddressBook; - -/** - * Represents a storage for {@link seedu.savvytasker.model.AddressBook}. - */ -public interface AddressBookStorage { - - /** - * Returns the file path of the data file. - */ - String getAddressBookFilePath(); - - /** - * Returns AddressBook data as a {@link ReadOnlyAddressBook}. - * Returns {@code Optional.empty()} if storage file is not found. - * @throws DataConversionException if the data in storage is not in the expected format. - * @throws IOException if there was any problem when reading from the storage. - */ - Optional readAddressBook() throws DataConversionException, IOException; - - /** - * @see #getAddressBookFilePath() - */ - Optional readAddressBook(String filePath) throws DataConversionException, IOException; - - /** - * Saves the given {@link ReadOnlyAddressBook} to the storage. - * @param addressBook cannot be null. - * @throws IOException if there was any problem writing to the file. - */ - void saveAddressBook(ReadOnlyAddressBook addressBook) throws IOException; - - /** - * @see #saveAddressBook(ReadOnlyAddressBook) - */ - void saveAddressBook(ReadOnlyAddressBook addressBook, String filePath) throws IOException; - -} diff --git a/src/main/java/seedu/savvytasker/storage/SavvyTaskerStorage.java b/src/main/java/seedu/savvytasker/storage/SavvyTaskerStorage.java index c4dfe119738a..2346201925f4 100644 --- a/src/main/java/seedu/savvytasker/storage/SavvyTaskerStorage.java +++ b/src/main/java/seedu/savvytasker/storage/SavvyTaskerStorage.java @@ -4,7 +4,6 @@ import java.util.Optional; import seedu.savvytasker.commons.exceptions.DataConversionException; -import seedu.savvytasker.model.ReadOnlyAddressBook; import seedu.savvytasker.model.ReadOnlySavvyTasker; /** diff --git a/src/main/java/seedu/savvytasker/storage/XmlAdaptedPerson.java b/src/main/java/seedu/savvytasker/storage/XmlAdaptedPerson.java deleted file mode 100644 index 1e1b0f535b9d..000000000000 --- a/src/main/java/seedu/savvytasker/storage/XmlAdaptedPerson.java +++ /dev/null @@ -1,69 +0,0 @@ -package seedu.savvytasker.storage; - -import javax.xml.bind.annotation.XmlElement; - -import seedu.savvytasker.commons.exceptions.IllegalValueException; -import seedu.savvytasker.model.person.*; -import seedu.savvytasker.model.tag.Tag; -import seedu.savvytasker.model.tag.UniqueTagList; - -import java.util.ArrayList; -import java.util.List; - -/** - * JAXB-friendly version of the Person. - */ -public class XmlAdaptedPerson { - - @XmlElement(required = true) - private String name; - @XmlElement(required = true) - private String phone; - @XmlElement(required = true) - private String email; - @XmlElement(required = true) - private String address; - - @XmlElement - private List tagged = new ArrayList<>(); - - /** - * No-arg constructor for JAXB use. - */ - public XmlAdaptedPerson() {} - - - /** - * Converts a given Person into this class for JAXB use. - * - * @param source future changes to this will not affect the created XmlAdaptedPerson - */ - public XmlAdaptedPerson(ReadOnlyPerson source) { - name = source.getName().fullName; - phone = source.getPhone().value; - email = source.getEmail().value; - address = source.getAddress().value; - tagged = new ArrayList<>(); - for (Tag tag : source.getTags()) { - tagged.add(new XmlAdaptedTag(tag)); - } - } - - /** - * Converts this jaxb-friendly adapted person object into the model's Person object. - * - * @throws IllegalValueException if there were any data constraints violated in the adapted person - */ - public Person toModelType() throws IllegalValueException { - final List personTags = new ArrayList<>(); - for (XmlAdaptedTag tag : tagged) { - personTags.add(tag.toModelType()); - } - final Name name = new Name(this.name); - final Phone phone = new Phone(this.phone); - final Email email = new Email(this.email); - final Address address = new Address(this.address); - final UniqueTagList tags = new UniqueTagList(personTags); - return new Person(name, phone, email, address, tags); - } -} diff --git a/src/main/java/seedu/savvytasker/storage/XmlAdaptedTag.java b/src/main/java/seedu/savvytasker/storage/XmlAdaptedTag.java deleted file mode 100644 index be4a7ba24565..000000000000 --- a/src/main/java/seedu/savvytasker/storage/XmlAdaptedTag.java +++ /dev/null @@ -1,40 +0,0 @@ -package seedu.savvytasker.storage; - -import javax.xml.bind.annotation.XmlValue; - -import seedu.savvytasker.commons.exceptions.IllegalValueException; -import seedu.savvytasker.commons.util.CollectionUtil; -import seedu.savvytasker.model.tag.Tag; - -/** - * JAXB-friendly adapted version of the Tag. - */ -public class XmlAdaptedTag { - - @XmlValue - public String tagName; - - /** - * No-arg constructor for JAXB use. - */ - public XmlAdaptedTag() {} - - /** - * Converts a given Tag into this class for JAXB use. - * - * @param source future changes to this will not affect the created - */ - public XmlAdaptedTag(Tag source) { - tagName = source.tagName; - } - - /** - * Converts this jaxb-friendly adapted tag object into the model's Tag object. - * - * @throws IllegalValueException if there were any data constraints violated in the adapted person - */ - public Tag toModelType() throws IllegalValueException { - return new Tag(tagName); - } - -} diff --git a/src/main/java/seedu/savvytasker/storage/XmlAdaptedTask.java b/src/main/java/seedu/savvytasker/storage/XmlAdaptedTask.java index a853b13d3cc8..c174b6679e2e 100644 --- a/src/main/java/seedu/savvytasker/storage/XmlAdaptedTask.java +++ b/src/main/java/seedu/savvytasker/storage/XmlAdaptedTask.java @@ -5,9 +5,10 @@ import javax.xml.bind.annotation.XmlElement; import seedu.savvytasker.commons.exceptions.IllegalValueException; -import seedu.savvytasker.model.person.*; import seedu.savvytasker.model.task.PriorityLevel; +import seedu.savvytasker.model.task.ReadOnlyTask; import seedu.savvytasker.model.task.RecurrenceType; +import seedu.savvytasker.model.task.Task; /** * JAXB-friendly version of the Task. diff --git a/src/main/java/seedu/savvytasker/storage/XmlSerializableSavvyTasker.java b/src/main/java/seedu/savvytasker/storage/XmlSerializableSavvyTasker.java index 758883d24544..60af43918762 100644 --- a/src/main/java/seedu/savvytasker/storage/XmlSerializableSavvyTasker.java +++ b/src/main/java/seedu/savvytasker/storage/XmlSerializableSavvyTasker.java @@ -5,8 +5,8 @@ import seedu.savvytasker.commons.exceptions.IllegalValueException; import seedu.savvytasker.model.ReadOnlySavvyTasker; -import seedu.savvytasker.model.person.ReadOnlyTask; -import seedu.savvytasker.model.person.TaskList; +import seedu.savvytasker.model.task.ReadOnlyTask; +import seedu.savvytasker.model.task.TaskList; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/seedu/savvytasker/ui/BrowserPanel.java b/src/main/java/seedu/savvytasker/ui/BrowserPanel.java index 61d4002ee809..97c49d2ecd7f 100644 --- a/src/main/java/seedu/savvytasker/ui/BrowserPanel.java +++ b/src/main/java/seedu/savvytasker/ui/BrowserPanel.java @@ -6,7 +6,7 @@ import javafx.scene.web.WebView; import seedu.savvytasker.commons.core.LogsCenter; import seedu.savvytasker.commons.util.FxViewUtil; -import seedu.savvytasker.model.person.ReadOnlyTask; +import seedu.savvytasker.model.task.ReadOnlyTask; import java.util.logging.Logger; diff --git a/src/main/java/seedu/savvytasker/ui/MainWindow.java b/src/main/java/seedu/savvytasker/ui/MainWindow.java index d2cb976d729e..426f6a7e0bf5 100644 --- a/src/main/java/seedu/savvytasker/ui/MainWindow.java +++ b/src/main/java/seedu/savvytasker/ui/MainWindow.java @@ -13,7 +13,7 @@ import seedu.savvytasker.commons.events.ui.ExitAppRequestEvent; import seedu.savvytasker.logic.Logic; import seedu.savvytasker.model.UserPrefs; -import seedu.savvytasker.model.person.ReadOnlyTask; +import seedu.savvytasker.model.task.ReadOnlyTask; /** * The Main Window. Provides the basic application layout containing diff --git a/src/main/java/seedu/savvytasker/ui/StatusBarFooter.java b/src/main/java/seedu/savvytasker/ui/StatusBarFooter.java index 82e78af5844d..d61565efed33 100644 --- a/src/main/java/seedu/savvytasker/ui/StatusBarFooter.java +++ b/src/main/java/seedu/savvytasker/ui/StatusBarFooter.java @@ -7,7 +7,7 @@ import javafx.scene.layout.GridPane; import javafx.stage.Stage; import seedu.savvytasker.commons.core.LogsCenter; -import seedu.savvytasker.commons.events.model.AddressBookChangedEvent; +import seedu.savvytasker.commons.events.model.SavvyTaskerChangedEvent; import seedu.savvytasker.commons.util.FxViewUtil; import org.controlsfx.control.StatusBar; @@ -91,9 +91,9 @@ public String getFxmlPath() { } @Subscribe - public void handleAddressBookChangedEvent(AddressBookChangedEvent abce) { + public void handleAddressBookChangedEvent(SavvyTaskerChangedEvent stce) { String lastUpdated = (new Date()).toString(); - logger.info(LogsCenter.getEventHandlingLogMessage(abce, "Setting last updated status to " + lastUpdated)); + logger.info(LogsCenter.getEventHandlingLogMessage(stce, "Setting last updated status to " + lastUpdated)); setSyncStatus("Last Updated: " + lastUpdated); } } diff --git a/src/main/java/seedu/savvytasker/ui/TaskCard.java b/src/main/java/seedu/savvytasker/ui/TaskCard.java index 181b6f5882d1..b3cc0f963fce 100644 --- a/src/main/java/seedu/savvytasker/ui/TaskCard.java +++ b/src/main/java/seedu/savvytasker/ui/TaskCard.java @@ -6,7 +6,7 @@ import javafx.scene.Node; import javafx.scene.control.Label; import javafx.scene.layout.HBox; -import seedu.savvytasker.model.person.ReadOnlyTask; +import seedu.savvytasker.model.task.ReadOnlyTask; public class TaskCard extends UiPart{ diff --git a/src/main/java/seedu/savvytasker/ui/TaskListPanel.java b/src/main/java/seedu/savvytasker/ui/TaskListPanel.java index ab563ccfbbf1..9556633a395d 100644 --- a/src/main/java/seedu/savvytasker/ui/TaskListPanel.java +++ b/src/main/java/seedu/savvytasker/ui/TaskListPanel.java @@ -12,7 +12,7 @@ import javafx.stage.Stage; import seedu.savvytasker.commons.core.LogsCenter; import seedu.savvytasker.commons.events.ui.TaskPanelSelectionChangedEvent; -import seedu.savvytasker.model.person.ReadOnlyTask; +import seedu.savvytasker.model.task.ReadOnlyTask; import java.util.logging.Logger; diff --git a/src/test/java/guitests/AddCommandTest.java b/src/test/java/guitests/AddCommandTest.java index 0bfa5b38948a..d845d6939c8d 100644 --- a/src/test/java/guitests/AddCommandTest.java +++ b/src/test/java/guitests/AddCommandTest.java @@ -5,13 +5,12 @@ import org.junit.Test; import seedu.savvytasker.commons.core.Messages; -import seedu.savvytasker.logic.commands.AddCommand; import seedu.savvytasker.testutil.TestTask; import seedu.savvytasker.testutil.TestUtil; import static org.junit.Assert.assertTrue; -public class AddCommandTest extends AddressBookGuiTest { +public class AddCommandTest extends SavvyTaskerGuiTest { @Test public void add() { diff --git a/src/test/java/guitests/ClearCommandTest.java b/src/test/java/guitests/ClearCommandTest.java index c050385dfd98..b34b5c5c0c79 100644 --- a/src/test/java/guitests/ClearCommandTest.java +++ b/src/test/java/guitests/ClearCommandTest.java @@ -4,7 +4,7 @@ import static org.junit.Assert.assertTrue; -public class ClearCommandTest extends AddressBookGuiTest { +public class ClearCommandTest extends SavvyTaskerGuiTest { @Test public void clear() { diff --git a/src/test/java/guitests/CommandBoxTest.java b/src/test/java/guitests/CommandBoxTest.java index 1a6e83c3e562..dbd8b655d036 100644 --- a/src/test/java/guitests/CommandBoxTest.java +++ b/src/test/java/guitests/CommandBoxTest.java @@ -4,7 +4,7 @@ import static org.junit.Assert.assertEquals; -public class CommandBoxTest extends AddressBookGuiTest { +public class CommandBoxTest extends SavvyTaskerGuiTest { @Test public void commandBox_commandSucceeds_textCleared() { diff --git a/src/test/java/guitests/DeleteCommandTest.java b/src/test/java/guitests/DeleteCommandTest.java index 71b4906d2f91..8a1d371f2841 100644 --- a/src/test/java/guitests/DeleteCommandTest.java +++ b/src/test/java/guitests/DeleteCommandTest.java @@ -2,14 +2,13 @@ import org.junit.Test; -import seedu.savvytasker.testutil.TestPerson; import seedu.savvytasker.testutil.TestTask; import seedu.savvytasker.testutil.TestUtil; import static org.junit.Assert.assertTrue; import static seedu.savvytasker.logic.commands.DeleteCommand.MESSAGE_DELETE_TASK_SUCCESS; -public class DeleteCommandTest extends AddressBookGuiTest { +public class DeleteCommandTest extends SavvyTaskerGuiTest { @Test public void delete() { diff --git a/src/test/java/guitests/FindCommandTest.java b/src/test/java/guitests/FindCommandTest.java index da744ae83173..57f8aae9ce6c 100644 --- a/src/test/java/guitests/FindCommandTest.java +++ b/src/test/java/guitests/FindCommandTest.java @@ -3,12 +3,11 @@ import org.junit.Test; import seedu.savvytasker.commons.core.Messages; -import seedu.savvytasker.testutil.TestPerson; import seedu.savvytasker.testutil.TestTask; import static org.junit.Assert.assertTrue; -public class FindCommandTest extends AddressBookGuiTest { +public class FindCommandTest extends SavvyTaskerGuiTest { @Test public void find_nonEmptyList() { diff --git a/src/test/java/guitests/HelpWindowTest.java b/src/test/java/guitests/HelpWindowTest.java index 436c485f1efe..988156dd3dec 100644 --- a/src/test/java/guitests/HelpWindowTest.java +++ b/src/test/java/guitests/HelpWindowTest.java @@ -5,7 +5,7 @@ import static org.junit.Assert.assertTrue; -public class HelpWindowTest extends AddressBookGuiTest { +public class HelpWindowTest extends SavvyTaskerGuiTest { @Test public void openHelpWindow() { diff --git a/src/test/java/guitests/ListCommandTest.java b/src/test/java/guitests/ListCommandTest.java index 23d159d059c8..1dc3be5934e0 100644 --- a/src/test/java/guitests/ListCommandTest.java +++ b/src/test/java/guitests/ListCommandTest.java @@ -3,12 +3,11 @@ import org.junit.Test; import seedu.savvytasker.commons.core.Messages; -import seedu.savvytasker.testutil.TestPerson; import seedu.savvytasker.testutil.TestTask; import static org.junit.Assert.assertTrue; -public class ListCommandTest extends AddressBookGuiTest { +public class ListCommandTest extends SavvyTaskerGuiTest { @Test public void list_nonEmptyList() { diff --git a/src/test/java/guitests/AddressBookGuiTest.java b/src/test/java/guitests/SavvyTaskerGuiTest.java similarity index 95% rename from src/test/java/guitests/AddressBookGuiTest.java rename to src/test/java/guitests/SavvyTaskerGuiTest.java index 3cec1060d631..3db0a8a67871 100644 --- a/src/test/java/guitests/AddressBookGuiTest.java +++ b/src/test/java/guitests/SavvyTaskerGuiTest.java @@ -12,8 +12,7 @@ import seedu.savvytasker.TestApp; import seedu.savvytasker.commons.core.EventsCenter; import seedu.savvytasker.model.SavvyTasker; -import seedu.savvytasker.model.person.ReadOnlyPerson; -import seedu.savvytasker.model.person.ReadOnlyTask; +import seedu.savvytasker.model.task.ReadOnlyTask; import seedu.savvytasker.testutil.TestUtil; import seedu.savvytasker.testutil.TypicalTestTasks; @@ -25,7 +24,7 @@ /** * A GUI Test class for AddressBook. */ -public abstract class AddressBookGuiTest { +public abstract class SavvyTaskerGuiTest { /* The TestName Rule makes the current test name available inside test methods */ @Rule diff --git a/src/test/java/guitests/SelectCommandTest.java b/src/test/java/guitests/SelectCommandTest.java index 28f68b2d897b..04a823f9147f 100644 --- a/src/test/java/guitests/SelectCommandTest.java +++ b/src/test/java/guitests/SelectCommandTest.java @@ -1,13 +1,6 @@ package guitests; -import org.junit.Test; - -import seedu.savvytasker.model.person.ReadOnlyPerson; -import seedu.savvytasker.model.person.ReadOnlyTask; - -import static org.junit.Assert.assertEquals; - -public class SelectCommandTest extends AddressBookGuiTest { +public class SelectCommandTest extends SavvyTaskerGuiTest { /** Not running the select test for now, not implemented @@ -34,7 +27,7 @@ public void selectPerson_emptyList(){ commandBox.runCommand("clear"); assertListSize(0); assertSelectionInvalid(1); //invalid index - }*/ + } private void assertSelectionInvalid(int index) { commandBox.runCommand("select " + index); @@ -56,6 +49,6 @@ private void assertPersonSelected(int index) { private void assertNoPersonSelected() { assertEquals(taskListPanel.getSelectedTasks().size(), 0); - } + }*/ } diff --git a/src/test/java/guitests/guihandles/MainGuiHandle.java b/src/test/java/guitests/guihandles/MainGuiHandle.java index 5266a7101816..198d6376e724 100644 --- a/src/test/java/guitests/guihandles/MainGuiHandle.java +++ b/src/test/java/guitests/guihandles/MainGuiHandle.java @@ -12,10 +12,6 @@ public class MainGuiHandle extends GuiHandle { public MainGuiHandle(GuiRobot guiRobot, Stage primaryStage) { super(guiRobot, primaryStage, TestApp.APP_TITLE); } - - public PersonListPanelHandle getPersonListPanel() { - return new PersonListPanelHandle(guiRobot, primaryStage); - } public TaskListPanelHandle getTaskListPanel() { return new TaskListPanelHandle(guiRobot, primaryStage); diff --git a/src/test/java/guitests/guihandles/PersonCardHandle.java b/src/test/java/guitests/guihandles/PersonCardHandle.java deleted file mode 100644 index 795942eaaf73..000000000000 --- a/src/test/java/guitests/guihandles/PersonCardHandle.java +++ /dev/null @@ -1,63 +0,0 @@ -package guitests.guihandles; - -import guitests.GuiRobot; -import javafx.scene.Node; -import javafx.stage.Stage; -import seedu.savvytasker.model.person.ReadOnlyPerson; - -/** - * Provides a handle to a person card in the person list panel. - */ -public class PersonCardHandle extends GuiHandle { - private static final String NAME_FIELD_ID = "#name"; - private static final String ADDRESS_FIELD_ID = "#address"; - private static final String PHONE_FIELD_ID = "#phone"; - private static final String EMAIL_FIELD_ID = "#email"; - - private Node node; - - public PersonCardHandle(GuiRobot guiRobot, Stage primaryStage, Node node){ - super(guiRobot, primaryStage, null); - this.node = node; - } - - protected String getTextFromLabel(String fieldId) { - return getTextFromLabel(fieldId, node); - } - - public String getFullName() { - return getTextFromLabel(NAME_FIELD_ID); - } - - public String getAddress() { - return getTextFromLabel(ADDRESS_FIELD_ID); - } - - public String getPhone() { - return getTextFromLabel(PHONE_FIELD_ID); - } - - public String getEmail() { - return getTextFromLabel(EMAIL_FIELD_ID); - } - - public boolean isSamePerson(ReadOnlyPerson person){ - return getFullName().equals(person.getName().fullName) && getPhone().equals(person.getPhone().value) - && getEmail().equals(person.getEmail().value) && getAddress().equals(person.getAddress().value); - } - - @Override - public boolean equals(Object obj) { - if(obj instanceof PersonCardHandle) { - PersonCardHandle handle = (PersonCardHandle) obj; - return getFullName().equals(handle.getFullName()) - && getAddress().equals(handle.getAddress()); //TODO: compare the rest - } - return super.equals(obj); - } - - @Override - public String toString() { - return getFullName() + " " + getAddress(); - } -} diff --git a/src/test/java/guitests/guihandles/PersonListPanelHandle.java b/src/test/java/guitests/guihandles/PersonListPanelHandle.java deleted file mode 100644 index 239e290db5e7..000000000000 --- a/src/test/java/guitests/guihandles/PersonListPanelHandle.java +++ /dev/null @@ -1,172 +0,0 @@ -package guitests.guihandles; - - -import guitests.GuiRobot; -import javafx.geometry.Point2D; -import javafx.scene.Node; -import javafx.scene.control.ListView; -import javafx.stage.Stage; -import seedu.savvytasker.TestApp; -import seedu.savvytasker.model.person.Person; -import seedu.savvytasker.model.person.ReadOnlyPerson; -import seedu.savvytasker.testutil.TestUtil; - -import java.util.List; -import java.util.Optional; -import java.util.Set; - -import static org.junit.Assert.assertTrue; - -/** - * Provides a handle for the panel containing the person list. - */ -public class PersonListPanelHandle extends GuiHandle { - - public static final int NOT_FOUND = -1; - public static final String CARD_PANE_ID = "#cardPane"; - - private static final String PERSON_LIST_VIEW_ID = "#personListView"; - - public PersonListPanelHandle(GuiRobot guiRobot, Stage primaryStage) { - super(guiRobot, primaryStage, TestApp.APP_TITLE); - } - - public List getSelectedPersons() { - ListView personList = getListView(); - return personList.getSelectionModel().getSelectedItems(); - } - - public ListView getListView() { - return (ListView) getNode(PERSON_LIST_VIEW_ID); - } - - /** - * Returns true if the list is showing the person details correctly and in correct order. - * @param persons A list of person in the correct order. - */ - public boolean isListMatching(ReadOnlyPerson... persons) { - return this.isListMatching(0, persons); - } - - /** - * Clicks on the ListView. - */ - public void clickOnListView() { - Point2D point= TestUtil.getScreenMidPoint(getListView()); - guiRobot.clickOn(point.getX(), point.getY()); - } - - /** - * Returns true if the {@code persons} appear as the sub list (in that order) at position {@code startPosition}. - */ - public boolean containsInOrder(int startPosition, ReadOnlyPerson... persons) { - List personsInList = getListView().getItems(); - - // Return false if the list in panel is too short to contain the given list - if (startPosition + persons.length > personsInList.size()){ - return false; - } - - // Return false if any of the persons doesn't match - for (int i = 0; i < persons.length; i++) { - if (!personsInList.get(startPosition + i).getName().fullName.equals(persons[i].getName().fullName)){ - return false; - } - } - - return true; - } - - /** - * Returns true if the list is showing the person details correctly and in correct order. - * @param startPosition The starting position of the sub list. - * @param persons A list of person in the correct order. - */ - public boolean isListMatching(int startPosition, ReadOnlyPerson... persons) throws IllegalArgumentException { - if (persons.length + startPosition != getListView().getItems().size()) { - throw new IllegalArgumentException("List size mismatched\n" + - "Expected " + (getListView().getItems().size() - 1) + " persons"); - } - assertTrue(this.containsInOrder(startPosition, persons)); - for (int i = 0; i < persons.length; i++) { - final int scrollTo = i + startPosition; - guiRobot.interact(() -> getListView().scrollTo(scrollTo)); - guiRobot.sleep(200); - if (!TestUtil.compareCardAndPerson(getPersonCardHandle(startPosition + i), persons[i])) { - return false; - } - } - return true; - } - - - public PersonCardHandle navigateToPerson(String name) { - guiRobot.sleep(500); //Allow a bit of time for the list to be updated - final Optional person = getListView().getItems().stream().filter(p -> p.getName().fullName.equals(name)).findAny(); - if (!person.isPresent()) { - throw new IllegalStateException("Name not found: " + name); - } - - return navigateToPerson(person.get()); - } - - /** - * Navigates the listview to display and select the person. - */ - public PersonCardHandle navigateToPerson(ReadOnlyPerson person) { - int index = getPersonIndex(person); - - guiRobot.interact(() -> { - getListView().scrollTo(index); - guiRobot.sleep(150); - getListView().getSelectionModel().select(index); - }); - guiRobot.sleep(100); - return getPersonCardHandle(person); - } - - - /** - * Returns the position of the person given, {@code NOT_FOUND} if not found in the list. - */ - public int getPersonIndex(ReadOnlyPerson targetPerson) { - List personsInList = getListView().getItems(); - for (int i = 0; i < personsInList.size(); i++) { - if(personsInList.get(i).getName().equals(targetPerson.getName())){ - return i; - } - } - return NOT_FOUND; - } - - /** - * Gets a person from the list by index - */ - public ReadOnlyPerson getPerson(int index) { - return getListView().getItems().get(index); - } - - public PersonCardHandle getPersonCardHandle(int index) { - return getPersonCardHandle(new Person(getListView().getItems().get(index))); - } - - public PersonCardHandle getPersonCardHandle(ReadOnlyPerson person) { - Set nodes = getAllCardNodes(); - Optional personCardNode = nodes.stream() - .filter(n -> new PersonCardHandle(guiRobot, primaryStage, n).isSamePerson(person)) - .findFirst(); - if (personCardNode.isPresent()) { - return new PersonCardHandle(guiRobot, primaryStage, personCardNode.get()); - } else { - return null; - } - } - - protected Set getAllCardNodes() { - return guiRobot.lookup(CARD_PANE_ID).queryAll(); - } - - public int getNumberOfPeople() { - return getListView().getItems().size(); - } -} diff --git a/src/test/java/guitests/guihandles/TaskCardHandle.java b/src/test/java/guitests/guihandles/TaskCardHandle.java index 5986aa3f423d..0eb1d2b9114b 100644 --- a/src/test/java/guitests/guihandles/TaskCardHandle.java +++ b/src/test/java/guitests/guihandles/TaskCardHandle.java @@ -3,7 +3,7 @@ import guitests.GuiRobot; import javafx.scene.Node; import javafx.stage.Stage; -import seedu.savvytasker.model.person.ReadOnlyTask; +import seedu.savvytasker.model.task.ReadOnlyTask; /** * Provides a handle to a person card in the person list panel. diff --git a/src/test/java/guitests/guihandles/TaskListPanelHandle.java b/src/test/java/guitests/guihandles/TaskListPanelHandle.java index ff5a68322000..787b7715a43e 100644 --- a/src/test/java/guitests/guihandles/TaskListPanelHandle.java +++ b/src/test/java/guitests/guihandles/TaskListPanelHandle.java @@ -7,8 +7,8 @@ import javafx.scene.control.ListView; import javafx.stage.Stage; import seedu.savvytasker.TestApp; -import seedu.savvytasker.model.person.ReadOnlyTask; -import seedu.savvytasker.model.person.Task; +import seedu.savvytasker.model.task.ReadOnlyTask; +import seedu.savvytasker.model.task.Task; import seedu.savvytasker.testutil.TestUtil; import java.util.List; @@ -36,7 +36,9 @@ public List getSelectedTasks() { return taskList.getSelectionModel().getSelectedItems(); } + @SuppressWarnings("unchecked") public ListView getListView() { + // Should be a listview of readonlytask only. return (ListView) getNode(TASK_LIST_VIEW_ID); } diff --git a/src/test/java/seedu/savvytasker/commons/util/ConfigUtilTest.java b/src/test/java/seedu/savvytasker/commons/util/ConfigUtilTest.java index d62176304361..f3fa7414459e 100644 --- a/src/test/java/seedu/savvytasker/commons/util/ConfigUtilTest.java +++ b/src/test/java/seedu/savvytasker/commons/util/ConfigUtilTest.java @@ -86,7 +86,8 @@ private Config getTypicalConfig() { private Optional read(String configFileInTestDataFolder) throws DataConversionException { String configFilePath = addToTestDataPathIfNotNull(configFileInTestDataFolder); - return new ConfigUtil().readConfig(configFilePath); + new ConfigUtil(); + return ConfigUtil.readConfig(configFilePath); } @Test @@ -106,24 +107,25 @@ public void saveConfig_allInOrder_success() throws DataConversionException, IOEx Config original = getTypicalConfig(); String configFilePath = testFolder.getRoot() + File.separator + "TempConfig.json"; - ConfigUtil configStorage = new ConfigUtil(); + new ConfigUtil(); //Try writing when the file doesn't exist - configStorage.saveConfig(original, configFilePath); - Config readBack = configStorage.readConfig(configFilePath).get(); + ConfigUtil.saveConfig(original, configFilePath); + Config readBack = ConfigUtil.readConfig(configFilePath).get(); assertEquals(original, readBack); //Try saving when the file exists original.setAppTitle("Updated Title"); original.setLogLevel(Level.FINE); - configStorage.saveConfig(original, configFilePath); - readBack = configStorage.readConfig(configFilePath).get(); + ConfigUtil.saveConfig(original, configFilePath); + readBack = ConfigUtil.readConfig(configFilePath).get(); assertEquals(original, readBack); } private void save(Config config, String configFileInTestDataFolder) throws IOException { String configFilePath = addToTestDataPathIfNotNull(configFileInTestDataFolder); - new ConfigUtil().saveConfig(config, configFilePath); + new ConfigUtil(); + ConfigUtil.saveConfig(config, configFilePath); } private String addToTestDataPathIfNotNull(String configFileInTestDataFolder) { diff --git a/src/test/java/seedu/savvytasker/commons/util/XmlUtilTest.java b/src/test/java/seedu/savvytasker/commons/util/XmlUtilTest.java index 8b3dba7cfdae..515df40c1155 100644 --- a/src/test/java/seedu/savvytasker/commons/util/XmlUtilTest.java +++ b/src/test/java/seedu/savvytasker/commons/util/XmlUtilTest.java @@ -6,7 +6,6 @@ import seedu.savvytasker.commons.util.FileUtil; import seedu.savvytasker.commons.util.XmlUtil; -import seedu.savvytasker.model.AddressBook; import seedu.savvytasker.model.SavvyTasker; import seedu.savvytasker.storage.XmlSerializableSavvyTasker; import seedu.savvytasker.testutil.SavvyTaskerBuilder; @@ -32,7 +31,7 @@ public class XmlUtilTest { @Test public void getDataFromFile_nullFile_AssertionError() throws Exception { thrown.expect(AssertionError.class); - XmlUtil.getDataFromFile(null, AddressBook.class); + XmlUtil.getDataFromFile(null, SavvyTasker.class); } @Test @@ -44,13 +43,13 @@ public void getDataFromFile_nullClass_AssertionError() throws Exception { @Test public void getDataFromFile_missingFile_FileNotFoundException() throws Exception { thrown.expect(FileNotFoundException.class); - XmlUtil.getDataFromFile(MISSING_FILE, AddressBook.class); + XmlUtil.getDataFromFile(MISSING_FILE, SavvyTasker.class); } @Test public void getDataFromFile_emptyFile_DataFormatMismatchException() throws Exception { thrown.expect(JAXBException.class); - XmlUtil.getDataFromFile(EMPTY_FILE, AddressBook.class); + XmlUtil.getDataFromFile(EMPTY_FILE, SavvyTasker.class); } @Test @@ -62,7 +61,7 @@ public void getDataFromFile_validFile_validResult() throws Exception { @Test public void saveDataToFile_nullFile_AssertionError() throws Exception { thrown.expect(AssertionError.class); - XmlUtil.saveDataToFile(null, new AddressBook()); + XmlUtil.saveDataToFile(null, new SavvyTasker()); } @Test @@ -74,7 +73,7 @@ public void saveDataToFile_nullClass_AssertionError() throws Exception { @Test public void saveDataToFile_missingFile_FileNotFoundException() throws Exception { thrown.expect(FileNotFoundException.class); - XmlUtil.saveDataToFile(MISSING_FILE, new AddressBook()); + XmlUtil.saveDataToFile(MISSING_FILE, new SavvyTasker()); } @Test diff --git a/src/test/java/seedu/savvytasker/logic/LogicManagerTest.java b/src/test/java/seedu/savvytasker/logic/LogicManagerTest.java index 876ade6fd0c3..868ec8334264 100644 --- a/src/test/java/seedu/savvytasker/logic/LogicManagerTest.java +++ b/src/test/java/seedu/savvytasker/logic/LogicManagerTest.java @@ -12,10 +12,10 @@ import seedu.savvytasker.logic.commands.*; import seedu.savvytasker.model.Model; import seedu.savvytasker.model.ModelManager; -import seedu.savvytasker.model.ReadOnlyAddressBook; import seedu.savvytasker.model.ReadOnlySavvyTasker; import seedu.savvytasker.model.SavvyTasker; -import seedu.savvytasker.model.person.*; +import seedu.savvytasker.model.task.ReadOnlyTask; +import seedu.savvytasker.model.task.Task; import seedu.savvytasker.storage.StorageManager; import org.junit.After; diff --git a/src/test/java/seedu/savvytasker/storage/XmlAddressBookStorageTest.java b/src/test/java/seedu/savvytasker/storage/XmlAddressBookStorageTest.java index fd45d942fa1f..11fb099cfba1 100644 --- a/src/test/java/seedu/savvytasker/storage/XmlAddressBookStorageTest.java +++ b/src/test/java/seedu/savvytasker/storage/XmlAddressBookStorageTest.java @@ -10,7 +10,7 @@ import seedu.savvytasker.commons.util.FileUtil; import seedu.savvytasker.model.ReadOnlySavvyTasker; import seedu.savvytasker.model.SavvyTasker; -import seedu.savvytasker.model.person.Task; +import seedu.savvytasker.model.task.Task; import seedu.savvytasker.storage.XmlSavvyTaskerStorage; import seedu.savvytasker.testutil.TypicalTestTasks; @@ -73,14 +73,14 @@ public void readAndSaveAddressBook_allInOrder_success() throws Exception { assertEquals(original, new SavvyTasker(readBack)); //Modify data, overwrite exiting file, and read back - original.addTask(new Task(TypicalTestTasks.happy)); - original.removeTask(new Task(TypicalTestTasks.happy)); + original.addTask(new Task(td.happy)); + original.removeTask(new Task(td.happy)); xmlSavvyTaskerStorage.saveSavvyTasker(original, filePath); readBack = xmlSavvyTaskerStorage.readSavvyTasker(filePath).get(); assertEquals(original, new SavvyTasker(readBack)); //Save and read without specifying file path - original.addTask(new Task(TypicalTestTasks.happy)); + original.addTask(new Task(td.happy)); xmlSavvyTaskerStorage.saveSavvyTasker(original); //file path not specified readBack = xmlSavvyTaskerStorage.readSavvyTasker().get(); //file path not specified assertEquals(original, new SavvyTasker(readBack)); diff --git a/src/test/java/seedu/savvytasker/testutil/AddressBookBuilder.java b/src/test/java/seedu/savvytasker/testutil/AddressBookBuilder.java deleted file mode 100644 index 2345c9fce0bb..000000000000 --- a/src/test/java/seedu/savvytasker/testutil/AddressBookBuilder.java +++ /dev/null @@ -1,35 +0,0 @@ -package seedu.savvytasker.testutil; - -import seedu.savvytasker.commons.exceptions.IllegalValueException; -import seedu.savvytasker.model.AddressBook; -import seedu.savvytasker.model.person.Person; -import seedu.savvytasker.model.person.UniquePersonList; -import seedu.savvytasker.model.tag.Tag; - -/** - * A utility class to help with building Addressbook objects. - * Example usage:
- * {@code AddressBook ab = new AddressBookBuilder().withPerson("John", "Doe").withTag("Friend").build();} - */ -public class AddressBookBuilder { - - private AddressBook addressBook; - - public AddressBookBuilder(AddressBook addressBook){ - this.addressBook = addressBook; - } - - public AddressBookBuilder withPerson(Person person) throws UniquePersonList.DuplicatePersonException { - addressBook.addPerson(person); - return this; - } - - public AddressBookBuilder withTag(String tagName) throws IllegalValueException { - addressBook.addTag(new Tag(tagName)); - return this; - } - - public AddressBook build(){ - return addressBook; - } -} diff --git a/src/test/java/seedu/savvytasker/testutil/PersonBuilder.java b/src/test/java/seedu/savvytasker/testutil/PersonBuilder.java deleted file mode 100644 index 580427840d3c..000000000000 --- a/src/test/java/seedu/savvytasker/testutil/PersonBuilder.java +++ /dev/null @@ -1,49 +0,0 @@ -package seedu.savvytasker.testutil; - -import seedu.savvytasker.commons.exceptions.IllegalValueException; -import seedu.savvytasker.model.person.*; -import seedu.savvytasker.model.tag.Tag; - -/** - * - */ -public class PersonBuilder { - - private TestPerson person; - - public PersonBuilder() { - this.person = new TestPerson(); - } - - public PersonBuilder withName(String name) throws IllegalValueException { - this.person.setName(new Name(name)); - return this; - } - - public PersonBuilder withTags(String ... tags) throws IllegalValueException { - for (String tag: tags) { - person.getTags().add(new Tag(tag)); - } - return this; - } - - public PersonBuilder withAddress(String address) throws IllegalValueException { - this.person.setAddress(new Address(address)); - return this; - } - - public PersonBuilder withPhone(String phone) throws IllegalValueException { - this.person.setPhone(new Phone(phone)); - return this; - } - - public PersonBuilder withEmail(String email) throws IllegalValueException { - this.person.setEmail(new Email(email)); - return this; - } - - public TestPerson build() { - return this.person; - } - -} diff --git a/src/test/java/seedu/savvytasker/testutil/SavvyTaskerBuilder.java b/src/test/java/seedu/savvytasker/testutil/SavvyTaskerBuilder.java index 153c3e1be516..d1b2337909b6 100644 --- a/src/test/java/seedu/savvytasker/testutil/SavvyTaskerBuilder.java +++ b/src/test/java/seedu/savvytasker/testutil/SavvyTaskerBuilder.java @@ -1,8 +1,8 @@ package seedu.savvytasker.testutil; import seedu.savvytasker.model.SavvyTasker; -import seedu.savvytasker.model.person.Task; -import seedu.savvytasker.model.person.TaskList.DuplicateTaskException; +import seedu.savvytasker.model.task.Task; +import seedu.savvytasker.model.task.TaskList.DuplicateTaskException; /** * A utility class to help with building SavvyTasker objects. diff --git a/src/test/java/seedu/savvytasker/testutil/TestPerson.java b/src/test/java/seedu/savvytasker/testutil/TestPerson.java deleted file mode 100644 index c67221403dd9..000000000000 --- a/src/test/java/seedu/savvytasker/testutil/TestPerson.java +++ /dev/null @@ -1,76 +0,0 @@ -package seedu.savvytasker.testutil; - -import seedu.savvytasker.model.person.*; -import seedu.savvytasker.model.tag.UniqueTagList; - -/** - * A mutable person object. For testing only. - */ -public class TestPerson implements ReadOnlyPerson { - - private Name name; - private Address address; - private Email email; - private Phone phone; - private UniqueTagList tags; - - public TestPerson() { - tags = new UniqueTagList(); - } - - public void setName(Name name) { - this.name = name; - } - - public void setAddress(Address address) { - this.address = address; - } - - public void setEmail(Email email) { - this.email = email; - } - - public void setPhone(Phone phone) { - this.phone = phone; - } - - @Override - public Name getName() { - return name; - } - - @Override - public Phone getPhone() { - return phone; - } - - @Override - public Email getEmail() { - return email; - } - - @Override - public Address getAddress() { - return address; - } - - @Override - public UniqueTagList getTags() { - return tags; - } - - @Override - public String toString() { - return getAsText(); - } - - public String getAddCommand() { - StringBuilder sb = new StringBuilder(); - sb.append("add " + this.getName().fullName + " "); - sb.append("p/" + this.getPhone().value + " "); - sb.append("e/" + this.getEmail().value + " "); - sb.append("a/" + this.getAddress().value + " "); - this.getTags().getInternalList().stream().forEach(s -> sb.append("t/" + s.tagName + " ")); - return sb.toString(); - } -} diff --git a/src/test/java/seedu/savvytasker/testutil/TestTask.java b/src/test/java/seedu/savvytasker/testutil/TestTask.java index 77995ad849b8..223e9c412af7 100644 --- a/src/test/java/seedu/savvytasker/testutil/TestTask.java +++ b/src/test/java/seedu/savvytasker/testutil/TestTask.java @@ -2,8 +2,8 @@ import java.util.Date; -import seedu.savvytasker.model.person.*; import seedu.savvytasker.model.task.PriorityLevel; +import seedu.savvytasker.model.task.ReadOnlyTask; import seedu.savvytasker.model.task.RecurrenceType; /** diff --git a/src/test/java/seedu/savvytasker/testutil/TestUtil.java b/src/test/java/seedu/savvytasker/testutil/TestUtil.java index 836a3a710feb..7f06bd27b935 100644 --- a/src/test/java/seedu/savvytasker/testutil/TestUtil.java +++ b/src/test/java/seedu/savvytasker/testutil/TestUtil.java @@ -1,7 +1,6 @@ package seedu.savvytasker.testutil; import com.google.common.io.Files; -import guitests.guihandles.PersonCardHandle; import guitests.guihandles.TaskCardHandle; import javafx.geometry.Bounds; import javafx.geometry.Point2D; @@ -15,13 +14,12 @@ import org.testfx.api.FxToolkit; import seedu.savvytasker.TestApp; -import seedu.savvytasker.commons.exceptions.IllegalValueException; import seedu.savvytasker.commons.util.FileUtil; import seedu.savvytasker.commons.util.XmlUtil; import seedu.savvytasker.model.SavvyTasker; -import seedu.savvytasker.model.person.*; -import seedu.savvytasker.model.tag.Tag; -import seedu.savvytasker.model.tag.UniqueTagList; +import seedu.savvytasker.model.task.ReadOnlyTask; +import seedu.savvytasker.model.task.Task; +import seedu.savvytasker.model.task.TaskList; import seedu.savvytasker.storage.XmlSerializableSavvyTasker; import java.io.File; @@ -62,47 +60,6 @@ public static void assertThrows(Class expected, Runnable ex */ public static String SANDBOX_FOLDER = FileUtil.getPath("./src/test/data/sandbox/"); - public static final Person[] samplePersonData = getSamplePersonData(); - - private static Person[] getSamplePersonData() { - try { - return new Person[]{ - new Person(new Name("Ali Muster"), new Phone("9482424"), new Email("hans@google.com"), new Address("4th street"), new UniqueTagList()), - new Person(new Name("Boris Mueller"), new Phone("87249245"), new Email("ruth@google.com"), new Address("81th street"), new UniqueTagList()), - new Person(new Name("Carl Kurz"), new Phone("95352563"), new Email("heinz@yahoo.com"), new Address("wall street"), new UniqueTagList()), - new Person(new Name("Daniel Meier"), new Phone("87652533"), new Email("cornelia@google.com"), new Address("10th street"), new UniqueTagList()), - new Person(new Name("Elle Meyer"), new Phone("9482224"), new Email("werner@gmail.com"), new Address("michegan ave"), new UniqueTagList()), - new Person(new Name("Fiona Kunz"), new Phone("9482427"), new Email("lydia@gmail.com"), new Address("little tokyo"), new UniqueTagList()), - new Person(new Name("George Best"), new Phone("9482442"), new Email("anna@google.com"), new Address("4th street"), new UniqueTagList()), - new Person(new Name("Hoon Meier"), new Phone("8482424"), new Email("stefan@mail.com"), new Address("little india"), new UniqueTagList()), - new Person(new Name("Ida Mueller"), new Phone("8482131"), new Email("hans@google.com"), new Address("chicago ave"), new UniqueTagList()) - }; - } catch (IllegalValueException e) { - assert false; - //not possible - return null; - } - } - - public static final Tag[] sampleTagData = getSampleTagData(); - - private static Tag[] getSampleTagData() { - try { - return new Tag[]{ - new Tag("relatives"), - new Tag("friends") - }; - } catch (IllegalValueException e) { - assert false; - return null; - //not possible - } - } - - public static List generateSamplePersonData() { - return Arrays.asList(samplePersonData); - } - public static final Task[] sampleTaskData = getSampleTaskData(); private static Task[] getSampleTaskData() { @@ -228,6 +185,7 @@ public static void tearDownRuntime() throws Exception { * * Caveat: only find method declared in the current Class, not inherited from supertypes */ + @SuppressWarnings({ "unchecked", "rawtypes" }) public static Method getPrivateMethod(Class objectClass, String methodName) throws NoSuchMethodException { Method method = objectClass.getDeclaredMethod(methodName); method.setAccessible(true); @@ -312,15 +270,15 @@ public static TestTask[] removeTaskFromList(final TestTask[] list, int targetInd } /** - * Replaces persons[i] with a person. - * @param persons The array of persons. - * @param person The replacement person - * @param index The index of the person to be replaced. + * Replaces tasks[i] with a task. + * @param tasks The array of tasks. + * @param task The replacement task + * @param index The index of the task to be replaced. * @return */ - public static TestPerson[] replacePersonFromList(TestPerson[] persons, TestPerson person, int index) { - persons[index] = person; - return persons; + public static TestTask[] replaceTaskFromList(TestTask[] tasks, TestTask task, int index) { + tasks[index] = task; + return tasks; } /** @@ -343,33 +301,8 @@ private static List asList(T[] objs) { return list; } - public static boolean compareCardAndPerson(PersonCardHandle card, ReadOnlyPerson person) { - return card.isSamePerson(person); - } - public static boolean compareCardAndTask(TaskCardHandle card, ReadOnlyTask task) { return card.isSameTask(task); } - public static Tag[] getTagList(String tags) { - - if (tags.equals("")) { - return new Tag[]{}; - } - - final String[] split = tags.split(", "); - - final List collect = Arrays.asList(split).stream().map(e -> { - try { - return new Tag(e.replaceFirst("Tag: ", "")); - } catch (IllegalValueException e1) { - //not possible - assert false; - return null; - } - }).collect(Collectors.toList()); - - return collect.toArray(new Tag[split.length]); - } - } diff --git a/src/test/java/seedu/savvytasker/testutil/TypicalTestPersons.java b/src/test/java/seedu/savvytasker/testutil/TypicalTestPersons.java deleted file mode 100644 index a8981e23a855..000000000000 --- a/src/test/java/seedu/savvytasker/testutil/TypicalTestPersons.java +++ /dev/null @@ -1,61 +0,0 @@ -package seedu.savvytasker.testutil; - -import seedu.savvytasker.commons.exceptions.IllegalValueException; -import seedu.savvytasker.model.AddressBook; -import seedu.savvytasker.model.person.*; - -/** - * - */ -public class TypicalTestPersons { - - public static TestPerson alice, benson, carl, daniel, elle, fiona, george, hoon, ida; - - public TypicalTestPersons() { - try { - alice = new PersonBuilder().withName("Alice Pauline").withAddress("123, Jurong West Ave 6, #08-111") - .withEmail("alice@gmail.com").withPhone("85355255") - .withTags("friends").build(); - benson = new PersonBuilder().withName("Benson Meier").withAddress("311, Clementi Ave 2, #02-25") - .withEmail("johnd@gmail.com").withPhone("98765432") - .withTags("owesMoney", "friends").build(); - carl = new PersonBuilder().withName("Carl Kurz").withPhone("95352563").withEmail("heinz@yahoo.com").withAddress("wall street").build(); - daniel = new PersonBuilder().withName("Daniel Meier").withPhone("87652533").withEmail("cornelia@google.com").withAddress("10th street").build(); - elle = new PersonBuilder().withName("Elle Meyer").withPhone("9482224").withEmail("werner@gmail.com").withAddress("michegan ave").build(); - fiona = new PersonBuilder().withName("Fiona Kunz").withPhone("9482427").withEmail("lydia@gmail.com").withAddress("little tokyo").build(); - george = new PersonBuilder().withName("George Best").withPhone("9482442").withEmail("anna@google.com").withAddress("4th street").build(); - - //Manually added - hoon = new PersonBuilder().withName("Hoon Meier").withPhone("8482424").withEmail("stefan@mail.com").withAddress("little india").build(); - ida = new PersonBuilder().withName("Ida Mueller").withPhone("8482131").withEmail("hans@google.com").withAddress("chicago ave").build(); - } catch (IllegalValueException e) { - e.printStackTrace(); - assert false : "not possible"; - } - } - - public static void loadAddressBookWithSampleData(AddressBook ab) { - - try { - ab.addPerson(new Person(alice)); - ab.addPerson(new Person(benson)); - ab.addPerson(new Person(carl)); - ab.addPerson(new Person(daniel)); - ab.addPerson(new Person(elle)); - ab.addPerson(new Person(fiona)); - ab.addPerson(new Person(george)); - } catch (UniquePersonList.DuplicatePersonException e) { - assert false : "not possible"; - } - } - - public TestPerson[] getTypicalPersons() { - return new TestPerson[]{alice, benson, carl, daniel, elle, fiona, george}; - } - - public AddressBook getTypicalAddressBook(){ - AddressBook ab = new AddressBook(); - loadAddressBookWithSampleData(ab); - return ab; - } -} diff --git a/src/test/java/seedu/savvytasker/testutil/TypicalTestTasks.java b/src/test/java/seedu/savvytasker/testutil/TypicalTestTasks.java index 33291b0f2eae..30d9ccb22167 100644 --- a/src/test/java/seedu/savvytasker/testutil/TypicalTestTasks.java +++ b/src/test/java/seedu/savvytasker/testutil/TypicalTestTasks.java @@ -5,18 +5,18 @@ import seedu.savvytasker.commons.exceptions.IllegalValueException; import seedu.savvytasker.model.SavvyTasker; -import seedu.savvytasker.model.person.*; -import seedu.savvytasker.model.person.TaskList.DuplicateTaskException; import seedu.savvytasker.model.task.PriorityLevel; +import seedu.savvytasker.model.task.Task; +import seedu.savvytasker.model.task.TaskList.DuplicateTaskException; /** * */ public class TypicalTestTasks { - public static TestTask highPriority, medPriority, lowPriority, furthestDue, + public TestTask highPriority, medPriority, lowPriority, furthestDue, nearerDue, notSoNearerDue, earliestDue, longDue, happy, haloween; - private static SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy"); + private SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy"); public TypicalTestTasks() { try { @@ -47,16 +47,16 @@ public TypicalTestTasks() { } public static void loadSavvyTaskerWithSampleData(SavvyTasker st) { - + TypicalTestTasks td = new TypicalTestTasks(); try { - st.addTask(new Task(highPriority)); - st.addTask(new Task(medPriority)); - st.addTask(new Task(lowPriority)); - st.addTask(new Task(furthestDue)); - st.addTask(new Task(nearerDue)); - st.addTask(new Task(notSoNearerDue)); - st.addTask(new Task(earliestDue)); - st.addTask(new Task(longDue)); + st.addTask(new Task(td.highPriority)); + st.addTask(new Task(td.medPriority)); + st.addTask(new Task(td.lowPriority)); + st.addTask(new Task(td.furthestDue)); + st.addTask(new Task(td.nearerDue)); + st.addTask(new Task(td.notSoNearerDue)); + st.addTask(new Task(td.earliestDue)); + st.addTask(new Task(td.longDue)); } catch (DuplicateTaskException e) { assert false : "not possible"; }