forked from nus-cs2103-AY2324S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f97cb9
commit e623822
Showing
2 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
src/test/java/seedu/address/logic/commands/ConvertClientToLeadCommandTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
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.Lead; | ||
import seedu.address.testutil.TypicalPersons; | ||
|
||
public class ConvertClientToLeadCommandTest { | ||
private Model model = new ModelManager(TypicalPersons.getTypicalAddressBook(), new UserPrefs()); | ||
private Model expectedModel = new ModelManager(TypicalPersons.getTypicalAddressBook(), new UserPrefs()); | ||
|
||
@Test | ||
public void execute_validClientIndex_success() { | ||
Client clientToConvert = TypicalPersons.getTypicalClients().get(0); // assuming you have a list of clients | ||
ConvertClientToLeadCommand command = new ConvertClientToLeadCommand(clientToConvert.getIndex()); | ||
|
||
String expectedMessage = String.format(ConvertClientToLeadCommand.MESSAGE_CONVERT_SUCCESS, clientToConvert); | ||
expectedModel.deletePerson(clientToConvert); | ||
expectedModel.addPerson(new Lead(clientToConvert)); // Assuming a constructor for Lead is available | ||
|
||
assertCommandSuccess(command, model, expectedMessage, expectedModel); | ||
} | ||
|
||
@Test | ||
public void execute_invalidClientIndex_failure() { | ||
int outOfBoundIndex = model.getFilteredPersonList().size() + 1; | ||
ConvertClientToLeadCommand command = new ConvertClientToLeadCommand(Index.fromOneBased(outOfBoundIndex)); | ||
|
||
assertCommandFailure(command, model, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); | ||
} | ||
|
||
// Add more test cases for edge cases, if necessary | ||
} | ||
|
41 changes: 41 additions & 0 deletions
41
src/test/java/seedu/address/logic/commands/ConvertLeadToClientCommandTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
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.Lead; | ||
import seedu.address.testutil.TypicalPersons; | ||
|
||
public class ConvertLeadToClientCommandTest { | ||
private Model model = new ModelManager(TypicalPersons.getTypicalAddressBook(), new UserPrefs()); | ||
private Model expectedModel = new ModelManager(TypicalPersons.getTypicalAddressBook(), new UserPrefs()); | ||
|
||
@Test | ||
public void execute_validLeadIndex_success() { | ||
Lead leadToConvert = TypicalPersons.getTypicalLeads().get(0); // assuming you have a list of leads | ||
ConvertLeadToClientCommand command = new ConvertLeadToClientCommand(leadToConvert.getIndex()); | ||
|
||
String expectedMessage = String.format(ConvertLeadToClientCommand.MESSAGE_CONVERT_SUCCESS, leadToConvert); | ||
expectedModel.deletePerson(leadToConvert); | ||
expectedModel.addPerson(new Client(leadToConvert)); // Assuming a constructor for Client is available | ||
|
||
assertCommandSuccess(command, model, expectedMessage, expectedModel); | ||
} | ||
|
||
@Test | ||
public void execute_invalidLeadIndex_failure() { | ||
int outOfBoundIndex = model.getFilteredPersonList().size() + 1; | ||
ConvertLeadToClientCommand command = new ConvertLeadToClientCommand(Index.fromOneBased(outOfBoundIndex)); | ||
|
||
assertCommandFailure(command, model, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); | ||
} | ||
|
||
// Add more test cases for edge cases, if necessary | ||
} | ||
|