Skip to content

Commit

Permalink
Update test cases of model manager and person list
Browse files Browse the repository at this point in the history
  • Loading branch information
CYX22222003 committed Oct 21, 2024
1 parent fc2cd66 commit adcfeac
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/test/java/seedu/address/model/ModelManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

import seedu.address.commons.core.GuiSettings;
import seedu.address.model.person.NameContainsKeywordsPredicate;
import seedu.address.model.person.Person;
import seedu.address.model.tag.Tag;
import seedu.address.testutil.CampusConnectBuilder;
import seedu.address.testutil.PersonBuilder;

public class ModelManagerTest {

Expand Down Expand Up @@ -93,6 +96,18 @@ public void getFilteredPersonList_modifyList_throwsUnsupportedOperationException
assertThrows(UnsupportedOperationException.class, () -> modelManager.getFilteredPersonList().remove(0));
}

@Test
public void deleteTag_personInCampusConnect_successfulDeletion() {
Person newAlice = new PersonBuilder(ALICE).withTags("friends", "copy").build();
modelManager.addPerson(newAlice);
modelManager.deletePersonTag(newAlice, new Tag("copy"));

ModelManager copyModelManager = new ModelManager();
copyModelManager.addPerson(ALICE);

assertEquals(modelManager, copyModelManager);
}

@Test
public void equals() {
CampusConnect campusConnect = new CampusConnectBuilder().withPerson(ALICE).withPerson(BENSON).build();
Expand Down
8 changes: 8 additions & 0 deletions src/test/java/seedu/address/model/person/PersonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import org.junit.jupiter.api.Test;

import seedu.address.model.tag.Tag;
import seedu.address.testutil.PersonBuilder;

public class PersonTest {
Expand Down Expand Up @@ -147,6 +148,13 @@ public void equals() {
assertFalse(ALICE.equals(editedAlice));
}

@Test
public void hasTag() {
Person aliceCopy = new PersonBuilder(ALICE).build();
assertTrue(aliceCopy.hasTag(new Tag("friends")));
assertFalse(aliceCopy.hasTag(new Tag("TEST")));
}

@Test
public void toStringMethod() {
String expected = Person.class.getCanonicalName() + "{name=" + ALICE.getName() + ", phone=" + ALICE.getPhone()
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/seedu/address/model/person/UniquePersonListTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;

import org.junit.jupiter.api.Test;

import seedu.address.model.person.exceptions.DuplicatePersonException;
import seedu.address.model.person.exceptions.PersonNotFoundException;
import seedu.address.model.tag.Tag;
import seedu.address.testutil.PersonBuilder;

public class UniquePersonListTest {
Expand Down Expand Up @@ -171,4 +173,14 @@ public void asUnmodifiableObservableList_modifyList_throwsUnsupportedOperationEx
public void toStringMethod() {
assertEquals(uniquePersonList.asUnmodifiableObservableList().toString(), uniquePersonList.toString());
}

@Test
public void deletePersonTap_list_successfulDeletionOfTag() {
Person newAlice = new PersonBuilder(ALICE).withTags("friends", "hello").build();
uniquePersonList.add(newAlice);
uniquePersonList.deletePersonTag(newAlice, new Tag("hello"));
UniquePersonList expectedUniquePersonList = new UniquePersonList();
expectedUniquePersonList.add(ALICE);
assertEquals(expectedUniquePersonList, uniquePersonList);
}
}

0 comments on commit adcfeac

Please sign in to comment.