Skip to content

Commit

Permalink
Merge pull request #205 from wlren/branch-tests
Browse files Browse the repository at this point in the history
Update Storage test and Minor changes to UG
  • Loading branch information
koh-jx authored Nov 8, 2021
2 parents 4ccabeb + b25e61e commit f852463
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ testers are expected to do more *exploratory* testing.

1. Re-launch the app by double-clicking the jar file.<br>
Expected: The most recent window size and location is retained.


### Deleting a person

Expand Down
5 changes: 4 additions & 1 deletion docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ Some prefixes require the user to follow certain formats in their commands.
| ------------- | ------------- | ------------- |
| `ts` | Timestamp, represents a date | `DD`-`MM`-`YYYY` <br/><br/> 1. Single-digit dates or months require a `0` appended at the front. For example, 3rd July 2021 is represented as `03-07-2021`. <br/><br/> 2. The day, month and year are separated by hyphens. |
| `e` | Email | `local-part@domain` <br/><br/> 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.<br/><br/>2. This is followed by a '@' and then a domain name. The domain name is made up of domain labels separated by periods. <br/><br/> The domain name must: <br/> - end with a domain label at least 2 characters long <br/> - have each domain label start and end with alphanumeric characters <br/> - 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 should contain only alphanumeric characters and spaces. |
| `c` and `n` | Contact/Name | !. Contact names should contain only alphanumeric characters and spaces. |


<a name="ab3comm"></a>
Expand Down Expand Up @@ -379,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.

Expand Down
2 changes: 1 addition & 1 deletion docs/team/wlren.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 [#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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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
} ]
} ]
}
Original file line number Diff line number Diff line change
@@ -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
} ]
} ]
}
65 changes: 65 additions & 0 deletions src/test/java/seedu/address/storage/JsonAdaptedTaskTest.java
Original file line number Diff line number Diff line change
@@ -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<JsonAdaptedTag> VALID_TAGS = BUY_GROCERIES.getTags().stream()
.map(JsonAdaptedTag::new).collect(Collectors.toList());
private static final List<JsonAdaptedContact> 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<JsonAdaptedTag> 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<JsonAdaptedContact> 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);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}

}
8 changes: 1 addition & 7 deletions src/test/java/seedu/address/testutil/TaskBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f852463

Please sign in to comment.