//@@author A0138848M
package seedu.oneline.model.task;

import static org.junit.Assert.*;

import seedu.oneline.commons.exceptions.IllegalValueException;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

public class TaskTimeTest {
    
    @Rule
    public ExpectedException thrown = ExpectedException.none();
    
    private void IllegalValueExceptionThrown(String inputTime, String errorMessage) throws Exception{
        thrown.expect(IllegalValueException.class);
        thrown.expectMessage(errorMessage);    
        new TaskTime(inputTime);
    }

    // Tests for invalid time inputs to TaskTime constructor
    
    /**
     * Invalid equivalence partitions for time: null, empty, other strings
     */
    
    @Test
    public void constructor_nullTime_assertionThrown() {
        thrown.expect(AssertionError.class);
        try {
            new TaskTime(null);
        } catch (IllegalValueException e){
            // should throw an assertion error instead of an illegal value exception
            assert false;
        }
    }

    @Test
    public void constructor_emptyTime_assertionThrown() throws Exception {
        IllegalValueExceptionThrown("", TaskTime.MESSAGE_TASK_TIME_CONSTRAINTS);
    }

    @Test
    public void constructor_unsupportedTimeFormats_assertionThrown() throws Exception {
        IllegalValueExceptionThrown("day after", TaskTime.MESSAGE_TASK_TIME_CONSTRAINTS);
        IllegalValueExceptionThrown("clearly not a time format", TaskTime.MESSAGE_TASK_TIME_CONSTRAINTS);
        IllegalValueExceptionThrown("Tuesd", TaskTime.MESSAGE_TASK_TIME_CONSTRAINTS);
    }
    

}

@@ -402,24 +402,28 @@
 String input
+Date
 Time, String
@@ -581,16 +581,20 @@
 me(input
+Date
 Time);%0A 
@@ -624,16 +624,20 @@
 invalid 
+date
 time inp
@@ -719,16 +719,20 @@
 ons for 
+date
 time: nu
@@ -738,15 +738,8 @@
 ull,
- empty,
  oth
@@ -804,16 +804,20 @@
 tor_null
+Date
 Time_ass
@@ -1137,17 +1137,34 @@
 tor_
-emptyTime
+unsupportedDateTimeFormats
 _ass
@@ -1234,16 +1234,25 @@
 Thrown(%22
+day after
 %22, TaskT
@@ -1291,113 +1291,8 @@
 S);%0A
-    %7D%0A%0A    @Test%0A    public void constructor_unsupportedTimeFormats_assertionThrown() throws Exception %7B%0A
     
@@ -1320,33 +1320,49 @@
 tionThrown(%22
-day after
+clearly not a time format
 %22, TaskTime.
@@ -1434,33 +1434,21 @@
 wn(%22
-clearly not a time format
+T u e s d a y
 %22, T
@@ -1495,90 +1495,505 @@
     
+%7D%0A
     
-IllegalValueExceptionThrown(%22Tuesd%22, TaskTime.MESSAGE_TASK_TIME_CONSTRAINTS);%0A
+%0A    // Tests for valid datetime inputs%0A    %0A    /**%0A     * Valid equivalence partitions for datetime:%0A     *  - day month and year specified%0A     *  - only day and month specified%0A     *  - only day specified%0A     *  - relative date specified%0A     *  - empty string%0A     */%0A%0A    @Test%0A    public void constructor_emptyDateTime() %7B%0A        try %7B%0A            TaskTime t = new TaskTime(%22%22);%0A            assert t.getDate() == null;%0A        %7D catch (Exception e) %7B%0A            assert false;%0A    
     
@@ -1998,12 +1998,17 @@
   %7D%0A    
-%0A
+%7D%0A    
 %0A%7D%0A

Add test case for empty tasktime string input