diff --git a/src/main/java/seedu/address/logic/commands/ListCommand.java b/src/main/java/seedu/address/logic/commands/ListCommand.java index e41f9300a0d..e613649283c 100644 --- a/src/main/java/seedu/address/logic/commands/ListCommand.java +++ b/src/main/java/seedu/address/logic/commands/ListCommand.java @@ -4,19 +4,19 @@ import static seedu.address.model.Model.PREDICATE_SHOW_ALL; import seedu.address.model.Model; +import seedu.address.model.internshipapplication.InternshipApplication; /** - * Lists all internship applications in the address book to the user. + * Lists all internship applications in hire me to the user. */ -public class ListCommand extends Command { +public class ListCommand extends Command { public static final String COMMAND_WORD = "list"; public static final String MESSAGE_SUCCESS = "Listed all internship applications"; - @Override - public CommandResult execute(Model model) { + public CommandResult execute(Model model) { requireNonNull(model); model.updateFilteredList(PREDICATE_SHOW_ALL); return new CommandResult(MESSAGE_SUCCESS); diff --git a/src/main/java/seedu/address/model/Model.java b/src/main/java/seedu/address/model/Model.java index 284b14467f8..e7ad67471b0 100644 --- a/src/main/java/seedu/address/model/Model.java +++ b/src/main/java/seedu/address/model/Model.java @@ -5,13 +5,14 @@ import javafx.collections.ObservableList; import seedu.address.commons.core.GuiSettings; +import seedu.address.model.internshipapplication.InternshipApplication; /** * The API of the Model component. */ public interface Model { /** {@code Predicate} that always evaluate to true */ - Predicate PREDICATE_SHOW_ALL = unused -> true; + Predicate PREDICATE_SHOW_ALL = unused -> true; /** * Replaces user prefs data with the data in {@code userPrefs}. diff --git a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java b/src/main/java/seedu/address/model/ReadOnlyAddressBook.java index 1339cdaea81..18233a219e5 100644 --- a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java +++ b/src/main/java/seedu/address/model/ReadOnlyAddressBook.java @@ -1,6 +1,7 @@ package seedu.address.model; import javafx.collections.ObservableList; +import seedu.address.model.internshipapplication.UniqueList; /** * Unmodifiable view of a book diff --git a/src/main/java/seedu/address/model/internshipapplication/UniqueList.java b/src/main/java/seedu/address/model/internshipapplication/UniqueList.java index 176edbd6962..3bb1b854141 100644 --- a/src/main/java/seedu/address/model/internshipapplication/UniqueList.java +++ b/src/main/java/seedu/address/model/internshipapplication/UniqueList.java @@ -15,9 +15,9 @@ /** * A list of persons that enforces uniqueness between its elements and does not allow nulls. * A person is considered unique by comparing using {@code Person#isSamePerson(Person)}. As such, adding and updating of - * persons uses Person#isSamePerson(Person) for equality so as to ensure that the person being added or updated is + * persons uses Person#isSamePerson(Person) for equality to ensure that the person being added or updated is * unique in terms of identity in the UniquePersonList. However, the removal of a person uses Person#equals(Object) so - * as to ensure that the person with exactly the same fields will be removed. + * to ensure that the person with exactly the same fields will be removed. * * Supports a minimal set of list operations. * @@ -80,15 +80,15 @@ public void remove(T toRemove) { } } + /** + * Replaces the contents of this list with {@code persons}. + * {@code persons} must not contain duplicate persons. + */ public void setItems(UniqueList replacement) { requireNonNull(replacement); internalList.setAll(replacement.internalList); } - /** - * Replaces the contents of this list with {@code persons}. - * {@code persons} must not contain duplicate persons. - */ public void setItems(List items) { requireAllNonNull(items); if (!areUnique(items)) { diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 481f0158d69..da1955d45e8 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -2,10 +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_ROLE; 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_DATE; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; import static seedu.address.testutil.Assert.assertThrows; @@ -17,55 +17,57 @@ import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.AddressBook; import seedu.address.model.Model; +import seedu.address.model.internshipapplication.InternshipApplication; import seedu.address.model.internshipapplication.NameContainsKeywordsPredicate; import seedu.address.model.internshipapplication.Person; import seedu.address.testutil.EditPersonDescriptorBuilder; +import seedu.address.testutil.InternshipApplicationBuilder; /** * Contains helper methods for testing commands. */ public class CommandTestUtil { - 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 VALID_NAME_APPLE = "Apple"; + public static final String VALID_NAME_BOFA = "BOFA"; + public static final String VALID_DATE_APPLE = "01/01/24"; + public static final String VALID_DATE_BOFA = "02/02/24"; + public static final String VALID_EMAIL_APPLE = "apple@example.com"; + public static final String VALID_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 NAME_DESC_AMY = " " + PREFIX_NAME + VALID_NAME_AMY; - public static final String NAME_DESC_BOB = " " + PREFIX_NAME + VALID_NAME_BOB; - public static final String PHONE_DESC_AMY = " " + PREFIX_PHONE + VALID_PHONE_AMY; - public static final String PHONE_DESC_BOB = " " + PREFIX_PHONE + VALID_PHONE_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 NAME_DESC_APPLE = " " + PREFIX_NAME + VALID_NAME_APPLE; + public static final String NAME_DESC_BOFA = " " + PREFIX_NAME + VALID_NAME_BOFA; + public static final String DATE_DESC_APPLE = " " + PREFIX_DATE + VALID_DATE_APPLE; + public static final String DATE_DESC_BOFA = " " + PREFIX_DATE + VALID_DATE_BOFA; + public static final String EMAIL_DESC_APPLE = " " + PREFIX_EMAIL + VALID_EMAIL_APPLE; + public static final String EMAIL_DESC_BOFA = " " + PREFIX_EMAIL + VALID_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_NAME_DESC = " " + PREFIX_NAME + "James&"; // '&' not allowed in names - public static final String INVALID_PHONE_DESC = " " + PREFIX_PHONE + "911a"; // 'a' not allowed in phones - public static final String INVALID_EMAIL_DESC = " " + PREFIX_EMAIL + "bob!yahoo"; // missing '@' symbol - public static final String INVALID_ADDRESS_DESC = " " + PREFIX_ADDRESS; // empty string not allowed for addresses + 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 public static final String PREAMBLE_WHITESPACE = "\t \r \n"; public static final String PREAMBLE_NON_EMPTY = "NonEmptyPreamble"; - public static final EditCommand.EditPersonDescriptor DESC_AMY; - public static final EditCommand.EditPersonDescriptor DESC_BOB; + public static final EditCommand.EditPersonDescriptor DESC_APPLE; + public static final EditCommand.EditPersonDescriptor DESC_BOFA; static { - DESC_AMY = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY) - .withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY) + DESC_APPLE = new EditPersonDescriptorBuilder().withName(VALID_NAME_APPLE) + .withPhone(VALID_DATE_APPLE).withEmail(VALID_EMAIL_APPLE).withAddress(VALID_ROLE_APPLE) .withTags(VALID_TAG_FRIEND).build(); - DESC_BOB = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB) - .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB) + DESC_BOFA = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOFA) + .withPhone(VALID_DATE_BOFA).withEmail(VALID_EMAIL_BOFA).withAddress(VALID_ROLE_BOFA) .withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND).build(); } @@ -74,8 +76,8 @@ public class CommandTestUtil { * - the returned {@link CommandResult} matches {@code expectedCommandResult}
* - the {@code actualModel} matches {@code expectedModel} */ - public static void assertCommandSuccess(Command command, Model actualModel, CommandResult expectedCommandResult, - Model expectedModel) { + public static void assertCommandSuccess(Command command, Model actualModel, CommandResult expectedCommandResult, + Model expectedModel) { try { CommandResult result = command.execute(actualModel); assertEquals(expectedCommandResult, result); @@ -89,8 +91,8 @@ public static void assertCommandSuccess(Command command, Model actualModel, Comm * Convenience wrapper to {@link #assertCommandSuccess(Command, Model, CommandResult, Model)} * that takes a string {@code expectedMessage}. */ - public static void assertCommandSuccess(Command command, Model actualModel, String expectedMessage, - Model expectedModel) { + public static void assertCommandSuccess(Command command, Model actualModel, String expectedMessage, + Model expectedModel) { CommandResult expectedCommandResult = new CommandResult(expectedMessage); assertCommandSuccess(command, actualModel, expectedCommandResult, expectedModel); } @@ -101,28 +103,28 @@ public static void assertCommandSuccess(Command command, Model actualModel, Stri * - the CommandException message matches {@code expectedMessage}
* - the address book, filtered person list and selected person in {@code actualModel} remain unchanged */ - public static void assertCommandFailure(Command command, Model actualModel, String expectedMessage) { + public static void assertCommandFailure(Command command, Model actualModel, String expectedMessage) { // we are unable to defensively copy the model for comparison later, so we can // only do so by copying its components. AddressBook expectedAddressBook = new AddressBook(actualModel.getAddressBook()); - List expectedFilteredList = new ArrayList<>(actualModel.getFilteredPersonList()); + List expectedFilteredList = new ArrayList<>(actualModel.getFilteredList()); assertThrows(CommandException.class, expectedMessage, () -> command.execute(actualModel)); assertEquals(expectedAddressBook, actualModel.getAddressBook()); - assertEquals(expectedFilteredList, actualModel.getFilteredPersonList()); + assertEquals(expectedFilteredList, actualModel.getFilteredList()); } /** * 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) { - assertTrue(targetIndex.getZeroBased() < model.getFilteredPersonList().size()); + public static void showPersonAtIndex(Model model, Index targetIndex) { + assertTrue(targetIndex.getZeroBased() < model.getFilteredList().size()); - Person person = model.getFilteredPersonList().get(targetIndex.getZeroBased()); - final String[] splitName = person.getName().getValue().split("\\s+"); - model.updateFilteredPersonList(new NameContainsKeywordsPredicate(Arrays.asList(splitName[0]))); + InternshipApplication internshipApplication = model.getFilteredList().get(targetIndex.getZeroBased()); + final String[] splitName = internshipApplication.getCompany().getName().getValue().split("\\s+"); + model.updateFilteredList(new NameContainsKeywordsPredicate(Arrays.asList(splitName[0]))); - assertEquals(1, model.getFilteredPersonList().size()); + assertEquals(1, model.getFilteredList().size()); } } diff --git a/src/test/java/seedu/address/logic/commands/ListCommandTest.java b/src/test/java/seedu/address/logic/commands/ListCommandTest.java index 435ff1f7275..ca9c9cc93f0 100644 --- a/src/test/java/seedu/address/logic/commands/ListCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/ListCommandTest.java @@ -3,7 +3,7 @@ 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.TypicalPersons.getTypicalAddressBook; +import static seedu.address.testutil.TypicalInternshipApplications.getTypicalAddressBook; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -11,19 +11,20 @@ import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; +import seedu.address.model.internshipapplication.InternshipApplication; /** * Contains integration tests (interaction with the Model) and unit tests for ListCommand. */ public class ListCommandTest { - private Model model; - private Model expectedModel; + private Model model; + private Model expectedModel; @BeforeEach public void setUp() { - model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); - expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); + model = new ModelManager<>(getTypicalAddressBook(), new UserPrefs()); + expectedModel = new ModelManager<>(model.getAddressBook(), new UserPrefs()); } @Test diff --git a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java index 14b0ef6c7df..35aa5df4011 100644 --- a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java @@ -1,30 +1,30 @@ package seedu.address.logic.parser; import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; -import static seedu.address.logic.commands.CommandTestUtil.ADDRESS_DESC_AMY; -import static seedu.address.logic.commands.CommandTestUtil.ADDRESS_DESC_BOB; -import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_AMY; -import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_BOB; -import static seedu.address.logic.commands.CommandTestUtil.INVALID_ADDRESS_DESC; +import static seedu.address.logic.commands.CommandTestUtil.ROLE_DESC_APPLE; +import static seedu.address.logic.commands.CommandTestUtil.ROLE_DESC_BOFA; +import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_APPLE; +import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_BOFA; +import static seedu.address.logic.commands.CommandTestUtil.INVALID_ROLE_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_EMAIL_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_NAME_DESC; -import static seedu.address.logic.commands.CommandTestUtil.INVALID_PHONE_DESC; +import static seedu.address.logic.commands.CommandTestUtil.INVALID_DATE_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_TAG_DESC; -import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_AMY; -import static seedu.address.logic.commands.CommandTestUtil.PHONE_DESC_AMY; -import static seedu.address.logic.commands.CommandTestUtil.PHONE_DESC_BOB; +import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_APPLE; +import static seedu.address.logic.commands.CommandTestUtil.DATE_DESC_APPLE; +import static seedu.address.logic.commands.CommandTestUtil.DATE_DESC_BOFA; import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_FRIEND; import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_HUSBAND; -import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_AMY; -import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_AMY; -import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_AMY; -import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_AMY; -import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_ROLE_APPLE; +import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_APPLE; +import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_APPLE; +import static seedu.address.logic.commands.CommandTestUtil.VALID_DATE_APPLE; +import static seedu.address.logic.commands.CommandTestUtil.VALID_DATE_BOFA; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_FRIEND; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; -import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; +import static seedu.address.logic.parser.CliSyntax.PREFIX_ROLE; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; -import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; +import static seedu.address.logic.parser.CliSyntax.PREFIX_DATE; 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; @@ -57,7 +57,7 @@ public class EditCommandParserTest { @Test public void parse_missingParts_failure() { // no index specified - assertParseFailure(parser, VALID_NAME_AMY, MESSAGE_INVALID_FORMAT); + assertParseFailure(parser, VALID_NAME_APPLE, MESSAGE_INVALID_FORMAT); // no field specified assertParseFailure(parser, "1", EditCommand.MESSAGE_NOT_EDITED); @@ -69,10 +69,10 @@ public void parse_missingParts_failure() { @Test public void parse_invalidPreamble_failure() { // negative index - assertParseFailure(parser, "-5" + NAME_DESC_AMY, MESSAGE_INVALID_FORMAT); + assertParseFailure(parser, "-5" + NAME_DESC_APPLE, MESSAGE_INVALID_FORMAT); // zero index - assertParseFailure(parser, "0" + NAME_DESC_AMY, MESSAGE_INVALID_FORMAT); + assertParseFailure(parser, "0" + NAME_DESC_APPLE, MESSAGE_INVALID_FORMAT); // invalid arguments being parsed as preamble assertParseFailure(parser, "1 some random string", MESSAGE_INVALID_FORMAT); @@ -84,13 +84,13 @@ public void parse_invalidPreamble_failure() { @Test public void parse_invalidValue_failure() { assertParseFailure(parser, "1" + INVALID_NAME_DESC, Name.MESSAGE_CONSTRAINTS); // invalid name - assertParseFailure(parser, "1" + INVALID_PHONE_DESC, Phone.MESSAGE_CONSTRAINTS); // invalid phone + assertParseFailure(parser, "1" + INVALID_DATE_DESC, Phone.MESSAGE_CONSTRAINTS); // invalid phone assertParseFailure(parser, "1" + INVALID_EMAIL_DESC, Email.MESSAGE_CONSTRAINTS); // invalid email - assertParseFailure(parser, "1" + INVALID_ADDRESS_DESC, Address.MESSAGE_CONSTRAINTS); // invalid address + assertParseFailure(parser, "1" + INVALID_ROLE_DESC, Address.MESSAGE_CONSTRAINTS); // invalid address assertParseFailure(parser, "1" + INVALID_TAG_DESC, Tag.MESSAGE_CONSTRAINTS); // invalid tag // invalid phone followed by valid email - assertParseFailure(parser, "1" + INVALID_PHONE_DESC + EMAIL_DESC_AMY, Phone.MESSAGE_CONSTRAINTS); + assertParseFailure(parser, "1" + INVALID_DATE_DESC + EMAIL_DESC_APPLE, Phone.MESSAGE_CONSTRAINTS); // while parsing {@code PREFIX_TAG} alone will reset the tags of the {@code Person} being edited, // parsing it together with a valid tag results in error @@ -99,18 +99,18 @@ public void parse_invalidValue_failure() { assertParseFailure(parser, "1" + TAG_EMPTY + TAG_DESC_FRIEND + TAG_DESC_HUSBAND, Tag.MESSAGE_CONSTRAINTS); // multiple invalid values, but only the first invalid value is captured - assertParseFailure(parser, "1" + INVALID_NAME_DESC + INVALID_EMAIL_DESC + VALID_ADDRESS_AMY + VALID_PHONE_AMY, + assertParseFailure(parser, "1" + INVALID_NAME_DESC + INVALID_EMAIL_DESC + VALID_ROLE_APPLE + VALID_DATE_APPLE, Name.MESSAGE_CONSTRAINTS); } @Test public void parse_allFieldsSpecified_success() { Index targetIndex = INDEX_SECOND_PERSON; - String userInput = targetIndex.getOneBased() + PHONE_DESC_BOB + TAG_DESC_HUSBAND - + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + NAME_DESC_AMY + TAG_DESC_FRIEND; + String userInput = targetIndex.getOneBased() + DATE_DESC_BOFA + TAG_DESC_HUSBAND + + EMAIL_DESC_APPLE + ROLE_DESC_APPLE + NAME_DESC_APPLE + TAG_DESC_FRIEND; - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY) - .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY) + EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_APPLE) + .withPhone(VALID_DATE_BOFA).withEmail(VALID_EMAIL_APPLE).withAddress(VALID_ROLE_APPLE) .withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND).build(); EditCommand expectedCommand = new EditCommand(targetIndex, descriptor); @@ -120,10 +120,10 @@ public void parse_allFieldsSpecified_success() { @Test public void parse_someFieldsSpecified_success() { Index targetIndex = INDEX_FIRST_PERSON; - String userInput = targetIndex.getOneBased() + PHONE_DESC_BOB + EMAIL_DESC_AMY; + String userInput = targetIndex.getOneBased() + DATE_DESC_BOFA + EMAIL_DESC_APPLE; - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withPhone(VALID_PHONE_BOB) - .withEmail(VALID_EMAIL_AMY).build(); + EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withPhone(VALID_DATE_BOFA) + .withEmail(VALID_EMAIL_APPLE).build(); EditCommand expectedCommand = new EditCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); @@ -133,26 +133,26 @@ public void parse_someFieldsSpecified_success() { public void parse_oneFieldSpecified_success() { // name Index targetIndex = INDEX_THIRD_PERSON; - String userInput = targetIndex.getOneBased() + NAME_DESC_AMY; - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY).build(); + String userInput = targetIndex.getOneBased() + NAME_DESC_APPLE; + EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_APPLE).build(); EditCommand expectedCommand = new EditCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); // phone - userInput = targetIndex.getOneBased() + PHONE_DESC_AMY; - descriptor = new EditPersonDescriptorBuilder().withPhone(VALID_PHONE_AMY).build(); + userInput = targetIndex.getOneBased() + DATE_DESC_APPLE; + descriptor = new EditPersonDescriptorBuilder().withPhone(VALID_DATE_APPLE).build(); expectedCommand = new EditCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); // email - userInput = targetIndex.getOneBased() + EMAIL_DESC_AMY; - descriptor = new EditPersonDescriptorBuilder().withEmail(VALID_EMAIL_AMY).build(); + userInput = targetIndex.getOneBased() + EMAIL_DESC_APPLE; + descriptor = new EditPersonDescriptorBuilder().withEmail(VALID_EMAIL_APPLE).build(); expectedCommand = new EditCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); // address - userInput = targetIndex.getOneBased() + ADDRESS_DESC_AMY; - descriptor = new EditPersonDescriptorBuilder().withAddress(VALID_ADDRESS_AMY).build(); + userInput = targetIndex.getOneBased() + ROLE_DESC_APPLE; + descriptor = new EditPersonDescriptorBuilder().withAddress(VALID_ROLE_APPLE).build(); expectedCommand = new EditCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); @@ -170,29 +170,29 @@ public void parse_multipleRepeatedFields_failure() { // valid followed by invalid Index targetIndex = INDEX_FIRST_PERSON; - String userInput = targetIndex.getOneBased() + INVALID_PHONE_DESC + PHONE_DESC_BOB; + String userInput = targetIndex.getOneBased() + INVALID_DATE_DESC + DATE_DESC_BOFA; - assertParseFailure(parser, userInput, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PHONE)); + assertParseFailure(parser, userInput, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_DATE)); // invalid followed by valid - userInput = targetIndex.getOneBased() + PHONE_DESC_BOB + INVALID_PHONE_DESC; + userInput = targetIndex.getOneBased() + DATE_DESC_BOFA + INVALID_DATE_DESC; - assertParseFailure(parser, userInput, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PHONE)); + assertParseFailure(parser, userInput, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_DATE)); // mulltiple valid fields repeated - userInput = targetIndex.getOneBased() + PHONE_DESC_AMY + ADDRESS_DESC_AMY + EMAIL_DESC_AMY - + TAG_DESC_FRIEND + PHONE_DESC_AMY + ADDRESS_DESC_AMY + EMAIL_DESC_AMY + TAG_DESC_FRIEND - + PHONE_DESC_BOB + ADDRESS_DESC_BOB + EMAIL_DESC_BOB + TAG_DESC_HUSBAND; + userInput = targetIndex.getOneBased() + DATE_DESC_APPLE + ROLE_DESC_APPLE + EMAIL_DESC_APPLE + + TAG_DESC_FRIEND + DATE_DESC_APPLE + ROLE_DESC_APPLE + EMAIL_DESC_APPLE + TAG_DESC_FRIEND + + DATE_DESC_BOFA + ROLE_DESC_BOFA + EMAIL_DESC_BOFA + TAG_DESC_HUSBAND; assertParseFailure(parser, userInput, - Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS)); + Messages.getErrorMessageForDuplicatePrefixes(PREFIX_DATE, PREFIX_EMAIL, PREFIX_ROLE)); // multiple invalid values - userInput = targetIndex.getOneBased() + INVALID_PHONE_DESC + INVALID_ADDRESS_DESC + INVALID_EMAIL_DESC - + INVALID_PHONE_DESC + INVALID_ADDRESS_DESC + INVALID_EMAIL_DESC; + userInput = targetIndex.getOneBased() + INVALID_DATE_DESC + INVALID_ROLE_DESC + INVALID_EMAIL_DESC + + INVALID_DATE_DESC + INVALID_ROLE_DESC + INVALID_EMAIL_DESC; assertParseFailure(parser, userInput, - Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS)); + Messages.getErrorMessageForDuplicatePrefixes(PREFIX_DATE, PREFIX_EMAIL, PREFIX_ROLE)); } @Test diff --git a/src/test/java/seedu/address/model/internshipapplication/UniqueListTest.java b/src/test/java/seedu/address/model/internshipapplication/UniqueListTest.java new file mode 100644 index 00000000000..67a522ee7c4 --- /dev/null +++ b/src/test/java/seedu/address/model/internshipapplication/UniqueListTest.java @@ -0,0 +1,176 @@ +package seedu.address.model.internshipapplication; + +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.VALID_ROLE_BOFA; +import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; +import static seedu.address.testutil.Assert.assertThrows; +import static seedu.address.testutil.TypicalInternshipApplications.AIRBNB; +import static seedu.address.testutil.TypicalInternshipApplications.BYTEDANCE; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.junit.jupiter.api.Test; + +import seedu.address.model.internshipapplication.exceptions.DuplicatePersonException; +import seedu.address.model.internshipapplication.exceptions.PersonNotFoundException; +import seedu.address.testutil.InternshipApplicationBuilder; +import seedu.address.testutil.PersonBuilder; + +public class UniqueListTest { + + private final UniqueList uniqueList = new UniqueList<>(); + + @Test + public void contains_nullPerson_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> uniqueList.contains(null)); + } + + @Test + public void contains_personNotInList_returnsFalse() { + assertFalse(uniqueList.contains(AIRBNB)); + } + + @Test + public void contains_personInList_returnsTrue() { + uniqueList.add(AIRBNB); + assertTrue(uniqueList.contains(AIRBNB)); + } + + @Test + public void contains_personWithSameIdentityFieldsInList_returnsTrue() { + uniqueList.add(AIRBNB); + InternshipApplication editedAirbnb = new InternshipApplicationBuilder(AIRBNB).withRole(VALID_ROLE_BOFA) + .build(); + assertTrue(uniqueList.contains(editedAirbnb)); + } + + @Test + public void add_nullPerson_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> uniqueList.add(null)); + } + + @Test + public void add_duplicatePerson_throwsDuplicatePersonException() { + uniqueList.add(AIRBNB); + assertThrows(DuplicatePersonException.class, () -> uniqueList.add(AIRBNB)); + } + + @Test + public void setPerson_nullTargetPerson_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> uniqueList.setItem(null, AIRBNB)); + } + + @Test + public void setPerson_nullEditedPerson_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> uniqueList.setItem(AIRBNB, null)); + } + + @Test + public void setPerson_targetPersonNotInList_throwsPersonNotFoundException() { + assertThrows(PersonNotFoundException.class, () -> uniqueList.setItem(AIRBNB, AIRBNB)); + } + + @Test + public void setPerson_editedPersonIsSamePerson_success() { + uniqueList.add(AIRBNB); + uniqueList.setItem(AIRBNB, AIRBNB); + UniqueList expectedUniqueList = new UniqueList(); + expectedUniqueList.add(AIRBNB); + assertEquals(expectedUniqueList, uniqueList); + } + + @Test + public void setPerson_editedPersonHasSameIdentity_success() { + uniqueList.add(AIRBNB); + InternshipApplication editedAirbnb = new InternshipApplicationBuilder(AIRBNB).withRole(VALID_ROLE_BOFA) + .build(); + uniqueList.setItem(AIRBNB, editedAirbnb); + UniqueList expectedUniqueList = new UniqueList(); + expectedUniqueList.add(editedAirbnb); + assertEquals(expectedUniqueList, uniqueList); + } + + @Test + public void setPerson_editedPersonHasDifferentIdentity_success() { + uniqueList.add(AIRBNB); + uniqueList.setItem(AIRBNB, BYTEDANCE); + UniqueList expectedUniqueList = new UniqueList(); + expectedUniqueList.add(BYTEDANCE); + assertEquals(expectedUniqueList, uniqueList); + } + + @Test + public void setPerson_editedPersonHasNonUniqueIdentity_throwsDuplicatePersonException() { + uniqueList.add(AIRBNB); + uniqueList.add(BYTEDANCE); + assertThrows(DuplicatePersonException.class, () -> uniqueList.setItem(AIRBNB, BYTEDANCE)); + } + + @Test + public void remove_nullPerson_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> uniqueList.remove(null)); + } + + @Test + public void remove_personDoesNotExist_throwsPersonNotFoundException() { + assertThrows(PersonNotFoundException.class, () -> uniqueList.remove(AIRBNB)); + } + + @Test + public void remove_existingPerson_removesPerson() { + uniqueList.add(AIRBNB); + uniqueList.remove(AIRBNB); + UniqueList expectedUniqueList = new UniqueList(); + assertEquals(expectedUniqueList, uniqueList); + } + + @Test + public void setPersons_nullUniqueList_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> uniqueList.setItems((List) null)); + } + + @Test + public void setPersons_uniqueList_replacesOwnListWithProvidedUniqueList() { + uniqueList.add(AIRBNB); + UniqueList expectedUniqueList = new UniqueList(); + expectedUniqueList.add(BYTEDANCE); + uniqueList.setItems(expectedUniqueList); + assertEquals(expectedUniqueList, uniqueList); + } + + @Test + public void setPersons_nullList_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> uniqueList.setItems((List) null)); + } + + @Test + public void setPersons_list_replacesOwnListWithProvidedList() { + uniqueList.add(AIRBNB); + List personList = Collections.singletonList(BYTEDANCE); + uniqueList.setItems(personList); + UniqueList expectedUniqueList = new UniqueList(); + expectedUniqueList.add(BYTEDANCE); + assertEquals(expectedUniqueList, uniqueList); + } + + @Test + public void setPersons_listWithDuplicatePersons_throwsDuplicatePersonException() { + List listWithDuplicatePersons = Arrays.asList(AIRBNB, AIRBNB); + assertThrows(DuplicatePersonException.class, () -> uniqueList.setItems(listWithDuplicatePersons)); + } + + @Test + public void asUnmodifiableObservableList_modifyList_throwsUnsupportedOperationException() { + assertThrows(UnsupportedOperationException.class, () + -> uniqueList.asUnmodifiableObservableList().remove(0)); + } + + @Test + public void toStringMethod() { + assertEquals(uniqueList.asUnmodifiableObservableList().toString(), uniqueList.toString()); + } +} diff --git a/src/test/java/seedu/address/model/internshipapplication/UniquePersonListTest.java b/src/test/java/seedu/address/model/internshipapplication/UniquePersonListTest.java deleted file mode 100644 index 05de83d2d9f..00000000000 --- a/src/test/java/seedu/address/model/internshipapplication/UniquePersonListTest.java +++ /dev/null @@ -1,175 +0,0 @@ -package seedu.address.model.internshipapplication; - -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.VALID_ADDRESS_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; -import static seedu.address.testutil.Assert.assertThrows; -import static seedu.address.testutil.TypicalPersons.ALICE; -import static seedu.address.testutil.TypicalPersons.BOB; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import org.junit.jupiter.api.Test; - -import seedu.address.model.internshipapplication.exceptions.DuplicatePersonException; -import seedu.address.model.internshipapplication.exceptions.PersonNotFoundException; -import seedu.address.testutil.PersonBuilder; - -public class UniquePersonListTest { - - private final UniquePersonList uniquePersonList = new UniquePersonList(); - - @Test - public void contains_nullPerson_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> uniquePersonList.contains(null)); - } - - @Test - public void contains_personNotInList_returnsFalse() { - assertFalse(uniquePersonList.contains(ALICE)); - } - - @Test - public void contains_personInList_returnsTrue() { - uniquePersonList.add(ALICE); - assertTrue(uniquePersonList.contains(ALICE)); - } - - @Test - public void contains_personWithSameIdentityFieldsInList_returnsTrue() { - uniquePersonList.add(ALICE); - Person editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) - .build(); - assertTrue(uniquePersonList.contains(editedAlice)); - } - - @Test - public void add_nullPerson_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> uniquePersonList.add(null)); - } - - @Test - public void add_duplicatePerson_throwsDuplicatePersonException() { - uniquePersonList.add(ALICE); - assertThrows(DuplicatePersonException.class, () -> uniquePersonList.add(ALICE)); - } - - @Test - public void setPerson_nullTargetPerson_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> uniquePersonList.setPerson(null, ALICE)); - } - - @Test - public void setPerson_nullEditedPerson_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> uniquePersonList.setPerson(ALICE, null)); - } - - @Test - public void setPerson_targetPersonNotInList_throwsPersonNotFoundException() { - assertThrows(PersonNotFoundException.class, () -> uniquePersonList.setPerson(ALICE, ALICE)); - } - - @Test - public void setPerson_editedPersonIsSamePerson_success() { - uniquePersonList.add(ALICE); - uniquePersonList.setPerson(ALICE, ALICE); - UniquePersonList expectedUniquePersonList = new UniquePersonList(); - expectedUniquePersonList.add(ALICE); - assertEquals(expectedUniquePersonList, uniquePersonList); - } - - @Test - public void setPerson_editedPersonHasSameIdentity_success() { - uniquePersonList.add(ALICE); - Person editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) - .build(); - uniquePersonList.setPerson(ALICE, editedAlice); - UniquePersonList expectedUniquePersonList = new UniquePersonList(); - expectedUniquePersonList.add(editedAlice); - assertEquals(expectedUniquePersonList, uniquePersonList); - } - - @Test - public void setPerson_editedPersonHasDifferentIdentity_success() { - uniquePersonList.add(ALICE); - uniquePersonList.setPerson(ALICE, BOB); - UniquePersonList expectedUniquePersonList = new UniquePersonList(); - expectedUniquePersonList.add(BOB); - assertEquals(expectedUniquePersonList, uniquePersonList); - } - - @Test - public void setPerson_editedPersonHasNonUniqueIdentity_throwsDuplicatePersonException() { - uniquePersonList.add(ALICE); - uniquePersonList.add(BOB); - assertThrows(DuplicatePersonException.class, () -> uniquePersonList.setPerson(ALICE, BOB)); - } - - @Test - public void remove_nullPerson_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> uniquePersonList.remove(null)); - } - - @Test - public void remove_personDoesNotExist_throwsPersonNotFoundException() { - assertThrows(PersonNotFoundException.class, () -> uniquePersonList.remove(ALICE)); - } - - @Test - public void remove_existingPerson_removesPerson() { - uniquePersonList.add(ALICE); - uniquePersonList.remove(ALICE); - UniquePersonList expectedUniquePersonList = new UniquePersonList(); - assertEquals(expectedUniquePersonList, uniquePersonList); - } - - @Test - public void setPersons_nullUniquePersonList_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> uniquePersonList.setPersons((UniquePersonList) null)); - } - - @Test - public void setPersons_uniquePersonList_replacesOwnListWithProvidedUniquePersonList() { - uniquePersonList.add(ALICE); - UniquePersonList expectedUniquePersonList = new UniquePersonList(); - expectedUniquePersonList.add(BOB); - uniquePersonList.setPersons(expectedUniquePersonList); - assertEquals(expectedUniquePersonList, uniquePersonList); - } - - @Test - public void setPersons_nullList_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> uniquePersonList.setPersons((List) null)); - } - - @Test - public void setPersons_list_replacesOwnListWithProvidedList() { - uniquePersonList.add(ALICE); - List personList = Collections.singletonList(BOB); - uniquePersonList.setPersons(personList); - UniquePersonList expectedUniquePersonList = new UniquePersonList(); - expectedUniquePersonList.add(BOB); - assertEquals(expectedUniquePersonList, uniquePersonList); - } - - @Test - public void setPersons_listWithDuplicatePersons_throwsDuplicatePersonException() { - List listWithDuplicatePersons = Arrays.asList(ALICE, ALICE); - assertThrows(DuplicatePersonException.class, () -> uniquePersonList.setPersons(listWithDuplicatePersons)); - } - - @Test - public void asUnmodifiableObservableList_modifyList_throwsUnsupportedOperationException() { - assertThrows(UnsupportedOperationException.class, () - -> uniquePersonList.asUnmodifiableObservableList().remove(0)); - } - - @Test - public void toStringMethod() { - assertEquals(uniquePersonList.asUnmodifiableObservableList().toString(), uniquePersonList.toString()); - } -} diff --git a/src/test/java/seedu/address/testutil/InternshipApplicationBuilder.java b/src/test/java/seedu/address/testutil/InternshipApplicationBuilder.java new file mode 100644 index 00000000000..08475584974 --- /dev/null +++ b/src/test/java/seedu/address/testutil/InternshipApplicationBuilder.java @@ -0,0 +1,83 @@ +package seedu.address.testutil; + +import seedu.address.model.internshipapplication.Company; +import seedu.address.model.internshipapplication.Date; +import seedu.address.model.internshipapplication.Email; +import seedu.address.model.internshipapplication.InternshipApplication; +import seedu.address.model.internshipapplication.Name; +import seedu.address.model.internshipapplication.Role; + + +public class InternshipApplicationBuilder { + public static final String DEFAULT_NAME = "Amazon"; + public static final String DEFAULT_ROLE = "Software Engineer Intern"; + public static final String DEFAULT_EMAIL = "amazon@gmail.com"; + public static final String DEFAULT_DATE_OF_APPLICATION = "12/03/24"; + + private Company company; + private Name name; + private Email email; + private Role role; + private Date dateOfApplication; + + /** + * Creates a {@code InternshipApplicationBuilder} with the default details. + */ + public InternshipApplicationBuilder() { + name = new Name(DEFAULT_NAME); + email = new Email(DEFAULT_EMAIL); + company = new Company(email, name); + role = new Role(DEFAULT_ROLE); + dateOfApplication = new Date(DEFAULT_DATE_OF_APPLICATION); + + } + + /** + * Initializes the InternshipApplicationBuilder with the data of {@code internshipApplicationToCopy}. + */ + public InternshipApplicationBuilder(InternshipApplication internshipApplicationToCopy) { + company = internshipApplicationToCopy.getCompany(); + role = internshipApplicationToCopy.getRole(); + dateOfApplication = internshipApplicationToCopy.getDateOfApplication(); + + } + + /** + * Sets the {@code Name} of the {@code InternshipApplication} that we are building. + */ + public InternshipApplicationBuilder withName(String name) { + this.name = new Name(name); + return this; + } + + + /** + * Sets the {@code Role} of the {@code InternshipApplication} that we are building. + */ + public InternshipApplicationBuilder withRole(String role) { + this.role = new Role(role); + return this; + } + + /** + * Sets the {@code Email} of the {@code InternshipApplication} that we are building. + */ + public InternshipApplicationBuilder withEmail(String email) { + this.email = new Email(email); + return this; + } + + /** + * Sets the {@code Date} of the {@code InternshipApplication} that we are building. + */ + public InternshipApplicationBuilder withDate(String date) { + this.dateOfApplication = new Date(date); + return this; + } + + public InternshipApplication build() { + company = new Company(email, name); + return new InternshipApplication(company, dateOfApplication, role); + } + +} diff --git a/src/test/java/seedu/address/testutil/TypicalInternshipApplications.java b/src/test/java/seedu/address/testutil/TypicalInternshipApplications.java new file mode 100644 index 00000000000..99a463e2895 --- /dev/null +++ b/src/test/java/seedu/address/testutil/TypicalInternshipApplications.java @@ -0,0 +1,99 @@ +package seedu.address.testutil; + +import static seedu.address.logic.commands.CommandTestUtil.VALID_ROLE_APPLE; +import static seedu.address.logic.commands.CommandTestUtil.VALID_ROLE_BOFA; +import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_APPLE; +import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_BOFA; +import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_APPLE; +import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOFA; +import static seedu.address.logic.commands.CommandTestUtil.VALID_DATE_APPLE; +import static seedu.address.logic.commands.CommandTestUtil.VALID_DATE_BOFA; +import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_FRIEND; +import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; +import static seedu.address.testutil.TypicalInternshipApplications.getTypicalInternshipApplications; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import seedu.address.model.AddressBook; +import seedu.address.model.internshipapplication.InternshipApplication; + +/** + * A utility class containing a list of {@code InternshipApplication} objects to be used in tests. + */ +public class TypicalInternshipApplications { + + public static final InternshipApplication AIRBNB = new InternshipApplicationBuilder().withName("Airbnb") + .withEmail("airbnb@example.com") + .withRole("Software Engineer Intern") + .withDate("01/01/24") + .build(); + public static final InternshipApplication BYTEDANCE = new InternshipApplicationBuilder().withName("ByteDance") + .withEmail("bytedance@example.com") + .withRole("Frontend Developer Intern") + .withDate("02/02/24") + .build(); + public static final InternshipApplication CITIBANK = new InternshipApplicationBuilder().withName("Citibank") + .withEmail("citibank@example.com") + .withRole("Backend Developer Intern") + .withDate("03/03/24") + .build(); + public static final InternshipApplication DELL = new InternshipApplicationBuilder().withName("Dell") + .withEmail("dell@example.com") + .withRole("Computer Engineer Intern") + .withDate("04/04/24") + .build(); + public static final InternshipApplication EY = new InternshipApplicationBuilder().withName("Ernest & Young") + .withEmail("ey@example.com") + .withRole("Fintech Intern") + .withDate("05/05/24") + .build(); + public static final InternshipApplication FIGMA = new InternshipApplicationBuilder().withName("Figma") + .withEmail("figma@example.com") + .withRole("UI/UX Intern") + .withDate("06/06/24") + .build(); + public static final InternshipApplication GOOGLE = new InternshipApplicationBuilder().withName("Google") + .withEmail("google@example.com") + .withRole("Full Stack Developer Intern") + .withDate("07/07/24") + .build(); + + // Manually added + public static final InternshipApplication HOON = new InternshipApplicationBuilder().withName("Hoon Company") + .withEmail("hoon@example.com") + .withRole("Hoon Intern") + .withDate("01/01/24") + .build(); + public static final InternshipApplication IDA = new InternshipApplicationBuilder().withName("Ida Company") + .withEmail("ida@example.com") + .withRole("Ida Intern") + .withDate("02/02/24") + .build(); + + // Manually added - InternshipApplication's details found in {@code CommandTestUtil} + public static final InternshipApplication APPLE = new InternshipApplicationBuilder().withName(VALID_NAME_APPLE) + .withEmail(VALID_EMAIL_APPLE).withRole(VALID_ROLE_APPLE).build(); + public static final InternshipApplication BOFA = new InternshipApplicationBuilder().withName(VALID_NAME_BOFA) + .withEmail(VALID_EMAIL_BOFA).withRole(VALID_ROLE_BOFA).build(); + + public static final String KEYWORD_MATCHING_HOON = "HOON"; // A keyword that matches HOON + + private TypicalInternshipApplications() {} // prevents instantiation + + /** + * Returns an {@code AddressBook} with all the typical persons. + */ + public static AddressBook getTypicalAddressBook() { + AddressBook ab = new AddressBook<>(); + for (InternshipApplication internshipApp : getTypicalInternshipApplications()) { + ab.addItem(internshipApp); + } + return ab; + } + + public static List getTypicalInternshipApplications() { + return new ArrayList<>(Arrays.asList(APPLE, BOFA, CITIBANK, DELL, EY, FIGMA, GOOGLE)); + } +} diff --git a/src/test/java/seedu/address/testutil/TypicalPersons.java b/src/test/java/seedu/address/testutil/TypicalPersons.java index 0e3e3846886..5473081ce25 100644 --- a/src/test/java/seedu/address/testutil/TypicalPersons.java +++ b/src/test/java/seedu/address/testutil/TypicalPersons.java @@ -1,13 +1,9 @@ package seedu.address.testutil; -import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_AMY; -import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_AMY; -import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_AMY; -import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_AMY; -import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_APPLE; +import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_BOFA; +import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_APPLE; +import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOFA; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_FRIEND; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; @@ -49,10 +45,10 @@ public class TypicalPersons { .withEmail("hans@example.com").withAddress("chicago ave").build(); // Manually added - Person's details found in {@code CommandTestUtil} - public static final Person AMY = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY) - .withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withTags(VALID_TAG_FRIEND).build(); - public static final Person BOB = new PersonBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) - .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND) + public static final Person APPLE = new PersonBuilder().withName(VALID_NAME_APPLE) + .withEmail(VALID_EMAIL_APPLE).withTags(VALID_TAG_FRIEND).build(); + public static final Person BOFA = new PersonBuilder().withName(VALID_NAME_BOFA) + .withEmail(VALID_EMAIL_BOFA).withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND) .build(); public static final String KEYWORD_MATCHING_MEIER = "Meier"; // A keyword that matches MEIER @@ -64,9 +60,6 @@ private TypicalPersons() {} // prevents instantiation */ public static AddressBook getTypicalAddressBook() { AddressBook ab = new AddressBook(); - for (Person person : getTypicalPersons()) { - ab.addPerson(person); - } return ab; }