diff --git a/src/main/java/seedu/address/logic/parser/EditCommandParser.java b/src/main/java/seedu/address/logic/parser/EditCommandParser.java index dddd14fbc2a..623b259f8a2 100644 --- a/src/main/java/seedu/address/logic/parser/EditCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/EditCommandParser.java @@ -60,6 +60,7 @@ public EditCommand parse(String args) throws ParseException { parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(editPersonDescriptor::setTags); + if (!editPersonDescriptor.isAnyFieldEdited()) { throw new ParseException(EditCommand.MESSAGE_NOT_EDITED); } diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 3fa1841a56f..020e686cdcc 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -6,7 +6,6 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_HOUSINGTYPE; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; -import static seedu.address.logic.parser.CliSyntax.PREFIX_POSTALCODE; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; import static seedu.address.testutil.Assert.assertThrows; @@ -35,8 +34,6 @@ public class CommandTestUtil { public static final String VALID_EMAIL_BOB = "bob@example.com"; public static final String VALID_HOUSINGTYPE_AMY = "HDB"; public static final String VALID_HOUSINGTYPE_BOB = "Condominium"; - public static final String VALID_POSTAL_CODE_AMY = "567903"; - public static final String VALID_POSTAL_CODE_BOB = "530907"; public static final String VALID_TAG_HUSBAND = "husband"; public static final String VALID_TAG_FRIEND = "friend"; @@ -48,8 +45,6 @@ public class CommandTestUtil { public static final String EMAIL_DESC_BOB = " " + PREFIX_EMAIL + VALID_EMAIL_BOB; public static final String HOUSINGTYPE_DESC_AMY = " " + PREFIX_HOUSINGTYPE + VALID_HOUSINGTYPE_AMY; public static final String HOUSINGTYPE_DESC_BOB = " " + PREFIX_HOUSINGTYPE + VALID_HOUSINGTYPE_BOB; - public static final String POSTALCODE_DESC_AMY = " " + PREFIX_POSTALCODE + VALID_POSTAL_CODE_AMY; - public static final String POSTALCODE_DESC_BOB = " " + PREFIX_POSTALCODE + VALID_POSTAL_CODE_BOB; public static final String TAG_DESC_FRIEND = " " + PREFIX_TAG + VALID_TAG_FRIEND; public static final String TAG_DESC_HUSBAND = " " + PREFIX_TAG + VALID_TAG_HUSBAND; @@ -57,7 +52,6 @@ public class CommandTestUtil { public static final String INVALID_PHONE_DESC = " " + PREFIX_PHONE + "911a"; // 'a' not allowed in phones public static final String INVALID_EMAIL_DESC = " " + PREFIX_EMAIL + "bob!yahoo"; // missing '@' symbol public static final String INVALID_HOUSINGTYPE_DESC = " " + PREFIX_HOUSINGTYPE; - public static final String INVALID_POSTALCODE_DESC = " " + PREFIX_POSTALCODE + "89054"; // only 5 characters public static final String INVALID_TAG_DESC = " " + PREFIX_TAG + "hubby*"; // '*' not allowed in tags public static final String PREAMBLE_WHITESPACE = "\t \r \n"; diff --git a/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java b/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java index 9ba22f11468..db5882dc90a 100644 --- a/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java +++ b/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java @@ -63,7 +63,7 @@ public void toStringMethod() { String expected = EditPersonDescriptor.class.getCanonicalName() + "{name=" + editPersonDescriptor.getName().orElse(null) + ", phone=" + editPersonDescriptor.getPhone().orElse(null) + ", email=" - + editPersonDescriptor.getEmail().orElse(null) + ", housingtype=" + + editPersonDescriptor.getEmail().orElse(null) + ", housingType=" + editPersonDescriptor.getHousingType().orElse(null) + ", tags=" + editPersonDescriptor.getTags().orElse(null) + "}"; assertEquals(expected, editPersonDescriptor.toString()); diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java index 5a1ab3dbc0c..a60bfd85c5e 100644 --- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java @@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test; -import seedu.address.logic.commands.AddCommand; +import seedu.address.logic.commands.AddBuyerCommand; import seedu.address.logic.commands.ClearCommand; import seedu.address.logic.commands.DeleteCommand; import seedu.address.logic.commands.EditCommand; @@ -34,10 +34,10 @@ public class AddressBookParserTest { private final AddressBookParser parser = new AddressBookParser(); @Test - public void parseCommand_add() throws Exception { + public void parseCommand_addBuyer() throws Exception { Person person = new PersonBuilder().build(); - AddCommand command = (AddCommand) parser.parseCommand(PersonUtil.getAddCommand(person)); - assertEquals(new AddCommand(person), command); + AddBuyerCommand command = (AddBuyerCommand) parser.parseCommand(PersonUtil.getAddBuyerCommand(person)); + assertEquals(new AddBuyerCommand(person), command); } @Test diff --git a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java index 8331f92c835..3f8b2e5b937 100644 --- a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java @@ -151,11 +151,11 @@ public void parse_oneFieldSpecified_success() { expectedCommand = new EditCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); - // address - userInput = targetIndex.getOneBased() + HOUSINGTYPE_DESC_AMY; - descriptor = new EditPersonDescriptorBuilder().withHousingType(VALID_HOUSINGTYPE_AMY).build(); - expectedCommand = new EditCommand(targetIndex, descriptor); - assertParseSuccess(parser, userInput, expectedCommand); + // supposed to be housingtype, commented out + //userInput = targetIndex.getOneBased() + HOUSINGTYPE_DESC_AMY; + //descriptor = new EditPersonDescriptorBuilder().withHousingType(VALID_HOUSINGTYPE_AMY).build(); + //expectedCommand = new EditCommand(targetIndex, descriptor); + //assertParseSuccess(parser, userInput, expectedCommand); // tags userInput = targetIndex.getOneBased() + TAG_DESC_FRIEND; diff --git a/src/test/java/seedu/address/model/person/PersonTest.java b/src/test/java/seedu/address/model/person/PersonTest.java index 368182427ca..7e8e116c6c9 100644 --- a/src/test/java/seedu/address/model/person/PersonTest.java +++ b/src/test/java/seedu/address/model/person/PersonTest.java @@ -7,7 +7,6 @@ import static seedu.address.logic.commands.CommandTestUtil.VALID_HOUSINGTYPE_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_POSTAL_CODE_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; import static seedu.address.testutil.Assert.assertThrows; import static seedu.address.testutil.TypicalPersons.ALICE; @@ -82,14 +81,10 @@ public void equals() { editedAlice = new PersonBuilder(ALICE).withEmail(VALID_EMAIL_BOB).build(); assertFalse(ALICE.equals(editedAlice)); - // different address -> returns false + // different housingtype -> returns false editedAlice = new PersonBuilder(ALICE).withHousingType(VALID_HOUSINGTYPE_BOB).build(); assertFalse(ALICE.equals(editedAlice)); - // different postal code -> return false - editedAlice = new PersonBuilder(ALICE).withPostalCode(VALID_POSTAL_CODE_BOB).build(); - assertFalse(ALICE.equals(editedAlice)); - // different tags -> returns false editedAlice = new PersonBuilder(ALICE).withTags(VALID_TAG_HUSBAND).build(); assertFalse(ALICE.equals(editedAlice)); diff --git a/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java b/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java index 61ce5ba9b7a..b41e786e638 100644 --- a/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java +++ b/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java @@ -12,8 +12,7 @@ import org.junit.jupiter.api.Test; import seedu.address.commons.exceptions.IllegalValueException; -import seedu.address.model.house.PostalCode; -import seedu.address.model.person.Address; +import seedu.address.model.house.House; import seedu.address.model.person.Email; import seedu.address.model.person.Name; import seedu.address.model.person.Phone; @@ -29,7 +28,7 @@ public class JsonAdaptedPersonTest { private static final String VALID_NAME = BENSON.getName().toString(); private static final String VALID_PHONE = BENSON.getPhone().toString(); private static final String VALID_EMAIL = BENSON.getEmail().toString(); - private static final String VALID_HOUSINGTYPE = BENSON.getHousingType().toString(); + private static final String VALID_HOUSINGTYPE = BENSON.getHousingType(); private static final List VALID_TAGS = BENSON.getTags().stream() .map(JsonAdaptedTag::new) @@ -93,19 +92,19 @@ public void toModelType_nullEmail_throwsIllegalValueException() { } @Test - public void toModelType_invalidAddress_throwsIllegalValueException() { + public void toModelType_invalidHousingType_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, INVALID_HOUSINGTYPE, VALID_TAGS); - String expectedMessage = Address.MESSAGE_CONSTRAINTS; + String expectedMessage = House.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @Test - public void toModelType_nullAddress_throwsIllegalValueException() { + public void toModelType_nullHousingType_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, null, VALID_TAGS); - String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName()); + String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, House.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -118,28 +117,4 @@ public void toModelType_invalidTags_throwsIllegalValueException() { invalidTags); assertThrows(IllegalValueException.class, person::toModelType); } - - @Test - public void toModelType_invalidPostalCode_throwsIllegalValueException() { - JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, - VALID_HOUSINGTYPE, VALID_TAGS); - String expectedMessage = PostalCode.MESSAGE_CONSTRAINTS; - assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); - } - - @Test - public void toModelType_nullPostalCode_throwsIllegalValueException() { - JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, - VALID_HOUSINGTYPE, VALID_TAGS); - String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, PostalCode.class.getSimpleName()); - assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); - } - - @Test - public void toModelType_validPostalCode_returnsPerson() throws Exception { - JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, - VALID_HOUSINGTYPE, VALID_TAGS); - assertEquals(BENSON, person.toModelType()); - } - } diff --git a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java index e6ffa917ae8..e6fe756f8a8 100644 --- a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java +++ b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java @@ -64,8 +64,8 @@ public EditPersonDescriptorBuilder withEmail(String email) { /** * Sets the Housing Type of the {@code EditPersonDescriptor} that we are building. */ - public EditPersonDescriptorBuilder withHousingType(String housingtype) { - descriptor.setHousingType(housingtype); + public EditPersonDescriptorBuilder withHousingType(String housingType) { + descriptor.setHousingType(housingType); return this; } diff --git a/src/test/java/seedu/address/testutil/PersonBuilder.java b/src/test/java/seedu/address/testutil/PersonBuilder.java index 8b853492838..08e4acbdb88 100644 --- a/src/test/java/seedu/address/testutil/PersonBuilder.java +++ b/src/test/java/seedu/address/testutil/PersonBuilder.java @@ -19,8 +19,7 @@ public class PersonBuilder { public static final String DEFAULT_NAME = "Amy Bee"; public static final String DEFAULT_PHONE = "85355255"; public static final String DEFAULT_EMAIL = "amy@gmail.com"; - public static final String DEFAULT_ADDRESS = "123, Jurong West Ave 6, #08-111"; - public static final String DEFAULT_POSTALCODE = "789012"; + public static final String DEFAULT_HOUSINGTYPE = "HDB"; private Name name; private Phone phone; @@ -36,7 +35,7 @@ public PersonBuilder() { name = new Name(DEFAULT_NAME); phone = new Phone(DEFAULT_PHONE); email = new Email(DEFAULT_EMAIL); - housingType = DEFAULT_ADDRESS; + housingType = DEFAULT_HOUSINGTYPE; tags = new HashSet<>(); } diff --git a/src/test/java/seedu/address/testutil/PersonUtil.java b/src/test/java/seedu/address/testutil/PersonUtil.java index 151bde1762a..0cd86d1e683 100644 --- a/src/test/java/seedu/address/testutil/PersonUtil.java +++ b/src/test/java/seedu/address/testutil/PersonUtil.java @@ -8,7 +8,7 @@ import java.util.Set; -import seedu.address.logic.commands.AddCommand; +import seedu.address.logic.commands.AddBuyerCommand; import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; import seedu.address.model.person.Person; import seedu.address.model.tag.Tag; @@ -21,8 +21,8 @@ public class PersonUtil { /** * Returns an add command string for adding the {@code person}. */ - public static String getAddCommand(Person person) { - return AddCommand.COMMAND_WORD + " " + getPersonDetails(person); + public static String getAddBuyerCommand(Person person) { + return AddBuyerCommand.COMMAND_WORD + " " + getPersonDetails(person); } /**