package seedu.taskboss.model.task;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.util.List;

import org.junit.Test;

import com.joestelmach.natty.DateGroup;

public class DateTimeTest {

    private com.joestelmach.natty.Parser nattyParser = new com.joestelmach.natty.Parser(); 

    @Test
    public void isValidDateTime() {
        // invalid dateTime
        List<DateGroup> dateGroupList = this.nattyParser.parse(" "); // spaces only
        int numDates = countDates(dateGroupList);
        boolean isSpaceValid = true;
        if (numDates != 1) {
            isSpaceValid = false;
        } 
        assertFalse(isSpaceValid);

        List<DateGroup> dateGroupList2 = this.nattyParser.parse("dateTime"); // invalid dateTime
        int numDates2 = countDates(dateGroupList2);
        boolean isRandomValid = true;
        if (numDates2 != 1) {
            isRandomValid = false;
        } 
        assertFalse(isRandomValid);

        List<DateGroup> dateGroupList3 = this.nattyParser.parse("this friday to next monday"); // not a single date
        int numDates3 = countDates(dateGroupList3);
        boolean isMultiplesValid = true;
        if (numDates3 != 1) {
            isMultiplesValid = false;
        } 
        assertFalse(isMultiplesValid);

        // valid dateTime
        List<DateGroup> dateGroupList4 = this.nattyParser.parse("next wednesday 8.59pm");
        int numDates4 = countDates(dateGroupList4);
        boolean isNaturalValid = true;
        if (numDates4 != 1) {
            isNaturalValid = false;
        } 
        assertTrue(isNaturalValid);

        List<DateGroup> dateGroupList5 = this.nattyParser.parse("11/03/2017");
        int numDates5 = countDates(dateGroupList5);
        boolean isSlashValid = true;
        if (numDates5 != 1) {
            isSlashValid = false;
        } 
        assertTrue(isSlashValid);

        List<DateGroup> dateGroupList6 = this.nattyParser.parse("Feb 29 3am");
        int numDates6 = countDates(dateGroupList6);
        boolean isWordValid = true;
        if (numDates6 != 1) {
            isWordValid = false;
        } 
        assertTrue(isWordValid);

        List<DateGroup> dateGroupList7 = this.nattyParser.parse("30-3-2015");
        int numDates7 = countDates(dateGroupList7);
        boolean isDashValid = true;
        if (numDates7 != 1) {
            isDashValid = false;
        } 
        assertTrue(isDashValid);
    }

    private int countDates(List<DateGroup> dateGroups) {
        int numTotalDates = 0;
        for (DateGroup dateGroup : dateGroups) {
            numTotalDates += dateGroup.getDates().size();
        }
        return numTotalDates;
    }
}

@@ -325,18 +325,17 @@
 arser();
- 
 %0A
+
 %0A    @Te
@@ -636,33 +636,32 @@
 false;%0A        %7D
- 
 %0A        assertF
@@ -934,33 +934,32 @@
 false;%0A        %7D
- 
 %0A        assertF
@@ -1258,33 +1258,32 @@
 false;%0A        %7D
- 
 %0A        assertF
@@ -1581,33 +1581,32 @@
 false;%0A        %7D
- 
 %0A        assertT
@@ -1860,33 +1860,32 @@
 false;%0A        %7D
- 
 %0A        assertT
@@ -2135,33 +2135,32 @@
 false;%0A        %7D
- 
 %0A        assertT
@@ -2399,32 +2399,32 @@
 hValid = false;%0A
+
         %7D %0A     
@@ -2416,17 +2416,16 @@
        %7D
- 
 %0A       

Remove trailing whitespaces::DateTimeTest