package seedu.jimi.testutil;

import seedu.jimi.model.datetime.DateTime;
import seedu.jimi.model.tag.Priority;
import seedu.jimi.model.tag.UniqueTagList;
import seedu.jimi.model.task.DeadlineTask;
import seedu.jimi.model.task.FloatingTask;
import seedu.jimi.model.task.Name;
import seedu.jimi.model.task.ReadOnlyTask;

/**
 * @@author A0143471L
 * 
 * A mutable deadline task object inherited from FloatingTask object. For testing only.
 *
 */
public class TestDeadlineTask extends FloatingTask implements ReadOnlyTask{

    private Name name;
    private UniqueTagList tags;
    private boolean isCompleted;
    private Priority priority;
    private DateTime deadline;
    
    public TestDeadlineTask(Name name, DateTime deadline, UniqueTagList tags, boolean isCompleted, Priority priority) {
        super(name, tags, isCompleted, priority);
        assert deadline != null;
        this.deadline = deadline;
    }
    
    public TestDeadlineTask(Name name, DateTime deadline, UniqueTagList tags, Priority priority) {
        super(name, tags, priority);
        assert deadline != null;
        this.deadline = deadline;
    }
    
    public void setName(Name name) {
        this.name = name;
    }

    @Override
    public Name getName() {
        return name;
    }
    
    @Override
    public UniqueTagList getTags() {
        return tags;
    }
    
    public void setTags(UniqueTagList tags) {
        this.tags = tags;
    }
    
    @Override
    public Priority getPriority()  {
        return priority;
    }
    
    public void setPriority(Priority priority) {
        this.priority = priority;
    }
    
    public void setCompleted(boolean isCompleted) {
        this.isCompleted = isCompleted;
    }
    
    @Override
    public boolean isCompleted() {
        return false;
    }
    
    public DateTime getDeadline() {
        return deadline;
    }
    
    public void setDeadline(DateTime deadline) {
        this.deadline = deadline;
    }
    
    @Override
    public String toString() {
        return getAsText();
    }
    

    public String getAddCommand() {
        StringBuilder sb = new StringBuilder();
        sb.append("add " + "\"" + this.getName().fullName + "\"" + " ");
        sb.append("due " + this.deadline);
        this.getTags().getInternalList().stream().forEach(s -> sb.append("t/" + s.tagName + " "));
        sb.append("p/" + this.getPriority().tagName + " ");
        return sb.toString();
    }
    
    @Override
    public String getAsText() {
        final StringBuilder builder = new StringBuilder();
        builder.append(getName())
               .append(" ")
               .append(getDeadline())
               .append(" Tags: ");
        getTags().forEach(builder::append);
        builder.append(" Priority: ")
        .append(getPriority());
        return builder.toString();
    }
    
    @Override
    public boolean isSameStateAs(ReadOnlyTask other) {
        return other == this // short circuit if same object
                || (other instanceof DeadlineTask // instanceof handles nulls
                && super.isSameStateAs(other)
                && ((DeadlineTask)other).getDeadline().equals(this.getDeadline())
                );
    }
}

@@ -475,16 +475,20 @@
 extends 
+Test
 Floating
@@ -517,16 +517,16 @@
 lyTask%7B%0A
-
 %0A    pri
@@ -705,429 +705,46 @@
 ask(
-Name name, DateTime deadline, UniqueTagList tags, boolean isCompleted, Priority priority) %7B%0A        super(name, tags, isCompleted, priority);%0A        assert deadline != null;%0A        this.deadline = deadline;%0A    %7D%0A    %0A    public TestDeadlineTask(Name name, DateTime deadline, UniqueTagList tags, Priority priority) %7B%0A        super(name, tags, priority);%0A        assert deadline != null;%0A        this.deadline = deadline
+) %7B%0A        tags = new UniqueTagList()
 ;%0A  
@@ -1868,24 +1868,82 @@
  + this.
-deadline
+getDeadline().getDate() + %22 %22 + this.getDeadline().getTime() + %22 %22
 );%0A     
@@ -2332,32 +2332,42 @@
 nd(getDeadline()
+.getDate()
 )%0A              
@@ -2377,16 +2377,119 @@
 ppend(%22 
+%22)%0A               .append(getDeadline().getTime())%0A               .append(%22 %22)%0A               .append(%22
 Tags: %22)

Refactor TestDeadlineTask