forked from nus-cs2103-AY2324S2/tp
-
Notifications
You must be signed in to change notification settings - Fork 4
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
2c80c49
commit d6be804
Showing
3 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
src/test/java/seedu/address/logic/commands/ListAlphabeticalCommandTest.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,55 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; | ||
import static seedu.address.logic.commands.CommandTestUtil.showPatientAtIndex; | ||
import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PATIENT; | ||
import static seedu.address.testutil.TypicalPatients.ALICE; | ||
import static seedu.address.testutil.TypicalPatients.BENSON; | ||
import static seedu.address.testutil.TypicalPatients.CARL; | ||
import static seedu.address.testutil.TypicalPatients.DANIEL; | ||
import static seedu.address.testutil.TypicalPatients.ELLE; | ||
import static seedu.address.testutil.TypicalPatients.FIONA; | ||
import static seedu.address.testutil.TypicalPatients.GEORGE; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.model.Model; | ||
import seedu.address.model.ModelManager; | ||
import seedu.address.model.PatientList; | ||
import seedu.address.model.UserPrefs; | ||
import seedu.address.model.patient.Patient; | ||
|
||
|
||
|
||
/** | ||
* Contains integration tests (interaction with the Model) and unit tests for ListAlphabeticalCommand. | ||
*/ | ||
public class ListAlphabeticalCommandTest { | ||
private Model model; | ||
private Model expectedModel; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
List<Patient> patientList = new ArrayList<>(Arrays.asList(GEORGE, CARL, DANIEL, ALICE, FIONA, BENSON, ELLE)); | ||
List<Patient> expectedPatientList = | ||
new ArrayList<>(Arrays.asList(ALICE, BENSON, CARL, DANIEL, ELLE, FIONA, GEORGE)); | ||
PatientList patients = new PatientList(); | ||
patients.setPatients(patientList); | ||
model = new ModelManager(patients, new UserPrefs()); | ||
PatientList expectedPatients = new PatientList(); | ||
expectedPatients.setPatients(expectedPatientList); | ||
expectedModel = new ModelManager(expectedPatients, new UserPrefs()); | ||
} | ||
|
||
@Test | ||
void testExecute() { | ||
showPatientAtIndex(model, INDEX_FIRST_PATIENT); | ||
assertCommandSuccess(new ListAlphabeticalCommand(), model, | ||
ListAlphabeticalCommand.MESSAGE_SUCCESS, expectedModel); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
src/test/java/seedu/address/logic/commands/ListByApptDateCommandTest.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,61 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static seedu.address.testutil.TypicalPatients.ALICE; | ||
import static seedu.address.testutil.TypicalPatients.BENSON; | ||
import static seedu.address.testutil.TypicalPatients.CARL; | ||
import static seedu.address.testutil.TypicalPatients.DANIEL; | ||
import static seedu.address.testutil.TypicalPatients.ELLE; | ||
import static seedu.address.testutil.TypicalPatients.FIONA; | ||
import static seedu.address.testutil.TypicalPatients.GEORGE; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.ModelManager; | ||
import seedu.address.model.PatientList; | ||
import seedu.address.model.UserPrefs; | ||
import seedu.address.model.patient.Patient; | ||
|
||
|
||
/** | ||
* Contains integration tests (interaction with the Model) and unit tests for ListCommand. | ||
*/ | ||
public class ListByApptDateCommandTest { | ||
|
||
private Model model; | ||
private Model expectedModel; | ||
|
||
|
||
@Test | ||
void testExecute() { | ||
List<Patient> patientList = new ArrayList<>( | ||
Arrays.asList(GEORGE, CARL, DANIEL, ALICE, FIONA, BENSON, ELLE)); | ||
List<Patient> expectedPatientList = new ArrayList<>( | ||
Arrays.asList(BENSON, DANIEL, ELLE, GEORGE, ALICE, CARL, FIONA)); | ||
PatientList patients = new PatientList(); | ||
patients.setPatients(patientList); | ||
model = new ModelManager(patients, new UserPrefs()); | ||
PatientList expectedPatients = new PatientList(); | ||
expectedPatients.setPatients(expectedPatientList); | ||
expectedModel = new ModelManager(expectedPatients, new UserPrefs()); | ||
|
||
//String expectedMessage = String.format(ListByApptDateCommand.MESSAGE_SUCCESS, 0); | ||
ListByApptDateCommand command = new ListByApptDateCommand(); | ||
//model.updateFilteredPatientList(PREDICATE_SHOW_ALL_PATIENTS); | ||
try { | ||
CommandResult commandResult = command.execute(model); | ||
assertEquals(commandResult, new CommandResult(ListByApptDateCommand.MESSAGE_SUCCESS)); | ||
//assertEquals(expectedPatientList, new ArrayList<Patient>(model.getFilteredPatientList())); | ||
} catch (CommandException e) { | ||
throw new RuntimeException(e); | ||
} | ||
//assertCommandSuccess(command, model, expectedMessage, expectedModel); | ||
//assertEquals(expectedPatientList, model.getFilteredPatientList()); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
src/test/java/seedu/address/logic/commands/ListByDateCriteriaCommandTest.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,65 @@ | ||
package seedu.address.logic.commands; | ||
|
||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static seedu.address.testutil.TypicalPatients.ALICE; | ||
import static seedu.address.testutil.TypicalPatients.BENSON; | ||
import static seedu.address.testutil.TypicalPatients.CARL; | ||
import static seedu.address.testutil.TypicalPatients.DANIEL; | ||
import static seedu.address.testutil.TypicalPatients.ELLE; | ||
import static seedu.address.testutil.TypicalPatients.FIONA; | ||
import static seedu.address.testutil.TypicalPatients.GEORGE; | ||
|
||
import java.time.LocalDate; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.logic.parser.ParserUtil; | ||
import seedu.address.logic.parser.exceptions.ParseException; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.ModelManager; | ||
import seedu.address.model.PatientList; | ||
import seedu.address.model.UserPrefs; | ||
import seedu.address.model.patient.ApptDateMatchesPredicate; | ||
import seedu.address.model.patient.Patient; | ||
|
||
|
||
/** | ||
* Contains integration tests (interaction with the Model) and unit tests for ListCommand. | ||
*/ | ||
public class ListByDateCriteriaCommandTest { | ||
private Model model; | ||
private Model expectedModel; | ||
|
||
@Test | ||
void testExecute() { | ||
List<Patient> patientList = new ArrayList<>( | ||
Arrays.asList(GEORGE, CARL, DANIEL, ALICE, FIONA, BENSON, ELLE)); | ||
List<Patient> expectedPatientList = new ArrayList<>( | ||
Arrays.asList(BENSON, DANIEL, ELLE, GEORGE, ALICE, CARL, FIONA)); | ||
PatientList patients = new PatientList(); | ||
patients.setPatients(patientList); | ||
model = new ModelManager(patients, new UserPrefs()); | ||
PatientList expectedPatients = new PatientList(); | ||
expectedPatients.setPatients(expectedPatientList); | ||
expectedModel = new ModelManager(expectedPatients, new UserPrefs()); | ||
|
||
try { | ||
LocalDate apptDate = ParserUtil.parseAppointment("27/2/2025").appointment; | ||
ApptDateMatchesPredicate predicate = new ApptDateMatchesPredicate(apptDate); | ||
ListByDateCriteriaCommand command = new ListByDateCriteriaCommand(predicate); | ||
CommandResult commandResult = null; | ||
commandResult = command.execute(model); | ||
assertEquals(commandResult, new CommandResult(ListByDateCriteriaCommand.MESSAGE_SUCCESS)); | ||
//assertEquals(expectedPatientList, new ArrayList<Patient>(model.getFilteredPatientList())); | ||
} catch (CommandException e) { | ||
throw new RuntimeException(e); | ||
} catch (ParseException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |