tagged = new ArrayList<>();
+
+ /**
+ * No-arg constructor for JAXB use.
+ */
+ public AdaptedPlayer() {
+ }
+
+
+ /**
+ * Converts a given Person into this class for JAXB use.
+ *
+ * @param source future changes to this will not affect the created AdaptedPlayer
+ */
+ public AdaptedPlayer(ReadOnlyPlayer source) {
+ name = source.getName().fullName;
+ position = source.getPositionPlayed().fullPosition;
+ age = source.getAge().value;
+ salary = source.getSalary().value;
+ goalsScored = source.getGoalsScored().value;
+ goalsAssisted = source.getGoalsAssisted().value;
+ team = source.getTeam().fullTeam;
+ country = source.getCountry().fullCountry;
+ jerseyNumber = source.getJerseyNumber().value;
+ appearance = source.getAppearance().value;
+ healthStatus = source.getHealthStatus().fullHs;
+
+ tagged = new ArrayList<>();
+ for (Tag tag : source.getTags()) {
+ tagged.add(new AdaptedTag(tag));
+ }
+ }
+
+ /**
+ * Returns true if any required field is missing.
+ *
+ * JAXB does not enforce (required = true) without a given XML schema.
+ * Since we do most of our validation using the data class constructors, the only extra logic we need
+ * is to ensure that every xml element in the document is present. JAXB sets missing elements as null,
+ * so we check for that.
+ */
+
+ public boolean isAnyRequiredFieldMissing() {
+ for (AdaptedTag tag : tagged) {
+ if (tag.isAnyRequiredFieldMissing()) {
+ return true;
+ }
+ }
+ // second call only happens if phone/email/address are all not null
+ return Utils.isAnyNull(name, position, age, salary, goalsScored, goalsAssisted, team, country, jerseyNumber,
+ appearance, healthStatus);
+ }
+
+ /**
+ * Converts this jaxb-friendly adapted player object into the Player object.
+ *
+ * @throws IllegalValueException if there were any data constraints violated in the adapted player
+ */
+ public Player toModelType() throws IllegalValueException {
+ final Set tags = new HashSet<>();
+ for (AdaptedTag tag : tagged) {
+ tags.add(tag.toModelType());
+ }
+ final Name name = new Name(this.name);
+ final PositionPlayed positionPlayed = new PositionPlayed(this.position);
+ final Age age = new Age(this.age);
+ final Salary salary = new Salary(this.salary);
+ final GoalsScored goalsScored = new GoalsScored(this.goalsScored);
+ final GoalsAssisted goalsAssisted = new GoalsAssisted(this.goalsAssisted);
+ final Team team = new Team(this.team);
+ final Country country = new Country(this.country);
+ final JerseyNumber jerseyNumber = new JerseyNumber(this.jerseyNumber);
+ final Appearance appearance = new Appearance(this.appearance);
+ final HealthStatus healthStatus = new HealthStatus(this.healthStatus);
+
+ return new Player(name, positionPlayed, age, salary, goalsScored, goalsAssisted,
+ team, country, jerseyNumber, appearance, healthStatus, tags);
+ }
+}
diff --git a/src/seedu/addressbook/storage/jaxb/AdaptedTeam.java b/src/seedu/addressbook/storage/jaxb/AdaptedTeam.java
index 553adf84f..360533b00 100644
--- a/src/seedu/addressbook/storage/jaxb/AdaptedTeam.java
+++ b/src/seedu/addressbook/storage/jaxb/AdaptedTeam.java
@@ -9,7 +9,7 @@
import seedu.addressbook.common.Utils;
import seedu.addressbook.data.exception.IllegalValueException;
-import seedu.addressbook.data.player.Person;
+import seedu.addressbook.data.player.Player;
import seedu.addressbook.data.tag.Tag;
import seedu.addressbook.data.team.Country;
import seedu.addressbook.data.team.Name;
@@ -17,7 +17,6 @@
import seedu.addressbook.data.team.Sponsor;
import seedu.addressbook.data.team.Team;
-
/**
* JAXB-friendly adapted team data holder class.
*/
@@ -29,7 +28,7 @@ public class AdaptedTeam {
@XmlElement(required = true)
private String sponsor;
@XmlElement
- private List playerlist = new ArrayList<>();
+ private List playerlist = new ArrayList<>();
@XmlElement
private List tagged = new ArrayList<>();
@@ -48,8 +47,8 @@ public AdaptedTeam(ReadOnlyTeam source) {
sponsor = source.getSponsor().toString();
playerlist = new ArrayList<>();
- for (Person person : source.getPlayers()) {
- playerlist.add(new AdaptedPerson(person));
+ for (Player player : source.getPlayers()) {
+ playerlist.add(new AdaptedPlayer(player));
}
tagged = new ArrayList<>();
@@ -80,9 +79,9 @@ public boolean isAnyRequiredFieldMissing() {
*/
public Team toModelType() throws IllegalValueException {
final Set tags = new HashSet<>();
- final Set players = new HashSet<>();
- for (AdaptedPerson person : playerlist) {
- players.add(person.toModelType());
+ final Set players = new HashSet<>();
+ for (AdaptedPlayer player : playerlist) {
+ players.add(player.toModelType());
}
for (AdaptedTag tag : tagged) {
tags.add(tag.toModelType());
diff --git a/src/seedu/addressbook/ui/Formatter.java b/src/seedu/addressbook/ui/Formatter.java
index 9d8b12419..5fa90d666 100644
--- a/src/seedu/addressbook/ui/Formatter.java
+++ b/src/seedu/addressbook/ui/Formatter.java
@@ -5,7 +5,7 @@
import seedu.addressbook.data.finance.ReadOnlyFinance;
import seedu.addressbook.data.match.ReadOnlyMatch;
-import seedu.addressbook.data.player.ReadOnlyPerson;
+import seedu.addressbook.data.player.ReadOnlyPlayer;
import seedu.addressbook.data.team.ReadOnlyTeam;
/**
@@ -37,14 +37,15 @@ public String format(String... messages) {
return sb.toString();
}
- /** Formats the given list of persons for displaying to the user. */
- public String formatPersonResult(List extends ReadOnlyPerson> persons) {
+ /** Formats the given list of players for displaying to the user. */
+ public String formatPersonResult(List extends ReadOnlyPlayer> players) {
final List formattedPersons = new ArrayList<>();
- for (ReadOnlyPerson person : persons) {
- formattedPersons.add(person.getAsTextHidePrivate());
+ for (ReadOnlyPlayer player : players) {
+ formattedPersons.add(player.getAsTextShowAll());
}
return format(asIndexedList(formattedPersons));
}
+
/** Formats the given list of teams for displaying to the user. */
public String formatTeamResult(List extends ReadOnlyTeam> teams) {
final List formattedTeams = new ArrayList<>();
diff --git a/src/seedu/addressbook/ui/MainWindow.java b/src/seedu/addressbook/ui/MainWindow.java
index 13e9eda7e..568740f18 100644
--- a/src/seedu/addressbook/ui/MainWindow.java
+++ b/src/seedu/addressbook/ui/MainWindow.java
@@ -16,11 +16,10 @@
import seedu.addressbook.commands.ExitCommand;
import seedu.addressbook.data.finance.ReadOnlyFinance;
import seedu.addressbook.data.match.ReadOnlyMatch;
-import seedu.addressbook.data.player.ReadOnlyPerson;
+import seedu.addressbook.data.player.ReadOnlyPlayer;
import seedu.addressbook.data.team.ReadOnlyTeam;
import seedu.addressbook.logic.Logic;
-
/**
* Main Window of the GUI.
*/
@@ -81,7 +80,7 @@ private void clearCommandInput() {
commandInput.setText("");
}
- /** Clears the output displayPersonResult area */
+ /** Clears the output displayPlayerResult area */
public void clearOutputConsole() {
outputConsole.clear();
}
@@ -89,12 +88,12 @@ public void clearOutputConsole() {
/** Displays the result of a command execution to the user. */
public void displayResult(CommandResult result) {
clearOutputConsole();
- final Optional> resultPersons = result.getRelevantPersons();
+ final Optional> resultPlayers = result.getRelevantPlayers();
final Optional> resultTeams = result.getRelevantTeams();
final Optional> resultMatches = result.getRelevantMatches();
final Optional> resultFinances = result.getRelevantFinances();
- if (resultPersons.isPresent()) {
- displayPersonResult(resultPersons.get());
+ if (resultPlayers.isPresent()) {
+ displayPlayerResult(resultPlayers.get());
}
if (resultTeams.isPresent()) {
displayTeamResult(resultTeams.get());
@@ -124,15 +123,15 @@ private void displayMatch(List extends ReadOnlyMatch> matches) {
}
/**
- * Displays the list of persons in the output displayPersonResult area, formatted as an indexed list.
+ * Displays the list of players in the output displayPlayerResult area, formatted as an indexed list.
* Private contact details are hidden.
*/
- private void displayPersonResult(List extends ReadOnlyPerson> persons) {
- display(new Formatter().formatPersonResult(persons));
+ private void displayPlayerResult(List extends ReadOnlyPlayer> players) {
+ display(new Formatter().formatPersonResult(players));
}
/**
- * Displays the list of teams in the output displayPersonResult area, formatted as an indexed list.
+ * Displays the list of teams in the output displayPlayerResult area, formatted as an indexed list.
* Private contact details are hidden.
*/
private void displayTeamResult(List extends ReadOnlyTeam> teams) {
@@ -148,7 +147,7 @@ private void displayFinanceResult(List extends ReadOnlyFinance> finances) {
}
/**
- * Displays the given messages on the output displayPersonResult area, after formatting appropriately.
+ * Displays the given messages on the output displayPlayerResult area, after formatting appropriately.
*/
private void display(String... messages) {
outputConsole.setText(outputConsole.getText() + new Formatter().format(messages));
diff --git a/test/data/StorageFileTest/InvalidData.txt b/test/data/StorageFileTest/InvalidData.txt
index 91e8971a4..93f711dff 100644
--- a/test/data/StorageFileTest/InvalidData.txt
+++ b/test/data/StorageFileTest/InvalidData.txt
@@ -1,6 +1,6 @@
-
+
data
-
+
diff --git a/test/data/StorageFileTest/ValidData.txt b/test/data/StorageFileTest/ValidData.txt
index fc6b00df6..cdfb4b4f5 100644
--- a/test/data/StorageFileTest/ValidData.txt
+++ b/test/data/StorageFileTest/ValidData.txt
@@ -1,17 +1,29 @@
-
- John Doe
- 98765432
- johnd@gmail.com
- John street, block 123, #01-01
-
-
- Betsy Crowe
- 1234567
- betsycrowe@gmail.com
- Newgate Prison
- friend
- criminal
-
+
+ Lionel Messi
+ RW
+ 30
+ 200
+ 30
+ 20
+ FC Barcelona
+ Argentina
+ 10
+ 54
+ Healthy
+
+
+ Luis Suarez
+ Striker
+ 32
+ 200
+ 30
+ 20
+ FC Barcelona
+ Uruguay
+ 9
+ 54
+ Healthy
+
diff --git a/test/java/seedu/addressbook/logic/LogicTest.java b/test/java/seedu/addressbook/logic/LogicTest.java
index e084dcc49..a324e4d2d 100644
--- a/test/java/seedu/addressbook/logic/LogicTest.java
+++ b/test/java/seedu/addressbook/logic/LogicTest.java
@@ -16,24 +16,31 @@
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
-import seedu.addressbook.commands.AddCommand;
-import seedu.addressbook.commands.ClearCommand;
import seedu.addressbook.commands.Command;
import seedu.addressbook.commands.CommandResult;
-import seedu.addressbook.commands.DeleteCommand;
import seedu.addressbook.commands.ExitCommand;
-import seedu.addressbook.commands.FindCommand;
import seedu.addressbook.commands.HelpCommand;
-import seedu.addressbook.commands.ViewAllCommand;
-import seedu.addressbook.commands.ViewCommand;
+import seedu.addressbook.commands.player.AddCommand;
+import seedu.addressbook.commands.player.AddFastCommand;
+import seedu.addressbook.commands.player.ClearCommand;
+import seedu.addressbook.commands.player.DeleteCommand;
+import seedu.addressbook.commands.player.FindCommand;
+import seedu.addressbook.commands.player.ViewAllCommand;
import seedu.addressbook.common.Messages;
import seedu.addressbook.data.AddressBook;
-import seedu.addressbook.data.player.Address;
-import seedu.addressbook.data.player.Email;
+import seedu.addressbook.data.player.Age;
+import seedu.addressbook.data.player.Appearance;
+import seedu.addressbook.data.player.Country;
+import seedu.addressbook.data.player.GoalsAssisted;
+import seedu.addressbook.data.player.GoalsScored;
+import seedu.addressbook.data.player.HealthStatus;
+import seedu.addressbook.data.player.JerseyNumber;
import seedu.addressbook.data.player.Name;
-import seedu.addressbook.data.player.Person;
-import seedu.addressbook.data.player.Phone;
-import seedu.addressbook.data.player.ReadOnlyPerson;
+import seedu.addressbook.data.player.Player;
+import seedu.addressbook.data.player.PositionPlayed;
+import seedu.addressbook.data.player.ReadOnlyPlayer;
+import seedu.addressbook.data.player.Salary;
+import seedu.addressbook.data.player.Team;
import seedu.addressbook.data.tag.Tag;
import seedu.addressbook.storage.StorageFile;
@@ -62,7 +69,7 @@ public void constructor() {
//Constructor is called in the setup() method which executes before every test, no need to call it here again.
//Confirm the last shown list is empty
- assertEquals(Collections.emptyList(), logic.getLastPersonShownList());
+ assertEquals(Collections.emptyList(), logic.getLastPlayerShownList());
}
@Test
@@ -75,6 +82,7 @@ public void execute_invalid() throws Exception {
/**
* Executes the command and confirms that the result message is correct.
* Both the 'address book' and the 'last shown list' are expected to be empty.
+ *
* @see #assertCommandBehavior(String, String, AddressBook, boolean, List)
*/
private void assertCommandBehavior(String inputCommand, String expectedMessage) throws Exception {
@@ -84,36 +92,36 @@ private void assertCommandBehavior(String inputCommand, String expectedMessage)
/**
* Executes the command and confirms that the result message is correct and
* also confirms that the following three parts of the Logic object's state are as expected:
- * - the internal address book data are same as those in the {@code expectedAddressBook}
- * - the internal 'last shown list' matches the {@code expectedLastList}
- * - the storage file content matches data in {@code expectedAddressBook}
+ * - the internal address book data are same as those in the {@code expectedAddressBook}
+ * - the internal 'last shown list' matches the {@code expectedLastList}
+ * - the storage file content matches data in {@code expectedAddressBook}
*/
private void assertCommandBehavior(String inputCommand,
- String expectedMessage,
- AddressBook expectedAddressBook,
- boolean isRelevantPersonsExpected,
- List extends ReadOnlyPerson> lastPersonList) throws Exception {
+ String expectedMessage,
+ AddressBook expectedAddressBook,
+ boolean isRelevantPlayersExpected,
+ List extends ReadOnlyPlayer> lastPlayerList) throws Exception {
//Execute the command
CommandResult r = logic.execute(inputCommand);
//Confirm the result contains the right data
assertEquals(expectedMessage, r.feedbackToUser);
- assertEquals(r.getRelevantPersons().isPresent(), isRelevantPersonsExpected);
- if (isRelevantPersonsExpected) {
- assertEquals(lastPersonList, r.getRelevantPersons().get());
+ assertEquals(r.getRelevantPlayers().isPresent(), isRelevantPlayersExpected);
+ if (isRelevantPlayersExpected) {
+ assertEquals(lastPlayerList, r.getRelevantPlayers().get());
}
//Confirm the state of data is as expected
assertEquals(expectedAddressBook, addressBook);
- assertEquals(lastPersonList, logic.getLastPersonShownList());
+ assertEquals(lastPlayerList, logic.getLastPlayerShownList());
assertEquals(addressBook, saveFile.load());
}
@Test
public void execute_unknownCommandWord() throws Exception {
- String unknownCommand = "uicfhmowqewca";
+ String unknownCommand = "thisisnonsensebutyeahwhocares";
assertCommandBehavior(unknownCommand, HelpCommand.MESSAGE_ALL_USAGES);
}
@@ -130,10 +138,10 @@ public void execute_exit() throws Exception {
@Test
public void execute_clear() throws Exception {
TestDataHelper helper = new TestDataHelper();
- addressBook.addPerson(helper.generatePerson(1, true));
- addressBook.addPerson(helper.generatePerson(2, true));
- addressBook.addPerson(helper.generatePerson(3, true));
-
+ addressBook.addPlayer(helper.generatePlayer(1));
+ addressBook.addPlayer(helper.generatePlayer(2));
+ addressBook.addPlayer(helper.generatePlayer(3));
+ addressBook.addPlayer(helper.generatePlayer(4));
assertCommandBehavior("clear", ClearCommand.MESSAGE_SUCCESS, AddressBook.empty(),
false, Collections.emptyList());
}
@@ -141,43 +149,148 @@ public void execute_clear() throws Exception {
@Test
public void execute_add_invalidArgsFormat() throws Exception {
String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE);
+
+ // anyhow argument
+ assertCommandBehavior(
+ "addPlayer wrong args wrong args", expectedMessage);
+
+ //no position prefix
+ assertCommandBehavior(
+ "addPlayer Valid Name Striker a/30 sal/20000 gs/0 "
+ + "ga/0 tm/validTeam.butNoPositionPrefix ctry/China "
+ + "jn/9 app/0 hs/Healthy", expectedMessage);
+
+ //no age prefix
assertCommandBehavior(
- "add wrong args wrong args", expectedMessage);
+ "addPlayer Valid Name p/Striker 30 sal/20000 gs/0 "
+ + "ga/0 tm/validTeam.butNoAgePrefix ctry/China "
+ + "jn/9 app/0 hs/Healthy", expectedMessage);
+
+ //no salary prefix
+ assertCommandBehavior(
+ "addPlayer Valid Name p/Striker a/30 20000 gs/0 "
+ + "ga/0 tm/validTeam.butNoSalaryPrefix ctry/China "
+ + "jn/9 app/0 hs/Healthy", expectedMessage);
+
+ //no goals scored prefix
assertCommandBehavior(
- "add Valid Name 12345 e/valid@email.butNoPhonePrefix a/valid, address", expectedMessage);
+ "addPlayer Valid Name p/Striker a/30 sal/20000 0 "
+ + "ga/0 tm/validTeam.butNoGoalsScoredPrefix ctry/China "
+ + "jn/9 app/0 hs/Healthy", expectedMessage);
+
+ //no goals assisted prefix
assertCommandBehavior(
- "add Valid Name p/12345 valid@email.butNoPrefix a/valid, address", expectedMessage);
+ "addPlayer Valid Name p/Striker a/30 sal/20000 gs/0 "
+ + "0 tm/validTeam.butNoGoalsAssistedPrefix ctry/China "
+ + "jn/9 app/0 hs/Healthy", expectedMessage);
+
+ //no team prefix
assertCommandBehavior(
- "add Valid Name p/12345 e/valid@email.butNoAddressPrefix valid, address", expectedMessage);
+ "addPlayer Valid Name p/Striker a/30 sal/20000 gs/0 "
+ + "ga/0 validTeam.butNoPrefix ctry/China "
+ + "jn/9 app/0 hs/Healthy", expectedMessage);
+
+ //no country prefix
+ assertCommandBehavior(
+ "addPlayer Valid Name p/Striker a/30 sal/20000 gs/0 "
+ + "ga/0 tm/validTeam.butNoCountryPrefix China "
+ + "jn/9 app/0 hs/Healthy", expectedMessage);
+
+ //no jersey number prefix
+ assertCommandBehavior(
+ "addPlayer Valid Name p/Striker a/30 sal/20000 gs/0 "
+ + "ga/0 tm/validTeam.butNoJerseyNumberPrefix ctry/China "
+ + "9 app/0 hs/Healthy", expectedMessage);
+
+ //no appearance prefix
+ assertCommandBehavior(
+ "addPlayer Valid Name p/Striker a/30 sal/20000 gs/0 "
+ + "ga/0 tm/validTeam.butNoAppearancePrefix ctry/China "
+ + "jn/9 0 hs/Healthy", expectedMessage);
+
+ //no health status prefix
+ assertCommandBehavior(
+ "addPlayer Valid Name p/Striker a/30 sal/20000 gs/0 "
+ + "ga/0 tm/validTeam.butNoHealthStatusPrefix ctry/China "
+ + "jn/9 app/0 Healthy", expectedMessage);
}
@Test
- public void execute_add_invalidPersonData() throws Exception {
+ public void execute_addFast_invalidArgsFormat() throws Exception {
+ String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddFastCommand.MESSAGE_USAGE);
+
assertCommandBehavior(
- "add []\\[;] p/12345 e/valid@e.mail a/valid, address", Name.MESSAGE_NAME_CONSTRAINTS);
+ "addFast ValidName Striker a/30 sal/20000 tm/FC_NUS.butNoPositionPrefix ctry/Singapore jn/10",
+ expectedMessage);
+
assertCommandBehavior(
- "add Valid Name p/not_numbers e/valid@e.mail a/valid, address", Phone.MESSAGE_PHONE_CONSTRAINTS);
+ "addFast ValidName p/Striker 30 sal/20000 tm/FC_NUS.butNoAgePrefix ctry/Singapore jn/10",
+ expectedMessage);
+
assertCommandBehavior(
- "add Valid Name p/12345 e/notAnEmail a/valid, address", Email.MESSAGE_EMAIL_CONSTRAINTS);
+ "addFast ValidName p/Striker a/30 20000 tm/FC_NUS.butNoSalaryPrefix ctry/Singapore jn/10",
+ expectedMessage);
+
assertCommandBehavior(
- "add Valid Name p/12345 e/valid@e.mail a/valid, address t/invalid_-[.tag", Tag.MESSAGE_TAG_CONSTRAINTS);
+ "addFast ValidName p/Striker a/30 sal/20000 FC_NUS.butNoPrefix ctry/Singapore jn/10",
+ expectedMessage);
+ assertCommandBehavior(
+ "addFast ValidName p/Striker a/30 sal/20000 tm/FC_NUS.butNoCountryPrefix Singapore jn/10",
+ expectedMessage);
+
+ assertCommandBehavior(
+ "addFast ValidName p/Striker a/30 sal/20000 tm/FC_NUS.butNoJerseyNumberPrefix ctry/Singapore 10",
+ expectedMessage);
+
+ }
+
+
+ @Test
+ public void execute_add_invalidPlayerData() throws Exception {
+ assertCommandBehavior(
+ "addPlayer []\\[;] p/Striker a/30 sal/20000 gs/0 ga/0 tm/validTeam ctry/China"
+ + "jn/9 app/0 hs/Healthy", Name.MESSAGE_NAME_CONSTRAINTS);
+ assertCommandBehavior(
+ "addPlayer Valid Name p/Striker a/thirty sal/20000 gs/0 ga/0 tm/validTeam ctry/China "
+ + "jn/9 app/0 hs/Healthy", Age.MESSAGE_AGE_CONSTRAINTS);
+ assertCommandBehavior(
+ "addPlayer Valid Name p/Striker a/30 sal/zero gs/0 ga/0 tm/validTeam ctry/China "
+ + "jn/9 app/0 hs/Healthy", Salary.MESSAGE_SALARY_CONSTRAINTS);
+ assertCommandBehavior(
+ "addPlayer Valid Name p/Striker a/30 sal/20000 gs/zero ga/0 tm/validTeam ctry/China "
+ + "jn/9 app/0 hs/Healthy", GoalsScored.MESSAGE_GS_CONSTRAINTS);
+ assertCommandBehavior(
+ "addPlayer Valid Name p/Striker a/30 sal/20000 gs/0 ga/zero tm/validTeam ctry/China "
+ + "jn/9 app/0 hs/Healthy", GoalsAssisted.MESSAGE_GA_CONSTRAINTS);
+ assertCommandBehavior(
+ "addPlayer Valid Name p/Striker a/30 sal/20000 gs/0 ga/0 tm/validTeam ctry/China "
+ + "jn/50 app/0 hs/Healthy", JerseyNumber.MESSAGE_JN_CONSTRAINTS);
+ assertCommandBehavior(
+ "addPlayer Valid Name p/Striker a/30 sal/20000 gs/0 ga/0 tm/validTeam ctry/China "
+ + "jn/nine app/0 hs/Healthy", JerseyNumber.MESSAGE_JN_CONSTRAINTS);
+ assertCommandBehavior(
+ "addPlayer Valid Name p/Striker a/30 sal/20000 gs/0 ga/0 tm/validTeam ctry/China "
+ + "jn/9 app/zero hs/Healthy", Appearance.MESSAGE_APPEARANCE_CONSTRAINTS);
+ assertCommandBehavior(
+ "addPlayer Valid Name p/Striker a/30 sal/20000 gs/0 ga/0 tm/validTeam ctry/China "
+ + "jn/9 app/0 hs/Healthy t/invalid_-[.tag", Tag.MESSAGE_TAG_CONSTRAINTS);
}
@Test
public void execute_add_successful() throws Exception {
// setup expectations
TestDataHelper helper = new TestDataHelper();
- Person toBeAdded = helper.adam();
+ Player toBeAdded = helper.messi();
AddressBook expectedAb = new AddressBook();
- expectedAb.addPerson(toBeAdded);
+ expectedAb.addPlayer(toBeAdded);
// execute command and verify result
assertCommandBehavior(helper.generateAddCommand(toBeAdded),
- String.format(AddCommand.MESSAGE_SUCCESS, toBeAdded),
- expectedAb,
- false,
- Collections.emptyList());
+ String.format(AddCommand.MESSAGE_SUCCESS, toBeAdded),
+ expectedAb,
+ false,
+ Collections.emptyList());
}
@@ -185,17 +298,17 @@ public void execute_add_successful() throws Exception {
public void execute_addDuplicate_notAllowed() throws Exception {
// setup expectations
TestDataHelper helper = new TestDataHelper();
- Person toBeAdded = helper.adam();
+ Player toBeAdded = helper.messi();
AddressBook expectedAb = new AddressBook();
- expectedAb.addPerson(toBeAdded);
+ expectedAb.addPlayer(toBeAdded);
// setup starting state
- addressBook.addPerson(toBeAdded); // player already in internal address book
+ addressBook.addPlayer(toBeAdded); // player already in internal address book
// execute command and verify result
assertCommandBehavior(
helper.generateAddCommand(toBeAdded),
- AddCommand.MESSAGE_DUPLICATE_PERSON,
+ AddCommand.MESSAGE_DUPLICATE_PLAYER,
expectedAb,
false,
Collections.emptyList());
@@ -206,92 +319,36 @@ public void execute_addDuplicate_notAllowed() throws Exception {
public void execute_list_showsAllPersons() throws Exception {
// prepare expectations
TestDataHelper helper = new TestDataHelper();
- AddressBook expectedAb = helper.generateAddressBook(false, true);
- List extends ReadOnlyPerson> expectedList = expectedAb.getAllPersons().immutableListView();
+ AddressBook expectedAb = helper.generateAddressBook(2);
+ List extends ReadOnlyPlayer> expectedList = expectedAb.getAllPlayers().immutableListView();
// prepare address book state
- helper.addToAddressBook(addressBook, false, true);
+ helper.addToAddressBook(addressBook, 2);
assertCommandBehavior("list",
- Command.getMessageForPersonListShownSummary(expectedList),
- expectedAb,
- true,
- expectedList);
- }
-
- @Test
- public void execute_view_invalidArgsFormat() throws Exception {
- String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, ViewCommand.MESSAGE_USAGE);
- assertCommandBehavior("view ", expectedMessage);
- assertCommandBehavior("view arg not number", expectedMessage);
+ Command.getMessageForPlayerListShownSummary(expectedList),
+ expectedAb,
+ true,
+ expectedList);
}
- @Test
- public void execute_view_invalidIndex() throws Exception {
- assertInvalidIndexBehaviorForCommand("view");
- }
/**
* Confirms the 'invalid argument index number behaviour' for the given command
* targeting a single player in the last shown list, using visible index.
+ *
* @param commandWord to test assuming it targets a single player in the last shown list based on visible index.
*/
private void assertInvalidIndexBehaviorForCommand(String commandWord) throws Exception {
- String expectedMessage = Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX;
- TestDataHelper helper = new TestDataHelper();
- List lastPersonList = helper.generatePersonList(false, true);
-
- logic.setLastPersonShownList(lastPersonList);
-
- assertCommandBehavior(commandWord + " -1", expectedMessage, AddressBook.empty(), false, lastPersonList);
- assertCommandBehavior(commandWord + " 0", expectedMessage, AddressBook.empty(), false, lastPersonList);
- assertCommandBehavior(commandWord + " 3", expectedMessage, AddressBook.empty(), false, lastPersonList);
-
- }
-
- @Test
- public void execute_view_onlyShowsNonPrivate() throws Exception {
-
- TestDataHelper helper = new TestDataHelper();
- Person p1 = helper.generatePerson(1, true);
- Person p2 = helper.generatePerson(2, false);
- List lastPersonList = helper.generatePersonList(p1, p2);
- AddressBook expectedAb = helper.generateAddressBook(lastPersonList);
- helper.addToAddressBook(addressBook, lastPersonList);
-
- logic.setLastPersonShownList(lastPersonList);
-
- assertCommandBehavior("view 1",
- String.format(ViewCommand.MESSAGE_VIEW_PERSON_DETAILS, p1.getAsTextHidePrivate()),
- expectedAb,
- false,
- lastPersonList);
-
- assertCommandBehavior("view 2",
- String.format(ViewCommand.MESSAGE_VIEW_PERSON_DETAILS, p2.getAsTextHidePrivate()),
- expectedAb,
- false,
- lastPersonList);
- }
-
- @Test
- public void execute_tryToViewMissingPerson_errorMessage() throws Exception {
+ String expectedMessage = Messages.MESSAGE_INVALID_PLAYER_DISPLAYED_INDEX;
TestDataHelper helper = new TestDataHelper();
- Person p1 = helper.generatePerson(1, false);
- Person p2 = helper.generatePerson(2, false);
- List lastPersonList = helper.generatePersonList(p1, p2);
+ List lastPlayerList = helper.generatePlayerList(2);
- AddressBook expectedAb = new AddressBook();
- expectedAb.addPerson(p2);
+ logic.setLastPlayerShownList(lastPlayerList);
- addressBook.addPerson(p2);
- logic.setLastPersonShownList(lastPersonList);
-
- assertCommandBehavior("view 1",
- Messages.MESSAGE_PERSON_NOT_IN_ADDRESSBOOK,
- expectedAb,
- false,
- lastPersonList);
+ assertCommandBehavior(commandWord + " -1", expectedMessage, AddressBook.empty(), false, lastPlayerList);
+ assertCommandBehavior(commandWord + " 0", expectedMessage, AddressBook.empty(), false, lastPlayerList);
+ assertCommandBehavior(commandWord + " 3", expectedMessage, AddressBook.empty(), false, lastPlayerList);
}
@Test
@@ -307,47 +364,23 @@ public void execute_viewAll_invalidIndex() throws Exception {
}
@Test
- public void execute_viewAll_alsoShowsPrivate() throws Exception {
- TestDataHelper helper = new TestDataHelper();
- Person p1 = helper.generatePerson(1, true);
- Person p2 = helper.generatePerson(2, false);
- List lastPersonList = helper.generatePersonList(p1, p2);
- AddressBook expectedAb = helper.generateAddressBook(lastPersonList);
- helper.addToAddressBook(addressBook, lastPersonList);
-
- logic.setLastPersonShownList(lastPersonList);
-
- assertCommandBehavior("viewall 1",
- String.format(ViewCommand.MESSAGE_VIEW_PERSON_DETAILS, p1.getAsTextShowAll()),
- expectedAb,
- false,
- lastPersonList);
-
- assertCommandBehavior("viewall 2",
- String.format(ViewCommand.MESSAGE_VIEW_PERSON_DETAILS, p2.getAsTextShowAll()),
- expectedAb,
- false,
- lastPersonList);
- }
-
- @Test
- public void execute_tryToViewAllPersonMissingInAddressBook_errorMessage() throws Exception {
+ public void execute_tryToViewAllPlayerMissingInAddressBook_errorMessage() throws Exception {
TestDataHelper helper = new TestDataHelper();
- Person p1 = helper.generatePerson(1, false);
- Person p2 = helper.generatePerson(2, false);
- List lastPersonList = helper.generatePersonList(p1, p2);
+ Player p1 = helper.generatePlayer(1);
+ Player p2 = helper.generatePlayer(2);
+ List lastPlayerList = helper.generatePlayerList(p1, p2);
AddressBook expectedAb = new AddressBook();
- expectedAb.addPerson(p1);
+ expectedAb.addPlayer(p1);
- addressBook.addPerson(p1);
- logic.setLastPersonShownList(lastPersonList);
+ addressBook.addPlayer(p1);
+ logic.setLastPlayerShownList(lastPlayerList);
assertCommandBehavior("viewall 2",
- Messages.MESSAGE_PERSON_NOT_IN_ADDRESSBOOK,
- expectedAb,
- false,
- lastPersonList);
+ Messages.MESSAGE_PLAYER_NOT_IN_LEAGUE,
+ expectedAb,
+ false,
+ lastPlayerList);
}
@Test
@@ -365,48 +398,47 @@ public void execute_delete_invalidIndex() throws Exception {
@Test
public void execute_delete_removesCorrectPerson() throws Exception {
TestDataHelper helper = new TestDataHelper();
- Person p1 = helper.generatePerson(1, false);
- Person p2 = helper.generatePerson(2, true);
- Person p3 = helper.generatePerson(3, true);
+ Player p1 = helper.generatePlayer(1);
+ Player p2 = helper.generatePlayer(2);
+ Player p3 = helper.generatePlayer(3);
- List threePersons = helper.generatePersonList(p1, p2, p3);
+ List threePlayers = helper.generatePlayerList(p1, p2, p3);
- AddressBook expectedAb = helper.generateAddressBook(threePersons);
- expectedAb.removePerson(p2);
+ AddressBook expectedAb = helper.generateAddressBook(threePlayers);
+ expectedAb.removePlayer(p2);
-
- helper.addToAddressBook(addressBook, threePersons);
- logic.setLastPersonShownList(threePersons);
+ helper.addToAddressBook(addressBook, threePlayers);
+ logic.setLastPlayerShownList(threePlayers);
assertCommandBehavior("delete 2",
- String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, p2),
- expectedAb,
- false,
- threePersons);
+ String.format(DeleteCommand.MESSAGE_DELETE_PLAYER_SUCCESS, p2),
+ expectedAb,
+ false,
+ threePlayers);
}
@Test
public void execute_delete_missingInAddressBook() throws Exception {
TestDataHelper helper = new TestDataHelper();
- Person p1 = helper.generatePerson(1, false);
- Person p2 = helper.generatePerson(2, true);
- Person p3 = helper.generatePerson(3, true);
+ Player p1 = helper.generatePlayer(1);
+ Player p2 = helper.generatePlayer(2);
+ Player p3 = helper.generatePlayer(3);
- List threePersons = helper.generatePersonList(p1, p2, p3);
+ List threePlayers = helper.generatePlayerList(p1, p2, p3);
- AddressBook expectedAb = helper.generateAddressBook(threePersons);
- expectedAb.removePerson(p2);
+ AddressBook expectedAb = helper.generateAddressBook(threePlayers);
+ expectedAb.removePlayer(p2);
- helper.addToAddressBook(addressBook, threePersons);
- addressBook.removePerson(p2);
- logic.setLastPersonShownList(threePersons);
+ helper.addToAddressBook(addressBook, threePlayers);
+ addressBook.removePlayer(p2);
+ logic.setLastPlayerShownList(threePlayers);
assertCommandBehavior("delete 2",
- Messages.MESSAGE_PERSON_NOT_IN_ADDRESSBOOK,
- expectedAb,
- false,
- threePersons);
+ Messages.MESSAGE_PLAYER_NOT_IN_LEAGUE,
+ expectedAb,
+ false,
+ threePlayers);
}
@Test
@@ -418,61 +450,61 @@ public void execute_find_invalidArgsFormat() throws Exception {
@Test
public void execute_find_onlyMatchesFullWordsInNames() throws Exception {
TestDataHelper helper = new TestDataHelper();
- Person pTarget1 = helper.generatePersonWithName("bla bla KEY bla");
- Person pTarget2 = helper.generatePersonWithName("bla KEY bla bceofeia");
- Person p1 = helper.generatePersonWithName("KE Y");
- Person p2 = helper.generatePersonWithName("KEYKEYKEY sduauo");
+ Player pTarget1 = helper.generatePlayerWithName("bla bla KEY bla");
+ Player pTarget2 = helper.generatePlayerWithName("bla KEY bla bceofeia");
+ Player p1 = helper.generatePlayerWithName("KE Y");
+ Player p2 = helper.generatePlayerWithName("KEYKEYKEY sduauo");
- List fourPersons = helper.generatePersonList(p1, pTarget1, p2, pTarget2);
- AddressBook expectedAb = helper.generateAddressBook(fourPersons);
- List expectedList = helper.generatePersonList(pTarget1, pTarget2);
- helper.addToAddressBook(addressBook, fourPersons);
+ List fourPlayers = helper.generatePlayerList(p1, pTarget1, p2, pTarget2);
+ AddressBook expectedAb = helper.generateAddressBook(fourPlayers);
+ List expectedList = helper.generatePlayerList(pTarget1, pTarget2);
+ helper.addToAddressBook(addressBook, fourPlayers);
assertCommandBehavior("find KEY",
- Command.getMessageForPersonListShownSummary(expectedList),
- expectedAb,
- true,
- expectedList);
+ Command.getMessageForPlayerListShownSummary(expectedList),
+ expectedAb,
+ true,
+ expectedList);
}
@Test
public void execute_find_isCaseSensitive() throws Exception {
TestDataHelper helper = new TestDataHelper();
- Person pTarget1 = helper.generatePersonWithName("bla bla KEY bla");
- Person pTarget2 = helper.generatePersonWithName("bla KEY bla bceofeia");
- Person p1 = helper.generatePersonWithName("key key");
- Person p2 = helper.generatePersonWithName("KEy sduauo");
+ Player pTarget1 = helper.generatePlayerWithName("bla bla KEY bla");
+ Player pTarget2 = helper.generatePlayerWithName("bla KEY bla bceofeia");
+ Player p1 = helper.generatePlayerWithName("key key");
+ Player p2 = helper.generatePlayerWithName("KEy sduauo");
- List fourPersons = helper.generatePersonList(p1, pTarget1, p2, pTarget2);
- AddressBook expectedAb = helper.generateAddressBook(fourPersons);
- List expectedList = helper.generatePersonList(pTarget1, pTarget2);
- helper.addToAddressBook(addressBook, fourPersons);
+ List fourPlayers = helper.generatePlayerList(p1, pTarget1, p2, pTarget2);
+ AddressBook expectedAb = helper.generateAddressBook(fourPlayers);
+ List expectedList = helper.generatePlayerList(pTarget1, pTarget2);
+ helper.addToAddressBook(addressBook, fourPlayers);
assertCommandBehavior("find KEY",
- Command.getMessageForPersonListShownSummary(expectedList),
- expectedAb,
- true,
- expectedList);
+ Command.getMessageForPlayerListShownSummary(expectedList),
+ expectedAb,
+ true,
+ expectedList);
}
@Test
public void execute_find_matchesIfAnyKeywordPresent() throws Exception {
TestDataHelper helper = new TestDataHelper();
- Person pTarget1 = helper.generatePersonWithName("bla bla KEY bla");
- Person pTarget2 = helper.generatePersonWithName("bla rAnDoM bla bceofeia");
- Person p1 = helper.generatePersonWithName("key key");
- Person p2 = helper.generatePersonWithName("KEy sduauo");
+ Player pTarget1 = helper.generatePlayerWithName("bla bla KEY bla");
+ Player pTarget2 = helper.generatePlayerWithName("bla rAnDoM bla bceofeia");
+ Player p1 = helper.generatePlayerWithName("key key");
+ Player p2 = helper.generatePlayerWithName("KEy sduauo");
- List fourPersons = helper.generatePersonList(p1, pTarget1, p2, pTarget2);
- AddressBook expectedAb = helper.generateAddressBook(fourPersons);
- List expectedList = helper.generatePersonList(pTarget1, pTarget2);
- helper.addToAddressBook(addressBook, fourPersons);
+ List fourPlayers = helper.generatePlayerList(p1, pTarget1, p2, pTarget2);
+ AddressBook expectedAb = helper.generateAddressBook(fourPlayers);
+ List expectedList = helper.generatePlayerList(pTarget1, pTarget2);
+ helper.addToAddressBook(addressBook, fourPlayers);
assertCommandBehavior("find KEY rAnDoM",
- Command.getMessageForPersonListShownSummary(expectedList),
- expectedAb,
- true,
- expectedList);
+ Command.getMessageForPlayerListShownSummary(expectedList),
+ expectedAb,
+ true,
+ expectedList);
}
/**
@@ -482,15 +514,24 @@ class TestDataHelper {
/**
* generate a person with the stated parameters
*/
- Person adam() throws Exception {
- Name name = new Name("Adam Brown");
- Phone privatePhone = new Phone("111111", true);
- Email email = new Email("adam@gmail.com", false);
- Address privateAddress = new Address("111, alpha street", true);
+ Player messi() throws Exception {
+ Name name = new Name("Lionel Messi");
+ PositionPlayed positionPlayed = new PositionPlayed("RW");
+ Age age = new Age("30");
+ Salary sal = new Salary("2000000");
+ GoalsScored goalsScored = new GoalsScored("30");
+ GoalsAssisted goalsAssisted = new GoalsAssisted("20");
+ Team team = new Team("FC Barcelona");
+ Country country = new Country("Argentina");
+ JerseyNumber jerseyNumber = new JerseyNumber("10");
+ Appearance appearance = new Appearance("54");
+ HealthStatus healthStatus = new HealthStatus("Healthy");
+
Tag tag1 = new Tag("tag1");
Tag tag2 = new Tag("tag2");
Set tags = new HashSet<>(Arrays.asList(tag1, tag2));
- return new Person(name, privatePhone, email, privateAddress, tags);
+ return new Player(name, positionPlayed, age, sal, goalsScored, goalsAssisted,
+ team, country, jerseyNumber, appearance, healthStatus, tags);
}
/**
@@ -499,110 +540,118 @@ Person adam() throws Exception {
* Each unique seed will generate a unique Person object.
*
* @param seed used to generate the player data field values
- * @param isAllFieldsPrivate determines if private-able fields (phone, email, address) will be private
*/
- Person generatePerson(int seed, boolean isAllFieldsPrivate) throws Exception {
- return new Person(
- new Name("Person " + seed),
- new Phone("" + Math.abs(seed), isAllFieldsPrivate),
- new Email(seed + "@email", isAllFieldsPrivate),
- new Address("House of " + seed, isAllFieldsPrivate),
+ Player generatePlayer(int seed) throws Exception {
+ return new Player(
+ new Name("Player " + seed),
+ new PositionPlayed("Position" + seed),
+ new Age("" + Math.abs(seed)),
+ new Salary("" + Math.abs(seed)),
+ new Team("Team" + Math.abs(seed)),
+ new Country("Country" + Math.abs(seed)),
+ new JerseyNumber("" + (Math.abs(seed) % 35)),
new HashSet<>(Arrays.asList(new Tag("tag" + Math.abs(seed)), new Tag("tag" + Math.abs(seed + 1))))
);
}
- /** Generates the correct add command based on the player given */
- String generateAddCommand(Person p) {
+ /**
+ * Generates the correct add command based on the player given
+ */
+ String generateAddCommand(Player p) {
StringJoiner cmd = new StringJoiner(" ");
- cmd.add("add");
-
+ cmd.add("addPlayer");
cmd.add(p.getName().toString());
- cmd.add((p.getPhone().isPrivate() ? "pp/" : "p/") + p.getPhone());
- cmd.add((p.getEmail().isPrivate() ? "pe/" : "e/") + p.getEmail());
- cmd.add((p.getAddress().isPrivate() ? "pa/" : "a/") + p.getAddress());
-
+ cmd.add(" p/" + p.getPositionPlayed().toString());
+ cmd.add(" a/" + p.getAge().toString());
+ cmd.add(" sal/" + p.getSalary().toString());
+ cmd.add(" gs/" + p.getGoalsScored().toString());
+ cmd.add(" ga/" + p.getGoalsAssisted().toString());
+ cmd.add(" tm/" + p.getTeam().toString());
+ cmd.add(" ctry/" + p.getCountry().toString());
+ cmd.add(" jn/" + p.getJerseyNumber().toString());
+ cmd.add(" app/" + p.getAppearance().toString());
+ cmd.add(" hs/" + p.getHealthStatus().toString());
Set tags = p.getTags();
- for (Tag t: tags) {
+ for (Tag t : tags) {
cmd.add("t/" + t.tagName);
}
-
return cmd.toString();
}
/**
* Generates an AddressBook with auto-generated persons.
- * @param isPrivateStatuses flags to indicate if all contact details of respective persons should be set to
- * private.
+ *
+ * @param num to indicate the number of player profiles that should be included in the League Tracker.
*/
- AddressBook generateAddressBook(Boolean... isPrivateStatuses) throws Exception {
+ AddressBook generateAddressBook(int num) throws Exception {
AddressBook addressBook = new AddressBook();
- addToAddressBook(addressBook, isPrivateStatuses);
+ addToAddressBook(addressBook, num);
return addressBook;
}
/**
* Generates an AddressBook based on the list of Persons given.
*/
- AddressBook generateAddressBook(List persons) throws Exception {
+ AddressBook generateAddressBook(List players) throws Exception {
AddressBook addressBook = new AddressBook();
- addToAddressBook(addressBook, persons);
+ addToAddressBook(addressBook, players);
return addressBook;
}
/**
* Adds auto-generated Person objects to the given AddressBook
+ *
* @param addressBook The AddressBook to which the Persons will be added
- * @param isPrivateStatuses flags to indicate if all contact details of generated persons should be set to
- * private.
+ * @param num to indicate the number of players profiles that should exist in the League Tracker.
*/
- void addToAddressBook(AddressBook addressBook, Boolean... isPrivateStatuses) throws Exception {
- addToAddressBook(addressBook, generatePersonList(isPrivateStatuses));
+ void addToAddressBook(AddressBook addressBook, int num) throws Exception {
+ addToAddressBook(addressBook, generatePlayerList(num));
}
/**
* Adds the given list of Persons to the given AddressBook
*/
- void addToAddressBook(AddressBook addressBook, List personsToAdd) throws Exception {
- for (Person p: personsToAdd) {
- addressBook.addPerson(p);
+ void addToAddressBook(AddressBook addressBook, List playersToAdd) throws Exception {
+ for (Player p : playersToAdd) {
+ addressBook.addPlayer(p);
}
}
/**
* Creates a list of Persons based on the give Person objects.
*/
- List generatePersonList(Person... persons) throws Exception {
- List personList = new ArrayList<>();
- for (Person p: persons) {
+ List generatePlayerList(Player... players) throws Exception {
+ List personList = new ArrayList<>();
+ for (Player p : players) {
personList.add(p);
}
return personList;
}
/**
- * Generates a list of Persons based on the flags.
- * @param isPrivateStatuses flags to indicate if all contact details of respective persons should be set to
- * private.
+ * Generates a list of Persons based on the number given.
*/
- List generatePersonList(Boolean... isPrivateStatuses) throws Exception {
- List persons = new ArrayList<>();
- int i = 1;
- for (Boolean p: isPrivateStatuses) {
- persons.add(generatePerson(i++, p));
+ List generatePlayerList(int num) throws Exception {
+ List players = new ArrayList<>();
+ for (int j = 1; j <= num; j++) {
+ players.add(generatePlayer(j));
}
- return persons;
+ return players;
}
/**
* Generates a Person object with given name. Other fields will have some dummy values.
*/
- Person generatePersonWithName(String name) throws Exception {
- return new Person(
+ Player generatePlayerWithName(String name) throws Exception {
+ return new Player(
new Name(name),
- new Phone("1", false),
- new Email("1@email", false),
- new Address("House of 1", false),
+ new PositionPlayed("Striker"),
+ new Age("25"),
+ new Salary("20000"),
+ new Team("FC Barcelona"),
+ new Country("Argentina"),
+ new JerseyNumber("10"),
Collections.singleton(new Tag("tag"))
);
}
diff --git a/test/java/seedu/addressbook/parser/ParserTest.java b/test/java/seedu/addressbook/parser/ParserTest.java
index 5d9803d21..95c1e95ed 100644
--- a/test/java/seedu/addressbook/parser/ParserTest.java
+++ b/test/java/seedu/addressbook/parser/ParserTest.java
@@ -11,24 +11,30 @@
import org.junit.Before;
import org.junit.Test;
-import seedu.addressbook.commands.AddCommand;
-import seedu.addressbook.commands.ClearCommand;
import seedu.addressbook.commands.Command;
-import seedu.addressbook.commands.DeleteCommand;
import seedu.addressbook.commands.ExitCommand;
-import seedu.addressbook.commands.FindCommand;
import seedu.addressbook.commands.HelpCommand;
import seedu.addressbook.commands.IncorrectCommand;
-import seedu.addressbook.commands.ListCommand;
-import seedu.addressbook.commands.ViewAllCommand;
-import seedu.addressbook.commands.ViewCommand;
+import seedu.addressbook.commands.player.AddCommand;
+import seedu.addressbook.commands.player.ClearCommand;
+import seedu.addressbook.commands.player.DeleteCommand;
+import seedu.addressbook.commands.player.FindCommand;
+import seedu.addressbook.commands.player.ListCommand;
+import seedu.addressbook.commands.player.ViewAllCommand;
import seedu.addressbook.data.exception.IllegalValueException;
-import seedu.addressbook.data.player.Address;
-import seedu.addressbook.data.player.Email;
+import seedu.addressbook.data.player.Age;
+import seedu.addressbook.data.player.Appearance;
+import seedu.addressbook.data.player.Country;
+import seedu.addressbook.data.player.GoalsAssisted;
+import seedu.addressbook.data.player.GoalsScored;
+import seedu.addressbook.data.player.HealthStatus;
+import seedu.addressbook.data.player.JerseyNumber;
import seedu.addressbook.data.player.Name;
-import seedu.addressbook.data.player.Person;
-import seedu.addressbook.data.player.Phone;
-import seedu.addressbook.data.player.ReadOnlyPerson;
+import seedu.addressbook.data.player.Player;
+import seedu.addressbook.data.player.PositionPlayed;
+import seedu.addressbook.data.player.ReadOnlyPlayer;
+import seedu.addressbook.data.player.Salary;
+import seedu.addressbook.data.player.Team;
import seedu.addressbook.data.tag.Tag;
public class ParserTest {
@@ -42,14 +48,14 @@ public void setup() {
@Test
public void emptyInput_returnsIncorrect() {
- final String[] emptyInputs = { "", " ", "\n \n" };
+ final String[] emptyInputs = {"", " ", "\n \n"};
final String resultMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, HelpCommand.MESSAGE_USAGE);
parseAndAssertIncorrectWithMessage(resultMessage, emptyInputs);
}
@Test
public void unknownCommandWord_returnsHelp() {
- final String input = "unknowncommandword arguments arguments";
+ final String input = "anyhowcommandword arguments arguments";
parseAndAssertCommandType(input, HelpCommand.class);
}
@@ -85,14 +91,14 @@ public void exitCommand_parsedCorrectly() {
*/
@Test
public void deleteCommand_noArgs() {
- final String[] inputs = { "delete", "delete " };
+ final String[] inputs = {"delete", "delete "};
final String resultMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteCommand.MESSAGE_USAGE);
parseAndAssertIncorrectWithMessage(resultMessage, inputs);
}
@Test
public void deleteCommand_argsIsNotSingleNumber() {
- final String[] inputs = { "delete notAnumber ", "delete 8*wh12", "delete 1 2 3 4 5" };
+ final String[] inputs = {"delete notANumber ", "delete 8*wh12", "delete 1 2 3 4 5"};
final String resultMessage;
resultMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteCommand.MESSAGE_USAGE);
parseAndAssertIncorrectWithMessage(resultMessage, inputs);
@@ -106,31 +112,9 @@ public void deleteCommand_numericArg_indexParsedCorrectly() {
assertEquals(result.getTargetIndex(), testIndex);
}
- @Test
- public void viewCommand_noArgs() {
- final String[] inputs = { "view", "view " };
- final String resultMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, ViewCommand.MESSAGE_USAGE);
- parseAndAssertIncorrectWithMessage(resultMessage, inputs);
- }
-
- @Test
- public void viewCommand_argsIsNotSingleNumber() {
- final String[] inputs = { "view notAnumber ", "view 8*wh12", "view 1 2 3 4 5" };
- final String resultMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, ViewCommand.MESSAGE_USAGE);
- parseAndAssertIncorrectWithMessage(resultMessage, inputs);
- }
-
- @Test
- public void viewCommand_numericArg_indexParsedCorrectly() {
- final int testIndex = 2;
- final String input = "view " + testIndex;
- final ViewCommand result = parseAndAssertCommandType(input, ViewCommand.class);
- assertEquals(result.getTargetIndex(), testIndex);
- }
-
@Test
public void viewAllCommand_noArgs() {
- final String[] inputs = { "viewall", "viewall " };
+ final String[] inputs = {"viewall", "viewall "};
final String resultMessage =
String.format(MESSAGE_INVALID_COMMAND_FORMAT, ViewAllCommand.MESSAGE_USAGE);
parseAndAssertIncorrectWithMessage(resultMessage, inputs);
@@ -138,7 +122,7 @@ public void viewAllCommand_noArgs() {
@Test
public void viewAllCommand_argsIsNotSingleNumber() {
- final String[] inputs = { "viewall notAnumber ", "viewall 8*wh12", "viewall 1 2 3 4 5" };
+ final String[] inputs = {"viewall notAnumber ", "viewall 8*wh12", "viewall 1 2 3 4 5"};
final String resultMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, ViewAllCommand.MESSAGE_USAGE);
parseAndAssertIncorrectWithMessage(resultMessage, inputs);
}
@@ -152,16 +136,13 @@ public void viewAllCommand_numericArg_indexParsedCorrectly() {
}
/**
- * Test find persons by keyword in name command
+ * Test find players by keyword in name command
*/
@Test
public void findCommand_invalidArgs() {
// no keywords
- final String[] inputs = {
- "find",
- "find "
- };
+ final String[] inputs = {"find", "find "};
final String resultMessage =
String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindCommand.MESSAGE_USAGE);
parseAndAssertIncorrectWithMessage(resultMessage, inputs);
@@ -169,7 +150,7 @@ public void findCommand_invalidArgs() {
@Test
public void findCommand_validArgs_parsedCorrectly() {
- final String[] keywords = { "key1", "key2", "key3" };
+ final String[] keywords = {"key1", "key2", "key3"};
final Set keySet = new HashSet<>(Arrays.asList(keywords));
final String input = "find " + String.join(" ", keySet);
@@ -180,7 +161,7 @@ public void findCommand_validArgs_parsedCorrectly() {
@Test
public void findCommand_duplicateKeys_parsedCorrectly() {
- final String[] keywords = { "key1", "key2", "key3" };
+ final String[] keywords = {"key1", "key2", "key3"};
final Set keySet = new HashSet<>(Arrays.asList(keywords));
// duplicate every keyword
@@ -195,44 +176,135 @@ public void findCommand_duplicateKeys_parsedCorrectly() {
*/
@Test
public void addCommand_invalidArgs() {
- final String[] inputs = {
- "add",
- "add ",
- "add wrong args format",
- // no phone prefix
- String.format("add $s $s e/$s a/$s", Name.EXAMPLE, Phone.EXAMPLE, Email.EXAMPLE, Address.EXAMPLE),
- // no email prefix
- String.format("add $s p/$s $s a/$s", Name.EXAMPLE, Phone.EXAMPLE, Email.EXAMPLE, Address.EXAMPLE),
- // no address prefix
- String.format("add $s p/$s e/$s $s", Name.EXAMPLE, Phone.EXAMPLE, Email.EXAMPLE, Address.EXAMPLE)
+ final String[] inputs = {"addPlayer", "addPlayer ", "addPlayer wrong args format",
+ // no position prefix
+ String.format("addPlayer %1$s %2$s a/%3$s sal/%4$s gs/%5$s "
+ + "ga/%6$s tm/%7$s ctry/%8$s jn/%9$s app/%10$s hs/%11$s",
+ Name.EXAMPLE, PositionPlayed.EXAMPLE, Age.EXAMPLE, Salary.EXAMPLE, GoalsScored.EXAMPLE,
+ GoalsAssisted.EXAMPLE, Team.EXAMPLE, Country.EXAMPLE, JerseyNumber.EXAMPLE, Appearance.EXAMPLE,
+ HealthStatus.EXAMPLE),
+
+ // no age prefix
+ String.format("addPlayer %1$s p/%2$s %3$s sal/%4$s gs/%5$s "
+ + "ga/%6$s tm/%7$s ctry/%8$s jn/%9$s app/%10$s hs/%11$s",
+ Name.EXAMPLE, PositionPlayed.EXAMPLE, Age.EXAMPLE, Salary.EXAMPLE, GoalsScored.EXAMPLE,
+ GoalsAssisted.EXAMPLE, Team.EXAMPLE, Country.EXAMPLE, JerseyNumber.EXAMPLE, Appearance.EXAMPLE,
+ HealthStatus.EXAMPLE),
+
+ // no salary prefix
+ String.format("addPlayer %1$s p/%2$s a/%3$s %4$s gs/%5$s "
+ + "ga/%6$s tm/%7$s ctry/%8$s jn/%9$s app/%10$s hs/%11$s",
+ Name.EXAMPLE, PositionPlayed.EXAMPLE, Age.EXAMPLE, Salary.EXAMPLE, GoalsScored.EXAMPLE,
+ GoalsAssisted.EXAMPLE, Team.EXAMPLE, Country.EXAMPLE, JerseyNumber.EXAMPLE, Appearance.EXAMPLE,
+ HealthStatus.EXAMPLE),
+
+ //no GoalsScored prefix
+ String.format("addPlayer %1$s p/%2$s a/%3$s sal/%4$s %5$s "
+ + "ga/%6$s tm/%7$s ctry/%8$s jn/%9$s app/%10$s hs/%11$s",
+ Name.EXAMPLE, PositionPlayed.EXAMPLE, Age.EXAMPLE, Salary.EXAMPLE, GoalsScored.EXAMPLE,
+ GoalsAssisted.EXAMPLE, Team.EXAMPLE, Country.EXAMPLE, JerseyNumber.EXAMPLE, Appearance.EXAMPLE,
+ HealthStatus.EXAMPLE),
+
+ //no GoalsAssisted prefix
+ String.format("addPlayer %1$s p/%2$s a/%3$s sal/%4$s gs/%5$s "
+ + "%6$s tm/%7$s ctry/%8$s jn/%9$s app/%10$s hs/%11$s",
+ Name.EXAMPLE, PositionPlayed.EXAMPLE, Age.EXAMPLE, Salary.EXAMPLE, GoalsScored.EXAMPLE,
+ GoalsAssisted.EXAMPLE, Team.EXAMPLE, Country.EXAMPLE, JerseyNumber.EXAMPLE, Appearance.EXAMPLE,
+ HealthStatus.EXAMPLE),
+
+ //no Team prefix
+ String.format("addPlayer %1$s p/%2$s a/%3$s sal/%4$s gs/%5$s "
+ + "ga/%6$s %7$s ctry/%8$s jn/%9$s app/%10$s hs/%11$s",
+ Name.EXAMPLE, PositionPlayed.EXAMPLE, Age.EXAMPLE, Salary.EXAMPLE, GoalsScored.EXAMPLE,
+ GoalsAssisted.EXAMPLE, Team.EXAMPLE, Country.EXAMPLE, JerseyNumber.EXAMPLE, Appearance.EXAMPLE,
+ HealthStatus.EXAMPLE),
+
+ //no Country prefix
+ String.format("addPlayer %1$s p/%2$s a/%3$s sal/%4$s gs/%5$s "
+ + "ga/%6$s tm/%7$s %8$s jn/%9$s app/%10$s hs/%11$s",
+ Name.EXAMPLE, PositionPlayed.EXAMPLE, Age.EXAMPLE, Salary.EXAMPLE, GoalsScored.EXAMPLE,
+ GoalsAssisted.EXAMPLE, Team.EXAMPLE, Country.EXAMPLE, JerseyNumber.EXAMPLE, Appearance.EXAMPLE,
+ HealthStatus.EXAMPLE),
+
+ //no JerseyNumber prefix
+ String.format("addPlayer %1$s p/%2$s a/%3$s sal/%4$s gs/%5$s "
+ + "ga/%6$s tm/%7$s ctry/%8$s %9$s app/%10$s hs/%11$s", Name.EXAMPLE,
+ PositionPlayed.EXAMPLE, Age.EXAMPLE, Salary.EXAMPLE, GoalsScored.EXAMPLE,
+ GoalsAssisted.EXAMPLE, Team.EXAMPLE, Country.EXAMPLE, JerseyNumber.EXAMPLE, Appearance.EXAMPLE,
+ HealthStatus.EXAMPLE),
+
+ //no Appearance prefix
+ String.format("addPlayer %1$s p/%2$s a/%3$s sal/%4$s gs/%5$s "
+ + "ga/%6$s tm/%7$s ctry/%8$s jn/%9$s %10$s hs/%11$s",
+ Name.EXAMPLE, PositionPlayed.EXAMPLE, Age.EXAMPLE, Salary.EXAMPLE, GoalsScored.EXAMPLE,
+ GoalsAssisted.EXAMPLE, Team.EXAMPLE, Country.EXAMPLE, JerseyNumber.EXAMPLE, Appearance.EXAMPLE,
+ HealthStatus.EXAMPLE),
+
+ //no HealthStatus prefix
+ String.format("addPlayer %1$s p/%2$s a/%3$s sal/%4$s gs/%5$s "
+ + "ga/%6$s tm/%7$s ctry/%8$s jn/%9$s app/%10$s %11$s",
+ Name.EXAMPLE, PositionPlayed.EXAMPLE, Age.EXAMPLE, Salary.EXAMPLE, GoalsScored.EXAMPLE,
+ GoalsAssisted.EXAMPLE, Team.EXAMPLE, Country.EXAMPLE, JerseyNumber.EXAMPLE, Appearance.EXAMPLE,
+ HealthStatus.EXAMPLE),
};
final String resultMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE);
parseAndAssertIncorrectWithMessage(resultMessage, inputs);
}
@Test
- public void addCommand_invalidPersonDataInArgs() {
+ public void addCommand_invalidPlayerDataInArgs() {
+ // name, age, salary, gs, ga, jn and appearance are the ones that need to be tested
final String invalidName = "[]\\[;]";
final String validName = Name.EXAMPLE;
- final String invalidPhoneArg = "p/not__numbers";
- final String validPhoneArg = "p/" + Phone.EXAMPLE;
- final String invalidEmailArg = "e/notAnEmail123";
- final String validEmailArg = "e/" + Email.EXAMPLE;
+ final String invalidAgeArg = "a/not_numbers";
+ final String validAgeArg = "a/" + Age.EXAMPLE;
+ final String invalidSalaryArg = "sal/not_number";
+ final String validSalaryArg = "sal/" + Salary.EXAMPLE;
+ final String invalidGsArg = "gs/not_number";
+ final String validGsArg = "gs/" + GoalsScored.EXAMPLE;
+ final String invalidGaArg = "ga/not_number";
+ final String validGaArg = "ga/" + GoalsAssisted.EXAMPLE;
+ final String invalidJnArg = "jn/not_number";
+ final String validJnArg = "jn/" + JerseyNumber.EXAMPLE;
+ final String invalidAppearanceArg = "app/not_number";
+ final String validAppearanceArg = "app/" + Appearance.EXAMPLE;
+
final String invalidTagArg = "t/invalid_-[.tag";
- // address can be any string, so no invalid address
- final String addCommandFormatString = "add $s $s $s a/" + Address.EXAMPLE;
+ // PositionPlayer, Team, Country and HealthStatus can be any string, so no invalid address
+ // name, age, salary, gs, ga, jn, app
+
+ final String addCommandFormatString = "addPlayer %1$s " + "p/"
+ + PositionPlayed.EXAMPLE + " %2$s %3$s %4$s %5$s " + "tm/"
+ + Team.EXAMPLE + " ctry/" + Country.EXAMPLE + " %6$s %7$s " + "hs/"
+ + HealthStatus.EXAMPLE + " ";
// test each incorrect player data field argument individually
final String[] inputs = {
// invalid name
- String.format(addCommandFormatString, invalidName, validPhoneArg, validEmailArg),
- // invalid phone
- String.format(addCommandFormatString, validName, invalidPhoneArg, validEmailArg),
- // invalid email
- String.format(addCommandFormatString, validName, validPhoneArg, invalidEmailArg),
+ String.format(addCommandFormatString, invalidName, validAgeArg, validSalaryArg, validGsArg,
+ validGaArg, validJnArg, validAppearanceArg),
+ // invalid age
+ String.format(addCommandFormatString, validName, invalidAgeArg, validSalaryArg, validGsArg,
+ validGaArg, validJnArg, validAppearanceArg),
+ // invalid salary
+ String.format(addCommandFormatString, validName, validAgeArg, invalidSalaryArg, validGsArg,
+ validGaArg, validJnArg, validAppearanceArg),
+ // invalid GS
+ String.format(addCommandFormatString, validName, validAgeArg, validSalaryArg, invalidGsArg,
+ validGaArg, validJnArg, validAppearanceArg),
+ // invalid GA
+ String.format(addCommandFormatString, validName, validAgeArg, validSalaryArg, validGsArg,
+ invalidGaArg, validJnArg, validAppearanceArg),
+ // invalid JN
+ String.format(addCommandFormatString, validName, validAgeArg, validSalaryArg, validGsArg,
+ validGaArg, invalidJnArg, validAppearanceArg),
+ // invalid Appearance
+ String.format(addCommandFormatString, validName, validAgeArg, validSalaryArg, validGsArg,
+ validGaArg, validJnArg, invalidAppearanceArg),
// invalid tag
- String.format(addCommandFormatString, validName, validPhoneArg, validEmailArg) + " " + invalidTagArg
+ String.format(addCommandFormatString, validName, validAgeArg, validSalaryArg, validGsArg,
+ validGaArg, validJnArg, validAppearanceArg) + " " + invalidTagArg
};
for (String input : inputs) {
parseAndAssertCommandType(input, IncorrectCommand.class);
@@ -240,36 +312,45 @@ public void addCommand_invalidPersonDataInArgs() {
}
@Test
- public void addCommand_validPersonData_parsedCorrectly() {
- final Person testPerson = generateTestPerson();
- final String input = convertPersonToAddCommandString(testPerson);
+ public void addCommand_validPlayerData_parsedCorrectly() {
+ final Player testPlayer = generateTestPlayer();
+ final String input = convertPlayerToAddCommandString(testPlayer);
final AddCommand result = parseAndAssertCommandType(input, AddCommand.class);
- assertEquals(result.getPerson(), testPerson);
+ assertEquals(result.getPlayer(), testPlayer);
}
@Test
public void addCommand_duplicateTags_merged() throws IllegalValueException {
- final Person testPerson = generateTestPerson();
- String input = convertPersonToAddCommandString(testPerson);
- for (Tag tag : testPerson.getTags()) {
+ final Player testPlayer = generateTestPlayer();
+ String input = convertPlayerToAddCommandString(testPlayer);
+ for (Tag tag : testPlayer.getTags()) {
// create duplicates by doubling each tag
input += " t/" + tag.tagName;
}
final AddCommand result = parseAndAssertCommandType(input, AddCommand.class);
- assertEquals(result.getPerson(), testPerson);
+ assertEquals(result.getPlayer(), testPlayer);
}
+
+
/**
- * generates a test person
+ * generates a test player
*/
- private static Person generateTestPerson() {
+ private static Player generateTestPlayer() {
try {
- return new Person(
- new Name(Name.EXAMPLE),
- new Phone(Phone.EXAMPLE, true),
- new Email(Email.EXAMPLE, false),
- new Address(Address.EXAMPLE, true),
- new HashSet<>(Arrays.asList(new Tag("tag1"), new Tag("tag2"), new Tag("tag3")))
+ return new Player(
+ new Name(Name.EXAMPLE),
+ new PositionPlayed(PositionPlayed.EXAMPLE),
+ new Age(Age.EXAMPLE),
+ new Salary(Salary.EXAMPLE),
+ new GoalsScored(GoalsScored.EXAMPLE),
+ new GoalsAssisted(GoalsAssisted.EXAMPLE),
+ new Team(Team.EXAMPLE),
+ new Country(Country.EXAMPLE),
+ new JerseyNumber(JerseyNumber.EXAMPLE),
+ new Appearance(Appearance.EXAMPLE),
+ new HealthStatus(HealthStatus.EXAMPLE),
+ new HashSet<>(Arrays.asList(new Tag("tag1"), new Tag("tag2"), new Tag("tag3")))
);
} catch (IllegalValueException ive) {
throw new RuntimeException("test player data should be valid by definition");
@@ -277,15 +358,22 @@ private static Person generateTestPerson() {
}
/**
- * Converts person to add command string
+ * Converts player to add command string
*/
- private static String convertPersonToAddCommandString(ReadOnlyPerson person) {
- String addCommand = "add "
- + person.getName().fullName
- + (person.getPhone().isPrivate() ? " pp/" : " p/") + person.getPhone().value
- + (person.getEmail().isPrivate() ? " pe/" : " e/") + person.getEmail().value
- + (person.getAddress().isPrivate() ? " pa/" : " a/") + person.getAddress().value;
- for (Tag tag : person.getTags()) {
+ private static String convertPlayerToAddCommandString(ReadOnlyPlayer player) {
+ String addCommand = "addPlayer "
+ + player.getName().fullName
+ + " p/" + player.getPositionPlayed().fullPosition
+ + " a/" + player.getAge().value
+ + " sal/" + player.getSalary().value
+ + " gs/" + player.getGoalsScored().value
+ + " ga/" + player.getGoalsAssisted().value
+ + " tm/" + player.getTeam().fullTeam
+ + " ctry/" + player.getCountry().fullCountry
+ + " jn/" + player.getJerseyNumber().value
+ + " app/" + player.getAppearance().value
+ + " hs/" + player.getHealthStatus().fullHs;
+ for (Tag tag : player.getTags()) {
addCommand += " t/" + tag.tagName;
}
return addCommand;
@@ -308,13 +396,16 @@ private void parseAndAssertIncorrectWithMessage(String feedbackMessage, String..
/**
* Utility method for parsing input and asserting the class/type of the returned command object.
*
- * @param input to be parsed
+ * @param input to be parsed
* @param expectedCommandClass expected class of returned command
* @return the parsed command object
*/
+
private T parseAndAssertCommandType(String input, Class expectedCommandClass) {
final Command result = parser.parseCommand(input);
assertTrue(result.getClass().isAssignableFrom(expectedCommandClass));
return (T) result;
}
+
+
}
diff --git a/test/java/seedu/addressbook/storage/StorageFileTest.java b/test/java/seedu/addressbook/storage/StorageFileTest.java
index f4e15faa5..daf290385 100644
--- a/test/java/seedu/addressbook/storage/StorageFileTest.java
+++ b/test/java/seedu/addressbook/storage/StorageFileTest.java
@@ -4,9 +4,7 @@
import static seedu.addressbook.util.TestUtil.assertTextFilesEqual;
import java.nio.file.Paths;
-import java.util.Arrays;
import java.util.Collections;
-import java.util.HashSet;
import org.junit.Rule;
import org.junit.Test;
@@ -15,12 +13,18 @@
import seedu.addressbook.data.AddressBook;
import seedu.addressbook.data.exception.IllegalValueException;
-import seedu.addressbook.data.player.Address;
-import seedu.addressbook.data.player.Email;
+import seedu.addressbook.data.player.Age;
+import seedu.addressbook.data.player.Appearance;
+import seedu.addressbook.data.player.Country;
+import seedu.addressbook.data.player.GoalsAssisted;
+import seedu.addressbook.data.player.GoalsScored;
+import seedu.addressbook.data.player.HealthStatus;
+import seedu.addressbook.data.player.JerseyNumber;
import seedu.addressbook.data.player.Name;
-import seedu.addressbook.data.player.Person;
-import seedu.addressbook.data.player.Phone;
-import seedu.addressbook.data.tag.Tag;
+import seedu.addressbook.data.player.Player;
+import seedu.addressbook.data.player.PositionPlayed;
+import seedu.addressbook.data.player.Salary;
+import seedu.addressbook.data.player.Team;
import seedu.addressbook.storage.StorageFile.StorageOperationException;
public class StorageFileTest {
@@ -59,7 +63,7 @@ public void load_validFormat() throws Exception {
// ensure loaded AddressBook is properly constructed with test data
// TODO: overwrite equals method in AddressBook class and replace with equals method below
- assertEquals(actualAb.getAllPersons(), expectedAb.getAllPersons());
+ assertEquals(actualAb.getAllPlayers(), expectedAb.getAllPlayers());
}
@Test
@@ -97,16 +101,32 @@ private StorageFile getTempStorage() throws Exception {
private AddressBook getTestAddressBook() throws Exception {
AddressBook ab = new AddressBook();
- ab.addPerson(new Person(new Name("John Doe"),
- new Phone("98765432", false),
- new Email("johnd@gmail.com", false),
- new Address("John street, block 123, #01-01", false),
+
+ ab.addPlayer(new Player(new Name("Lionel Messi"),
+ new PositionPlayed("RW"),
+ new Age("30"),
+ new Salary("200"),
+ new GoalsScored("30"),
+ new GoalsAssisted("20"),
+ new Team("FC Barcelona"),
+ new Country("Argentina"),
+ new JerseyNumber("10"),
+ new Appearance("54"),
+ new HealthStatus("Healthy"),
+ Collections.emptySet()));
+
+ ab.addPlayer(new Player(new Name("Luis Suarez"),
+ new PositionPlayed("Striker"),
+ new Age("32"),
+ new Salary("200"),
+ new GoalsScored("30"),
+ new GoalsAssisted("20"),
+ new Team("FC Barcelona"),
+ new Country("Uruguay"),
+ new JerseyNumber("9"),
+ new Appearance("54"),
+ new HealthStatus("Healthy"),
Collections.emptySet()));
- ab.addPerson(new Person(new Name("Betsy Crowe"),
- new Phone("1234567", true),
- new Email("betsycrowe@gmail.com", false),
- new Address("Newgate Prison", true),
- new HashSet<>(Arrays.asList(new Tag("friend"), new Tag("criminal")))));
return ab;
}
}