From 1a761c7ffae2fde17f96c9c736732c4f794eb636 Mon Sep 17 00:00:00 2001 From: Carl Date: Tue, 12 Mar 2024 22:44:00 +0800 Subject: [PATCH 01/24] Add new Level class This class is to be used by house class later on. --- .../java/seedu/address/model/house/Level.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/main/java/seedu/address/model/house/Level.java diff --git a/src/main/java/seedu/address/model/house/Level.java b/src/main/java/seedu/address/model/house/Level.java new file mode 100644 index 00000000000..15f44b21efa --- /dev/null +++ b/src/main/java/seedu/address/model/house/Level.java @@ -0,0 +1,61 @@ +package seedu.address.model.house; + +import static java.util.Objects.requireNonNull; +import static seedu.address.commons.util.AppUtil.checkArgument; + + +/** + * Represents a House's level. + * Guarantees: immutable; is valid as declared in {@link #isValidLevel(String)} + */ +public class Level { + + public static final String MESSAGE_CONSTRAINTS = + "Level should only contain numbers, and it should only be at most 2 digits long"; + public static final String VALIDATION_REGEX = "\\d{1,2}"; + public final String value; + + /** + * Constructs a {@code Level}. + * + * @param level A valid level. + */ + public Level(String level) { + requireNonNull(level); + checkArgument(isValidLevel(level), MESSAGE_CONSTRAINTS); + value = level; + } + + /** + * Returns true if a given string is a valid level. + */ + public static boolean isValidLevel(String test) { + return test.matches(VALIDATION_REGEX); + } + + @Override + public String toString() { + return value; + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + + // instanceof handles nulls + if (!(other instanceof Level)) { + return false; + } + + Level otherLevel = (Level) other; + return value.equals(otherLevel.value); + } + + @Override + public int hashCode() { + return value.hashCode(); + } + +} From e402955e6dda0026d3edda64d9a48d8b9eb3f6de Mon Sep 17 00:00:00 2001 From: Carl Date: Tue, 12 Mar 2024 23:02:30 +0800 Subject: [PATCH 02/24] Add test cases for level class The test cases are responsible for checking null entries, various invalid entries, and equals() method for Level class. --- .../seedu/address/model/house/LevelTest.java | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/test/java/seedu/address/model/house/LevelTest.java diff --git a/src/test/java/seedu/address/model/house/LevelTest.java b/src/test/java/seedu/address/model/house/LevelTest.java new file mode 100644 index 00000000000..6ddc90f2cf4 --- /dev/null +++ b/src/test/java/seedu/address/model/house/LevelTest.java @@ -0,0 +1,67 @@ +package seedu.address.model.house; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static seedu.address.testutil.Assert.assertThrows; + +import org.junit.jupiter.api.Test; + +public class LevelTest { + + @Test + public void constructor_null_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> new Level(null)); + } + + @Test + public void constructor_invalidLevel_throwsIllegalArgumentException() { + String invalidLevel = ""; + assertThrows(IllegalArgumentException.class, () -> new Level(invalidLevel)); + } + + @Test + public void isValidLevel() { + // null level + assertThrows(NullPointerException.class, () -> Level.isValidLevel(null)); + + // blank levels + assertFalse(Level.isValidLevel("")); // empty string + assertFalse(Level.isValidLevel(" ")); // spaces only + + // invalid levels + assertFalse(Level.isValidLevel("a")); // non-digit only + assertFalse(Level.isValidLevel("aa")); // non-digit only + assertFalse(Level.isValidLevel("###")); // non-digit only + assertFalse(Level.isValidLevel("!@#")); // non-digit only + assertFalse(Level.isValidLevel("a1")); // digit + non-digit + assertFalse(Level.isValidLevel("1a")); // non-digit + digit + assertFalse(Level.isValidLevel("111")); // number of digits > 2 + assertFalse(Level.isValidLevel("44aa")); // number of digits >= 2 with letters + assertFalse(Level.isValidLevel("44aaaaa")); // number of digits >= 2 with letters + + // valid levels + assertTrue(Level.isValidLevel("1")); // one digit + assertTrue(Level.isValidLevel("11")); // two digits + assertTrue(Level.isValidLevel("01")); // two digits + } + + @Test + public void equals() { + Level level = new Level("99"); + + // same values -> returns true + assertTrue(level.equals(new Level("99"))); + + // same object -> returns true + assertTrue(level.equals(level)); + + // null -> returns false + assertFalse(level.equals(null)); + + // different types -> returns false + assertFalse(level.equals(5.0f)); + + // different values -> returns false + assertFalse(level.equals(new Level("11"))); + } +} From 94513da34a87790fd1e778460ce8d26051406968 Mon Sep 17 00:00:00 2001 From: Carl Date: Tue, 12 Mar 2024 23:07:05 +0800 Subject: [PATCH 03/24] Add a prefix for level field --- src/main/java/seedu/address/logic/parser/CliSyntax.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/seedu/address/logic/parser/CliSyntax.java b/src/main/java/seedu/address/logic/parser/CliSyntax.java index 75b1a9bf119..a3ea3e542c6 100644 --- a/src/main/java/seedu/address/logic/parser/CliSyntax.java +++ b/src/main/java/seedu/address/logic/parser/CliSyntax.java @@ -12,4 +12,5 @@ public class CliSyntax { public static final Prefix PREFIX_ADDRESS = new Prefix("a/"); public static final Prefix PREFIX_TAG = new Prefix("t/"); + public static final Prefix PREFIX_LEVEL = new Prefix("level/"); } From de37b540c5dc05875802899b96118d61f32ddbe8 Mon Sep 17 00:00:00 2001 From: Carl Date: Wed, 13 Mar 2024 01:11:39 +0800 Subject: [PATCH 04/24] Add new Street class This class is to be used by house class later on. --- .../seedu/address/model/house/Street.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/main/java/seedu/address/model/house/Street.java diff --git a/src/main/java/seedu/address/model/house/Street.java b/src/main/java/seedu/address/model/house/Street.java new file mode 100644 index 00000000000..b80763ff0b1 --- /dev/null +++ b/src/main/java/seedu/address/model/house/Street.java @@ -0,0 +1,60 @@ +package seedu.address.model.house; + +import static java.util.Objects.requireNonNull; +import static seedu.address.commons.util.AppUtil.checkArgument; + +/** + * Represents a House's street. + * Guarantees: immutable; is valid as declared in {@link #isValidStreet(String)} + */ +public class Street { + + public static final String MESSAGE_CONSTRAINTS = + "Street should only contain alphanumeric characters."; + public static final String VALIDATION_REGEX = "^[a-zA-Z0-9]*$"; + public final String value; + + /** + * Constructs a {@code Street}. + * + * @param street A valid street. + */ + public Street(String street) { + requireNonNull(street); + checkArgument(isValidStreet(street), MESSAGE_CONSTRAINTS); + value = street; + } + + /** + * Returns true if a given string is a valid street. + */ + public static boolean isValidStreet(String test) { + return test.matches(VALIDATION_REGEX); + } + + @Override + public String toString() { + return value; + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + + // instanceof handles nulls + if (!(other instanceof Street)) { + return false; + } + + Street otherStreet = (Street) other; + return value.equals(otherStreet.value); + } + + @Override + public int hashCode() { + return value.hashCode(); + } + +} From 3a69bf3fbd60c9b991220a899f15534c8b6b3c7a Mon Sep 17 00:00:00 2001 From: Carl Date: Wed, 13 Mar 2024 01:31:42 +0800 Subject: [PATCH 05/24] Add test cases for Street class The test cases are responsible for checking null entries, various invalid entries, and equals() method for Street class. Update regex expression for street validation Previously, the regex expression accepts only whitespace inputs, and does not accept hyphens. Now, the regex now accepts streets with hyphens and does not allow whitespace-only inputs. --- .../seedu/address/model/house/Street.java | 4 +- .../seedu/address/model/house/StreetTest.java | 60 +++++++++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 src/test/java/seedu/address/model/house/StreetTest.java diff --git a/src/main/java/seedu/address/model/house/Street.java b/src/main/java/seedu/address/model/house/Street.java index b80763ff0b1..4955965b2a0 100644 --- a/src/main/java/seedu/address/model/house/Street.java +++ b/src/main/java/seedu/address/model/house/Street.java @@ -10,8 +10,8 @@ public class Street { public static final String MESSAGE_CONSTRAINTS = - "Street should only contain alphanumeric characters."; - public static final String VALIDATION_REGEX = "^[a-zA-Z0-9]*$"; + "Street should only contain alphanumeric characters and hyphens."; + public static final String VALIDATION_REGEX = "^(?=.*[a-zA-Z0-9])[a-zA-Z0-9\\s-]+$"; public final String value; /** diff --git a/src/test/java/seedu/address/model/house/StreetTest.java b/src/test/java/seedu/address/model/house/StreetTest.java new file mode 100644 index 00000000000..507f1f6785f --- /dev/null +++ b/src/test/java/seedu/address/model/house/StreetTest.java @@ -0,0 +1,60 @@ +package seedu.address.model.house; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static seedu.address.testutil.Assert.assertThrows; + +import org.junit.jupiter.api.Test; + +public class StreetTest { + @Test + public void constructor_null_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> new Street(null)); + } + + @Test + public void constructor_invalidPhone_throwsIllegalArgumentException() { + String invalidStreet = ""; + assertThrows(IllegalArgumentException.class, () -> new Street(invalidStreet)); + } + + @Test + public void isValidStreet() { + // null street + assertThrows(NullPointerException.class, () -> Street.isValidStreet(null)); + + // invalid street + assertFalse(Street.isValidStreet("")); // empty string + assertFalse(Street.isValidStreet(" ")); // spaces only + assertFalse(Street.isValidStreet("-")); // hyphen only + assertFalse(Street.isValidStreet("@!^&*%&^")); // non-alphanumeric + assertFalse(Street.isValidStreet("qwe!@#ert$%")); // non-alphanumeric + alphabets + assertFalse(Street.isValidStreet("!@#123")); // non-alphanumeric + numbers + assertFalse(Street.isValidStreet("t3$t!ng")); // non-alphanumeric + alphanumerics + + // valid street + assertTrue(Street.isValidStreet("292A East Coast Rd")); + assertTrue(Street.isValidStreet("350 Orchard Rd Sshaw House 13-01")); // with dash + assertTrue(Street.isValidStreet("46 PANDAN LOOP BLK 3 PANDAN LIGHT IND PARK")); // all caps + } + + @Test + public void equals() { + Street street = new Street("15 Kaki Bukit View 01-00"); + + // same values -> returns true + assertTrue(street.equals(new Street("15 Kaki Bukit View 01-00"))); + + // same object -> returns true + assertTrue(street.equals(street)); + + // null -> returns false + assertFalse(street.equals(null)); + + // different types -> returns false + assertFalse(street.equals(5.0f)); + + // different values -> returns false + assertFalse(street.equals(new Street("3 Sungei Kadut Street 6 Sungei Kadut Industrial Estate"))); + } +} From d21c472472c0a2563845843b98bb62f371ebddcd Mon Sep 17 00:00:00 2001 From: Carl Date: Wed, 13 Mar 2024 01:32:39 +0800 Subject: [PATCH 06/24] Add a prefix for street field --- src/main/java/seedu/address/logic/parser/CliSyntax.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/seedu/address/logic/parser/CliSyntax.java b/src/main/java/seedu/address/logic/parser/CliSyntax.java index 75b1a9bf119..650f65047c3 100644 --- a/src/main/java/seedu/address/logic/parser/CliSyntax.java +++ b/src/main/java/seedu/address/logic/parser/CliSyntax.java @@ -11,5 +11,5 @@ public class CliSyntax { public static final Prefix PREFIX_EMAIL = new Prefix("e/"); public static final Prefix PREFIX_ADDRESS = new Prefix("a/"); public static final Prefix PREFIX_TAG = new Prefix("t/"); - + public static final Prefix PREFIX_STREET = new Prefix("street/"); } From d17642cb8f91b153c609611f8faecb85a90b2b1f Mon Sep 17 00:00:00 2001 From: Carl Date: Wed, 13 Mar 2024 01:56:14 +0800 Subject: [PATCH 07/24] Fix typo in method name --- src/test/java/seedu/address/model/house/StreetTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/seedu/address/model/house/StreetTest.java b/src/test/java/seedu/address/model/house/StreetTest.java index 507f1f6785f..af3892cd6c4 100644 --- a/src/test/java/seedu/address/model/house/StreetTest.java +++ b/src/test/java/seedu/address/model/house/StreetTest.java @@ -13,7 +13,7 @@ public void constructor_null_throwsNullPointerException() { } @Test - public void constructor_invalidPhone_throwsIllegalArgumentException() { + public void constructor_invalidBlock_throwsIllegalArgumentException() { String invalidStreet = ""; assertThrows(IllegalArgumentException.class, () -> new Street(invalidStreet)); } From 6d7120b175817fdded0a1ff87c74ce4ef2afdf4e Mon Sep 17 00:00:00 2001 From: KhoonSun47 Date: Wed, 13 Mar 2024 10:36:11 +0800 Subject: [PATCH 08/24] Issue #46: Add Unit Number Update CLISyntax.java: Add prefix for unit number Add UnitNumber.java: Add functionality to add unit number to add command Add UnitNumberTest.java: Add test cases to test UnitNumber.java --- .../seedu/address/logic/parser/CliSyntax.java | 1 + .../seedu/address/model/house/UnitNumber.java | 59 ++++++++++++++++++ .../address/model/house/UnitNumberTest.java | 61 +++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 src/main/java/seedu/address/model/house/UnitNumber.java create mode 100644 src/test/java/seedu/address/model/house/UnitNumberTest.java diff --git a/src/main/java/seedu/address/logic/parser/CliSyntax.java b/src/main/java/seedu/address/logic/parser/CliSyntax.java index 75b1a9bf119..0ba0e476308 100644 --- a/src/main/java/seedu/address/logic/parser/CliSyntax.java +++ b/src/main/java/seedu/address/logic/parser/CliSyntax.java @@ -11,5 +11,6 @@ public class CliSyntax { public static final Prefix PREFIX_EMAIL = new Prefix("e/"); public static final Prefix PREFIX_ADDRESS = new Prefix("a/"); public static final Prefix PREFIX_TAG = new Prefix("t/"); + public static final Prefix PREFIX_UNITNUMBER = new Prefix("unitNo/"); } diff --git a/src/main/java/seedu/address/model/house/UnitNumber.java b/src/main/java/seedu/address/model/house/UnitNumber.java new file mode 100644 index 00000000000..c1ff33b2e34 --- /dev/null +++ b/src/main/java/seedu/address/model/house/UnitNumber.java @@ -0,0 +1,59 @@ +package seedu.address.model.house; + +import static java.util.Objects.requireNonNull; +import static seedu.address.commons.util.AppUtil.checkArgument; + +/** + * Represents a House Address's unit number in the address book. + * Guarantees: immutable; is valid as declared in {@link #isValidUnitNumber(String)} + */ +public class UnitNumber { + + public static final String MESSAGE_CONSTRAINTS = + "The unit number should only contain numbers, and it should only be 2 digits long."; + public static final String VALIDATION_REGEX = "\\d{2}"; + public final String value; + + /** + * Constructs a {@code UnitNumber}. + * + * @param unitNumber A valid unit number. + */ + public UnitNumber(String unitNumber) { + requireNonNull(unitNumber); + checkArgument(isValidUnitNumber(unitNumber), MESSAGE_CONSTRAINTS); + value = unitNumber; + } + + /** + * Returns true if a given string is a valid unit number. + */ + public static boolean isValidUnitNumber(String test) { + return test.matches(VALIDATION_REGEX); + } + + @Override + public String toString() { + return value; + } + + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + + if (!(other instanceof UnitNumber)) { + return false; + } + + UnitNumber otherUnitNumber = (UnitNumber) other; + return value.equals(otherUnitNumber.value); + } + + @Override + public int hashCode() { + return value.hashCode(); + } + +} diff --git a/src/test/java/seedu/address/model/house/UnitNumberTest.java b/src/test/java/seedu/address/model/house/UnitNumberTest.java new file mode 100644 index 00000000000..05f9af8f1d1 --- /dev/null +++ b/src/test/java/seedu/address/model/house/UnitNumberTest.java @@ -0,0 +1,61 @@ +package seedu.address.model.house; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static seedu.address.testutil.Assert.assertThrows; + +import org.junit.jupiter.api.Test; + +public class UnitNumberTest { + + @Test + public void constructor_null_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> new UnitNumber(null)); + } + + @Test + public void constructor_invalidUnitNumber_throwsIllegalArgumentException() { + String invalidUnitNumber = "1"; // Not 2 digits + assertThrows(IllegalArgumentException.class, () -> new UnitNumber(invalidUnitNumber)); + } + + @Test + public void isValidUnitNumber() { + // null unit number + assertThrows(NullPointerException.class, () -> UnitNumber.isValidUnitNumber(null)); + + // invalid unit numbers + assertFalse(UnitNumber.isValidUnitNumber("")); // empty string + assertFalse(UnitNumber.isValidUnitNumber(" ")); // spaces only + assertFalse(UnitNumber.isValidUnitNumber("9")); // less than 2 digits + assertFalse(UnitNumber.isValidUnitNumber("123")); // more than 2 digits + assertFalse(UnitNumber.isValidUnitNumber("ab")); // non-numeric + assertFalse(UnitNumber.isValidUnitNumber("1a")); // alphabets within digits + assertFalse(UnitNumber.isValidUnitNumber(" 12")); // spaces before digits + assertFalse(UnitNumber.isValidUnitNumber("12 ")); // spaces after digits + + // valid unit numbers + assertTrue(UnitNumber.isValidUnitNumber("10")); // exactly 2 digits + assertTrue(UnitNumber.isValidUnitNumber("99")); // exactly 2 digits + } + + @Test + public void equals() { + UnitNumber unitNumber = new UnitNumber("12"); + + // same values -> returns true + assertTrue(unitNumber.equals(new UnitNumber("12"))); + + // same object -> returns true + assertTrue(unitNumber.equals(unitNumber)); + + // null -> returns false + assertFalse(unitNumber.equals(null)); + + // different types -> returns false + assertFalse(unitNumber.equals(5.0f)); + + // different unit number -> returns false + assertFalse(unitNumber.equals(new UnitNumber("34"))); + } +} From b6f302ba6bdba02bd40372e5ca61dde40b19f230 Mon Sep 17 00:00:00 2001 From: KhoonSun47 Date: Wed, 13 Mar 2024 10:50:56 +0800 Subject: [PATCH 09/24] Issue #46: Add Unit Number Update UnitNumberTest.java: Remove two test cases --- src/test/java/seedu/address/model/house/UnitNumberTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/java/seedu/address/model/house/UnitNumberTest.java b/src/test/java/seedu/address/model/house/UnitNumberTest.java index 05f9af8f1d1..6fd31dbde5b 100644 --- a/src/test/java/seedu/address/model/house/UnitNumberTest.java +++ b/src/test/java/seedu/address/model/house/UnitNumberTest.java @@ -31,8 +31,6 @@ public void isValidUnitNumber() { assertFalse(UnitNumber.isValidUnitNumber("123")); // more than 2 digits assertFalse(UnitNumber.isValidUnitNumber("ab")); // non-numeric assertFalse(UnitNumber.isValidUnitNumber("1a")); // alphabets within digits - assertFalse(UnitNumber.isValidUnitNumber(" 12")); // spaces before digits - assertFalse(UnitNumber.isValidUnitNumber("12 ")); // spaces after digits // valid unit numbers assertTrue(UnitNumber.isValidUnitNumber("10")); // exactly 2 digits From 85464473572706410dae9084a5892550cfdb9e55 Mon Sep 17 00:00:00 2001 From: KhoonSun47 Date: Wed, 13 Mar 2024 11:17:40 +0800 Subject: [PATCH 10/24] Issue #46: Add Unit Number Update UnitNumber.java: Change the requirement such that unit number must be at least 1 digit, and at most 3 digits (but cannot be 0) Update UnitNumberTest.java: Change the test cases according to the new requirements --- .../java/seedu/address/model/house/UnitNumber.java | 14 +++++++++----- .../seedu/address/model/house/UnitNumberTest.java | 14 ++++++++------ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main/java/seedu/address/model/house/UnitNumber.java b/src/main/java/seedu/address/model/house/UnitNumber.java index c1ff33b2e34..77e448b0967 100644 --- a/src/main/java/seedu/address/model/house/UnitNumber.java +++ b/src/main/java/seedu/address/model/house/UnitNumber.java @@ -4,14 +4,16 @@ import static seedu.address.commons.util.AppUtil.checkArgument; /** - * Represents a House Address's unit number in the address book. + * Represents a House's unit number in the address book. * Guarantees: immutable; is valid as declared in {@link #isValidUnitNumber(String)} */ public class UnitNumber { public static final String MESSAGE_CONSTRAINTS = - "The unit number should only contain numbers, and it should only be 2 digits long."; - public static final String VALIDATION_REGEX = "\\d{2}"; + "The unit number should only contain numbers, it should be at least 1 digit " + + "and at most 3 digits long, and cannot be 0."; + public static final String VALIDATION_REGEX = "\\d{1,3}"; + public final String value; /** @@ -27,9 +29,12 @@ public UnitNumber(String unitNumber) { /** * Returns true if a given string is a valid unit number. + * + * @param test The string to test. + * @return true if the test matches the VALIDATION_REGEX and is not "0". */ public static boolean isValidUnitNumber(String test) { - return test.matches(VALIDATION_REGEX); + return test.matches(VALIDATION_REGEX) && !test.equals("0"); } @Override @@ -55,5 +60,4 @@ public boolean equals(Object other) { public int hashCode() { return value.hashCode(); } - } diff --git a/src/test/java/seedu/address/model/house/UnitNumberTest.java b/src/test/java/seedu/address/model/house/UnitNumberTest.java index 6fd31dbde5b..5a0dcc60d18 100644 --- a/src/test/java/seedu/address/model/house/UnitNumberTest.java +++ b/src/test/java/seedu/address/model/house/UnitNumberTest.java @@ -15,7 +15,7 @@ public void constructor_null_throwsNullPointerException() { @Test public void constructor_invalidUnitNumber_throwsIllegalArgumentException() { - String invalidUnitNumber = "1"; // Not 2 digits + String invalidUnitNumber = "abcd"; assertThrows(IllegalArgumentException.class, () -> new UnitNumber(invalidUnitNumber)); } @@ -25,16 +25,18 @@ public void isValidUnitNumber() { assertThrows(NullPointerException.class, () -> UnitNumber.isValidUnitNumber(null)); // invalid unit numbers + assertFalse(UnitNumber.isValidUnitNumber("0")); // '0' is invalid assertFalse(UnitNumber.isValidUnitNumber("")); // empty string assertFalse(UnitNumber.isValidUnitNumber(" ")); // spaces only - assertFalse(UnitNumber.isValidUnitNumber("9")); // less than 2 digits - assertFalse(UnitNumber.isValidUnitNumber("123")); // more than 2 digits + assertFalse(UnitNumber.isValidUnitNumber("1234")); // more than 3 digits assertFalse(UnitNumber.isValidUnitNumber("ab")); // non-numeric - assertFalse(UnitNumber.isValidUnitNumber("1a")); // alphabets within digits + assertFalse(UnitNumber.isValidUnitNumber("1a2")); // alphabets within digits // valid unit numbers - assertTrue(UnitNumber.isValidUnitNumber("10")); // exactly 2 digits - assertTrue(UnitNumber.isValidUnitNumber("99")); // exactly 2 digits + assertTrue(UnitNumber.isValidUnitNumber("1")); // minimum valid number + assertTrue(UnitNumber.isValidUnitNumber("01")); // leading 0 is allowed + assertTrue(UnitNumber.isValidUnitNumber("10")); // 2 digits + assertTrue(UnitNumber.isValidUnitNumber("999")); // maximum valid number } @Test From 80336602b901ae22f0519c0355ee3fc3eb9865cf Mon Sep 17 00:00:00 2001 From: KhoonSun47 Date: Wed, 13 Mar 2024 11:29:27 +0800 Subject: [PATCH 11/24] Issue #46: Add Unit Number Update UnitNumber.java: Add another regex to test for the following input '0', '00', '000', which should be invalid since a unit number cannot be '0's Update UnitNumberTest.java: Update the test cases according to the new requirements --- src/main/java/seedu/address/model/house/UnitNumber.java | 5 +++-- src/test/java/seedu/address/model/house/UnitNumberTest.java | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/seedu/address/model/house/UnitNumber.java b/src/main/java/seedu/address/model/house/UnitNumber.java index 77e448b0967..2e2713f7d8e 100644 --- a/src/main/java/seedu/address/model/house/UnitNumber.java +++ b/src/main/java/seedu/address/model/house/UnitNumber.java @@ -11,8 +11,9 @@ public class UnitNumber { public static final String MESSAGE_CONSTRAINTS = "The unit number should only contain numbers, it should be at least 1 digit " - + "and at most 3 digits long, and cannot be 0."; + + "and at most 3 digits long, and cannot be '0', '00' or '000'."; public static final String VALIDATION_REGEX = "\\d{1,3}"; + public static final String ZERO_REGEX = "^0+$"; public final String value; @@ -34,7 +35,7 @@ public UnitNumber(String unitNumber) { * @return true if the test matches the VALIDATION_REGEX and is not "0". */ public static boolean isValidUnitNumber(String test) { - return test.matches(VALIDATION_REGEX) && !test.equals("0"); + return test.matches(VALIDATION_REGEX) && !test.matches(ZERO_REGEX); } @Override diff --git a/src/test/java/seedu/address/model/house/UnitNumberTest.java b/src/test/java/seedu/address/model/house/UnitNumberTest.java index 5a0dcc60d18..eaeb7b3df5e 100644 --- a/src/test/java/seedu/address/model/house/UnitNumberTest.java +++ b/src/test/java/seedu/address/model/house/UnitNumberTest.java @@ -26,6 +26,8 @@ public void isValidUnitNumber() { // invalid unit numbers assertFalse(UnitNumber.isValidUnitNumber("0")); // '0' is invalid + assertFalse(UnitNumber.isValidUnitNumber("00")); // '00' is invalid + assertFalse(UnitNumber.isValidUnitNumber("000")); // '000' is invalid assertFalse(UnitNumber.isValidUnitNumber("")); // empty string assertFalse(UnitNumber.isValidUnitNumber(" ")); // spaces only assertFalse(UnitNumber.isValidUnitNumber("1234")); // more than 3 digits @@ -36,6 +38,7 @@ public void isValidUnitNumber() { assertTrue(UnitNumber.isValidUnitNumber("1")); // minimum valid number assertTrue(UnitNumber.isValidUnitNumber("01")); // leading 0 is allowed assertTrue(UnitNumber.isValidUnitNumber("10")); // 2 digits + assertTrue(UnitNumber.isValidUnitNumber("001")); // 3 digits assertTrue(UnitNumber.isValidUnitNumber("999")); // maximum valid number } From 34624fc5afbe47933a58476ca2cd9f8f4f4ff806 Mon Sep 17 00:00:00 2001 From: Carl Date: Thu, 14 Mar 2024 20:53:24 +0800 Subject: [PATCH 12/24] Fix level input validation Currently, the validation accepts '0' and '00' inputs, which should not be the case. '0' and '00' inputs are invalid as level 0 or 00 does not exist. --- src/main/java/seedu/address/model/house/Level.java | 4 +++- src/test/java/seedu/address/model/house/LevelTest.java | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/seedu/address/model/house/Level.java b/src/main/java/seedu/address/model/house/Level.java index 15f44b21efa..1198fd809a2 100644 --- a/src/main/java/seedu/address/model/house/Level.java +++ b/src/main/java/seedu/address/model/house/Level.java @@ -13,6 +13,8 @@ public class Level { public static final String MESSAGE_CONSTRAINTS = "Level should only contain numbers, and it should only be at most 2 digits long"; public static final String VALIDATION_REGEX = "\\d{1,2}"; + public static final String ZERO_REGEX = "^0+$"; + public final String value; /** @@ -30,7 +32,7 @@ public Level(String level) { * Returns true if a given string is a valid level. */ public static boolean isValidLevel(String test) { - return test.matches(VALIDATION_REGEX); + return test.matches(VALIDATION_REGEX) && !test.matches(ZERO_REGEX); } @Override diff --git a/src/test/java/seedu/address/model/house/LevelTest.java b/src/test/java/seedu/address/model/house/LevelTest.java index 6ddc90f2cf4..0bdff302e7d 100644 --- a/src/test/java/seedu/address/model/house/LevelTest.java +++ b/src/test/java/seedu/address/model/house/LevelTest.java @@ -29,6 +29,8 @@ public void isValidLevel() { assertFalse(Level.isValidLevel(" ")); // spaces only // invalid levels + assertFalse(Level.isValidLevel("0")); // 1 zero only + assertFalse(Level.isValidLevel("00")); // 2 zeroes only assertFalse(Level.isValidLevel("a")); // non-digit only assertFalse(Level.isValidLevel("aa")); // non-digit only assertFalse(Level.isValidLevel("###")); // non-digit only From 1238914d971b048310f1a70bd39b1773551a4b39 Mon Sep 17 00:00:00 2001 From: Carl Date: Thu, 14 Mar 2024 21:24:20 +0800 Subject: [PATCH 13/24] Update ParserUtil to parse Level inputs --- .../seedu/address/logic/parser/ParserUtil.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index b117acb9c55..2e1ed323b89 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -9,6 +9,7 @@ import seedu.address.commons.core.index.Index; import seedu.address.commons.util.StringUtil; import seedu.address.logic.parser.exceptions.ParseException; +import seedu.address.model.house.Level; import seedu.address.model.person.Address; import seedu.address.model.person.Email; import seedu.address.model.person.Name; @@ -121,4 +122,19 @@ public static Set parseTags(Collection tags) throws ParseException } return tagSet; } + + /** + * Parses a {@code String level} into a {@code Level}. + * Leading and trailing whitespaces will be trimmed. + * + * @throws ParseException if the given {@code level} is invalid. + */ + public static Level parseLevel(String level) throws ParseException { + requireNonNull(level); + String trimmedLevel = level.trim(); + if (!Level.isValidLevel(trimmedLevel)) { + throw new ParseException(Level.MESSAGE_CONSTRAINTS); + } + return new Level(trimmedLevel); + } } From 36ddaa426a9cc029a2ee06a140147de39ab744ca Mon Sep 17 00:00:00 2001 From: Carl Date: Thu, 14 Mar 2024 21:24:54 +0800 Subject: [PATCH 14/24] Add test cases for level parser --- .../address/logic/parser/ParserUtilTest.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java index 4256788b1a7..a44f057ed14 100644 --- a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java +++ b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java @@ -14,6 +14,7 @@ import org.junit.jupiter.api.Test; import seedu.address.logic.parser.exceptions.ParseException; +import seedu.address.model.house.Level; import seedu.address.model.person.Address; import seedu.address.model.person.Email; import seedu.address.model.person.Name; @@ -26,6 +27,7 @@ public class ParserUtilTest { private static final String INVALID_ADDRESS = " "; private static final String INVALID_EMAIL = "example.com"; private static final String INVALID_TAG = "#friend"; + private static final String INVALID_LEVEL = "aa"; private static final String VALID_NAME = "Rachel Walker"; private static final String VALID_PHONE = "123456"; @@ -33,6 +35,7 @@ public class ParserUtilTest { private static final String VALID_EMAIL = "rachel@example.com"; private static final String VALID_TAG_1 = "friend"; private static final String VALID_TAG_2 = "neighbour"; + private static final String VALID_LEVEL = "10"; private static final String WHITESPACE = " \t\r\n"; @@ -193,4 +196,27 @@ public void parseTags_collectionWithValidTags_returnsTagSet() throws Exception { assertEquals(expectedTagSet, actualTagSet); } + + @Test + public void parseLevel_null_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> ParserUtil.parseLevel((String) null)); + } + + @Test + public void parseLevel_invalidValue_throwsParseException() { + assertThrows(ParseException.class, () -> ParserUtil.parseLevel(INVALID_LEVEL)); + } + + @Test + public void parseLevel_validValueWithoutWhitespace_returnsLevel() throws Exception { + Level expectedLevel = new Level(VALID_LEVEL); + assertEquals(expectedLevel, ParserUtil.parseLevel(VALID_LEVEL)); + } + + @Test + public void parseLevel_validValueWithWhitespace_returnsTrimmedLevel() throws Exception { + String levelWithWhitespace = WHITESPACE + VALID_LEVEL + WHITESPACE; + Level expectedLevel = new Level(VALID_LEVEL); + assertEquals(expectedLevel, ParserUtil.parseLevel(levelWithWhitespace)); + } } From 66cdb094cbc430fe591acfec6f3cd005e8037835 Mon Sep 17 00:00:00 2001 From: Carl Date: Thu, 14 Mar 2024 21:30:42 +0800 Subject: [PATCH 15/24] Update ParserUtil to parse Street inputs --- .../seedu/address/logic/parser/ParserUtil.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index b117acb9c55..bfbdd04b1ed 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -9,6 +9,7 @@ import seedu.address.commons.core.index.Index; import seedu.address.commons.util.StringUtil; import seedu.address.logic.parser.exceptions.ParseException; +import seedu.address.model.house.Street; import seedu.address.model.person.Address; import seedu.address.model.person.Email; import seedu.address.model.person.Name; @@ -121,4 +122,19 @@ public static Set parseTags(Collection tags) throws ParseException } return tagSet; } + + /** + * Parses a {@code String street} into a {@code Street}. + * Leading and trailing whitespaces will be trimmed. + * + * @throws ParseException if the given {@code street} is invalid. + */ + public static Street parseStreet(String street) throws ParseException { + requireNonNull(street); + String trimmedStreet = street.trim(); + if (!Street.isValidStreet(trimmedStreet)) { + throw new ParseException(Street.MESSAGE_CONSTRAINTS); + } + return new Street(trimmedStreet); + } } From 54f404fadf050482cc82e58e7319dd335db4bdbf Mon Sep 17 00:00:00 2001 From: Carl Date: Thu, 14 Mar 2024 21:31:21 +0800 Subject: [PATCH 16/24] Add test cases for street parser --- .../address/logic/parser/ParserUtilTest.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java index 4256788b1a7..5959b4cb1f9 100644 --- a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java +++ b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java @@ -14,6 +14,7 @@ import org.junit.jupiter.api.Test; import seedu.address.logic.parser.exceptions.ParseException; +import seedu.address.model.house.Street; import seedu.address.model.person.Address; import seedu.address.model.person.Email; import seedu.address.model.person.Name; @@ -26,6 +27,7 @@ public class ParserUtilTest { private static final String INVALID_ADDRESS = " "; private static final String INVALID_EMAIL = "example.com"; private static final String INVALID_TAG = "#friend"; + private static final String INVALID_STREET = "t3$t!ng"; private static final String VALID_NAME = "Rachel Walker"; private static final String VALID_PHONE = "123456"; @@ -33,7 +35,7 @@ public class ParserUtilTest { private static final String VALID_EMAIL = "rachel@example.com"; private static final String VALID_TAG_1 = "friend"; private static final String VALID_TAG_2 = "neighbour"; - + private static final String VALID_STREET = "292A East Coast Rd"; private static final String WHITESPACE = " \t\r\n"; @Test @@ -193,4 +195,27 @@ public void parseTags_collectionWithValidTags_returnsTagSet() throws Exception { assertEquals(expectedTagSet, actualTagSet); } + + @Test + public void parseStreet_null_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> ParserUtil.parseStreet((String) null)); + } + + @Test + public void parseStreet_invalidValue_throwsParseException() { + assertThrows(ParseException.class, () -> ParserUtil.parseStreet(INVALID_STREET)); + } + + @Test + public void parseStreet_validValueWithoutWhitespace_returnsStreet() throws Exception { + Street expectedStreet = new Street(VALID_STREET); + assertEquals(expectedStreet, ParserUtil.parseStreet(VALID_STREET)); + } + + @Test + public void parseStreet_validValueWithWhitespace_returnsTrimmedStreet() throws Exception { + String streetWithWhitespace = WHITESPACE + VALID_STREET + WHITESPACE; + Street expectedStreet = new Street(VALID_STREET); + assertEquals(expectedStreet, ParserUtil.parseStreet(streetWithWhitespace)); + } } From 2126005384b4d8abb38d8db212bf039ac4e6f578 Mon Sep 17 00:00:00 2001 From: KhoonSun47 Date: Thu, 14 Mar 2024 22:44:15 +0800 Subject: [PATCH 17/24] Issue #46: Add Unit Number Update ParserUtil.java: Add parsing of unit numbers Update ParserUtilTest.java: Add test cases for parsing of unit numbers --- .../address/logic/parser/ParserUtil.java | 17 ++++++++++++ .../address/logic/parser/ParserUtilTest.java | 27 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index b117acb9c55..6707a1fef9f 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -9,6 +9,7 @@ import seedu.address.commons.core.index.Index; import seedu.address.commons.util.StringUtil; import seedu.address.logic.parser.exceptions.ParseException; +import seedu.address.model.house.UnitNumber; import seedu.address.model.person.Address; import seedu.address.model.person.Email; import seedu.address.model.person.Name; @@ -25,6 +26,7 @@ public class ParserUtil { /** * Parses {@code oneBasedIndex} into an {@code Index} and returns it. Leading and trailing whitespaces will be * trimmed. + * * @throws ParseException if the specified index is invalid (not non-zero unsigned integer). */ public static Index parseIndex(String oneBasedIndex) throws ParseException { @@ -121,4 +123,19 @@ public static Set parseTags(Collection tags) throws ParseException } return tagSet; } + + /** + * Parses a {@code String unitNumber} into a {@code unitNumber}. + * Leading and trailing whitespaces will be trimmed. + * + * @throws ParseException if the given {@code unitNumber} is invalid. + */ + public static UnitNumber parseUnitNumber(String unitNumber) throws ParseException { + requireNonNull(unitNumber); + String trimmedLevel = unitNumber.trim(); + if (!UnitNumber.isValidUnitNumber(trimmedLevel)) { + throw new ParseException(UnitNumber.MESSAGE_CONSTRAINTS); + } + return new UnitNumber(trimmedLevel); + } } diff --git a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java index 4256788b1a7..76705f1496d 100644 --- a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java +++ b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java @@ -14,6 +14,7 @@ import org.junit.jupiter.api.Test; import seedu.address.logic.parser.exceptions.ParseException; +import seedu.address.model.house.UnitNumber; import seedu.address.model.person.Address; import seedu.address.model.person.Email; import seedu.address.model.person.Name; @@ -26,6 +27,7 @@ public class ParserUtilTest { private static final String INVALID_ADDRESS = " "; private static final String INVALID_EMAIL = "example.com"; private static final String INVALID_TAG = "#friend"; + private static final String INVALID_UNIT_NUMBER = "1234"; private static final String VALID_NAME = "Rachel Walker"; private static final String VALID_PHONE = "123456"; @@ -33,6 +35,7 @@ public class ParserUtilTest { private static final String VALID_EMAIL = "rachel@example.com"; private static final String VALID_TAG_1 = "friend"; private static final String VALID_TAG_2 = "neighbour"; + private static final String VALID_UNIT_NUMBER = "123"; private static final String WHITESPACE = " \t\r\n"; @@ -193,4 +196,28 @@ public void parseTags_collectionWithValidTags_returnsTagSet() throws Exception { assertEquals(expectedTagSet, actualTagSet); } + + @Test + public void parseUnitNumber_null_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> ParserUtil.parseUnitNumber((String) null)); + } + + @Test + public void parseUnitNumber_invalidValue_throwsParseException() { + assertThrows(ParseException.class, () -> ParserUtil.parseUnitNumber(INVALID_UNIT_NUMBER)); + } + + @Test + public void parseUnitNumber_validValueWithoutWhitespace_returnsUnitNumber() throws Exception { + UnitNumber expectedUnitNumber = new UnitNumber(VALID_UNIT_NUMBER); + assertEquals(expectedUnitNumber, ParserUtil.parseUnitNumber(VALID_UNIT_NUMBER)); + } + + @Test + public void parseUnitNumber_validValueWithWhitespace_returnsTrimmedUnitNumber() throws Exception { + String unitNumberWithWhitespace = WHITESPACE + VALID_UNIT_NUMBER + WHITESPACE; + UnitNumber expectedUnitNumber = new UnitNumber(VALID_UNIT_NUMBER); + assertEquals(expectedUnitNumber, ParserUtil.parseUnitNumber(unitNumberWithWhitespace)); + } + } From 1dc2842ab14593b31476e666a29e47aec1f03f9d Mon Sep 17 00:00:00 2001 From: Felix Chan You Yuan <111300022+felixchanyy@users.noreply.github.com> Date: Fri, 15 Mar 2024 12:01:23 +0800 Subject: [PATCH 18/24] Fix ParserUtil.java Fix error when merging commit --- src/main/java/seedu/address/logic/parser/ParserUtil.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index d4dbce5c484..73d7655c03f 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -139,7 +139,8 @@ public static Level parseLevel(String level) throws ParseException { throw new ParseException(Level.MESSAGE_CONSTRAINTS); } return new Level(trimmedLevel); - + } + /** * Parses a {@code String block} into an {@code Block}. * Leading and trailing whitespaces will be trimmed. * @@ -152,7 +153,8 @@ public static Block parseBlock(String block) throws ParseException { throw new ParseException(Block.MESSAGE_CONSTRAINTS); } return new Block(trimmedBlock); - + } + /** * Parses a {@code String postalCode} into a {@code postalCode}. * Leading and trailing whitespaces will be trimmed. * From e0d9a967955b99c4e11b5edc0de23b580a65a189 Mon Sep 17 00:00:00 2001 From: Felix Chan You Yuan <111300022+felixchanyy@users.noreply.github.com> Date: Fri, 15 Mar 2024 12:10:59 +0800 Subject: [PATCH 19/24] Fix checkstyle in ParserUtil.java Move 'seedu.address.model.house.Block' before 'seedu.address.model.house.Level' --- src/main/java/seedu/address/logic/parser/ParserUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index 73d7655c03f..cb02c1c8ffb 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -9,8 +9,8 @@ import seedu.address.commons.core.index.Index; import seedu.address.commons.util.StringUtil; import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.house.Level; import seedu.address.model.house.Block; +import seedu.address.model.house.Level; import seedu.address.model.house.PostalCode; import seedu.address.model.person.Address; import seedu.address.model.person.Email; From f48c0a523e29cc2e7f8322e6595a15f8454cb3bd Mon Sep 17 00:00:00 2001 From: Felix Chan You Yuan <111300022+felixchanyy@users.noreply.github.com> Date: Fri, 15 Mar 2024 12:28:52 +0800 Subject: [PATCH 20/24] Fix ParserUtilTest.java Missing } when doing merge commit --- src/test/java/seedu/address/logic/parser/ParserUtilTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java index a91027992c0..d04a5f4af69 100644 --- a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java +++ b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java @@ -247,6 +247,8 @@ public void parseLevel_validValueWithWhitespace_returnsTrimmedLevel() throws Exc String levelWithWhitespace = WHITESPACE + VALID_LEVEL + WHITESPACE; Level expectedLevel = new Level(VALID_LEVEL); assertEquals(expectedLevel, ParserUtil.parseLevel(levelWithWhitespace)); + } + public void parseBlock_null_throwsNullPointerException() { assertThrows(NullPointerException.class, () -> ParserUtil.parseBlock((String) null)); } From b1d9b842f5ebcb4d629fa4bbc3d060d6335f6e7b Mon Sep 17 00:00:00 2001 From: Felix Chan You Yuan <111300022+felixchanyy@users.noreply.github.com> Date: Fri, 15 Mar 2024 12:33:26 +0800 Subject: [PATCH 21/24] Update ParserUtilTest.java Fix trailing whitespace --- src/test/java/seedu/address/logic/parser/ParserUtilTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java index d04a5f4af69..b5bd63e6ae4 100644 --- a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java +++ b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java @@ -248,7 +248,6 @@ public void parseLevel_validValueWithWhitespace_returnsTrimmedLevel() throws Exc Level expectedLevel = new Level(VALID_LEVEL); assertEquals(expectedLevel, ParserUtil.parseLevel(levelWithWhitespace)); } - public void parseBlock_null_throwsNullPointerException() { assertThrows(NullPointerException.class, () -> ParserUtil.parseBlock((String) null)); } From 320d9f566d91c05fff03afa393c747e9de472c1c Mon Sep 17 00:00:00 2001 From: Felix Chan You Yuan <111300022+felixchanyy@users.noreply.github.com> Date: Fri, 15 Mar 2024 12:36:44 +0800 Subject: [PATCH 22/24] Fix checkstyle of ParserUtilTest.java Move 'seedu.address.model.house.Block' import before 'seedu.address.model.house.Level'. --- src/test/java/seedu/address/logic/parser/ParserUtilTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java index b5bd63e6ae4..16af7bcd85d 100644 --- a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java +++ b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java @@ -14,8 +14,8 @@ import org.junit.jupiter.api.Test; import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.house.Level; import seedu.address.model.house.Block; +import seedu.address.model.house.Level; import seedu.address.model.house.PostalCode; import seedu.address.model.person.Address; import seedu.address.model.person.Email; From 9addd309d2ef6b4bd0c3d4bffc3f0f031f9bd0b0 Mon Sep 17 00:00:00 2001 From: Felix Chan You Yuan <111300022+felixchanyy@users.noreply.github.com> Date: Fri, 15 Mar 2024 12:44:10 +0800 Subject: [PATCH 23/24] Fix ParserUtil.java Error --- src/main/java/seedu/address/logic/parser/ParserUtil.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index 5e9495b2306..efc5055d4d4 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -9,9 +9,9 @@ import seedu.address.commons.core.index.Index; import seedu.address.commons.util.StringUtil; import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.house.UnitNumber; import seedu.address.model.house.Block; import seedu.address.model.house.PostalCode; +import seedu.address.model.house.UnitNumber; import seedu.address.model.person.Address; import seedu.address.model.person.Email; import seedu.address.model.person.Name; @@ -139,6 +139,8 @@ public static UnitNumber parseUnitNumber(String unitNumber) throws ParseExceptio throw new ParseException(UnitNumber.MESSAGE_CONSTRAINTS); } return new UnitNumber(trimmedLevel); + } + /** * Parses a {@code String block} into an {@code Block}. * Leading and trailing whitespaces will be trimmed. * @@ -151,7 +153,8 @@ public static Block parseBlock(String block) throws ParseException { throw new ParseException(Block.MESSAGE_CONSTRAINTS); } return new Block(trimmedBlock); - + } + /** * Parses a {@code String postalCode} into a {@code postalCode}. * Leading and trailing whitespaces will be trimmed. * From 2959dd0daadce502d9fe452cfa6a0e948d7ef306 Mon Sep 17 00:00:00 2001 From: Felix Chan You Yuan <111300022+felixchanyy@users.noreply.github.com> Date: Fri, 15 Mar 2024 12:48:37 +0800 Subject: [PATCH 24/24] Fix ParserUtilTest.java lexicographical order --- src/test/java/seedu/address/logic/parser/ParserUtilTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java index 0d422a4e677..f363378c13b 100644 --- a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java +++ b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java @@ -14,9 +14,9 @@ import org.junit.jupiter.api.Test; import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.house.UnitNumber; import seedu.address.model.house.Block; import seedu.address.model.house.PostalCode; +import seedu.address.model.house.UnitNumber; import seedu.address.model.person.Address; import seedu.address.model.person.Email; import seedu.address.model.person.Name;