Skip to content

Commit

Permalink
fix: update TypicalVisits and ModelManager not updating visitList
Browse files Browse the repository at this point in the history
  • Loading branch information
jovantanyk committed Apr 13, 2024
1 parent 4fead52 commit 09cd23c
Show file tree
Hide file tree
Showing 18 changed files with 42 additions and 40 deletions.
1 change: 1 addition & 0 deletions src/main/java/seedu/address/model/ImmuniMate.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public void resetData(ReadOnlyImmuniMate newData) {
requireNonNull(newData);

setPersons(newData.getPersonList());
setVisits(newData.getVisitList());
}

//// person-level operations
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seedu/address/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ public ModelManager(ReadOnlyImmuniMate immuniMate, ReadOnlyUserPrefs userPrefs)

this.immuniMate = new ImmuniMate(immuniMate);
this.userPrefs = new UserPrefs(userPrefs);
filteredPersons = new FilteredList<>(this.immuniMate.getPersonList());
filteredVisits = new FilteredList<>(this.immuniMate.getVisitList());
filteredPersons = new FilteredList<>(this.immuniMate.getPersonList());

}

public ModelManager() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure;
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook;
import static seedu.address.testutil.TypicalPersons.getTypicalPersonsAddressBook;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -23,7 +23,7 @@ public class AddVisitCommandIntegrationTest {

@BeforeEach
public void setUp() {
model = new ModelManager(getTypicalAddressBook(), new UserPrefs());
model = new ModelManager(getTypicalPersonsAddressBook(), new UserPrefs());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
import seedu.address.model.UserPrefs;
import seedu.address.model.person.Nric;
import seedu.address.model.person.NricContainsKeywordsPredicate;
import seedu.address.model.visit.Visit;
import seedu.address.model.visit.VisitContainsNricPredicate;
import seedu.address.testutil.TypicalVisits;

public class CheckCommandTest {

private final Model model = new ModelManager(TypicalVisits.getTypicalVisitAddressBook(), new UserPrefs());
private final Model expectedModel = new ModelManager(TypicalVisits.getTypicalVisitAddressBook(), new UserPrefs());

private final Model model = new ModelManager(TypicalVisits.getTypicalCombinedAddressBook(), new UserPrefs());
private final Model expectedModel = new ModelManager(
TypicalVisits.getTypicalCombinedAddressBook(), new UserPrefs());
@Test
void execute_validVisitNric_success() {

StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(ALICE.getName()).append(" (NRIC: ").append(VISIT_ALICE.getNric()).append("):\n");
stringBuilder.append(Messages.formatCheck(VISIT_ALICE)).append("\n");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package seedu.address.logic.commands;

import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook;
import static seedu.address.testutil.TypicalPersons.getTypicalPersonsAddressBook;

import org.junit.jupiter.api.Test;

Expand All @@ -22,8 +22,8 @@ public void execute_emptyAddressBook_success() {

@Test
public void execute_nonEmptyAddressBook_success() {
Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs());
Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs());
Model model = new ModelManager(getTypicalPersonsAddressBook(), new UserPrefs());
Model expectedModel = new ModelManager(getTypicalPersonsAddressBook(), new UserPrefs());
expectedModel.setImmuniMate(new ImmuniMate());

assertCommandSuccess(new ClearCommand(), model, ClearCommand.MESSAGE_SUCCESS, expectedModel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure;
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook;
import static seedu.address.testutil.TypicalPersons.getTypicalPersonsAddressBook;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -23,7 +23,7 @@ public class CreateCommandIntegrationTest {

@BeforeEach
public void setUp() {
model = new ModelManager(getTypicalAddressBook(), new UserPrefs());
model = new ModelManager(getTypicalPersonsAddressBook(), new UserPrefs());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import static seedu.address.logic.commands.CommandTestUtil.showPersonWithNric;
import static seedu.address.testutil.TypicalPersons.ALICE;
import static seedu.address.testutil.TypicalPersons.BOB;
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook;
import static seedu.address.testutil.TypicalPersons.getTypicalPersonsAddressBook;

import org.junit.jupiter.api.Test;

Expand All @@ -26,7 +26,7 @@
*/
public class DeleteCommandTest {

private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs());
private Model model = new ModelManager(getTypicalPersonsAddressBook(), new UserPrefs());

@Test
public void execute_validNricUnfilteredList_success() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.address.testutil.Assert.assertThrows;
import static seedu.address.testutil.TypicalPersons.ALICE;
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook;
import static seedu.address.testutil.TypicalPersons.getTypicalPersonsAddressBook;

import org.junit.jupiter.api.Test;

Expand All @@ -23,7 +23,7 @@


public class DeleteInfoCommandTest {
private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs());
private Model model = new ModelManager(getTypicalPersonsAddressBook(), new UserPrefs());

@Test
public void constructor_emptyInput_throwsException() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import static seedu.address.testutil.TypicalPersons.CARL;
import static seedu.address.testutil.TypicalPersons.ELLE;
import static seedu.address.testutil.TypicalPersons.FIONA;
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook;
import static seedu.address.testutil.TypicalPersons.getTypicalPersonsAddressBook;

import java.util.Arrays;
import java.util.Collections;
Expand All @@ -26,8 +26,8 @@
*/
public class FindCommandTest {

private final Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs());
private final Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs());
private final Model model = new ModelManager(getTypicalPersonsAddressBook(), new UserPrefs());
private final Model expectedModel = new ModelManager(getTypicalPersonsAddressBook(), new UserPrefs());

@Test
public void equals() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.address.logic.commands.CommandTestUtil.showPersonAtIndex;
import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON;
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook;
import static seedu.address.testutil.TypicalPersons.getTypicalPersonsAddressBook;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -22,7 +22,7 @@ public class ListCommandTest {

@BeforeEach
public void setUp() {
model = new ModelManager(getTypicalAddressBook(), new UserPrefs());
model = new ModelManager(getTypicalPersonsAddressBook(), new UserPrefs());
expectedModel = new ModelManager(model.getImmuniMate(), new UserPrefs());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.address.logic.commands.ReadCommand.MESSAGE_READ_PERSON_SUCCESS;
import static seedu.address.testutil.TypicalPersons.ALICE;
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook;
import static seedu.address.testutil.TypicalPersons.getTypicalPersonsAddressBook;

import org.junit.jupiter.api.Test;

Expand All @@ -21,8 +21,8 @@

public class ReadCommandTest {

private final Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs());
private final Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs());
private final Model model = new ModelManager(getTypicalPersonsAddressBook(), new UserPrefs());
private final Model expectedModel = new ModelManager(getTypicalPersonsAddressBook(), new UserPrefs());
@Test
void execute_validNric_success() {
String expectedMessage = String.format(MESSAGE_READ_PERSON_SUCCESS, Messages.format(ALICE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import static seedu.address.logic.commands.CommandTestUtil.showPersonAtIndex;
import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON;
import static seedu.address.testutil.TypicalPersons.ALICE;
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook;
import static seedu.address.testutil.TypicalPersons.getTypicalPersonsAddressBook;

import org.junit.jupiter.api.Test;

Expand All @@ -41,7 +41,7 @@
*/
public class UpdateCommandTest {

private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs());
private Model model = new ModelManager(getTypicalPersonsAddressBook(), new UserPrefs());

@Test
public void execute_allFieldsSpecifiedUnfilteredList_success() {
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/seedu/address/model/AddressBookTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB;
import static seedu.address.testutil.Assert.assertThrows;
import static seedu.address.testutil.TypicalPersons.ALICE;
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook;
import static seedu.address.testutil.TypicalPersons.getTypicalPersonsAddressBook;

import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -38,7 +38,7 @@ public void resetData_null_throwsNullPointerException() {

@Test
public void resetData_withValidReadOnlyAddressBook_replacesData() {
ImmuniMate newData = getTypicalAddressBook();
ImmuniMate newData = getTypicalPersonsAddressBook();
addressBook.resetData(newData);
assertEquals(newData, addressBook);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import static seedu.address.testutil.TypicalPersons.ALICE;
import static seedu.address.testutil.TypicalPersons.HOON;
import static seedu.address.testutil.TypicalPersons.IDA;
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook;
import static seedu.address.testutil.TypicalPersons.getTypicalPersonsAddressBook;

import java.io.IOException;
import java.nio.file.Path;
Expand Down Expand Up @@ -63,7 +63,7 @@ public void readAddressBook_invalidAndValidPersonAddressBook_throwDataLoadingExc
@Test
public void readAndSaveAddressBook_allInOrder_success() throws Exception {
Path filePath = testFolder.resolve("TempAddressBook.json");
ImmuniMate original = getTypicalAddressBook();
ImmuniMate original = getTypicalPersonsAddressBook();
JsonAddressBookStorage jsonAddressBookStorage = new JsonAddressBookStorage(filePath);

// Save in new file and read back
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void toModelType_typicalPersonsFile_success() throws Exception {
JsonSerializableAddressBook dataFromFile = JsonUtil.readJsonFile(TYPICAL_PERSONS_FILE,
JsonSerializableAddressBook.class).get();
ImmuniMate addressBookFromFile = dataFromFile.toModelType();
ImmuniMate typicalPersonsAddressBook = TypicalPersons.getTypicalAddressBook();
ImmuniMate typicalPersonsAddressBook = TypicalPersons.getTypicalPersonsAddressBook();
assertEquals(addressBookFromFile, typicalPersonsAddressBook);
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/seedu/address/storage/StorageManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook;
import static seedu.address.testutil.TypicalPersons.getTypicalPersonsAddressBook;

import java.nio.file.Path;

Expand Down Expand Up @@ -54,7 +54,7 @@ public void addressBookReadSave() throws Exception {
* {@link JsonAddressBookStorage} class.
* More extensive testing of UserPref saving/reading is done in {@link JsonAddressBookStorageTest} class.
*/
ImmuniMate original = getTypicalAddressBook();
ImmuniMate original = getTypicalPersonsAddressBook();
storageManager.saveAddressBook(original);
ReadOnlyImmuniMate retrieved = storageManager.readAddressBook().get();
assertEquals(original, new ImmuniMate(retrieved));
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/seedu/address/testutil/TypicalPersons.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private TypicalPersons() {} // prevents instantiation
/**
* Returns an {@code AddressBook} with all the typical persons.
*/
public static ImmuniMate getTypicalAddressBook() {
public static ImmuniMate getTypicalPersonsAddressBook() {
ImmuniMate ab = new ImmuniMate();
for (Person person : getTypicalPersons()) {
ab.addPerson(person);
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/seedu/address/testutil/TypicalVisits.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public class TypicalVisits {
.withSymptom("Fever, Headache, Nausea, Vomiting").withDiagnosis("Dengue").withStatus("UNWELL").build();
public static final Visit VISIT_ALICE_3 = new VisitBuilder().withNric("T0139571B").withDateOfVisit("2024-03-23")
.withSymptom("Dark Urine, Joint pain, Pale stool").withDiagnosis("Hepatitis B").withStatus("PENDING").build();
public static final Visit VISIT_BENSON_3 = new VisitBuilder().withNric("T0439571C").withDateOfVisit("2023-01-02").withSymptom("Headache")
.withDiagnosis("NIL").withStatus("HEALTHY").build();
public static final Visit VISIT_BENSON_3 = new VisitBuilder().withNric("T0439571C").withDateOfVisit("2023-01-02")
.withSymptom("Headache").withDiagnosis("NIL").withStatus("HEALTHY").build();
public static final Visit VISIT_CARL_3 =
new VisitBuilder().withNric("T0284994B").withDateOfVisit("2024-10-29").withSymptom("Slight Headache")
.withDiagnosis("Recovered").withStatus("HEALTHY").build();
Expand All @@ -61,7 +61,7 @@ private TypicalVisits() {
/**
* Returns an {@code AddressBook} with all the typical visits.
*/
public ImmuniMate getTypicalAddressBook() {
public ImmuniMate getTypicalVisitsAddressBook() {
ImmuniMate ab = new ImmuniMate();
for (Visit visit : getTypicalVisits()) {
ab.addVisit(visit);
Expand All @@ -72,8 +72,8 @@ public ImmuniMate getTypicalAddressBook() {
/**
* Returns an {@code AddressBook} with all the typical visits and typical persons.
*/
public static ImmuniMate getTypicalVisitAddressBook() {
ImmuniMate ab = TypicalPersons.getTypicalAddressBook();
public static ImmuniMate getTypicalCombinedAddressBook() {
ImmuniMate ab = TypicalPersons.getTypicalPersonsAddressBook();
for (Visit visit : getTypicalVisits()) {
ab.addVisit(visit);
}
Expand All @@ -83,6 +83,6 @@ public static ImmuniMate getTypicalVisitAddressBook() {
public static List<Visit> getTypicalVisits() {
return new ArrayList<>(
Arrays.asList(VISIT_ALICE, VISIT_ALICE_2, VISIT_ALICE_3, VISIT_BENSON, VISIT_BENSON_2, VISIT_BENSON_3,
VISIT_CARL, VISIT_CARL_2, VISIT_CARL_3, VISIT_AMY, VISIT_BOB));
VISIT_CARL, VISIT_CARL_2, VISIT_CARL_3));
}
}

0 comments on commit 09cd23c

Please sign in to comment.