package seedu.address.testutil;

import java.util.Optional;

import seedu.address.model.tag.UniqueTagList;
import seedu.address.model.task.Deadline;
import seedu.address.model.task.Name;
import seedu.address.model.task.ReadOnlyTask;
import seedu.address.model.task.StartEndDateTime;

/**
 * A mutable task object. For testing only.
 */
public class TestTask implements ReadOnlyTask {

    private Name name;
    private Optional<Deadline> deadline;
    private Optional<StartEndDateTime> startEndDateTime;
    private UniqueTagList tags;

    public TestTask() {
        // TODO perhaps a better idea for each of the test tasks to always have their dates
        // this is a temporary hack
        deadline = Optional.empty();
        startEndDateTime = Optional.empty();

        tags = new UniqueTagList();
    }

    /**
     * Creates a copy of {@code taskToCopy}.
     */
    public TestTask(TestTask taskToCopy) {
        // TODO perhaps a better idea for each of the test tasks to always have their dates
        // this is a temporary hack
        deadline = Optional.empty();
        startEndDateTime = Optional.empty();

        name = taskToCopy.getName();
        tags = taskToCopy.getTags();
    }

    public void setName(Name name) {
        this.name = name;
    }

    public void setTags(UniqueTagList tags) {
        this.tags = tags;
    }

    @Override
    public Name getName() {
        return name;
    }

    @Override
    public Optional<Deadline> getDeadline() {
        return deadline;
    }

    @Override
    public Optional<StartEndDateTime> getStartEndDateTime() {
        return startEndDateTime;
    }

    @Override
    public UniqueTagList getTags() {
        return tags;
    }

    @Override
    public String toString() {
        return getAsText();
    }

    public String getAddCommand() {
        // TODO add the new fields
        StringBuilder sb = new StringBuilder();
        sb.append("add " + this.getName().value + " ");
        this.getTags().asObservableList().stream().forEach(s -> sb.append("t/" + s.tagName + " "));
        return sb.toString();
    }
}

@@ -50,24 +50,70 @@
 .Optional;%0A%0A
+import seedu.address.logic.parser.ParserUtil;%0A
 import seedu
@@ -578,16 +578,41 @@
  tags;%0A%0A
+    //@@author A0140023E%0A
     publ
@@ -642,124 +642,248 @@
  // 
-TODO perhaps a better idea for each of the test tasks to always have their dates%0A        // this is a temporary hack
+Initialize TestTask with empty deadlines, startEndDateTime and tags because they are optional.%0A        // this will allow us to conveniently create TestTasks through TaskBuilder without being forced%0A        // to specify the optional fields
 %0A   
@@ -953,33 +953,32 @@
 tional.empty();%0A
-%0A
         tags = n
@@ -1059,303 +1059,296 @@
 opy%7D
-.%0A     */%0A    public TestTask(TestTask taskToCopy) %7B%0A        // TODO perhaps a better idea for each of the test tasks to always have their dates%0A        // this is a temporary hack%0A        deadline = Optional.empty();%0A        startEndDateTime = Optional.empty();%0A%0A        name = taskToCopy.getNa
+ by shallow copying only the data.%0A     * Shallow copying reduces the overhead of copying the data.%0A     */%0A    public TestTask(TestTask taskToCopy) %7B%0A        name = taskToCopy.getName();%0A        deadline = taskToCopy.getDeadline();%0A        startEndDateTime = taskToCopy.getStartEndDateTi
 me()
@@ -1385,32 +1385,47 @@
 tTags();%0A    %7D%0A%0A
+    //@@author%0A
     public void 
@@ -1470,32 +1470,318 @@
  = name;%0A    %7D%0A%0A
+    //@@author A0140023E%0A    public void setDeadline(Deadline dateTime) %7B%0A        this.deadline = Optional.of(dateTime);%0A    %7D%0A%0A    public void setStartEndDateTime(StartEndDateTime startEndDateTime) %7B%0A        this.startEndDateTime = Optional.of(startEndDateTime);%0A    %7D%0A%0A    //@@author%0A
     public void 
@@ -1905,32 +1905,57 @@
 rn name;%0A    %7D%0A%0A
+    //@@author A0140023E%0A
     @Override%0A  
@@ -2138,32 +2138,47 @@
 ateTime;%0A    %7D%0A%0A
+    //@@author%0A
     @Override%0A  
@@ -2312,32 +2312,57 @@
 sText();%0A    %7D%0A%0A
+    //@@author A0140023E%0A
     public Strin
@@ -2385,43 +2385,8 @@
 ) %7B%0A
-        // TODO add the new fields%0A
     
@@ -2456,21 +2456,16 @@
 add %22 + 
-this.
 getName(
@@ -2480,24 +2480,25 @@
 + %22 %22);%0A
+%0A
         
 this.get
@@ -2489,21 +2489,657 @@
         
-this.
+if (getDeadline().isPresent()) %7B%0A            sb.append(%22 by %22);%0A            // TODO change the format%0A            sb.append(getDeadline().get().getValue().format(ParserUtil.DATE_TIME_FORMAT));%0A        %7D%0A%0A        if (getStartEndDateTime().isPresent()) %7B%0A            // TODO change the format%0A            StartEndDateTime startEndDateTime = getStartEndDateTime().get();%0A            sb.append(%22 from %22);%0A            sb.append(startEndDateTime.getStartDateTime().format(ParserUtil.DATE_TIME_FORMAT));%0A            sb.append(%22 to %22);%0A            sb.append(startEndDateTime.getEndDateTime().format(ParserUtil.DATE_TIME_FORMAT));%0A        %7D%0A%0A        
 getTags(

Support deadlines and start/end dates in TestTask