From a7a5aa3c60da19a0b0af88b0a9c433690ef6e607 Mon Sep 17 00:00:00 2001 From: wlren Date: Mon, 8 Nov 2021 18:04:51 +0800 Subject: [PATCH 1/5] Update documentation --- docs/UserGuide.md | 3 ++- docs/team/wlren.md | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/UserGuide.md b/docs/UserGuide.md index 777d571e300..44c88537255 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -90,7 +90,8 @@ Some prefixes require the user to follow certain formats in their commands. | ------------- | ------------- | ------------- | | `ts` | Timestamp, represents a date | `DD`-`MM`-`YYYY`

1. Single-digit dates or months require a `0` appended at the front. For example, 3rd July 2021 is represented as `03-07-2021`.

2. The day, month and year are separated by hyphens. | | `e` | Email | `local-part@domain`

1. The local-part should only contain alphanumeric characters and these special characters, excluding the parentheses, (+_.-). The local-part may not start or end with any special characters.

2. This is followed by a '@' and then a domain name. The domain name is made up of domain labels separated by periods.

The domain name must:
- end with a domain label at least 2 characters long
- have each domain label start and end with alphanumeric characters
- have each domain label consist of alphanumeric characters, separated only by hyphens, if any. | - +| `p` | Phone | 1. Phone number provided must contain only numbers and must be at least 3 digits long. | +| `t' | Tag | !. Tags contain only alphanumeric characters. | diff --git a/docs/team/wlren.md b/docs/team/wlren.md index e60aa7300aa..22213cb986d 100644 --- a/docs/team/wlren.md +++ b/docs/team/wlren.md @@ -20,7 +20,7 @@ Given below are my contributions to the project. - Highlights: Having two separate lines of storage for two different parts of the TaskMaster2103 helps compartmentalize storage and makes sure that the reading and writing of data after an operation is more efficient as only the part that experiences changes would need to invoke the storage process. - **Testing**: - Updated Task testcases after Date semantics [#89](https://github.com/AY2122S1-CS2103-F09-2/tp/pull/89) - - Add Storage related testcases for tasks [#199](https://github.com/AY2122S1-CS2103-F09-2/tp/pull/199) + - Add Storage related testcases for tasks [#204](https://github.com/AY2122S1-CS2103-F09-2/tp/pull/199) - **Code contributed**: [RepoSense link](https://nus-cs2103-ay2122s1.github.io/tp-dashboard/?search=&sort=groupTitle&sortWithin=title&timeframe=commit&mergegroup=&groupSelect=groupByRepos&breakdown=true&checkedFileTypes=docs~functional-code~test-code~other&since=2021-09-17&tabOpen=true&tabType=authorship&tabAuthor=wlren&tabRepo=AY2122S1-CS2103-F09-2%2Ftp%5Bmaster%5D&authorshipIsMergeGroup=false&authorshipFileTypes=docs~functional-code~test-code~other&authorshipIsBinaryFileTypeChecked=false) - **Documentation**: - Developer Guide: From 31300c5120928ff5a01f9ee9d71397b7b96e5d07 Mon Sep 17 00:00:00 2001 From: wlren Date: Mon, 8 Nov 2021 19:13:27 +0800 Subject: [PATCH 2/5] Update User Guide --- docs/UserGuide.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/UserGuide.md b/docs/UserGuide.md index 44c88537255..b6a324cd888 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -91,7 +91,9 @@ Some prefixes require the user to follow certain formats in their commands. | `ts` | Timestamp, represents a date | `DD`-`MM`-`YYYY`

1. Single-digit dates or months require a `0` appended at the front. For example, 3rd July 2021 is represented as `03-07-2021`.

2. The day, month and year are separated by hyphens. | | `e` | Email | `local-part@domain`

1. The local-part should only contain alphanumeric characters and these special characters, excluding the parentheses, (+_.-). The local-part may not start or end with any special characters.

2. This is followed by a '@' and then a domain name. The domain name is made up of domain labels separated by periods.

The domain name must:
- end with a domain label at least 2 characters long
- have each domain label start and end with alphanumeric characters
- have each domain label consist of alphanumeric characters, separated only by hyphens, if any. | | `p` | Phone | 1. Phone number provided must contain only numbers and must be at least 3 digits long. | -| `t' | Tag | !. Tags contain only alphanumeric characters. | +| `t` | Tag | !. Tags should contain only alphanumeric characters and spaces. | +| `c` and `n` | Contact/Name | !. Contact names should contain only alphanumeric characters and spaces. | + From 7fdc1cae20ac34ed6316d750a7109b0e24734346 Mon Sep 17 00:00:00 2001 From: wlren Date: Mon, 8 Nov 2021 19:13:51 +0800 Subject: [PATCH 3/5] Add Storage tests --- .../invalidTasksTaskList.json | 43 ++++++++++++ .../typicalTasksTaskList.json | 37 +++++++++++ .../address/storage/JsonAdaptedTaskTest.java | 65 +++++++++++++++++++ .../storage/JsonSerializableTaskListTest.java | 38 +++++++++++ .../seedu/address/testutil/TaskBuilder.java | 8 +-- 5 files changed, 184 insertions(+), 7 deletions(-) create mode 100644 src/test/data/JsonSerializableTaskListTest/invalidTasksTaskList.json create mode 100644 src/test/data/JsonSerializableTaskListTest/typicalTasksTaskList.json create mode 100644 src/test/java/seedu/address/storage/JsonAdaptedTaskTest.java create mode 100644 src/test/java/seedu/address/storage/JsonSerializableTaskListTest.java diff --git a/src/test/data/JsonSerializableTaskListTest/invalidTasksTaskList.json b/src/test/data/JsonSerializableTaskListTest/invalidTasksTaskList.json new file mode 100644 index 00000000000..7045a155cef --- /dev/null +++ b/src/test/data/JsonSerializableTaskListTest/invalidTasksTaskList.json @@ -0,0 +1,43 @@ +{ + "tasks" : [ { + "title" : "Finish CS2103 tasks", + "description" : "1. Settle merge conflicts \n2. Create new PR\n3. Triage PE-D Bugs", + "timestamp" : "invalid timestamp", + "isDone" : "Not Done", + "tagged" : [ "todo", "urgent" ], + "contacts" : [ { + "name" : "Jeremy", + "isInAddressBook" : false + }, { + "name" : "Roy Balakrishnan", + "isInAddressBook" : true + } ] + }, { + "title" : "Finish CS2105 Assignment", + "description" : "Finish up the last question", + "timestamp" : "08-11-2021", + "isDone" : "Not Done", + "tagged" : [ ], + "contacts" : [ ] + }, { + "title" : "Submit CS2100 Assignment", + "description" : "Upload to Luminus", + "timestamp" : "08-11-2021", + "isDone" : "Done", + "tagged" : [ "todo", "urgent" ], + "contacts" : [ ] + }, { + "title" : "Finish this mod", + "description" : "Submit this project", + "timestamp" : "08-11-2021", + "isDone" : "Not Done", + "tagged" : [ "todo", "urgent" ], + "contacts" : [ { + "name" : "Jeremy", + "isInAddressBook" : false + }, { + "name" : "Roy Balakrishnan", + "isInAddressBook" : true + } ] + } ] +} \ No newline at end of file diff --git a/src/test/data/JsonSerializableTaskListTest/typicalTasksTaskList.json b/src/test/data/JsonSerializableTaskListTest/typicalTasksTaskList.json new file mode 100644 index 00000000000..e2f96606b3e --- /dev/null +++ b/src/test/data/JsonSerializableTaskListTest/typicalTasksTaskList.json @@ -0,0 +1,37 @@ +{ + "tasks" : [ { + "title" : "Buy groceries", + "description" : "Two eggs, one carton of milk and five tomatoes", + "timestamp" : "27-07-2021", + "isDone" : "Not Done", + "tagged" : [ ], + "contacts" : [ ] + }, { + "title" : "Do homework", + "description" : "Math, physics and chemistry", + "timestamp" : "27-07-2021", + "isDone" : "Not Done", + "tagged" : [ "important", "homework" ], + "contacts" : [ ] + }, { + "title" : "Clean my room", + "description" : "Two eggs, one carton of milk and five tomatoes", + "timestamp" : "27-07-2021", + "isDone" : "Not Done", + "tagged" : [ "important" ], + "contacts" : [ { + "name" : "Mother", + "isInAddressBook" : false + } ] + }, { + "title" : "Arrange meeting", + "description" : "Two eggs, one carton of milk and five tomatoes", + "timestamp" : "27-07-2021", + "isDone" : "Done", + "tagged" : [ "work", "important" ], + "contacts" : [ { + "name" : "Amy Bee", + "isInAddressBook" : false + } ] + } ] +} \ No newline at end of file diff --git a/src/test/java/seedu/address/storage/JsonAdaptedTaskTest.java b/src/test/java/seedu/address/storage/JsonAdaptedTaskTest.java new file mode 100644 index 00000000000..a49aa076511 --- /dev/null +++ b/src/test/java/seedu/address/storage/JsonAdaptedTaskTest.java @@ -0,0 +1,65 @@ +package seedu.address.storage; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static seedu.address.storage.JsonAdaptedTask.MISSING_FIELD_MESSAGE_FORMAT; +import static seedu.address.testutil.Assert.assertThrows; +import static seedu.address.testutil.TypicalTasks.BUY_GROCERIES; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import org.junit.jupiter.api.Test; + +import seedu.address.commons.exceptions.IllegalValueException; + +public class JsonAdaptedTaskTest { + + private static final String INVALID_TAG = "#friend"; + private static final String INVALID_TIMESTAMP = "1999-06-23"; + private static final String INVALID_CONTACT = "@jeff"; + + private static final String VALID_TITLE = BUY_GROCERIES.getTitle(); + private static final String VALID_DESCRIPTION = BUY_GROCERIES.getDescription().get(); + private static final String VALID_TIMESTAMP = BUY_GROCERIES.getTimestamp().get().toString(); + private static final String VALID_ISDONE = BUY_GROCERIES.isDone() ? "Done" : "Not Done"; + private static final List VALID_TAGS = BUY_GROCERIES.getTags().stream() + .map(JsonAdaptedTag::new).collect(Collectors.toList()); + private static final List VALID_CONTACTS = BUY_GROCERIES.getContacts().stream() + .map(JsonAdaptedContact::new).collect(Collectors.toList()); + + + @Test + public void toModelType_validTaskDetails_returnsTask() throws Exception { + JsonAdaptedTask task = new JsonAdaptedTask(BUY_GROCERIES); + assertEquals(BUY_GROCERIES.getTitle(), task.toModelType().getTitle()); + } + + @Test + public void toModelType_nulTaskTitle_throwsIllegalValueException() { + JsonAdaptedTask task = new JsonAdaptedTask(null, VALID_DESCRIPTION, + VALID_TIMESTAMP, VALID_ISDONE, VALID_TAGS, VALID_CONTACTS); + String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, "title"); + assertThrows(IllegalValueException.class, expectedMessage, task::toModelType); + } + + @Test + public void toModelType_invalidTaskTags_throwsIllegalValueException() { + List invalidTags = new ArrayList<>(VALID_TAGS); + invalidTags.add(new JsonAdaptedTag(INVALID_TAG)); + JsonAdaptedTask task = + new JsonAdaptedTask(VALID_TITLE, VALID_DESCRIPTION, VALID_TIMESTAMP, + VALID_ISDONE, invalidTags, VALID_CONTACTS); + assertThrows(IllegalValueException.class, task::toModelType); + } + + @Test + public void toModelType_invalidTaskContacts_throwsIllegalValueException() { + List invalidContacts = new ArrayList<>(VALID_CONTACTS); + invalidContacts.add(new JsonAdaptedContact(INVALID_CONTACT, false)); + JsonAdaptedTask task = + new JsonAdaptedTask(VALID_TITLE, VALID_DESCRIPTION, VALID_TIMESTAMP, + VALID_ISDONE, VALID_TAGS, invalidContacts); + assertThrows(IllegalValueException.class, task::toModelType); + } +} diff --git a/src/test/java/seedu/address/storage/JsonSerializableTaskListTest.java b/src/test/java/seedu/address/storage/JsonSerializableTaskListTest.java new file mode 100644 index 00000000000..bb35ec54659 --- /dev/null +++ b/src/test/java/seedu/address/storage/JsonSerializableTaskListTest.java @@ -0,0 +1,38 @@ +package seedu.address.storage; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static seedu.address.testutil.Assert.assertThrows; + +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.jupiter.api.Test; + +import seedu.address.commons.exceptions.IllegalValueException; +import seedu.address.commons.util.JsonUtil; +import seedu.address.model.TaskList; +import seedu.address.testutil.TypicalTasks; + +public class JsonSerializableTaskListTest { + + private static final Path TEST_DATA_FOLDER = Paths.get("src", "test", "data", "JsonSerializableTaskListTest"); + private static final Path TYPICAL_TASKS_FILE = TEST_DATA_FOLDER.resolve("typicalTasksTaskList.json"); + private static final Path INVALID_TASKS_FILE = TEST_DATA_FOLDER.resolve("invalidTasksTaskList.json"); + + @Test + public void toModelType_typicalTasksFile_success() throws Exception { + JsonSerializableTaskList dataFromFile = JsonUtil.readJsonFile(TYPICAL_TASKS_FILE, + JsonSerializableTaskList.class).get(); + TaskList tasklistFromFile = dataFromFile.toModelType(); + TaskList typicalTasksTaskList = TypicalTasks.getTypicalTaskList(); + assertEquals(tasklistFromFile, typicalTasksTaskList); + } + + @Test + public void toModelType_invalidTaskFile_throwsIllegalValueException() throws Exception { + JsonSerializableTaskList dataFromFile = JsonUtil.readJsonFile(INVALID_TASKS_FILE, + JsonSerializableTaskList.class).get(); + assertThrows(IllegalValueException.class, dataFromFile::toModelType); + } + +} diff --git a/src/test/java/seedu/address/testutil/TaskBuilder.java b/src/test/java/seedu/address/testutil/TaskBuilder.java index dcb8ef934b7..c7f930dabee 100644 --- a/src/test/java/seedu/address/testutil/TaskBuilder.java +++ b/src/test/java/seedu/address/testutil/TaskBuilder.java @@ -3,7 +3,6 @@ import java.util.HashSet; import java.util.Set; -import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.tag.Tag; import seedu.address.model.task.Contact; import seedu.address.model.task.Task; @@ -31,12 +30,7 @@ public class TaskBuilder { public TaskBuilder() { this.title = DEFAULT_TITLE; this.description = DEFAULT_DESCRIPTION; - try { - this.timestamp = Timestamp.of("2021-10-27"); - } catch (ParseException pe) { - //Never occurs - this.timestamp = null; - } + this.timestamp = Timestamp.tryParse("27-07-2021"); this.tags = DEFAULT_TAGS; this.isDone = DEFAULT_IS_DONE; this.contacts = DEFAULT_CONTACTS; From 1a18ee742c32cfd320a8ca4420a0e7db3b610d29 Mon Sep 17 00:00:00 2001 From: wlren Date: Mon, 8 Nov 2021 19:17:52 +0800 Subject: [PATCH 4/5] Checkstyle fixes --- docs/DeveloperGuide.md | 2 +- docs/UserGuide.md | 2 +- .../data/JsonSerializableTaskListTest/invalidTasksTaskList.json | 2 +- .../data/JsonSerializableTaskListTest/typicalTasksTaskList.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index 1624f016304..15948b9e544 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -907,7 +907,7 @@ testers are expected to do more *exploratory* testing. 1. Re-launch the app by double-clicking the jar file.
Expected: The most recent window size and location is retained. - + ### Deleting a person diff --git a/docs/UserGuide.md b/docs/UserGuide.md index b6a324cd888..83a8d4e1216 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -382,7 +382,7 @@ Upon clicking the Add Task Dialog button, the following popup window should appe ![result for pressing +new button](images/guiAddTaskDialog.png) -Enter relevant text into the text fields. +Enter relevant text into the text fields. To add tags or contacts, type the tag into the text field and press the `Enter` key. The tag should be displayed as seen below. diff --git a/src/test/data/JsonSerializableTaskListTest/invalidTasksTaskList.json b/src/test/data/JsonSerializableTaskListTest/invalidTasksTaskList.json index 7045a155cef..0349a66b701 100644 --- a/src/test/data/JsonSerializableTaskListTest/invalidTasksTaskList.json +++ b/src/test/data/JsonSerializableTaskListTest/invalidTasksTaskList.json @@ -40,4 +40,4 @@ "isInAddressBook" : true } ] } ] -} \ No newline at end of file +} diff --git a/src/test/data/JsonSerializableTaskListTest/typicalTasksTaskList.json b/src/test/data/JsonSerializableTaskListTest/typicalTasksTaskList.json index e2f96606b3e..725981b99b0 100644 --- a/src/test/data/JsonSerializableTaskListTest/typicalTasksTaskList.json +++ b/src/test/data/JsonSerializableTaskListTest/typicalTasksTaskList.json @@ -34,4 +34,4 @@ "isInAddressBook" : false } ] } ] -} \ No newline at end of file +} From b25e61e5092ae8c851b7488cb0578323de586fe8 Mon Sep 17 00:00:00 2001 From: Ren Weilin <66356390+wlren@users.noreply.github.com> Date: Mon, 8 Nov 2021 19:21:27 +0800 Subject: [PATCH 5/5] Update wlren.md --- docs/team/wlren.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/team/wlren.md b/docs/team/wlren.md index 22213cb986d..fb08dd922e1 100644 --- a/docs/team/wlren.md +++ b/docs/team/wlren.md @@ -20,7 +20,7 @@ Given below are my contributions to the project. - Highlights: Having two separate lines of storage for two different parts of the TaskMaster2103 helps compartmentalize storage and makes sure that the reading and writing of data after an operation is more efficient as only the part that experiences changes would need to invoke the storage process. - **Testing**: - Updated Task testcases after Date semantics [#89](https://github.com/AY2122S1-CS2103-F09-2/tp/pull/89) - - Add Storage related testcases for tasks [#204](https://github.com/AY2122S1-CS2103-F09-2/tp/pull/199) + - Add Storage related testcases for tasks [#205](https://github.com/AY2122S1-CS2103-F09-2/tp/pull/199) - **Code contributed**: [RepoSense link](https://nus-cs2103-ay2122s1.github.io/tp-dashboard/?search=&sort=groupTitle&sortWithin=title&timeframe=commit&mergegroup=&groupSelect=groupByRepos&breakdown=true&checkedFileTypes=docs~functional-code~test-code~other&since=2021-09-17&tabOpen=true&tabType=authorship&tabAuthor=wlren&tabRepo=AY2122S1-CS2103-F09-2%2Ftp%5Bmaster%5D&authorshipIsMergeGroup=false&authorshipFileTypes=docs~functional-code~test-code~other&authorshipIsBinaryFileTypeChecked=false) - **Documentation**: - Developer Guide: