Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update new Junit Test for new adjustment in EditCommand #96

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions src/main/java/seedu/address/model/person/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,30 +127,6 @@ public int hashCode() {
return Objects.hash(name, phone, email, tags);
}

/**
* changes name.
* @param newNameValue
*/
public void changeName(String newNameValue) {

}

/**
* changes number.
* @param newNumber
*/
public void changePhoneNumber(String newNumber) {

}

/**
* changes email.
* @param newEmail
*/
public void changeEmail(String newEmail) {

}

@Override
public String toString() {
return new ToStringBuilder(this)
Expand Down
38 changes: 37 additions & 1 deletion src/test/java/seedu/address/logic/commands/EditCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static seedu.address.logic.commands.CommandTestUtil.DESC_AMY;
import static seedu.address.logic.commands.CommandTestUtil.DESC_BOB;
import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_BOB;
Expand All @@ -13,6 +14,7 @@
import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailureWithoutModel;
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.address.logic.commands.CommandTestUtil.showPersonAtIndex;
import static seedu.address.logic.commands.EditCommand.MESSAGE_DUPLICATE_PERSON;
import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON;
import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PERSON;
import static seedu.address.testutil.TypicalPersons.getTypicalCampusConnect;
Expand All @@ -22,10 +24,12 @@
import seedu.address.commons.core.index.Index;
import seedu.address.logic.Messages;
import seedu.address.logic.commands.EditCommand.EditPersonDescriptor;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.CampusConnect;
import seedu.address.model.Model;
import seedu.address.model.ModelManager;
import seedu.address.model.UserPrefs;
import seedu.address.model.person.Name;
import seedu.address.model.person.Person;
import seedu.address.testutil.EditPersonDescriptorBuilder;
import seedu.address.testutil.PersonBuilder;
Expand Down Expand Up @@ -124,6 +128,7 @@ public void execute_duplicatePersonUnfilteredList_failure() {
EditCommand editCommand = new EditCommand(INDEX_SECOND_PERSON, descriptor);

assertCommandFailureWithoutModel(editCommand, model, EditCommand.MESSAGE_DUPLICATE_PERSON);

}

@Test
Expand All @@ -134,8 +139,8 @@ public void execute_duplicatePersonFilteredList_failure() {
Person personInList = model.getCampusConnect().getPersonList().get(INDEX_SECOND_PERSON.getZeroBased());
EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON,
new EditPersonDescriptorBuilder(personInList).build());

assertCommandFailureWithoutModel(editCommand, model, EditCommand.MESSAGE_DUPLICATE_PERSON);

}

@Test
Expand Down Expand Up @@ -199,4 +204,35 @@ public void toStringMethod() {
assertEquals(expected, editCommand.toString());
}

@Test
public void executeMethodCheckDuplicate1() {
Model testModel = new ModelManager(getTypicalCampusConnect(), new UserPrefs());
Index index = Index.fromOneBased(4);
EditPersonDescriptor editPersonDescriptor = new EditPersonDescriptor();
editPersonDescriptor.setName(new Name("Alice Pauline"));
EditCommand editCommand = new EditCommand(index, editPersonDescriptor);
try {
editCommand.execute(testModel);
fail("CommandException expected");
} catch (CommandException e) {
assertEquals(e.getMessage(), MESSAGE_DUPLICATE_PERSON);
}

}

@Test
public void executeMethodCheckDuplicate2() {
Model testModel = new ModelManager(getTypicalCampusConnect(), new UserPrefs());
Index index = Index.fromOneBased(1);
EditPersonDescriptor editPersonDescriptor = new EditPersonDescriptor();
editPersonDescriptor.setName(new Name("Alice Pauline"));
EditCommand editCommand = new EditCommand(index, editPersonDescriptor);
try {
editCommand.execute(testModel);
} catch (CommandException e) {
fail("No Exception Expected");
}

}

}