Skip to content

Commit

Permalink
Merge branch 'master' into Fix-bug-175
Browse files Browse the repository at this point in the history
  • Loading branch information
nuyer authored Apr 13, 2024
2 parents e62cbe9 + 5a81116 commit b7e2cc8
Show file tree
Hide file tree
Showing 16 changed files with 123 additions and 82 deletions.
126 changes: 85 additions & 41 deletions docs/UserGuide.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/main/java/seedu/address/model/person/Phone.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public class Phone {


public static final String MESSAGE_CONSTRAINTS =
"Phone numbers should only contain numbers, and it should be at least 3 digits long";
public static final String VALIDATION_REGEX = "\\d{3,}";
"Phone numbers should only contain numbers, and it should be 8 digits long";
public static final String VALIDATION_REGEX = "\\d{8}";
public final String value;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

/**
* Represents a Terms of Service in the address book.
* Guarantees: immutable; is valid as declared in {@link #isValidTermsOfService(String)}
*/
public class TermsOfService {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"id": 1,
"name": "Valid Client",
"phone": "9482424",
"phone": "94824241",
"email": "[email protected]",
"address": "123 Client St",
"role": "client",
Expand All @@ -15,7 +15,7 @@
{
"id": 2,
"name": "Valid Supplier",
"phone": "1111111",
"phone": "11111111",
"email": "[email protected]",
"address": "1 Supplier Ave",
"role": "supplier",
Expand All @@ -29,7 +29,7 @@
{
"id": 3,
"name": "Valid Employee",
"phone": "2222222",
"phone": "22222222",
"email": "[email protected]",
"address": "2 Employee Blvd",
"role": "employee",
Expand All @@ -46,7 +46,7 @@
{
"id": 4,
"name": "Person With Invalid Phone Field",
"phone": "948asdf2424",
"phone": "948asd24",
"email": "[email protected]",
"address": "4th street",
"role": "client",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"id": 1,
"name": "Hans Muster",
"phone": "9482424",
"phone": "94824248",
"email": "invalid@email!3e",
"address": "4th street",
"tags": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
{
"id": 4,
"name": "Elle Meyer",
"phone": "9482224",
"phone": "94822241",
"email": "[email protected]",
"address": "michegan ave",
"tags": [],
Expand All @@ -68,7 +68,7 @@
{
"id": 5,
"name": "Fiona Kunz",
"phone": "9482427",
"phone": "94824271",
"email": "[email protected]",
"address": "little tokyo",
"tags": [],
Expand All @@ -84,7 +84,7 @@
{
"id": 6,
"name": "George Best",
"phone": "9482442",
"phone": "94824421",
"email": "[email protected]",
"address": "4th street",
"tags": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ public void parse_validNames_returnsFindCommand() {
public void parse_validPhones_returnsFindCommand() {
// no leading and trailing whitespaces
FindCommand expectedFindCommand =
new FindCommand(new PhoneMatchesDigitsPredicate(Arrays.asList("123", "91234567")));
assertParseSuccess(parser, " p/123 p/91234567", expectedFindCommand);
new FindCommand(new PhoneMatchesDigitsPredicate(Arrays.asList("12345678", "91234567")));
assertParseSuccess(parser, " p/12345678 p/91234567", expectedFindCommand);

// multiple whitespaces between keywords
assertParseSuccess(parser, " \n p/123 \n \t p/91234567 \t", expectedFindCommand);
assertParseSuccess(parser, " \n p/12345678 \n \t p/91234567 \t", expectedFindCommand);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class ParserUtilTest {
private static final String INVALID_SKILLS = "Invalid Skills!@#";

private static final String VALID_NAME = "Rachel Walker";
private static final String VALID_PHONE = "123456";
private static final String VALID_PHONE = "12345678";
private static final String VALID_ADDRESS = "123 Main Street #0505";
private static final String VALID_EMAIL = "[email protected]";
private static final String VALID_TAG_1 = "friend";
Expand Down
14 changes: 7 additions & 7 deletions src/test/java/seedu/address/logic/utils/CsvExporterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ public void setUp() {
@Test
public void createDataList_correctlyConstructedList() {
List<Person> persons = Arrays.asList(
new EmployeeBuilder().withId(1).withName("John Doe").withPhone("1234567890")
new EmployeeBuilder().withId(1).withName("John Doe").withPhone("12345678")
.withEmail("[email protected]").withAddress("123 Main St").withDepartment("HR")
.withJobTitle("Manager").withSkills("Java, SQL").build(),
new ClientBuilder().withId(2).withName("Jane Smith").withPhone("9876543210")
new ClientBuilder().withId(2).withName("Jane Smith").withPhone("98765432")
.withEmail("[email protected]")
.withAddress("456 Elm St").withProducts("Product A").withPreferences("Likes discounts")
.build(),
new SupplierBuilder().withId(3).withName("Acme Inc").withPhone("5555555555").withEmail("[email protected]")
new SupplierBuilder().withId(3).withName("Acme Inc").withPhone("55555555").withEmail("[email protected]")
.withAddress("789 Oak St").withProducts("Product X").withTermsOfService("30 days").build()
);
FilteredList<Person> filteredList = new FilteredList<>(FXCollections.observableArrayList(persons));
Expand All @@ -65,11 +65,11 @@ public void createDataList_correctlyConstructedList() {
assertArrayEquals(new String[]{"ID", "Name", "Phone", "Email", "Address", "Remark", "Tags", "Department",
"Job Title", "Skills", "Products", "Preferences", "Terms of Service"}, dataList.get(0));

assertArrayEquals(new String[]{"1", "John Doe", "1234567890", "[email protected]", "\"123 Main St\"",
assertArrayEquals(new String[]{"1", "John Doe", "12345678", "[email protected]", "\"123 Main St\"",
"some remarks", "", "HR", "Manager", "Java, SQL", "", "", ""}, dataList.get(1));
assertArrayEquals(new String[]{"2", "Jane Smith", "9876543210", "[email protected]", "\"456 Elm St\"",
assertArrayEquals(new String[]{"2", "Jane Smith", "98765432", "[email protected]", "\"456 Elm St\"",
"some remarks", "", "", "", "", "Product A", "Likes discounts", ""}, dataList.get(2));
assertArrayEquals(new String[]{"3", "Acme Inc", "5555555555", "[email protected]", "\"789 Oak St\"",
assertArrayEquals(new String[]{"3", "Acme Inc", "55555555", "[email protected]", "\"789 Oak St\"",
"some remarks", "", "", "", "", "Product X", "", "30 days"}, dataList.get(3));
}

Expand Down Expand Up @@ -145,7 +145,7 @@ public void convertPersonToStringArray_client() {
@Test
public void convertPersonToStringArray_supplier() {
String[] expectedArray = new String[]{
"5", "Fiona Kunz", "9482427", "[email protected]", "\"little tokyo\"", "some remarks", "", "", "",
"5", "Fiona Kunz", "94824271", "[email protected]", "\"little tokyo\"", "some remarks", "", "", "",
"", "Office Supplies, Furniture", "", "Delivery within 2 weeks"
};
assertArrayEquals(expectedArray, csvExporter.convertPersonToStringArray(TypicalPersons.FIONA));
Expand Down
10 changes: 4 additions & 6 deletions src/test/java/seedu/address/model/person/PhoneTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,15 @@ public void isValidPhone() {
assertFalse(Phone.isValidPhone("9312 1534")); // spaces within digits

// valid phone numbers
assertTrue(Phone.isValidPhone("911")); // exactly 3 numbers
assertTrue(Phone.isValidPhone("93121534"));
assertTrue(Phone.isValidPhone("124293842033123")); // long phone numbers
assertTrue(Phone.isValidPhone("93112534"));
}

@Test
public void equals() {
Phone phone = new Phone("999");
Phone phone = new Phone("99999999");

// same values -> returns true
assertTrue(phone.equals(new Phone("999")));
assertTrue(phone.equals(new Phone("99999999")));

// same object -> returns true
assertTrue(phone.equals(phone));
Expand All @@ -55,6 +53,6 @@ public void equals() {
assertFalse(phone.equals(0.5f));

// different values -> returns false
assertFalse(phone.equals(new Phone("995")));
assertFalse(phone.equals(new Phone("55555555")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public void test_nameDoesNotContainKeywords_returnsFalse() {
assertFalse(predicate.test(new EmployeeBuilder().withName("Alice Bob").build()));

// Keywords match phone, email, and address, but does not match name
predicate = new NameContainsKeywordsPredicate(Arrays.asList("12345", "[email protected]", "Main", "Street"));
assertFalse(predicate.test(new ClientBuilder().withName("Alice").withPhone("12345")
predicate = new NameContainsKeywordsPredicate(Arrays.asList("12345678", "[email protected]", "Main", "Street"));
assertFalse(predicate.test(new ClientBuilder().withName("Alice").withPhone("12345678")
.withEmail("[email protected]").withAddress("Main Street").build()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void test_phoneDoesNotMatchDigits_returnsFalse() {

// Keywords match name, email and address, but does not match phone
predicate = new PhoneMatchesDigitsPredicate(Arrays.asList("Alice", "[email protected]", "Main", "Street"));
assertFalse(predicate.test(new ClientBuilder().withName("Alice").withPhone("12345")
assertFalse(predicate.test(new ClientBuilder().withName("Alice").withPhone("12345678")
.withEmail("[email protected]").withAddress("Main Street").build()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void test_remarkDoesNotContainKeywords_returnsFalse() {
// Keywords match name, phone, email and address, but does not match remark
predicate = new RemarkContainsKeywordsPredicate(
Arrays.asList("Alice", "[email protected]", "Main", "Street", "12345"));
assertFalse(predicate.test(new SupplierBuilder().withName("Alice").withPhone("12345")
assertFalse(predicate.test(new SupplierBuilder().withName("Alice").withPhone("12345678")
.withEmail("[email protected]").withAddress("Main Street").withRemark("biscuit").build()));

// Non-empty remark with empty keyword
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public void test_tagsDoesNotContainKeywords_returnsFalse() {

// Keywords match name, phone, email, and address, but does not match tags
predicate = new TagsContainsKeywordsPredicate(
Arrays.asList("Alice", "12345", "[email protected]", "Main", "Street"));
assertFalse(predicate.test(new ClientBuilder().withName("Alice").withPhone("12345")
Arrays.asList("Alice", "12345678", "[email protected]", "Main", "Street"));
assertFalse(predicate.test(new ClientBuilder().withName("Alice").withPhone("12345678")
.withEmail("[email protected]").withAddress("Main Street").withTags("friends").build()));
}

Expand Down
10 changes: 5 additions & 5 deletions src/test/java/seedu/address/testutil/TypicalPersons.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,24 @@ public class TypicalPersons {
.withSkills("Public Speaking", "Digital Marketing").build();

public static final Employee ELLE = new EmployeeBuilder().withId(4).withName("Elle Meyer")
.withPhone("9482224").withEmail("[email protected]").withAddress("michegan ave")
.withPhone("94822241").withEmail("[email protected]").withAddress("michegan ave")
.withDepartment("IT").withJobTitle("Developer").withSkills("Java", "C++").build();

public static final Supplier FIONA = new SupplierBuilder().withId(5).withName("Fiona Kunz")
.withPhone("9482427").withEmail("[email protected]").withAddress("little tokyo")
.withPhone("94824271").withEmail("[email protected]").withAddress("little tokyo")
.withProducts("Office Supplies", "Furniture").withTermsOfService("Delivery within 2 weeks").build();

public static final Supplier GEORGE = new SupplierBuilder().withId(6).withName("George Best")
.withPhone("9482442").withEmail("[email protected]").withAddress("4th street")
.withPhone("94824421").withEmail("[email protected]").withAddress("4th street")
.withProducts("Electronics", "Gadgets").withTermsOfService("Warranty for 1 year").build();

// Manually added
public static final Employee HOON = new EmployeeBuilder().withId(9).withName("Hoon Meier").withPhone("8482424")
public static final Employee HOON = new EmployeeBuilder().withId(9).withName("Hoon Meier").withPhone("84824241")
.withEmail("[email protected]").withAddress("little india")
.withDepartment("Tech Support").withJobTitle("Technician")
.withSkills("Technical Support", "Customer Service").build();

public static final Supplier IDA = new SupplierBuilder().withId(10).withName("Ida Mueller").withPhone("8482131")
public static final Supplier IDA = new SupplierBuilder().withId(10).withName("Ida Mueller").withPhone("84821311")
.withEmail("[email protected]").withAddress("chicago ave")
.withProducts("Computer Hardware", "Printers").withTermsOfService("Returns within 30 days").build();

Expand Down
4 changes: 2 additions & 2 deletions test_export.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ ID,Name,Phone,Email,Address,Remark,Tags,Department,Job Title,Skills,Products,Pre
1,Alice Pauline,94351253,[email protected],"123, Jurong West Ave 6, #08-111",some remarks,"friends",,,,Product1, Product2,Vegan,
2,Benson Meier,98765432,[email protected],"311, Clementi Ave 2, #02-25",some remarks,"owesMoney, friends",,,,Product3,Gluten-Free,
3,Daniel Meier,87652533,[email protected],"10th street",some remarks,"friends",Marketing,Manager,Digital Marketing, Public Speaking,,,
4,Elle Meyer,9482224,[email protected],"michegan ave",some remarks,,IT,Developer,Java, C++,,,
5,Fiona Kunz,9482427,[email protected],"little tokyo",some remarks,,,,,Office Supplies, Furniture,,Delivery within 2 weeks
4,Elle Meyer,94822241,[email protected],"michegan ave",some remarks,,IT,Developer,Java, C++,,,
5,Fiona Kunz,94824271,[email protected],"little tokyo",some remarks,,,,,Office Supplies, Furniture,,Delivery within 2 weeks

0 comments on commit b7e2cc8

Please sign in to comment.