package seedu.ezdo.commons.util;

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

import org.junit.Test;

import seedu.ezdo.testutil.TaskBuilder;
import seedu.ezdo.testutil.TestTask;

public class DateUtilTest {
    @Test
    public void noStartDate_pass() throws Exception {
        TestTask task = new TaskBuilder().withName("Alson").withPriority("3").withStartDate("")
                .withDueDate("10/10/2019")
                .withTags("guy").build();
        assertTrue(DateUtil.isTaskDateValid(task));
    }

    @Test
    public void noDueDate_pass() throws Exception {
        TestTask task = new TaskBuilder().withName("Alson").withPriority("3").withStartDate("02/02/2017")
                .withDueDate("")
                .withTags("guy").build();
        assertTrue(DateUtil.isTaskDateValid(task));
    }

    @Test
    public void twoDates_equal_pass() throws Exception {
        TestTask task = new TaskBuilder().withName("Alson").withPriority("3")
                .withStartDate("02/02/2017").withDueDate("02/02/2017")
                .withTags("guy").build();
        assertTrue(DateUtil.isTaskDateValid(task));
    }

    @Test
    public void startAfterDue_fail() throws Exception {
        TestTask task = new TaskBuilder().withName("Alson").withPriority("3")
                .withStartDate("02/02/2020").withDueDate("10/10/2019")
                .withTags("guy").build();
        assertFalse(DateUtil.isTaskDateValid(task));
    }
}

@@ -25,16 +25,53 @@
 ns.util;
+%0Aimport static org.mockito.Mockito.*;
 %0A%0Aimport
@@ -163,130 +163,1142 @@
 ort 
-org.junit.Test;%0A%0Aimport seedu.ezdo.testutil.TaskBuilder;%0Aimport seedu.ezdo.testutil.TestTask;%0A%0Apublic class DateUtilTest %7B
+java.text.ParseException;%0Aimport java.text.SimpleDateFormat;%0A%0Aimport org.junit.Rule;%0Aimport org.junit.Test;%0Aimport org.junit.rules.ExpectedException;%0Aimport org.junit.runner.RunWith;%0Aimport org.powermock.api.mockito.PowerMockito;%0Aimport org.powermock.core.classloader.annotations.PrepareForTest;%0Aimport org.powermock.modules.junit4.PowerMockRunner;%0A%0Aimport seedu.ezdo.testutil.TaskBuilder;%0Aimport seedu.ezdo.testutil.TestTask;%0A%0A@RunWith(PowerMockRunner.class)%0A@PrepareForTest(%7BDateUtil.class, SimpleDateFormat.class%7D)%0Apublic class DateUtilTest %7B%0A%0A    @Rule%0A    public ExpectedException thrown = ExpectedException.none();%0A%0A    @Test%0A    public void dateFormat_parseException() throws Exception %7B%0A        thrown.expect(AssertionError.class);%0A        SimpleDateFormat mock = mock(SimpleDateFormat.class);%0A        PowerMockito.whenNew(SimpleDateFormat.class).%0A        withAnyArguments().thenReturn(mock);%0A        String dateString1 = %22omg%22;%0A        String dateString2 = %22asdf%22;%0A        when(mock.parse(dateString1)).thenThrow(new ParseException(%22parse exception%22, 1));%0A        DateUtil.compareDateStrings(dateString1, dateString2);%0A    %7D%0A
 %0A   

Add tests to DateUtil