From 08cd96ce7345fe1d83af1d170cd684eed0575f48 Mon Sep 17 00:00:00 2001 From: Raghava Date: Thu, 17 Oct 2024 18:31:27 +0800 Subject: [PATCH 1/4] Remove unused files and person from project --- .../java/seedu/address/logic/Messages.java | 5 +- .../address/logic/commands/DeleteCommand.java | 2 +- .../address/logic/commands/EditCommand.java | 218 ------------------ .../address/logic/commands/FindCommand.java | 2 +- .../logic/parser/AddressBookParser.java | 4 - .../logic/parser/EditCommandParser.java | 79 ------- .../model/internshipapplication/Person.java | 117 ---------- .../storage/JsonSerializableAddressBook.java | 5 +- .../java/seedu/address/ui/MainWindow.java | 4 +- src/main/resources/view/MainWindow.fxml | 2 +- .../seedu/address/logic/LogicManagerTest.java | 6 +- .../logic/commands/AddCommandTest.java | 2 +- .../logic/commands/CommandTestUtil.java | 26 +-- .../logic/commands/DeleteCommandTest.java | 32 +-- .../logic/commands/EditCommandTest.java | 46 ++-- .../commands/EditPersonDescriptorTest.java | 61 ----- .../logic/commands/FindCommandTest.java | 10 +- .../logic/commands/ListCommandTest.java | 2 +- .../logic/parser/AddressBookParserTest.java | 10 +- .../logic/parser/DeleteCommandParserTest.java | 4 +- .../logic/parser/EditCommandParserTest.java | 16 +- .../address/logic/parser/ParserUtilTest.java | 6 +- .../seedu/address/model/ModelManagerTest.java | 8 +- .../JsonSerializableAddressBookTest.java | 2 +- .../testutil/EditPersonDescriptorBuilder.java | 81 ------- .../seedu/address/testutil/PersonBuilder.java | 96 -------- .../seedu/address/testutil/PersonUtil.java | 60 ----- .../java/seedu/address/testutil/TestUtil.java | 2 +- .../address/testutil/TypicalIndexes.java | 6 +- .../address/testutil/TypicalPersons.java | 53 ----- 30 files changed, 88 insertions(+), 879 deletions(-) delete mode 100644 src/main/java/seedu/address/logic/commands/EditCommand.java delete mode 100644 src/main/java/seedu/address/logic/parser/EditCommandParser.java delete mode 100644 src/main/java/seedu/address/model/internshipapplication/Person.java delete mode 100644 src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java delete mode 100644 src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java delete mode 100644 src/test/java/seedu/address/testutil/PersonBuilder.java delete mode 100644 src/test/java/seedu/address/testutil/PersonUtil.java delete mode 100644 src/test/java/seedu/address/testutil/TypicalPersons.java diff --git a/src/main/java/seedu/address/logic/Messages.java b/src/main/java/seedu/address/logic/Messages.java index c5891579e28..eec0133affb 100644 --- a/src/main/java/seedu/address/logic/Messages.java +++ b/src/main/java/seedu/address/logic/Messages.java @@ -14,8 +14,9 @@ public class Messages { public static final String MESSAGE_UNKNOWN_COMMAND = "Unknown command"; public static final String MESSAGE_INVALID_COMMAND_FORMAT = "Invalid command format! \n%1$s"; - public static final String MESSAGE_INVALID_PERSON_DISPLAYED_INDEX = "The person index provided is invalid"; - public static final String MESSAGE_PERSONS_LISTED_OVERVIEW = "%1$d persons listed!"; + public static final String MESSAGE_INVALID_INTERNSHIP_APPLICATION_DISPLAYED_INDEX = + "The internship application index provided is invalid"; + public static final String MESSAGE_INTERNSHIP_APPLICATIONS_LISTED_OVERVIEW = "%1$d internship applications listed!"; public static final String MESSAGE_DUPLICATE_FIELDS = "Multiple values specified for the following single-valued field(s): "; diff --git a/src/main/java/seedu/address/logic/commands/DeleteCommand.java b/src/main/java/seedu/address/logic/commands/DeleteCommand.java index eeaade2414a..ec447ce63eb 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteCommand.java @@ -37,7 +37,7 @@ public CommandResult execute(Model model) throws CommandE List lastShownList = model.getFilteredList(); if (targetIndex.getZeroBased() >= lastShownList.size()) { - throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + throw new CommandException(Messages.MESSAGE_INVALID_INTERNSHIP_APPLICATION_DISPLAYED_INDEX); } InternshipApplication internshipApplicationToDelete = lastShownList.get(targetIndex.getZeroBased()); diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java deleted file mode 100644 index ca967c4fe8a..00000000000 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ /dev/null @@ -1,218 +0,0 @@ -package seedu.address.logic.commands; - -import static java.util.Objects.requireNonNull; -import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; -import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; -import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; -import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; - -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; - -import seedu.address.commons.core.index.Index; -import seedu.address.commons.util.CollectionUtil; -import seedu.address.commons.util.ToStringBuilder; -import seedu.address.logic.Messages; -import seedu.address.logic.commands.exceptions.CommandException; -import seedu.address.model.Model; -import seedu.address.model.internshipapplication.Email; -import seedu.address.model.internshipapplication.InternshipApplication; -import seedu.address.model.internshipapplication.Name; -import seedu.address.model.tag.Tag; - -/** - * Edits the details of an existing person in the address book. - */ -public class EditCommand extends Command { - - public static final String COMMAND_WORD = "edit"; - - public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the person identified " - + "by the index number used in the displayed person list. " - + "Existing values will be overwritten by the input values.\n" - + "Parameters: INDEX (must be a positive integer) " - + "[" + PREFIX_NAME + "NAME] " - + "[" + PREFIX_PHONE + "PHONE] " - + "[" + PREFIX_EMAIL + "EMAIL] " - + "[" + PREFIX_ADDRESS + "ADDRESS] " - + "[" + PREFIX_TAG + "TAG]...\n" - + "Example: " + COMMAND_WORD + " 1 " - + PREFIX_PHONE + "91234567 " - + PREFIX_EMAIL + "johndoe@example.com"; - - public static final String MESSAGE_EDIT_PERSON_SUCCESS = "Edited Person: %1$s"; - public static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided."; - public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book."; - - private final Index index; - private final EditPersonDescriptor editPersonDescriptor; - - /** - * @param index of the person in the filtered person list to edit - * @param editPersonDescriptor details to edit the person with - */ - public EditCommand(Index index, EditPersonDescriptor editPersonDescriptor) { - requireNonNull(index); - requireNonNull(editPersonDescriptor); - - this.index = index; - this.editPersonDescriptor = new EditPersonDescriptor(editPersonDescriptor); - } - - @Override - public CommandResult execute(Model model) throws CommandException { - requireNonNull(model); - List lastShownList = model.getFilteredList(); - - if (index.getZeroBased() >= lastShownList.size()) { - throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); - } - - - // Internship personToEdit = lastShownList.get(index.getZeroBased()); - // Internship editedPerson = createEditedPerson(personToEdit, editPersonDescriptor); - // - // if (!personToEdit.isSame(editedPerson) && model.hasItem(editedPerson)) { - // throw new CommandException(MESSAGE_DUPLICATE_PERSON); - // } - // - // model.setItem(personToEdit, editedPerson); - // model.updateFilteredList((Predicate) PREDICATE_SHOW_ALL); - // return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson))); - return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, "")); - } - - // /** - // * Creates and returns a {@code Person} with the details of {@code personToEdit} - // * edited with {@code editPersonDescriptor}. - // */ - // private static Person createEditedPerson(Person personToEdit, EditPersonDescriptor editPersonDescriptor) { - // assert personToEdit != null; - // - // Name updatedName = editPersonDescriptor.getName().orElse(personToEdit.getName()); - // Phone updatedPhone = editPersonDescriptor.getPhone().orElse(personToEdit.getPhone()); - // Email updatedEmail = editPersonDescriptor.getEmail().orElse(personToEdit.getEmail()); - // Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress()); - // Set updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); - // - // return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedTags); - // } - - @Override - public boolean equals(Object other) { - if (other == this) { - return true; - } - - // instanceof handles nulls - if (!(other instanceof EditCommand)) { - return false; - } - - EditCommand otherEditCommand = (EditCommand) other; - return index.equals(otherEditCommand.index) - && editPersonDescriptor.equals(otherEditCommand.editPersonDescriptor); - } - - @Override - public String toString() { - return new ToStringBuilder(this) - .add("index", index) - .add("editPersonDescriptor", editPersonDescriptor) - .toString(); - } - - /** - * Stores the details to edit the person with. Each non-empty field value will replace the - * corresponding field value of the person. - */ - public static class EditPersonDescriptor { - private Name name; - private Email email; - private Set tags; - - public EditPersonDescriptor() {} - - /** - * Copy constructor. - * A defensive copy of {@code tags} is used internally. - */ - public EditPersonDescriptor(EditPersonDescriptor toCopy) { - setName(toCopy.name); - setEmail(toCopy.email); - setTags(toCopy.tags); - } - - /** - * Returns true if at least one field is edited. - */ - public boolean isAnyFieldEdited() { - return CollectionUtil.isAnyNonNull(name, email, tags); - } - - public void setName(Name name) { - this.name = name; - } - - public Optional getName() { - return Optional.ofNullable(name); - } - - public void setEmail(Email email) { - this.email = email; - } - - public Optional getEmail() { - return Optional.ofNullable(email); - } - - - /** - * Sets {@code tags} to this object's {@code tags}. - * A defensive copy of {@code tags} is used internally. - */ - public void setTags(Set tags) { - this.tags = (tags != null) ? new HashSet<>(tags) : null; - } - - /** - * Returns an unmodifiable tag set, which throws {@code UnsupportedOperationException} - * if modification is attempted. - * Returns {@code Optional#empty()} if {@code tags} is null. - */ - public Optional> getTags() { - return (tags != null) ? Optional.of(Collections.unmodifiableSet(tags)) : Optional.empty(); - } - - @Override - public boolean equals(Object other) { - if (other == this) { - return true; - } - - // instanceof handles nulls - if (!(other instanceof EditPersonDescriptor)) { - return false; - } - - EditPersonDescriptor otherEditPersonDescriptor = (EditPersonDescriptor) other; - return Objects.equals(name, otherEditPersonDescriptor.name) - && Objects.equals(email, otherEditPersonDescriptor.email) - && Objects.equals(tags, otherEditPersonDescriptor.tags); - } - - @Override - public String toString() { - return new ToStringBuilder(this) - .add("name", name) - .add("email", email) - .add("tags", tags) - .toString(); - } - } -} diff --git a/src/main/java/seedu/address/logic/commands/FindCommand.java b/src/main/java/seedu/address/logic/commands/FindCommand.java index eccf491f48d..06f61b917a2 100644 --- a/src/main/java/seedu/address/logic/commands/FindCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindCommand.java @@ -33,7 +33,7 @@ public CommandResult execute(Model model) { requireNonNull(model); model.updateFilteredList(predicate); return new CommandResult( - String.format(Messages.MESSAGE_PERSONS_LISTED_OVERVIEW, model.getFilteredList().size())); + String.format(Messages.MESSAGE_INTERNSHIP_APPLICATIONS_LISTED_OVERVIEW, model.getFilteredList().size())); } @Override diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java index 3149ee07e0b..ef4b29ab01a 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java @@ -12,7 +12,6 @@ import seedu.address.logic.commands.ClearCommand; import seedu.address.logic.commands.Command; import seedu.address.logic.commands.DeleteCommand; -import seedu.address.logic.commands.EditCommand; import seedu.address.logic.commands.ExitCommand; import seedu.address.logic.commands.FindCommand; import seedu.address.logic.commands.HelpCommand; @@ -56,9 +55,6 @@ public Command parseCommand(String userInput) throws ParseException { case AddCommand.COMMAND_WORD: return new AddCommandParser().parse(arguments); - case EditCommand.COMMAND_WORD: - return new EditCommandParser().parse(arguments); - case DeleteCommand.COMMAND_WORD: return new DeleteCommandParser().parse(arguments); diff --git a/src/main/java/seedu/address/logic/parser/EditCommandParser.java b/src/main/java/seedu/address/logic/parser/EditCommandParser.java deleted file mode 100644 index 2b578a59914..00000000000 --- a/src/main/java/seedu/address/logic/parser/EditCommandParser.java +++ /dev/null @@ -1,79 +0,0 @@ -package seedu.address.logic.parser; - -import static java.util.Objects.requireNonNull; -import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; -import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; -import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; -import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; -import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; - -import java.util.Collection; -import java.util.Collections; -import java.util.Optional; -import java.util.Set; - -import seedu.address.commons.core.index.Index; -import seedu.address.logic.commands.EditCommand; -import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; -import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.tag.Tag; - -/** - * Parses input arguments and creates a new EditCommand object - */ -public class EditCommandParser implements Parser { - - /** - * Parses the given {@code String} of arguments in the context of the EditCommand - * and returns an EditCommand object for execution. - * @throws ParseException if the user input does not conform the expected format - */ - public EditCommand parse(String args) throws ParseException { - requireNonNull(args); - ArgumentMultimap argMultimap = - ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_TAG); - - Index index; - - try { - index = ParserUtil.parseIndex(argMultimap.getPreamble()); - } catch (ParseException pe) { - throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, EditCommand.MESSAGE_USAGE), pe); - } - - argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS); - - EditPersonDescriptor editPersonDescriptor = new EditPersonDescriptor(); - - if (argMultimap.getValue(PREFIX_NAME).isPresent()) { - editPersonDescriptor.setName(ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get())); - } - if (argMultimap.getValue(PREFIX_EMAIL).isPresent()) { - editPersonDescriptor.setEmail(ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get())); - } - parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(editPersonDescriptor::setTags); - - if (!editPersonDescriptor.isAnyFieldEdited()) { - throw new ParseException(EditCommand.MESSAGE_NOT_EDITED); - } - - return new EditCommand(index, editPersonDescriptor); - } - - /** - * Parses {@code Collection tags} into a {@code Set} if {@code tags} is non-empty. - * If {@code tags} contain only one element which is an empty string, it will be parsed into a - * {@code Set} containing zero tags. - */ - private Optional> parseTagsForEdit(Collection tags) throws ParseException { - assert tags != null; - - if (tags.isEmpty()) { - return Optional.empty(); - } - Collection tagSet = tags.size() == 1 && tags.contains("") ? Collections.emptySet() : tags; - return Optional.of(ParserUtil.parseTags(tagSet)); - } - -} diff --git a/src/main/java/seedu/address/model/internshipapplication/Person.java b/src/main/java/seedu/address/model/internshipapplication/Person.java deleted file mode 100644 index 9b6d9664e65..00000000000 --- a/src/main/java/seedu/address/model/internshipapplication/Person.java +++ /dev/null @@ -1,117 +0,0 @@ -package seedu.address.model.internshipapplication; - -import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Objects; -import java.util.Set; - -import seedu.address.commons.util.ToStringBuilder; -import seedu.address.model.tag.Tag; - -/** - * Represents a Person in the address book. - * Guarantees: details are present and not null, field values are validated, immutable. - */ -public class Person { - - // Identity fields - private final Name name; - private final Phone phone; - private final Email email; - - // Data fields - private final Address address; - private final Set tags = new HashSet<>(); - - /** - * Every field must be present and not null. - */ - public Person(Name name, Phone phone, Email email, Address address, Set tags) { - requireAllNonNull(name, phone, email, address, tags); - this.name = name; - this.phone = phone; - this.email = email; - this.address = address; - this.tags.addAll(tags); - } - - public Name getName() { - return name; - } - - public Phone getPhone() { - return phone; - } - - public Email getEmail() { - return email; - } - - public Address getAddress() { - return address; - } - - /** - * Returns an immutable tag set, which throws {@code UnsupportedOperationException} - * if modification is attempted. - */ - public Set getTags() { - return Collections.unmodifiableSet(tags); - } - - /** - * Returns true if both persons have the same name. - * This defines a weaker notion of equality between two persons. - */ - public boolean isSamePerson(Person otherPerson) { - if (otherPerson == this) { - return true; - } - - return otherPerson != null - && otherPerson.getName().equals(getName()); - } - - /** - * Returns true if both persons have the same identity and data fields. - * This defines a stronger notion of equality between two persons. - */ - @Override - public boolean equals(Object other) { - if (other == this) { - return true; - } - - // instanceof handles nulls - if (!(other instanceof Person)) { - return false; - } - - Person otherPerson = (Person) other; - return name.equals(otherPerson.name) - && phone.equals(otherPerson.phone) - && email.equals(otherPerson.email) - && address.equals(otherPerson.address) - && tags.equals(otherPerson.tags); - } - - @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 new ToStringBuilder(this) - .add("name", name) - .add("phone", phone) - .add("email", email) - .add("address", address) - .add("tags", tags) - .toString(); - } - -} diff --git a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java b/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java index b67d67ea52d..9c6c3d4d20b 100644 --- a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java +++ b/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java @@ -19,7 +19,8 @@ @JsonRootName(value = "addressbook") class JsonSerializableAddressBook { - public static final String MESSAGE_DUPLICATE_PERSON = "Persons list contains duplicate person(s)."; + public static final String MESSAGE_DUPLICATE_INTERNSHIP_APPLICATION = + "Internship application list contains duplicate internship applications(s)."; private final List internships = new ArrayList<>(); @@ -50,7 +51,7 @@ public AddressBook toModelType() throws IllegalValueExcep for (JsonAdaptedInternship jsonAdaptedInternship : internships) { InternshipApplication internship = jsonAdaptedInternship.toModelType(); if (addressBook.hasItem(internship)) { - throw new IllegalValueException(MESSAGE_DUPLICATE_PERSON); + throw new IllegalValueException(MESSAGE_DUPLICATE_INTERNSHIP_APPLICATION); } addressBook.addItem(internship); } diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java index d435b235175..85cfb74e5b7 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/seedu/address/ui/MainWindow.java @@ -43,7 +43,7 @@ public class MainWindow extends UiPart { private MenuItem helpMenuItem; @FXML - private StackPane personListPanelPlaceholder; + private StackPane internshipApplicationListPanelPlaceholder; @FXML private StackPane resultDisplayPlaceholder; @@ -112,7 +112,7 @@ private void setAccelerator(MenuItem menuItem, KeyCombination keyCombination) { */ void fillInnerParts() { internshipListPanel = new InternshipListPanel(logic.getFilteredList()); - personListPanelPlaceholder.getChildren().add(internshipListPanel.getRoot()); + internshipApplicationListPanelPlaceholder.getChildren().add(internshipListPanel.getRoot()); resultDisplay = new ResultDisplay(); resultDisplayPlaceholder.getChildren().add(resultDisplay.getRoot()); diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml index 7778f666a0a..243620e5af4 100644 --- a/src/main/resources/view/MainWindow.fxml +++ b/src/main/resources/view/MainWindow.fxml @@ -50,7 +50,7 @@ - + diff --git a/src/test/java/seedu/address/logic/LogicManagerTest.java b/src/test/java/seedu/address/logic/LogicManagerTest.java index 05cfafe16ff..93a20783a6d 100644 --- a/src/test/java/seedu/address/logic/LogicManagerTest.java +++ b/src/test/java/seedu/address/logic/LogicManagerTest.java @@ -1,7 +1,7 @@ package seedu.address.logic; import static org.junit.jupiter.api.Assertions.assertEquals; -import static seedu.address.logic.Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX; +import static seedu.address.logic.Messages.MESSAGE_INVALID_INTERNSHIP_APPLICATION_DISPLAYED_INDEX; import static seedu.address.logic.Messages.MESSAGE_UNKNOWN_COMMAND; import static seedu.address.logic.commands.CommandTestUtil.COMPANY_EMAIL_DESC_APPLE; import static seedu.address.logic.commands.CommandTestUtil.COMPANY_NAME_DESC_APPLE; @@ -62,7 +62,7 @@ public void execute_invalidCommandFormat_throwsParseException() { @Test public void execute_commandExecutionError_throwsCommandException() { String deleteCommand = "/d 9"; - assertCommandException(deleteCommand, MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + assertCommandException(deleteCommand, MESSAGE_INVALID_INTERNSHIP_APPLICATION_DISPLAYED_INDEX); } @Test @@ -84,7 +84,7 @@ public void execute_storageThrowsAdException_throwsCommandException() { } @Test - public void getFilteredPersonList_modifyList_throwsUnsupportedOperationException() { + public void getFilteredInternshipApplicationList_modifyList_throwsUnsupportedOperationException() { assertThrows(UnsupportedOperationException.class, () -> logic.getFilteredList().remove(0)); } diff --git a/src/test/java/seedu/address/logic/commands/AddCommandTest.java b/src/test/java/seedu/address/logic/commands/AddCommandTest.java index 85c3954b984..1c09b9b2321 100644 --- a/src/test/java/seedu/address/logic/commands/AddCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/AddCommandTest.java @@ -45,7 +45,7 @@ public void execute_applicationAcceptedByModel_addSuccessful() throws Exception } @Test - public void execute_duplicatePerson_throwsCommandException() { + public void execute_duplicateInternshipApplication_throwsCommandException() { InternshipApplication validApplication = new InternshipApplicationBuilder().build(); AddCommand addCommand = new AddCommand(validApplication); ModelStub modelStub = new ModelStubWithInternshipApplication(validApplication); diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 8a1ff01400b..53d45ef182f 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -20,7 +20,6 @@ import seedu.address.model.Model; import seedu.address.model.internshipapplication.InternshipApplication; import seedu.address.model.internshipapplication.NameContainsKeywordsPredicate; -import seedu.address.testutil.EditPersonDescriptorBuilder; /** * Contains helper methods for testing commands. @@ -80,34 +79,11 @@ public class CommandTestUtil { public static final String ADDRESS_DESC_AMY = " " + PREFIX_ADDRESS + VALID_ADDRESS_AMY; public static final String ADDRESS_DESC_BOB = " " + PREFIX_ADDRESS + VALID_ADDRESS_BOB; public static final String INVALID_ADDRESS_DESC = " " + PREFIX_ADDRESS; // empty string not allowed for addresses - - public static final EditCommand.EditPersonDescriptor DESC_AMY; - - public static final EditCommand.EditPersonDescriptor DESC_BOB; - static { - DESC_AMY = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY) - .withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).build(); - DESC_BOB = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB) - .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).build(); - } //The list ends here public static final String PREAMBLE_WHITESPACE = "\t \r \n"; public static final String PREAMBLE_NON_EMPTY = "NonEmptyPreamble"; - // Todo when EDIT feature implemented - // public static final EditCommand.EditPersonDescriptor DESC_APPLE; - // public static final EditCommand.EditPersonDescriptor DESC_BOFA; - // - // static { - // DESC_APPLE = new EditPersonDescriptorBuilder().withName(VALID_COMPANY_NAME_APPLE) - // .withPhone(VALID_DATE_APPLE).withEmail(VALID_COMPANY_EMAIL_APPLE).withAddress(VALID_ROLE_APPLE) - // .withTags(VALID_TAG_FRIEND).build(); - // DESC_BOFA = new EditPersonDescriptorBuilder().withName(VALID_COMPANY_NAME_BOFA) - // .withPhone(VALID_DATE_BOFA).withEmail(VALID_COMPANY_EMAIL_BOFA).withAddress(VALID_ROLE_BOFA) - // .withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND).build(); - // } - /** * Executes the given {@code command}, confirms that
* - the returned {@link CommandResult} matches {@code expectedCommandResult}
@@ -158,7 +134,7 @@ public static void assertCommandFailure(Command command, * Updates {@code model}'s filtered list to show only the person at the given {@code targetIndex} in the * {@code model}'s address book. */ - public static void showPersonAtIndex(Model model, Index targetIndex) { + public static void showInternshipApplicationAtIndex(Model model, Index targetIndex) { assertTrue(targetIndex.getZeroBased() < model.getFilteredList().size()); InternshipApplication internshipApplication = model.getFilteredList().get(targetIndex.getZeroBased()); diff --git a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java b/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java index 664c93b3922..ff0f86264a6 100644 --- a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java @@ -6,8 +6,8 @@ import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; import static seedu.address.logic.commands.CommandTestUtil.showPersonAtIndex; -import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; -import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PERSON; +import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_INTERNSHIP_APPLICATION; +import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_INTERNSHIP_APPLICATION; import static seedu.address.testutil.TypicalInternshipApplications.getTypicalAddressBook; import org.junit.jupiter.api.Test; @@ -31,8 +31,8 @@ public class DeleteCommandTest { @Test public void execute_validIndexUnfilteredList_success() { InternshipApplication internshipApplicationToDelete = model - .getFilteredList().get(INDEX_FIRST_PERSON.getZeroBased()); - DeleteCommand deleteCommand = new DeleteCommand(INDEX_FIRST_PERSON); + .getFilteredList().get(INDEX_FIRST_INTERNSHIP_APPLICATION.getZeroBased()); + DeleteCommand deleteCommand = new DeleteCommand(INDEX_FIRST_INTERNSHIP_APPLICATION); String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_INTERNSHIP_APPLICATION_SUCCESS, Messages.format(internshipApplicationToDelete)); @@ -48,50 +48,50 @@ public void execute_invalidIndexUnfilteredList_throwsCommandException() { Index outOfBoundIndex = Index.fromOneBased(model.getFilteredList().size() + 1); DeleteCommand deleteCommand = new DeleteCommand(outOfBoundIndex); - assertCommandFailure(deleteCommand, model, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + assertCommandFailure(deleteCommand, model, Messages.MESSAGE_INVALID_INTERNSHIP_APPLICATION_DISPLAYED_INDEX); } @Test public void execute_validIndexFilteredList_success() { - showPersonAtIndex(model, INDEX_FIRST_PERSON); + showPersonAtIndex(model, INDEX_FIRST_INTERNSHIP_APPLICATION); InternshipApplication internshipApplicationToDelete = model - .getFilteredList().get(INDEX_FIRST_PERSON.getZeroBased()); - DeleteCommand deleteCommand = new DeleteCommand(INDEX_FIRST_PERSON); + .getFilteredList().get(INDEX_FIRST_INTERNSHIP_APPLICATION.getZeroBased()); + DeleteCommand deleteCommand = new DeleteCommand(INDEX_FIRST_INTERNSHIP_APPLICATION); String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_INTERNSHIP_APPLICATION_SUCCESS, Messages.format(internshipApplicationToDelete)); Model expectedModel = new ModelManager<>(model.getAddressBook(), new UserPrefs()); expectedModel.deleteItem(internshipApplicationToDelete); - showNoPerson(expectedModel); + showNoInternshipApplication(expectedModel); assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); } @Test public void execute_invalidIndexFilteredList_throwsCommandException() { - showPersonAtIndex(model, INDEX_FIRST_PERSON); + showPersonAtIndex(model, INDEX_FIRST_INTERNSHIP_APPLICATION); - Index outOfBoundIndex = INDEX_SECOND_PERSON; + Index outOfBoundIndex = INDEX_SECOND_INTERNSHIP_APPLICATION; // ensures that outOfBoundIndex is still in bounds of the internship application list assertTrue(outOfBoundIndex.getZeroBased() < model.getAddressBook().getList().size()); DeleteCommand deleteCommand = new DeleteCommand(outOfBoundIndex); - assertCommandFailure(deleteCommand, model, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + assertCommandFailure(deleteCommand, model, Messages.MESSAGE_INVALID_INTERNSHIP_APPLICATION_DISPLAYED_INDEX); } @Test public void equals() { - DeleteCommand deleteFirstCommand = new DeleteCommand(INDEX_FIRST_PERSON); - DeleteCommand deleteSecondCommand = new DeleteCommand(INDEX_SECOND_PERSON); + DeleteCommand deleteFirstCommand = new DeleteCommand(INDEX_FIRST_INTERNSHIP_APPLICATION); + DeleteCommand deleteSecondCommand = new DeleteCommand(INDEX_SECOND_INTERNSHIP_APPLICATION); // same object -> returns true assertTrue(deleteFirstCommand.equals(deleteFirstCommand)); // same values -> returns true - DeleteCommand deleteFirstCommandCopy = new DeleteCommand(INDEX_FIRST_PERSON); + DeleteCommand deleteFirstCommandCopy = new DeleteCommand(INDEX_FIRST_INTERNSHIP_APPLICATION); assertTrue(deleteFirstCommand.equals(deleteFirstCommandCopy)); // different types -> returns false @@ -115,7 +115,7 @@ public void toStringMethod() { /** * Updates {@code model}'s filtered list to show no one. */ - private void showNoPerson(Model model) { + private void showNoInternshipApplication(Model model) { model.updateFilteredList(p -> false); assertTrue(model.getFilteredList().isEmpty()); diff --git a/src/test/java/seedu/address/logic/commands/EditCommandTest.java b/src/test/java/seedu/address/logic/commands/EditCommandTest.java index 6b5c02ccb08..cf4d427b126 100644 --- a/src/test/java/seedu/address/logic/commands/EditCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/EditCommandTest.java @@ -13,8 +13,8 @@ //import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; //import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; ////import static seedu.address.logic.commands.CommandTestUtil.showPersonAtIndex; -//import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; -//import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PERSON; +//import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_INTERNSHIP_APPLICATION; +//import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_INTERNSHIP_APPLICATION; //import static seedu.address.testutil.TypicalInternshipApplications.getTypicalAddressBook; // //import org.junit.jupiter.api.Test; @@ -42,7 +42,7 @@ // public void execute_allFieldsSpecifiedUnfilteredList_success() { // Person editedPerson = new PersonBuilder().build(); // EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(editedPerson).build(); -// EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, descriptor); +// EditCommand editCommand = new EditCommand(INDEX_FIRST_INTERNSHIP_APPLICATION, descriptor); // // String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages // .format(editedPerson)); @@ -79,8 +79,8 @@ // // @Test // public void execute_noFieldSpecifiedUnfilteredList_success() { -// EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, new EditPersonDescriptor()); -// Person editedPerson = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); +// EditCommand editCommand = new EditCommand(INDEX_FIRST_INTERNSHIP_APPLICATION, new EditPersonDescriptor()); +// Person editedPerson = model.getFilteredPersonList().get(INDEX_FIRST_INTERNSHIP_APPLICATION.getZeroBased()); // // String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, // Messages.format(editedPerson)); @@ -93,11 +93,11 @@ ////Todo when FILTER feature is implemented //// @Test //// public void execute_filteredList_success() { -//// showPersonAtIndex(model, INDEX_FIRST_PERSON); +//// showPersonAtIndex(model, INDEX_FIRST_INTERNSHIP_APPLICATION); //// -//// Person personInFilteredList = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); +//// Person personInFilteredList = model.getFilteredPersonList().get(INDEX_FIRST_INTERNSHIP_APPLICATION.getZeroBased()); //// Person editedPerson = new PersonBuilder(personInFilteredList).withName(VALID_NAME_BOB).build(); -//// EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, +//// EditCommand editCommand = new EditCommand(INDEX_FIRST_INTERNSHIP_APPLICATION, //// new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB).build()); //// //// String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, @@ -112,24 +112,24 @@ // // @Test // public void execute_duplicatePersonUnfilteredList_failure() { -// Person firstPerson = model.getFilteredList().get(INDEX_FIRST_PERSON.getZeroBased()); +// Person firstPerson = model.getFilteredList().get(INDEX_FIRST_INTERNSHIP_APPLICATION.getZeroBased()); // EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(firstPerson).build(); -// EditCommand editCommand = new EditCommand(INDEX_SECOND_PERSON, descriptor); +// EditCommand editCommand = new EditCommand(INDEX_SECOND_INTERNSHIP_APPLICATION, descriptor); // -// assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_PERSON); +// assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_INTERNSHIP_APPLICATION); // } // ////Todo when FILTER feature is implemented //// @Test //// public void execute_duplicatePersonFilteredList_failure() { -//// showPersonAtIndex(model, INDEX_FIRST_PERSON); +//// showPersonAtIndex(model, INDEX_FIRST_INTERNSHIP_APPLICATION); //// //// // edit person in filtered list into a duplicate in address book -//// Person personInList = model.getAddressBook().getPersonList().get(INDEX_SECOND_PERSON.getZeroBased()); -//// EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, +//// Person personInList = model.getAddressBook().getPersonList().get(INDEX_SECOND_INTERNSHIP_APPLICATION.getZeroBased()); +//// EditCommand editCommand = new EditCommand(INDEX_FIRST_INTERNSHIP_APPLICATION, //// new EditPersonDescriptorBuilder(personInList).build()); //// -//// assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_PERSON); +//// assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_INTERNSHIP_APPLICATION); //// } // // @Test @@ -138,7 +138,7 @@ // EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB).build(); // EditCommand editCommand = new EditCommand(outOfBoundIndex, descriptor); // -// assertCommandFailure(editCommand, model, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); +// assertCommandFailure(editCommand, model, Messages.MESSAGE_INVALID_INTERNSHIP_APPLICATION_DISPLAYED_INDEX); // } // // //Todo when FILTER feature is implemented @@ -148,24 +148,24 @@ //// */ //// @Test //// public void execute_invalidPersonIndexFilteredList_failure() { -//// showPersonAtIndex(model, INDEX_FIRST_PERSON); -//// Index outOfBoundIndex = INDEX_SECOND_PERSON; +//// showPersonAtIndex(model, INDEX_FIRST_INTERNSHIP_APPLICATION); +//// Index outOfBoundIndex = INDEX_SECOND_INTERNSHIP_APPLICATION; //// // ensures that outOfBoundIndex is still in bounds of address book list //// assertTrue(outOfBoundIndex.getZeroBased() < model.getAddressBook().getPersonList().size()); //// //// EditCommand editCommand = new EditCommand(outOfBoundIndex, //// new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB).build()); //// -//// assertCommandFailure(editCommand, model, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); +//// assertCommandFailure(editCommand, model, Messages.MESSAGE_INVALID_INTERNSHIP_APPLICATION_DISPLAYED_INDEX); //// } // // @Test // public void equals() { -// final EditCommand standardCommand = new EditCommand(INDEX_FIRST_PERSON, DESC_AMY); +// final EditCommand standardCommand = new EditCommand(INDEX_FIRST_INTERNSHIP_APPLICATION, DESC_AMY); // // // same values -> returns true // EditPersonDescriptor copyDescriptor = new EditPersonDescriptor(DESC_AMY); -// EditCommand commandWithSameValues = new EditCommand(INDEX_FIRST_PERSON, copyDescriptor); +// EditCommand commandWithSameValues = new EditCommand(INDEX_FIRST_INTERNSHIP_APPLICATION, copyDescriptor); // assertTrue(standardCommand.equals(commandWithSameValues)); // // // same object -> returns true @@ -178,10 +178,10 @@ // assertFalse(standardCommand.equals(new ClearCommand())); // // // different index -> returns false -// assertFalse(standardCommand.equals(new EditCommand(INDEX_SECOND_PERSON, DESC_AMY))); +// assertFalse(standardCommand.equals(new EditCommand(INDEX_SECOND_INTERNSHIP_APPLICATION, DESC_AMY))); // // // different descriptor -> returns false -// assertFalse(standardCommand.equals(new EditCommand(INDEX_FIRST_PERSON, DESC_BOB))); +// assertFalse(standardCommand.equals(new EditCommand(INDEX_FIRST_INTERNSHIP_APPLICATION, DESC_BOB))); // } // // @Test diff --git a/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java b/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java deleted file mode 100644 index cb7202b063a..00000000000 --- a/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package seedu.address.logic.commands; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.logic.commands.CommandTestUtil.DESC_AMY; -import static seedu.address.logic.commands.CommandTestUtil.DESC_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; - -import org.junit.jupiter.api.Test; - -import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; -import seedu.address.testutil.EditPersonDescriptorBuilder; - -public class EditPersonDescriptorTest { - - @Test - public void equals() { - // same values -> returns true - EditPersonDescriptor descriptorWithSameValues = new EditPersonDescriptor(DESC_AMY); - assertTrue(DESC_AMY.equals(descriptorWithSameValues)); - - // same object -> returns true - assertTrue(DESC_AMY.equals(DESC_AMY)); - - // null -> returns false - assertFalse(DESC_AMY.equals(null)); - - // different types -> returns false - assertFalse(DESC_AMY.equals(5)); - - // different values -> returns false - assertFalse(DESC_AMY.equals(DESC_BOB)); - - // different name -> returns false - EditPersonDescriptor editedAmy = new EditPersonDescriptorBuilder(DESC_AMY).withName(VALID_NAME_BOB).build(); - assertFalse(DESC_AMY.equals(editedAmy)); - - - // different email -> returns false - editedAmy = new EditPersonDescriptorBuilder(DESC_AMY).withEmail(VALID_EMAIL_BOB).build(); - assertFalse(DESC_AMY.equals(editedAmy)); - - - // different tags -> returns false - editedAmy = new EditPersonDescriptorBuilder(DESC_AMY).withTags(VALID_TAG_HUSBAND).build(); - assertFalse(DESC_AMY.equals(editedAmy)); - } - - @Test - public void toStringMethod() { - EditPersonDescriptor editPersonDescriptor = new EditPersonDescriptor(); - String expected = EditPersonDescriptor.class.getCanonicalName() + "{name=" - + editPersonDescriptor.getName().orElse(null) + ", email=" - + editPersonDescriptor.getEmail().orElse(null) + ", tags=" - + editPersonDescriptor.getTags().orElse(null) + "}"; - assertEquals(expected, editPersonDescriptor.toString()); - } -} diff --git a/src/test/java/seedu/address/logic/commands/FindCommandTest.java b/src/test/java/seedu/address/logic/commands/FindCommandTest.java index 0af0f1ab88a..ce561efb00c 100644 --- a/src/test/java/seedu/address/logic/commands/FindCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/FindCommandTest.java @@ -3,7 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.logic.Messages.MESSAGE_PERSONS_LISTED_OVERVIEW; +import static seedu.address.logic.Messages.MESSAGE_INTERNSHIP_APPLICATIONS_LISTED_OVERVIEW; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; import static seedu.address.testutil.TypicalInternshipApplications.APPLE; import static seedu.address.testutil.TypicalInternshipApplications.YAHOO; @@ -59,8 +59,8 @@ public void equals() { } @Test - public void execute_zeroKeywords_noPersonFound() { - String expectedMessage = String.format(MESSAGE_PERSONS_LISTED_OVERVIEW, 0); + public void execute_zeroKeywords_noInternshipApplicationsFound() { + String expectedMessage = String.format(MESSAGE_INTERNSHIP_APPLICATIONS_LISTED_OVERVIEW, 0); NameContainsKeywordsPredicate predicate = preparePredicate(" "); FindCommand command = new FindCommand(predicate); expectedModel.updateFilteredList(predicate); @@ -69,8 +69,8 @@ public void execute_zeroKeywords_noPersonFound() { } @Test - public void execute_multipleKeywords_multiplePersonsFound() { - String expectedMessage = String.format(MESSAGE_PERSONS_LISTED_OVERVIEW, 2); + public void execute_multipleKeywords_multipleInternshipApplicationsFound() { + String expectedMessage = String.format(MESSAGE_INTERNSHIP_APPLICATIONS_LISTED_OVERVIEW, 2); NameContainsKeywordsPredicate predicate = preparePredicate("Apple Yahoo"); FindCommand command = new FindCommand(predicate); expectedModel.updateFilteredList(predicate); diff --git a/src/test/java/seedu/address/logic/commands/ListCommandTest.java b/src/test/java/seedu/address/logic/commands/ListCommandTest.java index be5c7d884f3..f12ffcb9ca4 100644 --- a/src/test/java/seedu/address/logic/commands/ListCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/ListCommandTest.java @@ -33,7 +33,7 @@ public void execute_listIsNotFiltered_showsSameList() { //Todo when FILTER feature is implemented // @Test // public void execute_listIsFiltered_showsEverything() { - // showPersonAtIndex(model, INDEX_FIRST_PERSON); + // showPersonAtIndex(model, INDEX_FIRST_INTERNSHIP_APPLICATION); // assertCommandSuccess(new ListCommand(), model, ListCommand.MESSAGE_SUCCESS, expectedModel); // } } diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java index d7a52d31dce..d0191e3cde7 100644 --- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java @@ -5,7 +5,7 @@ import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import static seedu.address.logic.Messages.MESSAGE_UNKNOWN_COMMAND; import static seedu.address.testutil.Assert.assertThrows; -import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; +import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_INTERNSHIP_APPLICATION; import java.util.Arrays; import java.util.List; @@ -48,8 +48,8 @@ public void parseCommand_clear() throws Exception { @Test public void parseCommand_delete() throws Exception { DeleteCommand command = (DeleteCommand) parser.parseCommand( - DeleteCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased()); - assertEquals(new DeleteCommand(INDEX_FIRST_PERSON), command); + DeleteCommand.COMMAND_WORD + " " + INDEX_FIRST_INTERNSHIP_APPLICATION.getOneBased()); + assertEquals(new DeleteCommand(INDEX_FIRST_INTERNSHIP_APPLICATION), command); } // Todo when EDIT feature is implemented @@ -59,8 +59,8 @@ public void parseCommand_delete() throws Exception { // Person person = new PersonBuilder().build(); // EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(person).build(); // EditCommand command = (EditCommand) parser.parseCommand(EditCommand.COMMAND_WORD + " " - // + INDEX_FIRST_PERSON.getOneBased() + " " + PersonUtil.getEditPersonDescriptorDetails(descriptor)); - // assertEquals(new EditCommand(INDEX_FIRST_PERSON, descriptor), command); + // + INDEX_FIRST_INTERNSHIP_APPLICATION.getOneBased() + " " + PersonUtil.getEditPersonDescriptorDetails(descriptor)); + // assertEquals(new EditCommand(INDEX_FIRST_INTERNSHIP_APPLICATION, descriptor), command); // } @Test diff --git a/src/test/java/seedu/address/logic/parser/DeleteCommandParserTest.java b/src/test/java/seedu/address/logic/parser/DeleteCommandParserTest.java index 6a40e14a649..43393ab400a 100644 --- a/src/test/java/seedu/address/logic/parser/DeleteCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/DeleteCommandParserTest.java @@ -3,7 +3,7 @@ import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; -import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; +import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_INTERNSHIP_APPLICATION; import org.junit.jupiter.api.Test; @@ -22,7 +22,7 @@ public class DeleteCommandParserTest { @Test public void parse_validArgs_returnsDeleteCommand() { - assertParseSuccess(parser, "1", new DeleteCommand(INDEX_FIRST_PERSON)); + assertParseSuccess(parser, "1", new DeleteCommand(INDEX_FIRST_INTERNSHIP_APPLICATION)); } @Test diff --git a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java index 1289fa5df25..6848876a8b8 100644 --- a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java @@ -28,9 +28,9 @@ //import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; //import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; //import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; -//import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; -//import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PERSON; -//import static seedu.address.testutil.TypicalIndexes.INDEX_THIRD_PERSON; +//import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_INTERNSHIP_APPLICATION; +//import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_INTERNSHIP_APPLICATION; +//import static seedu.address.testutil.TypicalIndexes.INDEX_THIRD_INTERNSHIP_APPLICATION; // //import org.junit.jupiter.api.Test; // @@ -105,7 +105,7 @@ // // @Test // public void parse_allFieldsSpecified_success() { -// Index targetIndex = INDEX_SECOND_PERSON; +// Index targetIndex = INDEX_SECOND_INTERNSHIP_APPLICATION; // String userInput = targetIndex.getOneBased() + DATE_DESC_BOFA + TAG_DESC_HUSBAND // + COMPANY_EMAIL_DESC_APPLE + ROLE_DESC_APPLE + COMPANY_NAME_DESC_APPLE + TAG_DESC_FRIEND; // @@ -119,7 +119,7 @@ // // @Test // public void parse_someFieldsSpecified_success() { -// Index targetIndex = INDEX_FIRST_PERSON; +// Index targetIndex = INDEX_FIRST_INTERNSHIP_APPLICATION; // String userInput = targetIndex.getOneBased() + DATE_DESC_BOFA + COMPANY_EMAIL_DESC_APPLE; // // EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withPhone(VALID_DATE_BOFA) @@ -132,7 +132,7 @@ // @Test // public void parse_oneFieldSpecified_success() { // // name -// Index targetIndex = INDEX_THIRD_PERSON; +// Index targetIndex = INDEX_THIRD_INTERNSHIP_APPLICATION; // String userInput = targetIndex.getOneBased() + COMPANY_NAME_DESC_APPLE; // EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_COMPANY_NAME_APPLE) // .build(); @@ -170,7 +170,7 @@ // // AddCommandParserTest#parse_repeatedNonTagValue_failure() // // // valid followed by invalid -// Index targetIndex = INDEX_FIRST_PERSON; +// Index targetIndex = INDEX_FIRST_INTERNSHIP_APPLICATION; // String userInput = targetIndex.getOneBased() + INVALID_DATE_DESC + DATE_DESC_BOFA; // // assertParseFailure(parser, userInput, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_DATE)); @@ -198,7 +198,7 @@ // // @Test // public void parse_resetTags_success() { -// Index targetIndex = INDEX_THIRD_PERSON; +// Index targetIndex = INDEX_THIRD_INTERNSHIP_APPLICATION; // String userInput = targetIndex.getOneBased() + TAG_EMPTY; // // EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withTags().build(); diff --git a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java index 74feffabafc..caf71f80845 100644 --- a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java +++ b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java @@ -4,7 +4,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.logic.parser.ParserUtil.MESSAGE_INVALID_INDEX; import static seedu.address.testutil.Assert.assertThrows; -import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; +import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_INTERNSHIP_APPLICATION; import java.util.Arrays; import java.util.Collections; @@ -48,10 +48,10 @@ public void parseIndex_outOfRangeInput_throwsParseException() { @Test public void parseIndex_validInput_success() throws Exception { // No whitespaces - assertEquals(INDEX_FIRST_PERSON, ParserUtil.parseIndex("1")); + assertEquals(INDEX_FIRST_INTERNSHIP_APPLICATION, ParserUtil.parseIndex("1")); // Leading and trailing whitespaces - assertEquals(INDEX_FIRST_PERSON, ParserUtil.parseIndex(" 1 ")); + assertEquals(INDEX_FIRST_INTERNSHIP_APPLICATION, ParserUtil.parseIndex(" 1 ")); } @Test diff --git a/src/test/java/seedu/address/model/ModelManagerTest.java b/src/test/java/seedu/address/model/ModelManagerTest.java index 5b4705f614b..35d97f2df3a 100644 --- a/src/test/java/seedu/address/model/ModelManagerTest.java +++ b/src/test/java/seedu/address/model/ModelManagerTest.java @@ -72,23 +72,23 @@ public void setAddressBookFilePath_validPath_setsAddressBookFilePath() { } @Test - public void hasPerson_nullPerson_throwsNullPointerException() { + public void hasInternshipApplication_nullInternshipApplication_throwsNullPointerException() { assertThrows(NullPointerException.class, () -> modelManager.hasItem(null)); } @Test - public void hasPerson_personNotInAddressBook_returnsFalse() { + public void hasInternshipApplication_internshipApplicationNotInAddressBook_returnsFalse() { assertFalse(modelManager.hasItem(GOOGLE)); } @Test - public void hasPerson_personInAddressBook_returnsTrue() { + public void hasInternshipApplication_internshipApplicationInAddressBook_returnsTrue() { modelManager.addItem(GOOGLE); assertTrue(modelManager.hasItem(GOOGLE)); } @Test - public void getFilteredPersonList_modifyList_throwsUnsupportedOperationException() { + public void getFilteredInternshipApplicationList_modifyList_throwsUnsupportedOperationException() { assertThrows(UnsupportedOperationException.class, () -> modelManager.getFilteredList().remove(0)); } diff --git a/src/test/java/seedu/address/storage/JsonSerializableAddressBookTest.java b/src/test/java/seedu/address/storage/JsonSerializableAddressBookTest.java index dfb816bd310..85fef6d2dfe 100644 --- a/src/test/java/seedu/address/storage/JsonSerializableAddressBookTest.java +++ b/src/test/java/seedu/address/storage/JsonSerializableAddressBookTest.java @@ -46,7 +46,7 @@ public void toModelType_invalidInternshipFile_throwsIllegalValueException() thro public void toModelType_duplicateInternship_throwsIllegalValueException() throws Exception { JsonSerializableAddressBook dataFromFile = JsonUtil.readJsonFile(DUPLICATE_INTERNSHIP_FILE, JsonSerializableAddressBook.class).get(); - assertThrows(IllegalValueException.class, JsonSerializableAddressBook.MESSAGE_DUPLICATE_PERSON, + assertThrows(IllegalValueException.class, JsonSerializableAddressBook.MESSAGE_DUPLICATE_INTERNSHIP_APPLICATION, dataFromFile::toModelType); } diff --git a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java deleted file mode 100644 index c7a113fa32f..00000000000 --- a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java +++ /dev/null @@ -1,81 +0,0 @@ -package seedu.address.testutil; - -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; -import seedu.address.model.internshipapplication.Email; -import seedu.address.model.internshipapplication.Name; -import seedu.address.model.internshipapplication.Person; -import seedu.address.model.tag.Tag; - -/** - * A utility class to help with building EditPersonDescriptor objects. - */ -public class EditPersonDescriptorBuilder { - - private EditPersonDescriptor descriptor; - - public EditPersonDescriptorBuilder() { - descriptor = new EditPersonDescriptor(); - } - - public EditPersonDescriptorBuilder(EditPersonDescriptor descriptor) { - this.descriptor = new EditPersonDescriptor(descriptor); - } - - /** - * Returns an {@code EditPersonDescriptor} with fields containing {@code person}'s details - */ - public EditPersonDescriptorBuilder(Person person) { - descriptor = new EditPersonDescriptor(); - descriptor.setName(person.getName()); - descriptor.setEmail(person.getEmail()); - descriptor.setTags(person.getTags()); - } - - /** - * Sets the {@code Name} of the {@code EditPersonDescriptor} that we are building. - */ - public EditPersonDescriptorBuilder withName(String name) { - descriptor.setName(new Name(name)); - return this; - } - - /** - * Sets the {@code Phone} of the {@code EditPersonDescriptor} that we are building. - */ - public EditPersonDescriptorBuilder withPhone(String phone) { - return this; - } - - /** - * Sets the {@code Email} of the {@code EditPersonDescriptor} that we are building. - */ - public EditPersonDescriptorBuilder withEmail(String email) { - descriptor.setEmail(new Email(email)); - return this; - } - - /** - * Sets the {@code Address} of the {@code EditPersonDescriptor} that we are building. - */ - public EditPersonDescriptorBuilder withAddress(String address) { - return this; - } - - /** - * Parses the {@code tags} into a {@code Set} and set it to the {@code EditPersonDescriptor} - * that we are building. - */ - public EditPersonDescriptorBuilder withTags(String... tags) { - Set tagSet = Stream.of(tags).map(Tag::new).collect(Collectors.toSet()); - descriptor.setTags(tagSet); - return this; - } - - public EditPersonDescriptor build() { - return descriptor; - } -} diff --git a/src/test/java/seedu/address/testutil/PersonBuilder.java b/src/test/java/seedu/address/testutil/PersonBuilder.java deleted file mode 100644 index 71b9750a34b..00000000000 --- a/src/test/java/seedu/address/testutil/PersonBuilder.java +++ /dev/null @@ -1,96 +0,0 @@ -package seedu.address.testutil; - -import java.util.HashSet; -import java.util.Set; - -import seedu.address.model.internshipapplication.Address; -import seedu.address.model.internshipapplication.Email; -import seedu.address.model.internshipapplication.Name; -import seedu.address.model.internshipapplication.Person; -import seedu.address.model.internshipapplication.Phone; -import seedu.address.model.tag.Tag; -import seedu.address.model.util.SampleDataUtil; - -/** - * A utility class to help with building Person objects. - */ -public class PersonBuilder { - - public static final String DEFAULT_NAME = "Amy Bee"; - public static final String DEFAULT_PHONE = "85355255"; - public static final String DEFAULT_EMAIL = "amy@gmail.com"; - public static final String DEFAULT_ADDRESS = "123, Jurong West Ave 6, #08-111"; - - private Name name; - private Phone phone; - private Email email; - private Address address; - private Set tags; - - /** - * Creates a {@code PersonBuilder} with the default details. - */ - public PersonBuilder() { - name = new Name(DEFAULT_NAME); - phone = new Phone(DEFAULT_PHONE); - email = new Email(DEFAULT_EMAIL); - address = new Address(DEFAULT_ADDRESS); - tags = new HashSet<>(); - } - - /** - * Initializes the PersonBuilder with the data of {@code personToCopy}. - */ - public PersonBuilder(Person personToCopy) { - name = personToCopy.getName(); - phone = personToCopy.getPhone(); - email = personToCopy.getEmail(); - address = personToCopy.getAddress(); - tags = new HashSet<>(personToCopy.getTags()); - } - - /** - * Sets the {@code Name} of the {@code Person} that we are building. - */ - public PersonBuilder withName(String name) { - this.name = new Name(name); - return this; - } - - /** - * Parses the {@code tags} into a {@code Set} and set it to the {@code Person} that we are building. - */ - public PersonBuilder withTags(String ... tags) { - this.tags = SampleDataUtil.getTagSet(tags); - return this; - } - - /** - * Sets the {@code Address} of the {@code Person} that we are building. - */ - public PersonBuilder withAddress(String address) { - this.address = new Address(address); - return this; - } - - /** - * Sets the {@code Phone} of the {@code Person} that we are building. - */ - public PersonBuilder withPhone(String phone) { - this.phone = new Phone(phone); - return this; - } - - /** - * Sets the {@code Email} of the {@code Person} that we are building. - */ - public PersonBuilder withEmail(String email) { - this.email = new Email(email); - return this; - } - - public Person build() { - return new Person(name, phone, email, address, tags); - } - -} diff --git a/src/test/java/seedu/address/testutil/PersonUtil.java b/src/test/java/seedu/address/testutil/PersonUtil.java deleted file mode 100644 index 2390b2b031d..00000000000 --- a/src/test/java/seedu/address/testutil/PersonUtil.java +++ /dev/null @@ -1,60 +0,0 @@ -package seedu.address.testutil; - -import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; -import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; -import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; -import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; - -import java.util.Set; - -import seedu.address.logic.commands.AddCommand; -import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; -import seedu.address.model.internshipapplication.Person; -import seedu.address.model.tag.Tag; - -/** - * A utility class for Person. - */ -public class PersonUtil { - - /** - * Returns an add command string for adding the {@code person}. - */ - public static String getAddCommand(Person person) { - return AddCommand.COMMAND_WORD + " " + getPersonDetails(person); - } - - /** - * Returns the part of command string for the given {@code person}'s details. - */ - public static String getPersonDetails(Person person) { - StringBuilder sb = new StringBuilder(); - sb.append(PREFIX_NAME + person.getName().getValue() + " "); - sb.append(PREFIX_PHONE + person.getPhone().value + " "); - sb.append(PREFIX_EMAIL + person.getEmail().getValue() + " "); - sb.append(PREFIX_ADDRESS + person.getAddress().value + " "); - person.getTags().stream().forEach( - s -> sb.append(PREFIX_TAG + s.tagName + " ") - ); - return sb.toString(); - } - - /** - * Returns the part of command string for the given {@code EditPersonDescriptor}'s details. - */ - public static String getEditPersonDescriptorDetails(EditPersonDescriptor descriptor) { - StringBuilder sb = new StringBuilder(); - descriptor.getName().ifPresent(name -> sb.append(PREFIX_NAME).append(name.getValue()).append(" ")); - descriptor.getEmail().ifPresent(email -> sb.append(PREFIX_EMAIL).append(email.getValue()).append(" ")); - if (descriptor.getTags().isPresent()) { - Set tags = descriptor.getTags().get(); - if (tags.isEmpty()) { - sb.append(PREFIX_TAG); - } else { - tags.forEach(s -> sb.append(PREFIX_TAG).append(s.tagName).append(" ")); - } - } - return sb.toString(); - } -} diff --git a/src/test/java/seedu/address/testutil/TestUtil.java b/src/test/java/seedu/address/testutil/TestUtil.java index e45d0f89b95..73ed748f833 100644 --- a/src/test/java/seedu/address/testutil/TestUtil.java +++ b/src/test/java/seedu/address/testutil/TestUtil.java @@ -49,7 +49,7 @@ public static Index getLastIndex(Model model) { /** * Returns the internship application in the {@code model}'s internship application list at {@code index}. */ - public static InternshipApplication getPerson(Model model, Index index) { + public static InternshipApplication getInternshipApplication(Model model, Index index) { return model.getFilteredList().get(index.getZeroBased()); } } diff --git a/src/test/java/seedu/address/testutil/TypicalIndexes.java b/src/test/java/seedu/address/testutil/TypicalIndexes.java index 1e613937657..663bb518812 100644 --- a/src/test/java/seedu/address/testutil/TypicalIndexes.java +++ b/src/test/java/seedu/address/testutil/TypicalIndexes.java @@ -6,7 +6,7 @@ * A utility class containing a list of {@code Index} objects to be used in tests. */ public class TypicalIndexes { - public static final Index INDEX_FIRST_PERSON = Index.fromOneBased(1); - public static final Index INDEX_SECOND_PERSON = Index.fromOneBased(2); - public static final Index INDEX_THIRD_PERSON = Index.fromOneBased(3); + public static final Index INDEX_FIRST_INTERNSHIP_APPLICATION = Index.fromOneBased(1); + public static final Index INDEX_SECOND_INTERNSHIP_APPLICATION = Index.fromOneBased(2); + public static final Index INDEX_THIRD_INTERNSHIP_APPLICATION = Index.fromOneBased(3); } diff --git a/src/test/java/seedu/address/testutil/TypicalPersons.java b/src/test/java/seedu/address/testutil/TypicalPersons.java deleted file mode 100644 index 4c3eb996c7f..00000000000 --- a/src/test/java/seedu/address/testutil/TypicalPersons.java +++ /dev/null @@ -1,53 +0,0 @@ -package seedu.address.testutil; - -import static seedu.address.logic.commands.CommandTestUtil.VALID_COMPANY_EMAIL_APPLE; -import static seedu.address.logic.commands.CommandTestUtil.VALID_COMPANY_EMAIL_BOFA; -import static seedu.address.logic.commands.CommandTestUtil.VALID_COMPANY_NAME_APPLE; -import static seedu.address.logic.commands.CommandTestUtil.VALID_COMPANY_NAME_BOFA; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_FRIEND; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; - -import seedu.address.model.internshipapplication.Person; - -/** - * A utility class containing a list of {@code Person} objects to be used in tests. - */ -public class TypicalPersons { - - public static final Person ALICE = new PersonBuilder().withName("Alice Pauline") - .withAddress("123, Jurong West Ave 6, #08-111").withEmail("alice@example.com") - .withPhone("94351253") - .withTags("friends").build(); - public static final Person BENSON = new PersonBuilder().withName("Benson Meier") - .withAddress("311, Clementi Ave 2, #02-25") - .withEmail("johnd@example.com").withPhone("98765432") - .withTags("owesMoney", "friends").build(); - public static final Person CARL = new PersonBuilder().withName("Carl Kurz").withPhone("95352563") - .withEmail("heinz@example.com").withAddress("wall street").build(); - public static final Person DANIEL = new PersonBuilder().withName("Daniel Meier").withPhone("87652533") - .withEmail("cornelia@example.com").withAddress("10th street").withTags("friends").build(); - public static final Person ELLE = new PersonBuilder().withName("Elle Meyer").withPhone("9482224") - .withEmail("werner@example.com").withAddress("michegan ave").build(); - public static final Person FIONA = new PersonBuilder().withName("Fiona Kunz").withPhone("9482427") - .withEmail("lydia@example.com").withAddress("little tokyo").build(); - public static final Person GEORGE = new PersonBuilder().withName("George Best").withPhone("9482442") - .withEmail("anna@example.com").withAddress("4th street").build(); - - // Manually added - public static final Person HOON = new PersonBuilder().withName("Hoon Meier").withPhone("8482424") - .withEmail("stefan@example.com").withAddress("little india").build(); - public static final Person IDA = new PersonBuilder().withName("Ida Mueller").withPhone("8482131") - .withEmail("hans@example.com").withAddress("chicago ave").build(); - - // Manually added - Person's details found in {@code CommandTestUtil} - public static final Person APPLE = new PersonBuilder().withName(VALID_COMPANY_NAME_APPLE) - .withEmail(VALID_COMPANY_EMAIL_APPLE).withTags(VALID_TAG_FRIEND).build(); - public static final Person BOFA = new PersonBuilder().withName(VALID_COMPANY_NAME_BOFA) - .withEmail(VALID_COMPANY_EMAIL_BOFA).withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND) - .build(); - - public static final String KEYWORD_MATCHING_MEIER = "Meier"; // A keyword that matches MEIER - - private TypicalPersons() {} // prevents instantiation - -} From 678e2cb3d652129b4d2d85ba77ab60a15fff1c9b Mon Sep 17 00:00:00 2001 From: Raghava Date: Thu, 17 Oct 2024 18:35:01 +0800 Subject: [PATCH 2/4] Remove commented out code --- .../address/logic/commands/FindCommand.java | 4 +- .../logic/commands/DeleteCommandTest.java | 6 +- .../logic/commands/EditCommandTest.java | 197 ------------------ .../logic/parser/AddressBookParserTest.java | 11 - 4 files changed, 5 insertions(+), 213 deletions(-) delete mode 100644 src/test/java/seedu/address/logic/commands/EditCommandTest.java diff --git a/src/main/java/seedu/address/logic/commands/FindCommand.java b/src/main/java/seedu/address/logic/commands/FindCommand.java index 06f61b917a2..398e135cd6a 100644 --- a/src/main/java/seedu/address/logic/commands/FindCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindCommand.java @@ -32,8 +32,8 @@ public FindCommand(NameContainsKeywordsPredicate predicate) { public CommandResult execute(Model model) { requireNonNull(model); model.updateFilteredList(predicate); - return new CommandResult( - String.format(Messages.MESSAGE_INTERNSHIP_APPLICATIONS_LISTED_OVERVIEW, model.getFilteredList().size())); + return new CommandResult(String.format(Messages.MESSAGE_INTERNSHIP_APPLICATIONS_LISTED_OVERVIEW, + model.getFilteredList().size())); } @Override diff --git a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java b/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java index ff0f86264a6..dc5d70cabac 100644 --- a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java @@ -5,7 +5,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; -import static seedu.address.logic.commands.CommandTestUtil.showPersonAtIndex; +import static seedu.address.logic.commands.CommandTestUtil.showInternshipApplicationAtIndex; import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_INTERNSHIP_APPLICATION; import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_INTERNSHIP_APPLICATION; import static seedu.address.testutil.TypicalInternshipApplications.getTypicalAddressBook; @@ -53,7 +53,7 @@ public void execute_invalidIndexUnfilteredList_throwsCommandException() { @Test public void execute_validIndexFilteredList_success() { - showPersonAtIndex(model, INDEX_FIRST_INTERNSHIP_APPLICATION); + showInternshipApplicationAtIndex(model, INDEX_FIRST_INTERNSHIP_APPLICATION); InternshipApplication internshipApplicationToDelete = model .getFilteredList().get(INDEX_FIRST_INTERNSHIP_APPLICATION.getZeroBased()); @@ -71,7 +71,7 @@ public void execute_validIndexFilteredList_success() { @Test public void execute_invalidIndexFilteredList_throwsCommandException() { - showPersonAtIndex(model, INDEX_FIRST_INTERNSHIP_APPLICATION); + showInternshipApplicationAtIndex(model, INDEX_FIRST_INTERNSHIP_APPLICATION); Index outOfBoundIndex = INDEX_SECOND_INTERNSHIP_APPLICATION; // ensures that outOfBoundIndex is still in bounds of the internship application list diff --git a/src/test/java/seedu/address/logic/commands/EditCommandTest.java b/src/test/java/seedu/address/logic/commands/EditCommandTest.java deleted file mode 100644 index cf4d427b126..00000000000 --- a/src/test/java/seedu/address/logic/commands/EditCommandTest.java +++ /dev/null @@ -1,197 +0,0 @@ -// Todo when EDIT feature is implemented - -//package seedu.address.logic.commands; -// -//import static org.junit.jupiter.api.Assertions.assertEquals; -//import static org.junit.jupiter.api.Assertions.assertFalse; -//import static org.junit.jupiter.api.Assertions.assertTrue; -//import static seedu.address.logic.commands.CommandTestUtil.DESC_APPLE; -//import static seedu.address.logic.commands.CommandTestUtil.DESC_BOFA; -//import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; -//import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; -//import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; -//import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; -//import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; -////import static seedu.address.logic.commands.CommandTestUtil.showPersonAtIndex; -//import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_INTERNSHIP_APPLICATION; -//import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_INTERNSHIP_APPLICATION; -//import static seedu.address.testutil.TypicalInternshipApplications.getTypicalAddressBook; -// -//import org.junit.jupiter.api.Test; -// -//import seedu.address.commons.core.index.Index; -//import seedu.address.logic.Messages; -//import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; -//import seedu.address.model.AddressBook; -//import seedu.address.model.Model; -//import seedu.address.model.ModelManager; -//import seedu.address.model.UserPrefs; -//import seedu.address.model.internshipapplication.Person; -//import seedu.address.testutil.EditPersonDescriptorBuilder; -//import seedu.address.testutil.PersonBuilder; -// -///** -// * Contains integration tests (interaction with the Model) and unit tests for EditCommand. -// */ -//public class EditCommandTest { -// -// private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); - - -// @Test -// public void execute_allFieldsSpecifiedUnfilteredList_success() { -// Person editedPerson = new PersonBuilder().build(); -// EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(editedPerson).build(); -// EditCommand editCommand = new EditCommand(INDEX_FIRST_INTERNSHIP_APPLICATION, descriptor); -// -// String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages -// .format(editedPerson)); -// -// Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), -// new UserPrefs()); -// expectedModel.setPerson(model.getFilteredPersonList().get(0), editedPerson); -// -// assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); -// } -// -// @Test -// public void execute_someFieldsSpecifiedUnfilteredList_success() { -// Index indexLastPerson = Index.fromOneBased(model.getFilteredPersonList().size()); -// Person lastPerson = model.getFilteredPersonList().get(indexLastPerson.getZeroBased()); -// -// PersonBuilder personInList = new PersonBuilder(lastPerson); -// Person editedPerson = personInList.withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) -// .withTags(VALID_TAG_HUSBAND).build(); -// -// EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB) -// .withPhone(VALID_PHONE_BOB).withTags(VALID_TAG_HUSBAND).build(); -// EditCommand editCommand = new EditCommand(indexLastPerson, descriptor); -// -// String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, -// Messages.format(editedPerson)); -// -// Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), -// new UserPrefs()); -// expectedModel.setPerson(lastPerson, editedPerson); -// -// assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); -// } -// -// @Test -// public void execute_noFieldSpecifiedUnfilteredList_success() { -// EditCommand editCommand = new EditCommand(INDEX_FIRST_INTERNSHIP_APPLICATION, new EditPersonDescriptor()); -// Person editedPerson = model.getFilteredPersonList().get(INDEX_FIRST_INTERNSHIP_APPLICATION.getZeroBased()); -// -// String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, -// Messages.format(editedPerson)); -// -// Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), -// new UserPrefs()); -// -// assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); -// } -////Todo when FILTER feature is implemented -//// @Test -//// public void execute_filteredList_success() { -//// showPersonAtIndex(model, INDEX_FIRST_INTERNSHIP_APPLICATION); -//// -//// Person personInFilteredList = model.getFilteredPersonList().get(INDEX_FIRST_INTERNSHIP_APPLICATION.getZeroBased()); -//// Person editedPerson = new PersonBuilder(personInFilteredList).withName(VALID_NAME_BOB).build(); -//// EditCommand editCommand = new EditCommand(INDEX_FIRST_INTERNSHIP_APPLICATION, -//// new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB).build()); -//// -//// String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, -// Messages.format(editedPerson)); -//// -//// Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), -// new UserPrefs()); -//// expectedModel.setPerson(model.getFilteredPersonList().get(0), editedPerson); -//// -//// assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); -//// } -// -// @Test -// public void execute_duplicatePersonUnfilteredList_failure() { -// Person firstPerson = model.getFilteredList().get(INDEX_FIRST_INTERNSHIP_APPLICATION.getZeroBased()); -// EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(firstPerson).build(); -// EditCommand editCommand = new EditCommand(INDEX_SECOND_INTERNSHIP_APPLICATION, descriptor); -// -// assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_INTERNSHIP_APPLICATION); -// } -// -////Todo when FILTER feature is implemented -//// @Test -//// public void execute_duplicatePersonFilteredList_failure() { -//// showPersonAtIndex(model, INDEX_FIRST_INTERNSHIP_APPLICATION); -//// -//// // edit person in filtered list into a duplicate in address book -//// Person personInList = model.getAddressBook().getPersonList().get(INDEX_SECOND_INTERNSHIP_APPLICATION.getZeroBased()); -//// EditCommand editCommand = new EditCommand(INDEX_FIRST_INTERNSHIP_APPLICATION, -//// new EditPersonDescriptorBuilder(personInList).build()); -//// -//// assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_INTERNSHIP_APPLICATION); -//// } -// -// @Test -// public void execute_invalidPersonIndexUnfilteredList_failure() { -// Index outOfBoundIndex = Index.fromOneBased(model.getFilteredPersonList().size() + 1); -// EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB).build(); -// EditCommand editCommand = new EditCommand(outOfBoundIndex, descriptor); -// -// assertCommandFailure(editCommand, model, Messages.MESSAGE_INVALID_INTERNSHIP_APPLICATION_DISPLAYED_INDEX); -// } -// -// //Todo when FILTER feature is implemented -//// /** -//// * Edit filtered list where index is larger than size of filtered list, -//// * but smaller than size of address book -//// */ -//// @Test -//// public void execute_invalidPersonIndexFilteredList_failure() { -//// showPersonAtIndex(model, INDEX_FIRST_INTERNSHIP_APPLICATION); -//// Index outOfBoundIndex = INDEX_SECOND_INTERNSHIP_APPLICATION; -//// // ensures that outOfBoundIndex is still in bounds of address book list -//// assertTrue(outOfBoundIndex.getZeroBased() < model.getAddressBook().getPersonList().size()); -//// -//// EditCommand editCommand = new EditCommand(outOfBoundIndex, -//// new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB).build()); -//// -//// assertCommandFailure(editCommand, model, Messages.MESSAGE_INVALID_INTERNSHIP_APPLICATION_DISPLAYED_INDEX); -//// } -// -// @Test -// public void equals() { -// final EditCommand standardCommand = new EditCommand(INDEX_FIRST_INTERNSHIP_APPLICATION, DESC_AMY); -// -// // same values -> returns true -// EditPersonDescriptor copyDescriptor = new EditPersonDescriptor(DESC_AMY); -// EditCommand commandWithSameValues = new EditCommand(INDEX_FIRST_INTERNSHIP_APPLICATION, copyDescriptor); -// assertTrue(standardCommand.equals(commandWithSameValues)); -// -// // same object -> returns true -// assertTrue(standardCommand.equals(standardCommand)); -// -// // null -> returns false -// assertFalse(standardCommand.equals(null)); -// -// // different types -> returns false -// assertFalse(standardCommand.equals(new ClearCommand())); -// -// // different index -> returns false -// assertFalse(standardCommand.equals(new EditCommand(INDEX_SECOND_INTERNSHIP_APPLICATION, DESC_AMY))); -// -// // different descriptor -> returns false -// assertFalse(standardCommand.equals(new EditCommand(INDEX_FIRST_INTERNSHIP_APPLICATION, DESC_BOB))); -// } -// -// @Test -// public void toStringMethod() { -// Index index = Index.fromOneBased(1); -// EditPersonDescriptor editPersonDescriptor = new EditPersonDescriptor(); -// EditCommand editCommand = new EditCommand(index, editPersonDescriptor); -// String expected = EditCommand.class.getCanonicalName() + "{index=" + index + ", editPersonDescriptor=" -// + editPersonDescriptor + "}"; -// assertEquals(expected, editCommand.toString()); -// } - -//} diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java index d0191e3cde7..cfd1760644c 100644 --- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java @@ -52,17 +52,6 @@ public void parseCommand_delete() throws Exception { assertEquals(new DeleteCommand(INDEX_FIRST_INTERNSHIP_APPLICATION), command); } - // Todo when EDIT feature is implemented - // - // @Test - // public void parseCommand_edit() throws Exception { - // Person person = new PersonBuilder().build(); - // EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(person).build(); - // EditCommand command = (EditCommand) parser.parseCommand(EditCommand.COMMAND_WORD + " " - // + INDEX_FIRST_INTERNSHIP_APPLICATION.getOneBased() + " " + PersonUtil.getEditPersonDescriptorDetails(descriptor)); - // assertEquals(new EditCommand(INDEX_FIRST_INTERNSHIP_APPLICATION, descriptor), command); - // } - @Test public void parseCommand_exit() throws Exception { assertTrue(parser.parseCommand(ExitCommand.COMMAND_WORD) instanceof ExitCommand); From 1b1cf37537b346c8db97f774f14348bb91c09515 Mon Sep 17 00:00:00 2001 From: Raghava Date: Thu, 17 Oct 2024 18:37:00 +0800 Subject: [PATCH 3/4] Remove comments --- .../address/logic/parser/AddressBookParserTest.java | 12 +++++------- .../seedu/address/logic/parser/ParserUtilTest.java | 4 ---- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java index cfd1760644c..178cad44604 100644 --- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java @@ -66,13 +66,11 @@ public void parseCommand_find() throws Exception { assertEquals(new FindCommand(new NameContainsKeywordsPredicate(keywords)), command); } - // Todo when HELP feature is implemented - // - // @Test - // public void parseCommand_help() throws Exception { - // assertTrue(parser.parseCommand(HelpCommand.COMMAND_WORD) instanceof HelpCommand); - // assertTrue(parser.parseCommand(HelpCommand.COMMAND_WORD + " 3") instanceof HelpCommand); - // } + @Test + public void parseCommand_help() throws Exception { + assertTrue(parser.parseCommand(HelpCommand.COMMAND_WORD) instanceof HelpCommand); + assertTrue(parser.parseCommand(HelpCommand.COMMAND_WORD + " 3") instanceof HelpCommand); + } @Test public void parseCommand_list() throws Exception { diff --git a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java index caf71f80845..ab03a4c970f 100644 --- a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java +++ b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java @@ -20,14 +20,10 @@ public class ParserUtilTest { private static final String INVALID_NAME = "R@chel"; - private static final String INVALID_PHONE = "+651234"; - private static final String INVALID_ADDRESS = " "; private static final String INVALID_EMAIL = "example.com"; private static final String INVALID_TAG = "#friend"; private static final String VALID_NAME = "Rachel Walker"; - private static final String VALID_PHONE = "123456"; - private static final String VALID_ADDRESS = "123 Main Street #0505"; private static final String VALID_EMAIL = "rachel@example.com"; private static final String VALID_TAG_1 = "friend"; private static final String VALID_TAG_2 = "neighbour"; From 4e97978469c31fafede3850a0135d84c5d73ddd6 Mon Sep 17 00:00:00 2001 From: Raghava Date: Thu, 17 Oct 2024 18:41:34 +0800 Subject: [PATCH 4/4] Remove unused code --- .../seedu/address/logic/parser/CliSyntax.java | 1 - src/main/resources/view/MainWindow.fxml | 1 - .../logic/commands/CommandTestUtil.java | 26 ------------------- 3 files changed, 28 deletions(-) diff --git a/src/main/java/seedu/address/logic/parser/CliSyntax.java b/src/main/java/seedu/address/logic/parser/CliSyntax.java index 3bb6f3078ef..b3c0b64fd30 100644 --- a/src/main/java/seedu/address/logic/parser/CliSyntax.java +++ b/src/main/java/seedu/address/logic/parser/CliSyntax.java @@ -7,7 +7,6 @@ public class CliSyntax { /* Prefix definitions */ public static final Prefix PREFIX_NAME = new Prefix("n/"); - public static final Prefix PREFIX_PHONE = new Prefix("p/"); public static final Prefix PREFIX_EMAIL = new Prefix("e/"); public static final Prefix PREFIX_ADDRESS = new Prefix("a/"); public static final Prefix PREFIX_TAG = new Prefix("t/"); diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml index 243620e5af4..dc0a6253f0c 100644 --- a/src/main/resources/view/MainWindow.fxml +++ b/src/main/resources/view/MainWindow.fxml @@ -6,7 +6,6 @@ - diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 53d45ef182f..c7e47612cb5 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -2,12 +2,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; import static seedu.address.logic.parser.CliSyntax.PREFIX_DATE; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_ROLE; -import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; import static seedu.address.testutil.Assert.assertThrows; import java.util.ArrayList; @@ -43,8 +41,6 @@ public class CommandTestUtil { public static final String VALID_COMPANY_EMAIL_BOFA = "bofa@example.com"; public static final String VALID_ROLE_APPLE = "Software Engineer Intern"; public static final String VALID_ROLE_BOFA = "Backend Intern"; - public static final String VALID_TAG_HUSBAND = "husband"; - public static final String VALID_TAG_FRIEND = "friend"; public static final String COMPANY_NAME_DESC_APPLE = " " + PREFIX_NAME + VALID_COMPANY_NAME_APPLE; public static final String COMPANY_NAME_DESC_BOFA = " " + PREFIX_NAME + VALID_COMPANY_NAME_BOFA; @@ -54,33 +50,11 @@ public class CommandTestUtil { public static final String COMPANY_EMAIL_DESC_BOFA = " " + PREFIX_EMAIL + VALID_COMPANY_EMAIL_BOFA; public static final String ROLE_DESC_APPLE = " " + PREFIX_ROLE + VALID_ROLE_APPLE; public static final String ROLE_DESC_BOFA = " " + PREFIX_ROLE + VALID_ROLE_BOFA; - public static final String TAG_DESC_FRIEND = " " + PREFIX_TAG + VALID_TAG_FRIEND; - public static final String TAG_DESC_HUSBAND = " " + PREFIX_TAG + VALID_TAG_HUSBAND; public static final String INVALID_COMPANY_NAME_DESC = " " + PREFIX_NAME + "Google!"; // '&' not allowed in names public static final String INVALID_DATE_DESC = " " + PREFIX_DATE + "911a"; // 'a' not allowed in dates public static final String INVALID_EMAIL_DESC = " " + PREFIX_EMAIL + "bofa!yahoo"; // missing '@' symbol public static final String INVALID_ROLE_DESC = " " + PREFIX_ROLE; // empty string not allowed for role - public static final String INVALID_TAG_DESC = " " + PREFIX_TAG + "hubby*"; // '*' not allowed in tags - - //TODO Delete the unnecessary fields. These are here got tests legacy purposes - public static final String VALID_NAME_AMY = "Amy Bee"; - public static final String VALID_NAME_BOB = "Bob Choo"; - public static final String VALID_PHONE_AMY = "11111111"; - public static final String VALID_PHONE_BOB = "22222222"; - public static final String VALID_EMAIL_AMY = "amy@example.com"; - public static final String VALID_EMAIL_BOB = "bob@example.com"; - public static final String VALID_ADDRESS_AMY = "Block 312, Amy Street 1"; - public static final String VALID_ADDRESS_BOB = "Block 123, Bobby Street 3"; - public static final String NAME_DESC_AMY = " " + PREFIX_NAME + VALID_NAME_AMY; - public static final String NAME_DESC_BOB = " " + PREFIX_NAME + VALID_NAME_BOB; - public static final String EMAIL_DESC_AMY = " " + PREFIX_EMAIL + VALID_EMAIL_AMY; - public static final String EMAIL_DESC_BOB = " " + PREFIX_EMAIL + VALID_EMAIL_BOB; - public static final String ADDRESS_DESC_AMY = " " + PREFIX_ADDRESS + VALID_ADDRESS_AMY; - public static final String ADDRESS_DESC_BOB = " " + PREFIX_ADDRESS + VALID_ADDRESS_BOB; - public static final String INVALID_ADDRESS_DESC = " " + PREFIX_ADDRESS; // empty string not allowed for addresses - //The list ends here - public static final String PREAMBLE_WHITESPACE = "\t \r \n"; public static final String PREAMBLE_NON_EMPTY = "NonEmptyPreamble";