//@@author A0139925U
package seedu.tache.model.task;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import seedu.tache.commons.exceptions.IllegalValueException;

public class DateTimeTest {

    @Test(expected = IllegalValueException.class)
    public void testInvalidDateTime() throws IllegalValueException {
        DateTime test = new DateTime("happy");
    }

    @Test
    public void testCorrectDateParsing() throws IllegalValueException {
        DateTime test = new DateTime("02/07/19");
        assertEquals(test.getAmericanDateOnly(), "02/07/2019");
        assertEquals(test.getDateOnly(), "07/02/2019");
        assertEquals(test.getAmericanDateTime(), "02/07/2019 00:00:00");
        assertEquals(test.getTimeOnly(), "00:00:00");
        assertEquals(test.getDateTimeForFullCalendar(), "2019-02-07T00:00:00");
    }

    @Test
    public void testCorrectTimeParsing() throws IllegalValueException {
        DateTime test = new DateTime("3pm");
        assertEquals(test.getTimeOnly(), "15:00:00");
    }

    @Test
    public void testCorrectDateTimeParsing() throws IllegalValueException {
        DateTime test = new DateTime("02/07/19 3pm");
        assertEquals(test.getAmericanDateOnly(), "02/07/2019");
        assertEquals(test.getDateOnly(), "07/02/2019");
        assertEquals(test.getAmericanDateTime(), "02/07/2019 15:00:00");
        assertEquals(test.getTimeOnly(), "15:00:00");
        assertEquals(test.getDateTimeForFullCalendar(), "2019-02-07T15:00:00");

        DateTime test2 = new DateTime("3pm 02/07/19");
        assertEquals(test2.getAmericanDateOnly(), "02/07/2019");
        assertEquals(test2.getDateOnly(), "07/02/2019");
        assertEquals(test2.getAmericanDateTime(), "02/07/2019 15:00:00");
        assertEquals(test2.getTimeOnly(), "15:00:00");
        assertEquals(test2.getDateTimeForFullCalendar(), "2019-02-07T15:00:00");

        DateTime test3 = new DateTime("3pm 02-07-19");
        assertEquals(test3.getAmericanDateOnly(), "02/07/2019");
        assertEquals(test3.getDateOnly(), "07/02/2019");
        assertEquals(test3.getAmericanDateTime(), "02/07/2019 15:00:00");
        assertEquals(test3.getTimeOnly(), "15:00:00");
        assertEquals(test3.getDateTimeForFullCalendar(), "2019-02-07T15:00:00");
    }
}

@@ -91,16 +91,127 @@
 tEquals;
+%0Aimport static org.junit.Assert.assertFalse;%0Aimport static org.junit.Assert.assertTrue;%0A%0Aimport java.util.Date;
 %0A%0Aimport
@@ -2395,10 +2395,2073 @@
 ;%0A    %7D%0A
+    %0A    //@@author A0139961U%0A    @Test%0A    public void isSameDateSuccess() throws IllegalValueException %7B%0A        Date now = new Date();%0A        DateTime test = new DateTime(now.toString());%0A        Date date = new Date();%0A        assertTrue(test.isSameDate(date));%0A    %7D%0A    %0A    @Test%0A    public void isSameDateFailure() throws IllegalValueException %7B%0A        Date now = new Date();%0A        DateTime test = new DateTime(now.toString());%0A        Date date = new Date(0);%0A        assertFalse(test.isSameDate(date));%0A    %7D%0A    %0A    @Test%0A    public void isTodaySuccess() throws IllegalValueException %7B%0A        Date today = new Date();%0A        DateTime test = new DateTime(today.toString());%0A        assertTrue(test.isToday());%0A    %7D%0A    %0A    @Test%0A    public void isTodayFailure() throws IllegalValueException %7B%0A        Date past = new Date(0);%0A        DateTime testPast = new DateTime(past.toString());%0A        assertFalse(testPast.isToday());%0A        %0A        DateTime yesterday = new DateTime(%22yesterday%22);%0A        assertFalse(yesterday.isToday());%0A        %0A        DateTime tomorrow = new DateTime(%22tomorrow%22);%0A        assertFalse(tomorrow.isToday());%0A        %0A        Date future = new Date(Long.MAX_VALUE);%0A        DateTime testFuture = new DateTime(future.toString());%0A        assertFalse(testFuture.isToday());%0A    %7D%0A    %0A    @Test%0A    public void isSameWeekSuccess() throws IllegalValueException %7B%0A        DateTime thisWeek = new DateTime(%22this week%22);%0A        assertTrue(thisWeek.isSameWeek());%0A    %7D%0A    %0A    @Test%0A    public void isSameWeekFailure() throws IllegalValueException %7B%0A        DateTime lastWeek = new DateTime(%22last week%22);%0A        assertFalse(lastWeek.isSameWeek());%0A        %0A        DateTime nextWeek = new DateTime(%22next week%22);%0A        assertFalse(nextWeek.isSameWeek());%0A    %7D%0A    %0A    @Test%0A    public void removeTimeSuccess() throws IllegalValueException %7B%0A        Date date = new Date();%0A        DateTime today = new DateTime(%22today 00:00AM%22);%0A        assertEquals(DateTime.removeTime(date), today.getDate());%0A    %7D%0A    //@@author%0A
 %7D%0A

Add Unit Test for DateTime functions