package seedu.task.testutil;

import java.util.ArrayList;

import seedu.task.model.tag.UniqueTagList;
import seedu.task.model.task.Description;
import seedu.task.model.task.Priority;
import seedu.task.model.task.ReadOnlyTask;
import seedu.task.model.task.RecurringFrequency;
import seedu.task.model.task.RecurringTaskOccurrence;
import seedu.task.model.task.Timing;

// @@author A0163559U
/**
 * A mutable Task object. For testing only.
 */
public class TestTask implements ReadOnlyTask {

    private Description description;
    private Priority priority;
    private ArrayList<RecurringTaskOccurrence> occurrences;
    private boolean recurring;
    private UniqueTagList tags;
    private RecurringFrequency frequency;
    private ArrayList<Integer> occurrenceIndexList = new ArrayList<Integer>();


    public TestTask() {
        tags = new UniqueTagList();
    }

    /**
     * Creates a copy of {@code taskToCopy}.
     */
    public TestTask(TestTask taskToCopy) {
        this.description = taskToCopy.getDescription();
        this.priority = taskToCopy.getPriority();
        this.occurrences = taskToCopy.getOccurrences();
        this.recurring = taskToCopy.isRecurring();
        this.tags = taskToCopy.getTags();
        this.frequency = taskToCopy.getFrequency();
        this.occurrenceIndexList = taskToCopy.getOccurrenceIndexList();
    }

    public void setDescription(Description description) {
        this.description = description;
    }

    public void setPriority(Priority priority) {
        this.priority = priority;
    }

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

    @Override
    public void setStartTiming(Timing startTiming) {
        assert startTiming != null;
        this.occurrences.get(0).setStartTiming(startTiming);
    }

    @Override
    public void setEndTiming(Timing endTiming) {
        assert endTiming != null;
        this.occurrences.get(0).setEndTiming(endTiming);
    }

    public void setComplete(boolean complete) {
        this.occurrences.get(0).setComplete(true);
    }

    @Override
    public Description getDescription() {
        return description;
    }

    @Override
    public Priority getPriority() {
        return priority;
    }

    @Override
    public Timing getStartTiming(int i) {
        return this.occurrences.get(i).getStartTiming();
    }

    @Override
    public Timing getStartTiming() {
        return getStartTiming(0);
    }

    @Override
    public Timing getEndTiming() {
        return this.occurrences.get(0).getEndTiming();
    }

    @Override
    public boolean isComplete() {
        return this.occurrences.get(0).isComplete();
    }

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

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

    // TODO add complete instance variable?
    public String getAddCommand() {
        StringBuilder sb = new StringBuilder();
        sb.append("add " + this.getDescription().description + " ");
        sb.append("p/" + this.getPriority().value + " ");
        sb.append("sd/" + this.getStartTiming().value + " ");
        sb.append("ed/" + this.getEndTiming().value + " ");
        sb.append("r/" + this.getFrequency().frequency + " ");
        this.getTags().asObservableList().stream().forEach(s -> sb.append("t/" + s.tagName + " "));
        return sb.toString();
    }

    @Override
    public boolean isRecurring() {
        return recurring;
    }

    @Override
    public RecurringFrequency getFrequency() {
        return frequency;
    }

    @Override
    public ArrayList<RecurringTaskOccurrence> getOccurrences() {
        return occurrences;
    }

    @Override
    public ArrayList<Integer> getOccurrenceIndexList() {
        return occurrenceIndexList;
    }

    @Override
    public void setOccurrenceIndexList(ArrayList<Integer> list) {
        occurrenceIndexList = list;
    }

}

@@ -1572,59 +1572,1185 @@
  set
-Tags(UniqueTagList tags) %7B%0A        this.tags = tags
+Occurrences(ArrayList%3CRecurringTaskOccurrence%3E occurrences) %7B%0A        this.occurrences = occurrences;%0A    %7D%0A%0A    public void setRecurring(boolean isRecurring) %7B%0A        this.recurring = isRecurring;%0A    %7D%0A%0A    public void setTags(UniqueTagList tags) %7B%0A        this.tags = tags;%0A    %7D%0A%0A    public void setFrequency(RecurringFrequency recurringFrequency) %7B%0A        this.frequency = recurringFrequency;%0A    %7D%0A%0A    @Override%0A    public void setOccurrenceIndexList(ArrayList%3CInteger%3E list) %7B%0A        occurrenceIndexList = list;%0A    %7D%0A%0A    @Override%0A    public Description getDescription() %7B%0A        return description;%0A    %7D%0A%0A    @Override%0A    public Priority getPriority() %7B%0A        return priority;%0A    %7D%0A%0A    @Override%0A    public ArrayList%3CRecurringTaskOccurrence%3E getOccurrences() %7B%0A        return occurrences;%0A    %7D%0A%0A    @Override%0A    public boolean isRecurring() %7B%0A        return recurring;%0A    %7D%0A%0A    @Override%0A    public UniqueTagList getTags() %7B%0A        return tags;%0A    %7D%0A%0A    @Override%0A    public RecurringFrequency getFrequency() %7B%0A        return frequency;%0A    %7D%0A%0A    @Override%0A    public ArrayList%3CInteger%3E getOccurrenceIndexList() %7B%0A        return occurrenceIndexList
 ;%0A  
@@ -3221,147 +3221,66 @@
 lic 
-Description getDescription() %7B%0A        return description;%0A    %7D%0A%0A    @Override%0A    public Priority getPriority() %7B%0A        return priority
+Timing getStartTiming() %7B%0A        return getStartTiming(0)
 ;%0A  
@@ -3408,100 +3408,8 @@
  %7D%0A%0A
-    @Override%0A    public Timing getStartTiming() %7B%0A        return getStartTiming(0);%0A    %7D%0A%0A
     
@@ -3627,87 +3627,8 @@
  %7D%0A%0A
-    @Override%0A    public UniqueTagList getTags() %7B%0A        return tags;%0A    %7D%0A%0A
     
@@ -4284,533 +4284,8 @@
  %7D%0A%0A
-    @Override%0A    public boolean isRecurring() %7B%0A        return recurring;%0A    %7D%0A%0A    @Override%0A    public RecurringFrequency getFrequency() %7B%0A        return frequency;%0A    %7D%0A%0A    @Override%0A    public ArrayList%3CRecurringTaskOccurrence%3E getOccurrences() %7B%0A        return occurrences;%0A    %7D%0A%0A    @Override%0A    public ArrayList%3CInteger%3E getOccurrenceIndexList() %7B%0A        return occurrenceIndexList;%0A    %7D%0A%0A    @Override%0A    public void setOccurrenceIndexList(ArrayList%3CInteger%3E list) %7B%0A        occurrenceIndexList = list;%0A    %7D
 %0A%0A%7D%0A

add setters to TestTask.java