Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #81 from rayshawntan/update-test-data
Browse files Browse the repository at this point in the history
[Week 9] Continue refining TestData
  • Loading branch information
rayshawntan authored Oct 20, 2023
2 parents a7d8510 + ecbc784 commit 1441c70
Show file tree
Hide file tree
Showing 36 changed files with 413 additions and 349 deletions.
2 changes: 0 additions & 2 deletions src/main/java/seedu/address/model/Contacts.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import seedu.address.model.contact.Contact;
import seedu.address.model.contact.UniqueContactList;



/**
* Mutable {@link Contact}s, both readable and writable.
*
Expand Down
12 changes: 6 additions & 6 deletions src/test/data/JsonContactsStorageTest/typicalContacts.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"name" : "Alice Pauline",
"phone" : "94351253",
"email" : "[email protected]",
"note" : "123, Jurong West Ave 6, #08-111",
"note" : "Best Friend",
"tags" : ["friends"]
}, {
"name" : "Benson Meier",
"phone" : "98765432",
"email" : "[email protected]",
"note" : "311, Clementi Ave 2, #02-25",
"note" : "Address: 311, Clementi Ave 2, #02-25",
"tags" : ["owesMoney", "friends"]
}, {
"name" : "Carl Kurz",
Expand All @@ -22,25 +22,25 @@
"name" : "Daniel Meier",
"phone" : "87652533",
"email" : "[email protected]",
"note" : "10th street",
"note" : "Close Friend",
"tags" : ["friends"]
}, {
"name" : "Elle Meyer",
"phone" : "9482224",
"email" : "[email protected]",
"note" : "michegan ave",
"note" : "Groupmate",
"tags" : []
}, {
"name" : "Fiona Kunz",
"phone" : "9482427",
"email" : "[email protected]",
"note" : "little tokyo",
"note" : "Classmate",
"tags" : []
}, {
"name" : "George Best",
"phone" : "9482442",
"email" : "[email protected]",
"note" : "4th street",
"note" : "Tutor",
"tags" : []
}]
}
2 changes: 0 additions & 2 deletions src/test/java/seedu/address/commons/util/AppUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

import seedu.address.ui.UiManager;



public class AppUtilTest {
@Test
public void getImage_appIcon_imageReturned() {
Expand Down
2 changes: 0 additions & 2 deletions src/test/java/seedu/address/commons/util/ConfigUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import seedu.address.commons.exceptions.DataLoadingException;
import seedu.address.testutil.TestData;



public class ConfigUtilTest {
private static final Path TEST_DATA_FOLDER = Paths.get(
"src",
Expand Down
2 changes: 0 additions & 2 deletions src/test/java/seedu/address/commons/util/JsonUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

import seedu.address.testutil.SerializableClass;



public class JsonUtilTest {
private static final String TEST_CLASS_JSON = String.format(
"{"
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/seedu/address/logic/LogicManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import static seedu.address.logic.Messages.COMMAND_UNKNOWN;
import static seedu.address.logic.Messages.MESSAGE_INVALID_CONTACT_DISPLAYED_INDEX;
import static seedu.address.testutil.Assert.assertThrows;
import static seedu.address.testutil.TestData.EMAIL_DESC_AMY;
import static seedu.address.testutil.TestData.NAME_DESC_AMY;
import static seedu.address.testutil.TestData.NOTE_DESC_AMY;
import static seedu.address.testutil.TestData.PHONE_DESC_AMY;
import static seedu.address.testutil.TestData.Valid.EMAIL_DESC_AMY;
import static seedu.address.testutil.TestData.Valid.NAME_DESC_AMY;
import static seedu.address.testutil.TestData.Valid.NOTE_DESC_AMY;
import static seedu.address.testutil.TestData.Valid.PHONE_DESC_AMY;

import java.io.IOException;
import java.nio.file.AccessDeniedException;
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.TestData.getTypicalContacts;
import static seedu.address.testutil.TestData.Valid.Contact.getTypicalContacts;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.address.testutil.Assert.assertThrows;
import static seedu.address.testutil.TestData.ALICE;
import static seedu.address.testutil.TestData.Valid.Contact.ALICE;

import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -24,8 +24,6 @@
import seedu.address.model.contact.Contact;
import seedu.address.testutil.ContactBuilder;



public class AddCommandTest {
@Test
public void constructor_nullContact_throwsNullPointerException() {
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.TestData.getTypicalContacts;
import static seedu.address.testutil.TestData.Valid.Contact.getTypicalContacts;

import org.junit.jupiter.api.Test;

Expand All @@ -10,8 +10,6 @@
import seedu.address.model.ModelManager;
import seedu.address.model.Settings;



public class ClearCommandTest {
@Test
public void execute_emptyContacts_success() {
Expand Down
28 changes: 14 additions & 14 deletions src/test/java/seedu/address/logic/commands/DeleteCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure;
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.address.logic.commands.CommandTestUtil.showContactAtIndex;
import static seedu.address.testutil.TestData.INDEX_FIRST_CONTACT;
import static seedu.address.testutil.TestData.INDEX_SECOND_CONTACT;
import static seedu.address.testutil.TestData.getTypicalContacts;
import static seedu.address.testutil.TestData.IndexContact.FIRST_CONTACT;
import static seedu.address.testutil.TestData.IndexContact.SECOND_CONTACT;
import static seedu.address.testutil.TestData.Valid.Contact.getTypicalContacts;

import org.junit.jupiter.api.Test;

Expand All @@ -29,8 +29,8 @@ public class DeleteCommandTest {

@Test
public void execute_validIndexUnfilteredList_success() {
Contact contactToDelete = model.getFilteredContactList().get(INDEX_FIRST_CONTACT.getZeroBased());
DeleteCommand deleteCommand = new DeleteCommand(INDEX_FIRST_CONTACT);
Contact contactToDelete = model.getFilteredContactList().get(FIRST_CONTACT.getZeroBased());
DeleteCommand deleteCommand = new DeleteCommand(FIRST_CONTACT);

String expectedMessage = String.format(Messages.MESSAGE_DELETE_COMMAND_SUCCESS,
Contact.format(contactToDelete));
Expand All @@ -51,10 +51,10 @@ public void execute_invalidIndexUnfilteredList_throwsCommandException() {

@Test
public void execute_validIndexFilteredList_success() {
showContactAtIndex(model, INDEX_FIRST_CONTACT);
showContactAtIndex(model, FIRST_CONTACT);

Contact contactToDelete = model.getFilteredContactList().get(INDEX_FIRST_CONTACT.getZeroBased());
DeleteCommand deleteCommand = new DeleteCommand(INDEX_FIRST_CONTACT);
Contact contactToDelete = model.getFilteredContactList().get(FIRST_CONTACT.getZeroBased());
DeleteCommand deleteCommand = new DeleteCommand(FIRST_CONTACT);

String expectedMessage = String.format(Messages.MESSAGE_DELETE_COMMAND_SUCCESS,
Contact.format(contactToDelete));
Expand All @@ -68,10 +68,10 @@ public void execute_validIndexFilteredList_success() {

@Test
public void execute_invalidIndexFilteredList_throwsCommandException() {
showContactAtIndex(model, INDEX_FIRST_CONTACT);
showContactAtIndex(model, FIRST_CONTACT);

Index outOfBoundIndex = INDEX_SECOND_CONTACT;
// ensures that outOfBoundIndex is still in bounds of Contacts
Index outOfBoundIndex = SECOND_CONTACT;
// ensures that outOfBoundIndex is still in bounds of address book list
assertTrue(outOfBoundIndex.getZeroBased() < model.getContacts().getUnmodifiableList().size());

DeleteCommand deleteCommand = new DeleteCommand(outOfBoundIndex);
Expand All @@ -81,14 +81,14 @@ public void execute_invalidIndexFilteredList_throwsCommandException() {

@Test
public void equals() {
DeleteCommand deleteFirstCommand = new DeleteCommand(INDEX_FIRST_CONTACT);
DeleteCommand deleteSecondCommand = new DeleteCommand(INDEX_SECOND_CONTACT);
DeleteCommand deleteFirstCommand = new DeleteCommand(FIRST_CONTACT);
DeleteCommand deleteSecondCommand = new DeleteCommand(SECOND_CONTACT);

// same object -> returns true
assertTrue(deleteFirstCommand.equals(deleteFirstCommand));

// same values -> returns true
DeleteCommand deleteFirstCommandCopy = new DeleteCommand(INDEX_FIRST_CONTACT);
DeleteCommand deleteFirstCommandCopy = new DeleteCommand(FIRST_CONTACT);
assertTrue(deleteFirstCommand.equals(deleteFirstCommandCopy));

// different types -> returns false
Expand Down
60 changes: 29 additions & 31 deletions src/test/java/seedu/address/logic/commands/EditCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure;
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.address.logic.commands.CommandTestUtil.showContactAtIndex;
import static seedu.address.testutil.TestData.INDEX_FIRST_CONTACT;
import static seedu.address.testutil.TestData.INDEX_SECOND_CONTACT;
import static seedu.address.testutil.TestData.VALID_NAME_BOB;
import static seedu.address.testutil.TestData.VALID_PHONE_BOB;
import static seedu.address.testutil.TestData.getTypicalContacts;
import static seedu.address.testutil.TestData.IndexContact.FIRST_CONTACT;
import static seedu.address.testutil.TestData.IndexContact.SECOND_CONTACT;
import static seedu.address.testutil.TestData.Valid.Contact.getTypicalContacts;
import static seedu.address.testutil.TestData.Valid.NAME_BOB;
import static seedu.address.testutil.TestData.Valid.PHONE_BOB;

import org.junit.jupiter.api.Test;

Expand All @@ -26,8 +26,6 @@
import seedu.address.testutil.EditContactDescriptorBuilder;
import seedu.address.testutil.TestData;



/**
* Contains integration tests (interaction with the Model) and unit tests for EditCommand.
*/
Expand All @@ -39,7 +37,7 @@ public class EditCommandTest {
public void execute_allFieldsSpecifiedUnfilteredList_success() {
Contact editedContact = new ContactBuilder().build();
EditContactDescriptor descriptor = new EditContactDescriptorBuilder(editedContact).build();
EditCommand editCommand = new EditCommand(INDEX_FIRST_CONTACT, descriptor);
EditCommand editCommand = new EditCommand(FIRST_CONTACT, descriptor);

String expectedMessage = String.format(Messages.MESSAGE_EDIT_COMMAND_SUCCESS, Contact.format(editedContact));

Expand All @@ -55,11 +53,11 @@ public void execute_someFieldsSpecifiedUnfilteredList_success() {
Contact lastContact = model.getFilteredContactList().get(indexLastContact.getZeroBased());

ContactBuilder contactInList = new ContactBuilder(lastContact);
Contact editedContact = contactInList.withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB)
Contact editedContact = contactInList.withName(NAME_BOB).withPhone(PHONE_BOB)
.withTags(TestData.Valid.Tag.ALPHANUMERIC_SPACES).build();

EditContactDescriptor descriptor = new EditContactDescriptorBuilder().withName(VALID_NAME_BOB)
.withPhone(VALID_PHONE_BOB).withTags(TestData.Valid.Tag.ALPHANUMERIC_SPACES).build();
EditContactDescriptor descriptor = new EditContactDescriptorBuilder().withName(NAME_BOB)
.withPhone(PHONE_BOB).withTags(TestData.Valid.Tag.ALPHANUMERIC_SPACES).build();
EditCommand editCommand = new EditCommand(indexLastContact, descriptor);

String expectedMessage = String.format(Messages.MESSAGE_EDIT_COMMAND_SUCCESS, Contact.format(editedContact));
Expand All @@ -72,8 +70,8 @@ public void execute_someFieldsSpecifiedUnfilteredList_success() {

@Test
public void execute_noFieldSpecifiedUnfilteredList_success() {
EditCommand editCommand = new EditCommand(INDEX_FIRST_CONTACT, new EditContactDescriptor());
Contact editedContact = model.getFilteredContactList().get(INDEX_FIRST_CONTACT.getZeroBased());
EditCommand editCommand = new EditCommand(FIRST_CONTACT, new EditContactDescriptor());
Contact editedContact = model.getFilteredContactList().get(FIRST_CONTACT.getZeroBased());

String expectedMessage = String.format(Messages.MESSAGE_EDIT_COMMAND_SUCCESS, Contact.format(editedContact));

Expand All @@ -84,12 +82,12 @@ public void execute_noFieldSpecifiedUnfilteredList_success() {

@Test
public void execute_filteredList_success() {
showContactAtIndex(model, INDEX_FIRST_CONTACT);
showContactAtIndex(model, FIRST_CONTACT);

Contact contactInFilteredList = model.getFilteredContactList().get(INDEX_FIRST_CONTACT.getZeroBased());
Contact editedContact = new ContactBuilder(contactInFilteredList).withName(VALID_NAME_BOB).build();
EditCommand editCommand = new EditCommand(INDEX_FIRST_CONTACT,
new EditContactDescriptorBuilder().withName(VALID_NAME_BOB).build());
Contact contactInFilteredList = model.getFilteredContactList().get(FIRST_CONTACT.getZeroBased());
Contact editedContact = new ContactBuilder(contactInFilteredList).withName(NAME_BOB).build();
EditCommand editCommand = new EditCommand(FIRST_CONTACT,
new EditContactDescriptorBuilder().withName(NAME_BOB).build());

String expectedMessage = String.format(Messages.MESSAGE_EDIT_COMMAND_SUCCESS, Contact.format(editedContact));

Expand All @@ -101,20 +99,20 @@ public void execute_filteredList_success() {

@Test
public void execute_duplicateContactUnfilteredList_failure() {
Contact firstContact = model.getFilteredContactList().get(INDEX_FIRST_CONTACT.getZeroBased());
Contact firstContact = model.getFilteredContactList().get(FIRST_CONTACT.getZeroBased());
EditContactDescriptor descriptor = new EditContactDescriptorBuilder(firstContact).build();
EditCommand editCommand = new EditCommand(INDEX_SECOND_CONTACT, descriptor);
EditCommand editCommand = new EditCommand(SECOND_CONTACT, descriptor);

assertCommandFailure(editCommand, model, Messages.MESSAGE_COMMAND_DUPLICATE_CONTACT);
}

@Test
public void execute_duplicateContactFilteredList_failure() {
showContactAtIndex(model, INDEX_FIRST_CONTACT);
showContactAtIndex(model, FIRST_CONTACT);

// edit contact in filtered list into a duplicate
Contact contactInList = model.getContacts().getUnmodifiableList().get(INDEX_SECOND_CONTACT.getZeroBased());
EditCommand editCommand = new EditCommand(INDEX_FIRST_CONTACT,
Contact contactInList = model.getContacts().getUnmodifiableList().get(SECOND_CONTACT.getZeroBased());
EditCommand editCommand = new EditCommand(FIRST_CONTACT,
new EditContactDescriptorBuilder(contactInList).build());

assertCommandFailure(editCommand, model, Messages.MESSAGE_COMMAND_DUPLICATE_CONTACT);
Expand All @@ -123,7 +121,7 @@ public void execute_duplicateContactFilteredList_failure() {
@Test
public void execute_invalidContactIndexUnfilteredList_failure() {
Index outOfBoundIndex = Index.fromOneBased(model.getFilteredContactList().size() + 1);
EditContactDescriptor descriptor = new EditContactDescriptorBuilder().withName(VALID_NAME_BOB).build();
EditContactDescriptor descriptor = new EditContactDescriptorBuilder().withName(NAME_BOB).build();
EditCommand editCommand = new EditCommand(outOfBoundIndex, descriptor);

assertCommandFailure(editCommand, model, Messages.MESSAGE_INVALID_CONTACT_DISPLAYED_INDEX);
Expand All @@ -135,24 +133,24 @@ public void execute_invalidContactIndexUnfilteredList_failure() {
*/
@Test
public void execute_invalidContactIndexFilteredList_failure() {
showContactAtIndex(model, INDEX_FIRST_CONTACT);
Index outOfBoundIndex = INDEX_SECOND_CONTACT;
showContactAtIndex(model, FIRST_CONTACT);
Index outOfBoundIndex = SECOND_CONTACT;
// ensures that outOfBoundIndex is still in bounds of Contacts
assertTrue(outOfBoundIndex.getZeroBased() < model.getContacts().getUnmodifiableList().size());

EditCommand editCommand = new EditCommand(outOfBoundIndex,
new EditContactDescriptorBuilder().withName(VALID_NAME_BOB).build());
new EditContactDescriptorBuilder().withName(NAME_BOB).build());

assertCommandFailure(editCommand, model, Messages.MESSAGE_INVALID_CONTACT_DISPLAYED_INDEX);
}

@Test
public void equals() {
final EditCommand standardCommand = new EditCommand(INDEX_FIRST_CONTACT, TestData.Valid.EditDescriptor.AMY);
final EditCommand standardCommand = new EditCommand(FIRST_CONTACT, TestData.Valid.EditDescriptor.AMY);

// same values -> returns true
EditContactDescriptor copyDescriptor = new EditContactDescriptor(TestData.Valid.EditDescriptor.AMY);
EditCommand commandWithSameValues = new EditCommand(INDEX_FIRST_CONTACT, copyDescriptor);
EditCommand commandWithSameValues = new EditCommand(FIRST_CONTACT, copyDescriptor);
assertTrue(standardCommand.equals(commandWithSameValues));

// same object -> returns true
Expand All @@ -165,10 +163,10 @@ public void equals() {
assertFalse(standardCommand.equals(new ClearCommand()));

// different index -> returns false
assertFalse(standardCommand.equals(new EditCommand(INDEX_SECOND_CONTACT, TestData.Valid.EditDescriptor.AMY)));
assertFalse(standardCommand.equals(new EditCommand(SECOND_CONTACT, TestData.Valid.EditDescriptor.AMY)));

// different descriptor -> returns false
assertFalse(standardCommand.equals(new EditCommand(INDEX_FIRST_CONTACT, TestData.Valid.EditDescriptor.BOB)));
assertFalse(standardCommand.equals(new EditCommand(FIRST_CONTACT, TestData.Valid.EditDescriptor.BOB)));
}

@Test
Expand Down
Loading

0 comments on commit 1441c70

Please sign in to comment.