package seedu.taskitty.model;

import seedu.taskitty.commons.exceptions.IllegalValueException;
import seedu.taskitty.model.task.TaskDate;
import seedu.taskitty.model.task.TaskPeriod;
import seedu.taskitty.model.task.TaskTime;

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

//@@author A0139930B
public class TaskTest {

    @Rule
    public ExpectedException thrown = ExpectedException.none();
    
    @Test
    public void invalidDateFormat_exceptionThrown() throws Exception {
        thrown.expect(IllegalValueException.class);
        TaskDate date = new TaskDate("25-12-2016");
    }
    
    @Test
    public void invalidDate_exceptionThrown() throws Exception {
        thrown.expect(IllegalValueException.class);
        TaskDate date = new TaskDate("29/2/2015");
    }
    
    @Test
    public void invalidTimeFormat_exceptionThrown() throws Exception {
        thrown.expect(IllegalValueException.class);
        TaskTime date = new TaskTime("3pm");
    }
    
    @Test
    public void invalidTime_exceptionThrown() throws Exception {
        thrown.expect(IllegalValueException.class);
        TaskDate date = new TaskDate("25:00");
    }
    
    @Test
    public void invalidPeriod_startDateAfterEndDate_exceptionThrown() throws Exception {
        thrown.expect(IllegalValueException.class);
        TaskPeriod period = new TaskPeriod(new TaskDate("25/12/2016"), new TaskTime("10:00"),
                        new TaskDate("24/12/2016"), new TaskTime("12:00"));
    }
    
    @Test
    public void invalidPeriod_startTimeAfterEndTime_exceptionThrown() throws Exception {
        thrown.expect(IllegalValueException.class);
        TaskDate date = new TaskDate("25/12/2016");
        TaskPeriod period = new TaskPeriod(date, new TaskTime("10:00"),
                        date, new TaskTime("9:00"));
    }
}

@@ -220,16 +220,54 @@
 kTime;%0A%0A
+import static org.junit.Assert.fail;%0A%0A
 import o
@@ -281,16 +281,16 @@
 t.Rule;%0A
-
 import o
@@ -612,32 +612,16 @@
 %0A       
- TaskDate date =
  new Tas
@@ -637,24 +637,40 @@
 -12-2016%22);%0A
+        fail();%0A
     %7D%0A    %0A 
@@ -802,32 +802,16 @@
 %0A       
- TaskDate date =
  new Tas
@@ -826,24 +826,40 @@
 9/2/2015%22);%0A
+        fail();%0A
     %7D%0A    %0A 
@@ -1001,24 +1001,8 @@
     
- TaskTime date =
  new
@@ -1015,24 +1015,40 @@
 ime(%223pm%22);%0A
+        fail();%0A
     %7D%0A    %0A 
@@ -1180,32 +1180,16 @@
 %0A       
- TaskDate date =
  new Tas
@@ -1200,24 +1200,40 @@
 e(%2225:00%22);%0A
+        fail();%0A
     %7D%0A    %0A 
@@ -1389,36 +1389,16 @@
 %0A       
- TaskPeriod period =
  new Tas
@@ -1472,24 +1472,16 @@
         
-        
 new Task
@@ -1520,24 +1520,40 @@
 (%2212:00%22));%0A
+        fail();%0A
     %7D%0A    %0A 
@@ -1765,28 +1765,8 @@
     
- TaskPeriod period =
  new
@@ -1822,24 +1822,16 @@
         
-        
 date, ne
@@ -1847,20 +1847,36 @@
 e(%229:00%22));%0A
+        fail();%0A
     %7D%0A%7D%0A

Fix codacy issues for TaskTest