diff --git a/docs/UserGuide.md b/docs/UserGuide.md index 983f84f2ff6..346be9a99ca 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -128,7 +128,6 @@ Example: addclient n/John Doe p/98765432 e/johnd@example.com a/311, Clementi Ave In output section of the `List of all clients` -

Examples of usage:

@@ -137,6 +136,15 @@ In output section of the

After using listclient command

+- Precise expected outputs when the commands succeeds: +``` +Listed all clients +``` +- Precise expected outputs when there are no clients stored: +``` +There are no clients in the address book +``` + ### View all leads - What it does: View all leads you have stored, including their basic information and index in the list of leads, e.g. id, name, age, gender, occupation, etc. @@ -145,7 +153,6 @@ In output section of the `List of all leads` -

Example usage:

@@ -154,6 +161,15 @@ In output section of the

After using listlead command

+- Precise expected outputs when commands succeeds: +``` +Listed all leads +``` +- Precise expected outputs when there are no leads stored: +``` +There are no leads in the address book +``` + ### View Specific Person - What it does: View a specific person that you have stored, including their basic information and another relevant lead/client @@ -353,10 +369,22 @@ only entries with a meeting time. ### Convert lead to client - What it does: Converts a lead to client. -- Command format: `convertoclient INDEX` +- Command format: `converttoclient INDEX` - Example usage: `converttoclient 1` - Acceptable values for each parameter: - `INDEX`: Any integer from `1` to the last index of the leads list +- Example usage + +
+ +

Before using converttoclient

+
+ +
+ +

After using converttoclient

+
+ - Precise expected outputs when the command succeeds: `Converted lead to client` @@ -365,16 +393,28 @@ only entries with a meeting time. `The person index provided is invalid` + ### Convert client to lead - What it does: Converts a client into lead, the ``KEY_MILESTONE`` is 1 year from current date to ensure a follow-up by the user. -- Command format: `convertolead INDEX` +- Command format: `converttolead INDEX` - Example usage: `converttolead 1` - Acceptable values for each parameter: - `INDEX`: Any integer from `1` to the last index of the leads list. -- Precise expected outputs when the command succeeds: +- Example usage +
+ +

Before using converttolead

+
+ +
+ +

After using converttolead

+
+ +- Precise expected outputs when the command succeeds: `Converted client to lead` - Precise expected outputs when the command fails: diff --git a/docs/images/beforeconverttoclient.png b/docs/images/beforeconverttoclient.png new file mode 100644 index 00000000000..672fa6bfa96 Binary files /dev/null and b/docs/images/beforeconverttoclient.png differ diff --git a/docs/images/beforeconverttolead.png b/docs/images/beforeconverttolead.png new file mode 100644 index 00000000000..e120db48b85 Binary files /dev/null and b/docs/images/beforeconverttolead.png differ diff --git a/docs/images/converttoclient.png b/docs/images/converttoclient.png new file mode 100644 index 00000000000..4c1e0f8a503 Binary files /dev/null and b/docs/images/converttoclient.png differ diff --git a/docs/images/converttolead.png b/docs/images/converttolead.png new file mode 100644 index 00000000000..b0b3dda6104 Binary files /dev/null and b/docs/images/converttolead.png differ diff --git a/src/main/java/seedu/address/logic/commands/ListClientCommand.java b/src/main/java/seedu/address/logic/commands/ListClientCommand.java index 0e924f0c3fd..5f54aa695f0 100644 --- a/src/main/java/seedu/address/logic/commands/ListClientCommand.java +++ b/src/main/java/seedu/address/logic/commands/ListClientCommand.java @@ -18,6 +18,7 @@ public class ListClientCommand extends Command { public static final String COMMAND_WORD = "listclient"; public static final String MESSAGE_SUCCESS = "Listed all clients"; + public static final String MESSAGE_NO_CLIENTS = "There are no clients in the address book"; public static final Predicate CLIENT_TAG_PREDICATE = person -> person.isClient(); private static final Logger logger = LogsCenter.getLogger(ListClientCommand.class); @@ -25,8 +26,10 @@ public class ListClientCommand extends Command { @Override public CommandResult execute(Model model) { requireNonNull(model); - model.updateFilteredPersonList(CLIENT_TAG_PREDICATE); + if (model.getFilteredPersonList().size() == 0) { + return new CommandResult(MESSAGE_NO_CLIENTS); + } return new CommandResult(MESSAGE_SUCCESS); } } diff --git a/src/main/java/seedu/address/logic/commands/ListLeadCommand.java b/src/main/java/seedu/address/logic/commands/ListLeadCommand.java index 98061897755..5b9283eb866 100644 --- a/src/main/java/seedu/address/logic/commands/ListLeadCommand.java +++ b/src/main/java/seedu/address/logic/commands/ListLeadCommand.java @@ -17,7 +17,7 @@ public class ListLeadCommand extends Command { public static final String COMMAND_WORD = "listlead"; public static final String MESSAGE_SUCCESS = "Listed all leads"; - + public static final String MESSAGE_NO_LEADS = "There are no leads in the address book"; public static final Predicate LEAD_TAG_PREDICATE = person -> person.isLead(); private static final Logger logger = LogsCenter.getLogger(ListLeadCommand.class); @@ -25,8 +25,10 @@ public class ListLeadCommand extends Command { @Override public CommandResult execute(Model model) { requireNonNull(model); - model.updateFilteredPersonList(LEAD_TAG_PREDICATE); + if (model.getFilteredPersonList().size() == 0) { + return new CommandResult(MESSAGE_NO_LEADS); + } return new CommandResult(MESSAGE_SUCCESS); } } diff --git a/src/test/java/seedu/address/logic/commands/ListClientCommandTest.java b/src/test/java/seedu/address/logic/commands/ListClientCommandTest.java index 8f47098aa56..0b74a68f90c 100644 --- a/src/test/java/seedu/address/logic/commands/ListClientCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/ListClientCommandTest.java @@ -1,6 +1,8 @@ package seedu.address.logic.commands; +import static org.junit.jupiter.api.Assertions.assertEquals; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; +import static seedu.address.logic.commands.ListClientCommand.MESSAGE_NO_CLIENTS; import static seedu.address.logic.commands.ListClientCommand.MESSAGE_SUCCESS; import static seedu.address.testutil.TypicalClients.getTypicalClientsAddressBook; import static seedu.address.testutil.TypicalLeads.getTypicalLeadsAddressBook; @@ -14,14 +16,15 @@ import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; +import seedu.address.model.person.Client; import seedu.address.model.person.Person; +import seedu.address.testutil.PersonBuilder; public class ListClientCommandTest { private Model personModel; private Model expectedPersonModel; private Model leadModel; - private Model expectedLeadModel; private Model clientModel; private Model expectedClientModel; @@ -32,7 +35,6 @@ public void setUp() { clientModel = new ModelManager(getTypicalClientsAddressBook(), new UserPrefs()); expectedClientModel = new ModelManager(clientModel.getAddressBook(), new UserPrefs()); leadModel = new ModelManager(getTypicalLeadsAddressBook(), new UserPrefs()); - expectedLeadModel = new ModelManager(leadModel.getAddressBook(), new UserPrefs()); } //filter list with both client and leads @@ -44,23 +46,25 @@ public void execute_personListIsFiltered_showsEverything() { expectedPersonModel.updateFilteredPersonList(predicate); assertCommandSuccess(new ListClientCommand(), personModel, MESSAGE_SUCCESS, expectedPersonModel); } - //filter list with only clients + + //filter list with only leads + + @Test - public void execute_clientListIsFiltered_showsEverything() { - // Filter the model as required by ListClientCommand - Predicate predicate = ListClientCommand.CLIENT_TAG_PREDICATE; - clientModel.updateFilteredPersonList(predicate); - expectedClientModel.updateFilteredPersonList(predicate); - assertCommandSuccess(new ListClientCommand(), clientModel, MESSAGE_SUCCESS, expectedClientModel); + public void execute_clientListIsEmpty() { + ListClientCommand listClientCommand = new ListClientCommand(); + CommandResult commandResult = listClientCommand.execute(leadModel); + String stringOutput = commandResult.getFeedbackToUser(); + assertEquals(stringOutput, MESSAGE_NO_CLIENTS); } - //filter list with only leads @Test - public void execute_leadListIsFiltered_showsEverything() { - // Filter the model as required by ListLeadCommand - Predicate predicate = ListClientCommand.CLIENT_TAG_PREDICATE; - leadModel.updateFilteredPersonList(predicate); - expectedLeadModel.updateFilteredPersonList(predicate); - assertCommandSuccess(new ListClientCommand(), leadModel, ListClientCommand.MESSAGE_SUCCESS, expectedLeadModel); + public void execute_clientListIsFiltered_showsEverything() { + Client exampleClient = new PersonBuilder().buildClient(); + leadModel.addClient(exampleClient); + ListClientCommand listClientCommand = new ListClientCommand(); + CommandResult commandResult = listClientCommand.execute(leadModel); + String stringOutput = commandResult.getFeedbackToUser(); + assertEquals(stringOutput, ListClientCommand.MESSAGE_SUCCESS); } } diff --git a/src/test/java/seedu/address/logic/commands/ListLeadCommandTest.java b/src/test/java/seedu/address/logic/commands/ListLeadCommandTest.java index 7796e2d7940..e6db8c36d8a 100644 --- a/src/test/java/seedu/address/logic/commands/ListLeadCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/ListLeadCommandTest.java @@ -1,5 +1,6 @@ package seedu.address.logic.commands; +import static org.junit.jupiter.api.Assertions.assertEquals; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; import static seedu.address.logic.commands.ListLeadCommand.MESSAGE_SUCCESS; import static seedu.address.testutil.TypicalClients.getTypicalClientsAddressBook; @@ -14,7 +15,9 @@ import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; +import seedu.address.model.person.Lead; import seedu.address.model.person.Person; +import seedu.address.testutil.PersonBuilder; public class ListLeadCommandTest { @@ -23,7 +26,6 @@ public class ListLeadCommandTest { private Model leadModel; private Model expectedLeadModel; private Model clientModel; - private Model expectedClientModel; @BeforeEach public void setUp() { personModel = new ModelManager(getTypicalAddressBook(), new UserPrefs()); @@ -31,7 +33,6 @@ public void setUp() { leadModel = new ModelManager(getTypicalLeadsAddressBook(), new UserPrefs()); expectedLeadModel = new ModelManager(leadModel.getAddressBook(), new UserPrefs()); clientModel = new ModelManager(getTypicalClientsAddressBook(), new UserPrefs()); - expectedClientModel = new ModelManager(clientModel.getAddressBook(), new UserPrefs()); } @@ -44,24 +45,26 @@ public void execute_personListIsFiltered_showsEverything() { assertCommandSuccess(new ListLeadCommand(), personModel, MESSAGE_SUCCESS, expectedPersonModel); } - //filter list with only leads + //filter list with only clients @Test - public void execute_leadListIsFiltered_showsEverything() { + public void execute_leadListIsEmpty() { // Filter the model as required by ListLeadCommand - Predicate predicate = ListLeadCommand.LEAD_TAG_PREDICATE; + Predicate predicate = ListClientCommand.CLIENT_TAG_PREDICATE; leadModel.updateFilteredPersonList(predicate); expectedLeadModel.updateFilteredPersonList(predicate); - assertCommandSuccess(new ListLeadCommand(), leadModel, ListLeadCommand.MESSAGE_SUCCESS, expectedLeadModel); + assertCommandSuccess( + new ListClientCommand(), leadModel, ListClientCommand.MESSAGE_NO_CLIENTS, expectedLeadModel); } - //filter list with only clients @Test - public void execute_clientListIsFiltered_showsEverything() { + public void execute_leadListIsFiltered_showsEverything() { // Filter the model as required by ListLeadCommand - Predicate predicate = ListLeadCommand.LEAD_TAG_PREDICATE; - clientModel.updateFilteredPersonList(predicate); - expectedClientModel.updateFilteredPersonList(predicate); - assertCommandSuccess(new ListLeadCommand(), clientModel, MESSAGE_SUCCESS, expectedClientModel); + Lead exampleLead = new PersonBuilder().buildLead(); + leadModel.addLead(exampleLead); + ListLeadCommand listLeadCommand = new ListLeadCommand(); + CommandResult commandResult = listLeadCommand.execute(leadModel); + String stringOutput = commandResult.getFeedbackToUser(); + assertEquals(stringOutput, ListLeadCommand.MESSAGE_SUCCESS); } }