Skip to content

Commit

Permalink
Merge pull request #151 from Tsenrae/Branch-DeprecatePerson
Browse files Browse the repository at this point in the history
Deprecate Name, Phone and Address and update test cases to reflect new changes
  • Loading branch information
Bandov authored Apr 3, 2024
2 parents c5c8d41 + 4b0cbf4 commit fa35674
Show file tree
Hide file tree
Showing 24 changed files with 216 additions and 450 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.Messages.MESSAGE_UNKNOWN_COMMAND;

import java.util.Map;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -33,7 +32,6 @@
import seedu.address.logic.relationship.FamilySearchCommand;
import seedu.address.logic.relationship.FamilySearchCommandParser;
import seedu.address.logic.relationship.ListRelationshipTypesCommand;
import seedu.address.model.person.Person;

/**
* Parses user input.
Expand All @@ -54,7 +52,6 @@ public class AddressBookParser {
* @throws ParseException if the user input does not conform the expected format
*/
public Command parseCommand(String userInput) throws ParseException, CommandException {
Map<String, Person> personMap; // Assume this is populated elsewhere
final Matcher matcher = BASIC_COMMAND_FORMAT.matcher(userInput.trim());
if (!matcher.matches()) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, HelpCommand.MESSAGE_USAGE));
Expand Down
65 changes: 0 additions & 65 deletions src/main/java/seedu/address/model/person/Address.java

This file was deleted.

67 changes: 0 additions & 67 deletions src/main/java/seedu/address/model/person/Name.java

This file was deleted.

20 changes: 1 addition & 19 deletions src/main/java/seedu/address/model/person/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public boolean deleteAttribute(String attributeType) {
}


private static void assertValidAttribute(Attribute attribute) {
static void assertValidAttribute(Attribute attribute) {
if (attribute == null) {
throw new IllegalArgumentException("Attribute cannot be null.");
}
Expand All @@ -185,24 +185,6 @@ private static void assertAttributeExistsInPerson(String attributeType, Map<Stri
}
}

/**
* Returns true if both persons have the same name.
* This defines a weaker notion of equality between two persons.
*/
public boolean isSamePerson(Person otherPerson) {
if (otherPerson == this) {
return true;
}

Attribute otherPersonNameAttribute = otherPerson.attributes.get("Name");
Attribute thisPersonNameAttribute = this.attributes.get("Name");

return otherPerson != null
&& otherPersonNameAttribute != null
&& thisPersonNameAttribute != null
&& otherPersonNameAttribute.getValueAsString().equals(thisPersonNameAttribute.getValueAsString());
}

/**
* Returns true if both persons have the same identity and data fields.
* This defines a stronger notion of equality between two persons.
Expand Down
61 changes: 0 additions & 61 deletions src/main/java/seedu/address/model/person/Phone.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* Supports a minimal set of list operations.
*
* @see Person#isSamePerson(Person)
* @see Person#equals(Object)
*/
public class UniquePersonList implements Iterable<Person> {

Expand Down Expand Up @@ -61,7 +61,7 @@ public void setPerson(Person target, Person editedPerson) {
throw new PersonNotFoundException();
}

if (!target.isSamePerson(editedPerson) && contains(editedPerson)) {
if (!target.equals(editedPerson) && contains(editedPerson)) {
throw new DuplicatePersonException();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
{
"persons": [ {
"name": "Valid Person",
"phone": "9482424",
"email": "[email protected]",
"address": "4th street"
"persons" : [ {
"uuid" : "00000000-0000-0000-0000-000000000001",
"attributes" : [
{ "name": "Name", "value": "Alice Pauline" },
{ "name": "Phone", "value": "94351253" },
{ "name": "Email", "value": "[email protected]" },
{ "name": "Address", "value": "123, Jurong West Ave 6, #08-111" }
]
}, {
"name": "Person With Invalid Phone Field",
"phone": "948asdf2424",
"email": "[email protected]",
"address": "4th street"
"uuid" : "invalid uuid",
"attributes" : [
{ "name": "Name", "value": "Alice Pauline" },
{ "name": "Phone", "value": "94351253" },
{ "name": "Email", "value": "[email protected]" },
{ "name": "Address", "value": "123, Jurong West Ave 6, #08-111" }
]
} ]
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"persons": [ {
"name": "Person with invalid name field: Ha!ns Mu@ster",
"phone": "9482424",
"email": "[email protected]",
"address": "4th street"
"uuid" : "invalid uuid",
"attributes" : [
{ "name": "Name", "value": "Alice Pauline" },
{ "name": "Phone", "value": "94351253" },
{ "name": "Email", "value": "[email protected]" },
{ "name": "Address", "value": "123, Jurong West Ave 6, #08-111" }
]
} ]
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"persons": [ {
"name": "Hans Muster",
"phone": "9482424",
"email": "invalid@email!3e",
"address": "4th street"
"uuid" : "invalid uuid",
"attributes" : [
{ "name": "Name", "value": "Alice Pauline" },
{ "name": "Phone", "value": "94351253" },
{ "name": "Email", "value": "[email protected]" },
{ "name": "Address", "value": "123, Jurong West Ave 6, #08-111" }
]
} ]
}
2 changes: 1 addition & 1 deletion src/test/java/seedu/address/logic/LogicManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_AMY;
import static seedu.address.logic.commands.CommandTestUtil.PHONE_DESC_AMY;
import static seedu.address.testutil.Assert.assertThrows;
import static seedu.address.testutil.TypicalPersons.AMY;
import static seedu.address.testutil.TypicalPersonsUuid.AMY;

import java.io.IOException;
import java.nio.file.AccessDeniedException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ private class ModelStubWithPerson extends ModelStub {
@Override
public boolean hasPerson(Person person) {
requireNonNull(person);
return this.person.isSamePerson(person);
return this.person.equals(person);
}
}

Expand All @@ -267,7 +267,7 @@ private class ModelStubAcceptingPersonAdded extends ModelStub {
@Override
public boolean hasPerson(Person person) {
requireNonNull(person);
return personsAdded.stream().anyMatch(person::isSamePerson);
return personsAdded.stream().anyMatch(person::equals);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package seedu.address.logic.commands;

import static org.junit.jupiter.api.Assertions.assertThrows;
import static seedu.address.testutil.TypicalPersons.ALICE;
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook;
import static seedu.address.testutil.TypicalPersonsUuid.ALICE;
import static seedu.address.testutil.TypicalPersonsUuid.getTypicalAddressBook;

import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.DeleteAttributeCommand;
import seedu.address.logic.commands.DeleteCommand;
import seedu.address.logic.commands.EditAttributeCommand;
import seedu.address.logic.commands.ExitCommand;
import seedu.address.logic.commands.FindCommand;
import seedu.address.logic.commands.HelpCommand;
Expand Down Expand Up @@ -107,6 +108,14 @@ public void parseCommand_delAttribute() throws Exception {
assertTrue(command instanceof DeleteAttributeCommand);
}

@Test
public void parseCommand_editAttribute() throws Exception {
String userInput = "editAttribute /4000 /Name John /Name John Doe";
Command command = parser.parseCommand(userInput);

assertTrue(command instanceof EditAttributeCommand);
}

@Test
public void parseCommand_unrecognisedInput_throwsParseException() {
assertThrows(ParseException.class, String.format(MESSAGE_INVALID_COMMAND_FORMAT, HelpCommand.MESSAGE_USAGE), ()
Expand Down
Loading

0 comments on commit fa35674

Please sign in to comment.