Skip to content

Commit

Permalink
Merge pull request nus-cs2103-AY2324S1#178 from LicongHuang/convertlead
Browse files Browse the repository at this point in the history
Update UserGuide
  • Loading branch information
yuxunn committed Nov 7, 2023
2 parents 266ed35 + 4feb4c0 commit 86a6e91
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 36 deletions.
50 changes: 45 additions & 5 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ Example: addclient n/John Doe p/98765432 e/[email protected] a/311, Clementi Ave
In output section of the
`List of all clients`

<h4>Examples of usage:</h4>

<div align="center">
<img src="./images/List.png" width="500" />
Expand All @@ -149,6 +148,15 @@ In output section of the
<p>After using listclient command</p>
</div>

- 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.
Expand All @@ -157,7 +165,6 @@ In output section of the

`List of all leads`

<h4>Example usage:</h4>

<div align="center">
<img src="./images/List.png" width = "500"/>
Expand All @@ -166,6 +173,15 @@ In output section of the
<p>After using listlead command</p>
</div>

- 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
Expand Down Expand Up @@ -365,10 +381,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

<div align="center">
<img src="./images/beforeconverttoclient.png" width = "500"/>
<p>Before using converttoclient</p>
</div>

<div align="center">
<img src="./images/converttoclient.png" width = "500"/>
<p>After using converttoclient</p>
</div>

- Precise expected outputs when the command succeeds:

`Converted lead to client`
Expand All @@ -377,16 +405,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

<div align="center">
<img src="./images/beforeconverttolead.png" width = "500"/>
<p>Before using converttolead</p>
</div>

<div align="center">
<img src="./images/converttolead.png" width = "500"/>
<p>After using converttolead</p>
</div>

- Precise expected outputs when the command succeeds:
`Converted client to lead`

- Precise expected outputs when the command fails:
Expand Down
Binary file added docs/images/beforeconverttoclient.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/beforeconverttolead.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/converttoclient.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/converttolead.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@ 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<Person> CLIENT_TAG_PREDICATE = person -> person.isClient();

private static final Logger logger = LogsCenter.getLogger(ListClientCommand.class);

@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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ 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<Person> LEAD_TAG_PREDICATE = person -> person.isLead();

private static final Logger logger = LogsCenter.getLogger(ListLeadCommand.class);

@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);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand All @@ -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
Expand All @@ -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<Person> 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<Person> 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);
}
}
27 changes: 15 additions & 12 deletions src/test/java/seedu/address/logic/commands/ListLeadCommandTest.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {

Expand All @@ -23,15 +26,13 @@ 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());
expectedPersonModel = new ModelManager(personModel.getAddressBook(), new UserPrefs());
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());
}


Expand All @@ -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<Person> predicate = ListLeadCommand.LEAD_TAG_PREDICATE;
Predicate<Person> 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<Person> 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);
}
}

0 comments on commit 86a6e91

Please sign in to comment.